Repository: opendatacube/datacube-core

Issue:
Numpy is throwing a deprecation warning for `np.bool`
### Expected behaviour

No warnings are raised. 

### Actual behaviour

```
/usr/local/lib/python3.8/dist-packages/datacube/utils/masking.py:127: DeprecationWarning: `np.bool` is a deprecated alias for the builtin `bool`. To silence this warning, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` here.
Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
  output_dtypes=[numpy.bool])
```

### Steps to reproduce the behaviour

Run one of the masking functions.

### Environment information

* 1.8.5
* DE Africa



Discussion:

Resolving patch:
diff --git a/datacube/utils/masking.py b/datacube/utils/masking.py
--- a/datacube/utils/masking.py
+++ b/datacube/utils/masking.py
@@ -11,7 +11,6 @@
 import collections
 
 import pandas
-import numpy
 import xarray
 from xarray import DataArray, Dataset
 
@@ -124,7 +123,7 @@ def valid_data_mask(data):
 
     return xarray.apply_ufunc(valid_mask, data, nodata,
                               dask='parallelized',
-                              output_dtypes=[numpy.bool])
+                              output_dtypes=[bool])
 
 
 def mask_invalid_data(data, keep_attrs=True):
diff --git a/datacube/utils/math.py b/datacube/utils/math.py
--- a/datacube/utils/math.py
+++ b/datacube/utils/math.py
@@ -110,11 +110,11 @@ def snap_scale(s, tol=1e-6):
             return s
 
         # Check for simple fractions
-        s_inv = 1/s
+        s_inv = 1 / s
         s_inv_snapped = maybe_int(s_inv, tol)
         if s_inv_snapped is s_inv:
             return s
-        return 1/s_inv_snapped
+        return 1 / s_inv_snapped
 
 
 def clamp(x, lo, up):
@@ -152,7 +152,7 @@ def valid_mask(xx, nodata):
         return ~numpy.isnan(xx) & (xx != nodata)
 
     if nodata is None:
-        return numpy.full_like(xx, True, dtype=numpy.bool)
+        return numpy.full_like(xx, True, dtype=bool)
     return xx != nodata
 
 
@@ -166,7 +166,7 @@ def invalid_mask(xx, nodata):
         return numpy.isnan(xx) | (xx == nodata)
 
     if nodata is None:
-        return numpy.full_like(xx, False, dtype=numpy.bool)
+        return numpy.full_like(xx, False, dtype=bool)
     return xx == nodata
 
 
diff --git a/datacube/virtual/transformations.py b/datacube/virtual/transformations.py
--- a/datacube/virtual/transformations.py
+++ b/datacube/virtual/transformations.py
@@ -126,7 +126,7 @@ def compute(self, data):
             mask = ~xarray.apply_ufunc(binary_erosion,
                                        ~mask,
                                        kernel.reshape((1, ) + kernel.shape),
-                                       output_dtypes=[numpy.bool],
+                                       output_dtypes=[bool],
                                        dask='parallelized',
                                        keep_attrs=True)
 
@@ -136,7 +136,7 @@ def compute(self, data):
             mask = ~xarray.apply_ufunc(binary_dilation,
                                        ~mask,
                                        kernel.reshape((1, ) + kernel.shape),
-                                       output_dtypes=[numpy.bool],
+                                       output_dtypes=[bool],
                                        dask='parallelized',
                                        keep_attrs=True)
 
@@ -330,7 +330,7 @@ def result(output_var, output_desc):
             dtype = result.dtype
             mask = evaluate_nodata_mask(formula, data, parser, MaskEvaluator)
 
-            if numpy.dtype(dtype) == numpy.bool:
+            if numpy.dtype(dtype) == bool:
                 # any operation on nodata should evaluate to False
                 # omission of attrs['nodata'] is deliberate
                 result = result.where(~mask, False)


Test patch: