diff --git a/nata/containers/ParticleDataset_old.py b/nata/containers/ParticleDataset_old.py index 612dad5..166ca35 100644 --- a/nata/containers/ParticleDataset_old.py +++ b/nata/containers/ParticleDataset_old.py @@ -95,7 +95,6 @@ def __init__( particles: Union[int, np.ndarray] = _extract_from_data, dtype: np.dtype = _extract_from_data, ) -> None: - if not isinstance(data, np.ndarray): data = np.asanyarray(data) diff --git a/nata/plots/elements.py b/nata/plots/elements.py index 76049db..0096cc5 100644 --- a/nata/plots/elements.py +++ b/nata/plots/elements.py @@ -84,7 +84,6 @@ def scale_from_str(name: str): def mpl_norm_from_scale(scale: Scale, colorrange: Sequence[Numbers]): - if not scale or isinstance(scale, LinearScale): return mpl.colors.Normalize(vmin=colorrange[0], vmax=colorrange[1]) diff --git a/nata/plots/figure.py b/nata/plots/figure.py index 1b7802a..50f9489 100644 --- a/nata/plots/figure.py +++ b/nata/plots/figure.py @@ -32,7 +32,6 @@ def __init__( size: Optional[Sequence[Numbers]] = None, theme: Theme = Theme(name="light"), ): - self.theme = theme with mpl.rc_context(rc=self.theme.rc): @@ -81,7 +80,6 @@ def scatter( size=None, alpha=None, ): - has_colors = ( color is not None and isinstance(color, (Sequence, np.ndarray)) @@ -135,7 +133,6 @@ def image( colormap=None, colorbar=None, ): - with mpl.rc_context(rc=self.theme.rc): img = self.backend_ax.imshow( np.transpose(color), diff --git a/nata/plots/kinds.py b/nata/plots/kinds.py index d141874..47e34f5 100644 --- a/nata/plots/kinds.py +++ b/nata/plots/kinds.py @@ -14,7 +14,6 @@ @dataclass class PlotKind: def to_dict(self): - kind_dict = {} for field in fields(self): kind_dict[field.name] = getattr(self, field.name) diff --git a/nata/plugins/plot/collection.py b/nata/plugins/plot/collection.py index 5db5de0..b8c6fbc 100644 --- a/nata/plugins/plot/collection.py +++ b/nata/plugins/plot/collection.py @@ -22,7 +22,6 @@ def plot_collection( interactive: bool = True, n: int = 0, ) -> Figure: - # check if collection is not empty if not collection.store: raise ValueError("Collection is empty.") diff --git a/nata/plugins/plot/dataset.py b/nata/plugins/plot/dataset.py index cb4b057..52a3479 100644 --- a/nata/plugins/plot/dataset.py +++ b/nata/plugins/plot/dataset.py @@ -45,7 +45,6 @@ def plot_dataset( interact = False if interact: - if start not in range(len(data)): raise ValueError("invalid start index") diff --git a/nata/plugins/plot/grid.py b/nata/plugins/plot/grid.py index efde8ab..248cef0 100644 --- a/nata/plugins/plot/grid.py +++ b/nata/plugins/plot/grid.py @@ -56,7 +56,6 @@ def plot_data_array( theme: Optional[Union[Theme, str]] = None, kind: Optional[PlotKind] = None, ): - if kind and not is_valid_plot_kind(data, kind): raise ValueError(f"invalid plot kind for {type(data)} `{data.name}`") @@ -109,7 +108,6 @@ def plot_data_array( ) elif data.ndim == 2: - if not kind.colorbar: kind.colorbar = Colorbar( label=f"{data.label}" + (f" [{data.unit}]" if data.unit else "") diff --git a/nata/plugins/plot/particle.py b/nata/plugins/plot/particle.py index 322bc4f..7be33e4 100644 --- a/nata/plugins/plot/particle.py +++ b/nata/plugins/plot/particle.py @@ -44,7 +44,6 @@ def plot_particle_array( theme: Optional[Union[Theme, str]] = None, kind: Optional[PlotKind] = None, ): - if kind and not is_valid_plot_kind(data, kind): raise ValueError(f"invalid plot kind for {type(data)} `{data.name}`") @@ -84,7 +83,6 @@ def plot_particle_array( ) if isinstance(kind, Scatter): - # check that color is either: # - an array with the right size # - an array with size 3/4 representing an RGB/RGBA value diff --git a/nata/utils/zdf.py b/nata/utils/zdf.py index 3757690..1e3b753 100644 --- a/nata/utils/zdf.py +++ b/nata/utils/zdf.py @@ -128,7 +128,6 @@ def __read_float64(self): return np.fromfile(self.__file, dtype=" 0: @@ -207,7 +206,6 @@ def __read_float64_arr(self, nx): return data def __read_arr(self, dtype, nx): - if dtype == 5: data = self.__read_int32_arr(nx) elif dtype == 3: @@ -235,7 +233,6 @@ def __read_arr(self, dtype, nx): # ----------------------------------------------------------------------------- def read_record(self, skip=False): - rec = ZDF_Record() rec.pos = self.__file.tell() @@ -396,7 +393,6 @@ def read_part_info(self, rec=False): # ----------------------------------------------------------------------------- def read_track_info(self, rec=False): - if rec is False: rec = self.read_record() @@ -448,7 +444,6 @@ def read_track_info(self, rec=False): # -------------------------------------------------------------------------- def read_dataset(self, rec=False): - if rec is False: rec = self.read_record() @@ -494,7 +489,6 @@ def read_dataset(self, rec=False): # -------------------------------------------------------------------------- def read_cdset(self, rec=False, pos=0): - if rec is False: rec = self.read_record() @@ -547,7 +541,6 @@ def read_cdset(self, rec=False, pos=0): name = "" while name != end_name: - # Read next record rec = self.read_record() @@ -580,7 +573,6 @@ def read_cdset(self, rec=False, pos=0): ] = chunk else: - self.__record_skip(rec) # If requested, position file pointer at the end of the cdset_start @@ -671,7 +663,6 @@ def read_element(self, rec=False, name=False, type_id=False): # ----------------------------------------------------------------------------- def read_part_data(self, quants): - # Read all quantities data = dict() @@ -706,7 +697,6 @@ def read_part_data(self, quants): # ----------------------------------------------------------------------------- def read_track_data(self, trackInfo): - rec = self.read_record() if rec.name != "itermap": print( diff --git a/tests/plugins/fft_test.py b/tests/plugins/fft_test.py index 2a3057b..f78dcba 100644 --- a/tests/plugins/fft_test.py +++ b/tests/plugins/fft_test.py @@ -9,13 +9,11 @@ def test_array_fft_invalid_ndim(): - with pytest.raises(ValueError, match="0 dimensional GridArrays"): GridArray.from_array(1).fft() def test_array_fft_invalid_axis(): - for invalid_axis in [2, -3]: with pytest.raises(ValueError, match="invalid axis index"): GridArray.from_array( @@ -107,6 +105,5 @@ def test_dataset_fft_selection(): def test_dataset_fft_invalid_ndim(): - with pytest.raises(ValueError, match="0 dimensional GridDatasets"): GridDataset.from_array(np.arange(5)).fft() diff --git a/tests/plugins/slice_test.py b/tests/plugins/slice_test.py index 8d8e10f..c3a59bf 100644 --- a/tests/plugins/slice_test.py +++ b/tests/plugins/slice_test.py @@ -35,7 +35,6 @@ def test_array_slice_selection(): def test_array_slice_invalid_ndim(): - with pytest.raises(ValueError, match="0 dimensional GridArrays"): GridArray.from_array(1).slice(constant="axis0", value=0) @@ -61,6 +60,5 @@ def test_dataset_slice_selection(): def test_dataset_slice_invalid_ndim(): - with pytest.raises(ValueError, match="0 dimensional GridDatasets"): GridDataset.from_array(np.arange(5)).slice(constant="axis0", value=1) diff --git a/tests/plugins/streak_test.py b/tests/plugins/streak_test.py index 980fc0e..09d33ed 100644 --- a/tests/plugins/streak_test.py +++ b/tests/plugins/streak_test.py @@ -20,7 +20,6 @@ def test_streak_shape(): def test_streak_axes_shape(): - time = np.arange(3) x = np.arange(10) @@ -37,6 +36,5 @@ def test_streak_axes_shape(): def test_streak_invalid_ndim(): - with pytest.raises(ValueError, match="0 dimensional GridDatasets"): GridDataset.from_array(np.arange(5)).streak() diff --git a/tests/plugins/transpose_test.py b/tests/plugins/transpose_test.py index e4f8a93..801d4dc 100644 --- a/tests/plugins/transpose_test.py +++ b/tests/plugins/transpose_test.py @@ -7,7 +7,6 @@ def test_array_transpose_invalid_axes(): - grid = GridArray.from_array(np.arange(7 * 6).reshape((7, 6))) for invalid_axes in [ @@ -24,7 +23,6 @@ def test_array_transpose_invalid_axes(): def test_array_transpose_shape(): - data = np.zeros((7, 6, 5)) grid = GridArray.from_array(data) @@ -40,7 +38,6 @@ def test_array_transpose_shape(): def test_array_transpose_axes(): - data = np.zeros((7, 6, 5)) grid = GridArray.from_array(data) @@ -52,7 +49,6 @@ def test_array_transpose_axes(): def test_array_transpose_data(): - data = np.arange(7 * 6 * 5).reshape((7, 6, 5)) grid = GridArray.from_array(data) @@ -62,7 +58,6 @@ def test_array_transpose_data(): def test_dataset_transpose_shape(): - data = np.zeros((7, 6, 5)) grid = GridDataset.from_array(data)