From b761b668247a953e21eaa5c519a9c4db4deb89e0 Mon Sep 17 00:00:00 2001 From: Zolan Date: Fri, 16 Jan 2026 14:55:31 -0700 Subject: [PATCH] convert np.float_ to np.float64 --- .../sofast/lib/calculation_data_classes.py | 2 +- .../cv/spot_analysis/SpotAnalysisOperable.py | 4 ++-- .../SpotAnalysisPopulationStatistics.py | 6 ++--- .../AverageByGroupImageProcessor.py | 2 +- .../test/TestAverageByGroupImageProcessor.py | 24 +++++++++---------- opencsp/common/lib/geometry/Vxy.py | 2 +- opencsp/common/lib/geometry/Vxyz.py | 2 +- opencsp/common/lib/geometry/angle.py | 8 +++---- opencsp/common/lib/tool/math_tools.py | 2 +- 9 files changed, 26 insertions(+), 26 deletions(-) diff --git a/opencsp/app/sofast/lib/calculation_data_classes.py b/opencsp/app/sofast/lib/calculation_data_classes.py index 74e0cef46..77522ba57 100644 --- a/opencsp/app/sofast/lib/calculation_data_classes.py +++ b/opencsp/app/sofast/lib/calculation_data_classes.py @@ -269,7 +269,7 @@ class CalculationFacetEnsemble(hdf5_tools.HDF5_SaveAbstract): """ trans_facet_ensemble: TransformXYZ = None - slopes_ensemble_xy: npt.NDArray[np.float_] = None + slopes_ensemble_xy: npt.NDArray[np.float64] = None v_surf_points_ensemble: Vxyz = None v_facet_pointing_ensemble: Vxyz = None diff --git a/opencsp/common/lib/cv/spot_analysis/SpotAnalysisOperable.py b/opencsp/common/lib/cv/spot_analysis/SpotAnalysisOperable.py index 14c40f0be..8058bb7c4 100644 --- a/opencsp/common/lib/cv/spot_analysis/SpotAnalysisOperable.py +++ b/opencsp/common/lib/cv/spot_analysis/SpotAnalysisOperable.py @@ -313,7 +313,7 @@ def best_primary_pathnameext(self) -> str: return os.path.join(*self.get_primary_path_nameext()) @property - def max_popf(self) -> npt.NDArray[np.float_]: + def max_popf(self) -> npt.NDArray[np.float64]: """Returns the maximum population float value, if it exists. Otherwise returns the maximum value for this instance's primary image.""" if self.population_statistics is not None: @@ -322,7 +322,7 @@ def max_popf(self) -> npt.NDArray[np.float_]: return np.max(self.primary_image.nparray) @property - def min_popf(self) -> npt.NDArray[np.float_]: + def min_popf(self) -> npt.NDArray[np.float64]: """Returns the minimum population float value, if it exists. Otherwise returns the minimum value for this instance's primary image.""" if self.population_statistics is not None: diff --git a/opencsp/common/lib/cv/spot_analysis/SpotAnalysisPopulationStatistics.py b/opencsp/common/lib/cv/spot_analysis/SpotAnalysisPopulationStatistics.py index 111edcdb2..9734e7ffa 100644 --- a/opencsp/common/lib/cv/spot_analysis/SpotAnalysisPopulationStatistics.py +++ b/opencsp/common/lib/cv/spot_analysis/SpotAnalysisPopulationStatistics.py @@ -5,11 +5,11 @@ @dataclass class SpotAnalysisPopulationStatistics: - maxf: npt.NDArray[np.float_] = None + maxf: npt.NDArray[np.float64] = None """ Maximum value seen across images. None if not yet calculated. """ - minf: npt.NDArray[np.float_] = None + minf: npt.NDArray[np.float64] = None """ Minimum value seen across images. None if not yet calculated. """ - avgf_rolling_window: npt.NDArray[np.float_] = None + avgf_rolling_window: npt.NDArray[np.float64] = None """ Average value seen across images. None if not yet calculated. """ window_size: int = 1 diff --git a/opencsp/common/lib/cv/spot_analysis/image_processor/AverageByGroupImageProcessor.py b/opencsp/common/lib/cv/spot_analysis/image_processor/AverageByGroupImageProcessor.py index 3c54de9de..adf5ca31e 100644 --- a/opencsp/common/lib/cv/spot_analysis/image_processor/AverageByGroupImageProcessor.py +++ b/opencsp/common/lib/cv/spot_analysis/image_processor/AverageByGroupImageProcessor.py @@ -43,7 +43,7 @@ def _execute_aggregate( + f"First image is '{operables[0].primary_image_source_path}', current image is '{operable.primary_image_source_path}'.", ) averaged_image += other_image - averaged_image = averaged_image.astype(np.float_) + averaged_image = averaged_image.astype(np.float64) averaged_image /= len(operables) averaged_image = averaged_image.astype(operables[0].primary_image.nparray.dtype) diff --git a/opencsp/common/lib/cv/spot_analysis/image_processor/test/TestAverageByGroupImageProcessor.py b/opencsp/common/lib/cv/spot_analysis/image_processor/test/TestAverageByGroupImageProcessor.py index a7d8c9923..2f56beb12 100644 --- a/opencsp/common/lib/cv/spot_analysis/image_processor/test/TestAverageByGroupImageProcessor.py +++ b/opencsp/common/lib/cv/spot_analysis/image_processor/test/TestAverageByGroupImageProcessor.py @@ -49,7 +49,7 @@ def test_single_image(self): self.assertEqual(1, len(operables)) operable = operables[0] - np.testing.assert_array_equal(operable.primary_image.nparray, self.a1_img.nparray.astype(np.float_)) + np.testing.assert_array_equal(operable.primary_image.nparray, self.a1_img.nparray.astype(np.float64)) def test_two_images_one_group(self): operables = self.processor.process_operable(self.a1) @@ -60,7 +60,7 @@ def test_two_images_one_group(self): self.assertEqual(1, len(operables)) operable = operables[0] - np.testing.assert_array_equal(operable.primary_image.nparray, np.array([15], dtype=np.float_)) + np.testing.assert_array_equal(operable.primary_image.nparray, np.array([15], dtype=np.float64)) def test_two_images_two_groups(self): operables = self.processor.process_operable(self.a1) @@ -71,9 +71,9 @@ def test_two_images_two_groups(self): self.assertEqual(1, len(operables_b)) operable = operables_a[0] - np.testing.assert_array_equal(operable.primary_image.nparray, self.a1_img.nparray.astype(np.float_)) + np.testing.assert_array_equal(operable.primary_image.nparray, self.a1_img.nparray.astype(np.float64)) operable = operables_b[0] - np.testing.assert_array_equal(operable.primary_image.nparray, self.b1_img.nparray.astype(np.float_)) + np.testing.assert_array_equal(operable.primary_image.nparray, self.b1_img.nparray.astype(np.float64)) def test_three_images_two_groups(self): operables = self.processor.process_operable(self.a1) @@ -86,9 +86,9 @@ def test_three_images_two_groups(self): self.assertEqual(1, len(operables_b)) operable = operables_a[0] - np.testing.assert_array_equal(operable.primary_image.nparray, np.array([15], dtype=np.float_)) + np.testing.assert_array_equal(operable.primary_image.nparray, np.array([15], dtype=np.float64)) operable = operables_b[0] - np.testing.assert_array_equal(operable.primary_image.nparray, self.b1_img.nparray.astype(np.float_)) + np.testing.assert_array_equal(operable.primary_image.nparray, self.b1_img.nparray.astype(np.float64)) def test_four_images_two_groups(self): operables = self.processor.process_operable(self.a1) @@ -103,9 +103,9 @@ def test_four_images_two_groups(self): self.assertEqual(1, len(operables_b)) operable = operables_a[0] - np.testing.assert_array_equal(operable.primary_image.nparray, np.array([15], dtype=np.float_)) + np.testing.assert_array_equal(operable.primary_image.nparray, np.array([15], dtype=np.float64)) operable = operables_b[0] - np.testing.assert_array_equal(operable.primary_image.nparray, np.array([35], dtype=np.float_)) + np.testing.assert_array_equal(operable.primary_image.nparray, np.array([35], dtype=np.float64)) def test_four_images_alternating_group(self): operables = self.processor.process_operable(self.a1) @@ -120,13 +120,13 @@ def test_four_images_alternating_group(self): self.assertEqual(1, len(operables_b2)) operable = operables_a1[0] - np.testing.assert_array_equal(operable.primary_image.nparray, self.a1_img.nparray.astype(np.float_)) + np.testing.assert_array_equal(operable.primary_image.nparray, self.a1_img.nparray.astype(np.float64)) operable = operables_a2[0] - np.testing.assert_array_equal(operable.primary_image.nparray, self.a2_img.nparray.astype(np.float_)) + np.testing.assert_array_equal(operable.primary_image.nparray, self.a2_img.nparray.astype(np.float64)) operable = operables_b1[0] - np.testing.assert_array_equal(operable.primary_image.nparray, self.b1_img.nparray.astype(np.float_)) + np.testing.assert_array_equal(operable.primary_image.nparray, self.b1_img.nparray.astype(np.float64)) operable = operables_b2[0] - np.testing.assert_array_equal(operable.primary_image.nparray, self.b2_img.nparray.astype(np.float_)) + np.testing.assert_array_equal(operable.primary_image.nparray, self.b2_img.nparray.astype(np.float64)) if __name__ == "__main__": diff --git a/opencsp/common/lib/geometry/Vxy.py b/opencsp/common/lib/geometry/Vxy.py index c1ae51d44..e855bcaca 100644 --- a/opencsp/common/lib/geometry/Vxy.py +++ b/opencsp/common/lib/geometry/Vxy.py @@ -246,7 +246,7 @@ def normalize_in_place(self) -> None: """ self._data /= self._magnitude_with_zero_check() - def magnitude(self) -> npt.NDArray[np.float_]: + def magnitude(self) -> npt.NDArray[np.float64]: """ Returns magnitude of each vector. diff --git a/opencsp/common/lib/geometry/Vxyz.py b/opencsp/common/lib/geometry/Vxyz.py index ef98108ad..b46a26997 100644 --- a/opencsp/common/lib/geometry/Vxyz.py +++ b/opencsp/common/lib/geometry/Vxyz.py @@ -265,7 +265,7 @@ def normalize_in_place(self) -> None: """ self._data /= self._magnitude_with_zero_check() - def magnitude(self) -> npt.NDArray[np.float_]: + def magnitude(self) -> npt.NDArray[np.float64]: """ Returns magnitude of each vector as a new array. diff --git a/opencsp/common/lib/geometry/angle.py b/opencsp/common/lib/geometry/angle.py index 02dd7fe0f..0b0723876 100644 --- a/opencsp/common/lib/geometry/angle.py +++ b/opencsp/common/lib/geometry/angle.py @@ -167,12 +167,12 @@ def normalize(angle: float) -> float: @overload -def normalize(angles: npt.NDArray[np.float_] | Iterable) -> npt.NDArray[np.float_]: +def normalize(angles: npt.NDArray[np.float64] | Iterable) -> npt.NDArray[np.float64]: """Normalizes an array of angles to the range [0, 2π].""" # "ChatGPT 4o" assisted with generating this docstring. -def normalize(angle_or_angles: float | npt.NDArray[np.float_] | Iterable) -> float | npt.NDArray[np.float_]: +def normalize(angle_or_angles: float | npt.NDArray[np.float64] | Iterable) -> float | npt.NDArray[np.float64]: """ Adjusts the given angle or angles to be in the range [0, 2π]. @@ -181,12 +181,12 @@ def normalize(angle_or_angles: float | npt.NDArray[np.float_] | Iterable) -> flo Parameters ---------- - angle_or_angles : float or :py:meth:`npt.NDArray[np.float_]` or Iterable + angle_or_angles : float or :py:meth:`npt.NDArray[np.float64]` or Iterable A single angle or an array/iterable of angles to normalize. Returns ------- - float or py:meth:`npt.NDArray[np.float_]` + float or py:meth:`npt.NDArray[np.float64]` The normalized angle or array of normalized angles. """ # "ChatGPT 4o" assisted with generating this docstring. diff --git a/opencsp/common/lib/tool/math_tools.py b/opencsp/common/lib/tool/math_tools.py index ddc6808c8..a5106fce1 100644 --- a/opencsp/common/lib/tool/math_tools.py +++ b/opencsp/common/lib/tool/math_tools.py @@ -301,7 +301,7 @@ def gaussian_convolution(num_points: int): return y_vals -def rolling_average(data: list[float] | npt.NDArray[np.float_], window_size: int): +def rolling_average(data: list[float] | npt.NDArray[np.float64], window_size: int): """Compute the rolling average over all values in the given list. For each point x at index i, assign a new value equal to sum([i-w/2:i+w/2]) / 2.