Replace np.single with np.float32 for consistancy

这个提交包含在:
nmannall
2024-11-26 16:01:19 +00:00
父节点 8ca45710ff
当前提交 11008f9e97
共有 4 个文件被更改,包括 27 次插入27 次删除

查看文件

@@ -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]:

查看文件

@@ -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]

查看文件

@@ -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__(

查看文件

@@ -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: