From 11008f9e97f4e9cf8e363ddbd03c93b089b622d9 Mon Sep 17 00:00:00 2001 From: nmannall Date: Tue, 26 Nov 2024 16:01:19 +0000 Subject: [PATCH] Replace np.single with np.float32 for consistancy --- gprMax/geometry_outputs.py | 6 ++--- gprMax/grid/fdtd_grid.py | 20 ++++++++-------- gprMax/snapshots.py | 4 ++-- gprMax/vtkhdf_filehandlers/vtk_image_data.py | 24 ++++++++++---------- 4 files changed, 27 insertions(+), 27 deletions(-) diff --git a/gprMax/geometry_outputs.py b/gprMax/geometry_outputs.py index 4c54ec44..7dd41b8e 100644 --- a/gprMax/geometry_outputs.py +++ b/gprMax/geometry_outputs.py @@ -410,10 +410,10 @@ class Metadata: def srcs_rx_gv_comment( self, srcs: Union[Sequence[Source], List[Rx]] - ) -> Tuple[List[str], npt.NDArray[np.single]]: + ) -> Tuple[List[str], npt.NDArray[np.float32]]: """Used to name sources and/or receivers.""" names: List[str] = [] - positions: npt.NDArray[np.single] = np.empty((len(srcs), 3)) + positions: npt.NDArray[np.float32] = np.empty((len(srcs), 3)) for index, src in enumerate(srcs): position = src.coord * self.grid.dl names.append(src.ID) @@ -421,7 +421,7 @@ class Metadata: return names, positions - def dx_dy_dz_comment(self) -> npt.NDArray[np.single]: + def dx_dy_dz_comment(self) -> npt.NDArray[np.float32]: return self.grid.dl def nx_ny_nz_comment(self) -> npt.NDArray[np.intc]: diff --git a/gprMax/grid/fdtd_grid.py b/gprMax/grid/fdtd_grid.py index 021e54a0..53d61d88 100644 --- a/gprMax/grid/fdtd_grid.py +++ b/gprMax/grid/fdtd_grid.py @@ -58,21 +58,21 @@ class FDTDGrid: self.nx = 0 self.ny = 0 self.nz = 0 - self.dl = np.ones(3, dtype=np.single) + self.dl = np.ones(3, dtype=np.float32) self.dt = 0.0 # Field Arrays - self.Ex: npt.NDArray[np.single] - self.Ey: npt.NDArray[np.single] - self.Ez: npt.NDArray[np.single] - self.Hx: npt.NDArray[np.single] - self.Hy: npt.NDArray[np.single] - self.Hz: npt.NDArray[np.single] + self.Ex: npt.NDArray[np.float32] + self.Ey: npt.NDArray[np.float32] + self.Ez: npt.NDArray[np.float32] + self.Hx: npt.NDArray[np.float32] + self.Hy: npt.NDArray[np.float32] + self.Hz: npt.NDArray[np.float32] # Dispersive Arrays - self.Tx: npt.NDArray[np.single] - self.Ty: npt.NDArray[np.single] - self.Tz: npt.NDArray[np.single] + self.Tx: npt.NDArray[np.float32] + self.Ty: npt.NDArray[np.float32] + self.Tz: npt.NDArray[np.float32] # Geometry Arrays self.solid: npt.NDArray[np.uint32] diff --git a/gprMax/snapshots.py b/gprMax/snapshots.py index 210bd36d..ce1fed87 100644 --- a/gprMax/snapshots.py +++ b/gprMax/snapshots.py @@ -110,7 +110,7 @@ class Snapshot: filename: str, fileext: str, outputs: Dict[str, bool], - grid_dl: npt.NDArray[np.single], + grid_dl: npt.NDArray[np.float32], grid_dt: float, ): """ @@ -358,7 +358,7 @@ class MPISnapshot(Snapshot): filename: str, fileext: str, outputs: Dict[str, bool], - grid_dl: npt.NDArray[np.single], + grid_dl: npt.NDArray[np.float32], grid_dt: float, ): super().__init__( diff --git a/gprMax/vtkhdf_filehandlers/vtk_image_data.py b/gprMax/vtkhdf_filehandlers/vtk_image_data.py index e521d201..9cc44622 100644 --- a/gprMax/vtkhdf_filehandlers/vtk_image_data.py +++ b/gprMax/vtkhdf_filehandlers/vtk_image_data.py @@ -30,9 +30,9 @@ class VtkImageData(VtkHdfFile): self, filename: Union[str, PathLike], shape: npt.NDArray[np.intc], - origin: Optional[npt.NDArray[np.single]] = None, - spacing: Optional[npt.NDArray[np.single]] = None, - direction: Optional[npt.NDArray[np.single]] = None, + origin: Optional[npt.NDArray[np.float32]] = None, + spacing: Optional[npt.NDArray[np.float32]] = None, + direction: Optional[npt.NDArray[np.float32]] = None, comm: Optional[MPI.Comm] = None, ): """Create a new VtkImageData file. @@ -77,15 +77,15 @@ class VtkImageData(VtkHdfFile): self._set_root_attribute(self.WHOLE_EXTENT_ATTR, whole_extent) if origin is None: - origin = np.zeros(self.DIMENSIONS, dtype=np.single) + origin = np.zeros(self.DIMENSIONS, dtype=np.float32) self.set_origin(origin) if spacing is None: - spacing = np.ones(self.DIMENSIONS, dtype=np.single) + spacing = np.ones(self.DIMENSIONS, dtype=np.float32) self.set_spacing(spacing) if direction is None: - direction = np.diag(np.ones(self.DIMENSIONS, dtype=np.single)) + direction = np.diag(np.ones(self.DIMENSIONS, dtype=np.float32)) self.set_direction(direction) @property @@ -93,18 +93,18 @@ class VtkImageData(VtkHdfFile): return self._get_root_attribute(self.WHOLE_EXTENT_ATTR) @property - def origin(self) -> npt.NDArray[np.single]: + def origin(self) -> npt.NDArray[np.float32]: return self._get_root_attribute(self.ORIGIN_ATTR) @property - def spacing(self) -> npt.NDArray[np.single]: + def spacing(self) -> npt.NDArray[np.float32]: return self._get_root_attribute(self.SPACING_ATTR) @property - def direction(self) -> npt.NDArray[np.single]: + def direction(self) -> npt.NDArray[np.float32]: return self._get_root_attribute(self.DIRECTION_ATTR) - def set_origin(self, origin: npt.NDArray[np.single]): + def set_origin(self, origin: npt.NDArray[np.float32]): """Set the origin coordinate of the image data. Args: @@ -114,7 +114,7 @@ class VtkImageData(VtkHdfFile): raise ValueError(f"Origin attribute must have {self.DIMENSIONS} dimensions.") self._set_root_attribute(self.ORIGIN_ATTR, origin) - def set_spacing(self, spacing: npt.NDArray[np.single]): + def set_spacing(self, spacing: npt.NDArray[np.float32]): """Set the discritisation of the image data. Args: @@ -124,7 +124,7 @@ class VtkImageData(VtkHdfFile): raise ValueError(f"Spacing attribute must have {self.DIMENSIONS} dimensions.") self._set_root_attribute(self.SPACING_ATTR, spacing) - def set_direction(self, direction: npt.NDArray[np.single]): + def set_direction(self, direction: npt.NDArray[np.float32]): """Set the coordinate system of the image data. Args: