Commit c8ff37fb authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

Replaced deprecated numpy data types. Bumped version.


Signed-off-by: Daniel Scheffler's avatarDaniel Scheffler <danschef@gfz-potsdam.de>
parent 395d7761
Pipeline #36287 canceled with stages
in 7 minutes and 55 seconds
......@@ -66,7 +66,7 @@ class MinimumDistance_Classifier(_ImageClassifier):
if nodataVal_cmap is not None and lbl == nodataVal_cmap:
continue
mask = labels == lbl
centroid = self.class_centroids[list(self.train_labels).index(lbl), :].reshape(1, -1).astype(np.float)
centroid = self.class_centroids[list(self.train_labels).index(lbl), :].reshape(1, -1).astype(float)
diff = spectra[mask, :] - centroid
distances[mask] = np.sqrt((diff ** 2).sum(axis=1))
......@@ -114,7 +114,7 @@ class kNN_MinimumDistance_Classifier(MinimumDistance_Classifier, _kNN_ImageClass
# loop over all training spectra and compute spectral angle for each pixel
for n_sample in range(n_samples):
train_spectrum = endmembers[n_sample, :].reshape(1, 1, n_features).astype(np.float)
train_spectrum = endmembers[n_sample, :].reshape(1, 1, n_features).astype(float)
diff = image - train_spectrum
dists[:, :, n_sample] = np.sqrt((diff ** 2).sum(axis=2))
......
......@@ -53,8 +53,8 @@ class FEDSA_Classifier(_ImageClassifier):
# normalize input data because SAM asserts only data between -1 and 1
train_spectra_norm, tileimdata_norm = normalize_endmembers_image(endmembers, image)
angles = np.zeros((image.shape[0], image.shape[1], self.n_samples), np.float)
ed = np.zeros((image.shape[0], image.shape[1], self.n_samples), np.float)
angles = np.zeros((image.shape[0], image.shape[1], self.n_samples), float)
ed = np.zeros((image.shape[0], image.shape[1], self.n_samples), float)
tileimspectra = im2spectra(image)
# if np.std(tileimdata) == 0: # skip tiles that only contain the same value
......@@ -62,8 +62,8 @@ class FEDSA_Classifier(_ImageClassifier):
for n_sample in range(self.n_samples):
train_spectrum = train_spectra_norm[n_sample, :].reshape(1, 1, self.n_features)
angles[:, :, n_sample] = calc_sam(tileimdata_norm, train_spectrum, axis=2)
ed[:, :, n_sample] = np.sqrt(np.sum((tileimspectra.astype(np.float) -
train_spectrum.flatten().astype(np.float)) ** 2, axis=1))\
ed[:, :, n_sample] = np.sqrt(np.sum((tileimspectra.astype(float) -
train_spectrum.flatten().astype(float)) ** 2, axis=1))\
.reshape(image.shape[:2])
angles_norm = angles / angles.max()
......
......@@ -54,7 +54,7 @@ class SID_Classifier(_ImageClassifier):
# normalize input data because SID asserts only data between -1 and 1
train_spectra_norm, tileimdata_norm = normalize_endmembers_image(endmembers, imdata[:])
sid = np.zeros((imdata.shape[0], imdata.shape[1], self.n_samples), np.float)
sid = np.zeros((imdata.shape[0], imdata.shape[1], self.n_samples), float)
# if np.std(tileimdata) == 0: # skip tiles that only contain the same value
# loop over all training spectra and compute spectral information divergence for each pixel
......
......@@ -34,8 +34,8 @@ def normalize_endmembers_image(endmembers, image):
# type: (np.ndarray, np.ndarray) -> Tuple[np.ndarray, np.ndarray]
from sklearn.preprocessing import MaxAbsScaler # avoids static TLS errors here
em = endmembers.astype(np.float)
im = image.astype(np.float)
em = endmembers.astype(float)
im = image.astype(float)
# provide training values as 2D ROW (n samples x 1 feature),
# because normalization should be applied globally, not band-by-band
......
......@@ -24,5 +24,5 @@
# limitations under the License.
__version__ = '0.3.1'
__versionalias__ = '20211215.01'
__version__ = '0.3.2'
__versionalias__ = '20211215.02'
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment