Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
rev: v6.0.0
hooks:
- id: no-commit-to-branch
name: Don't commit to master
- id: fix-encoding-pragma
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/PyCQA/isort
rev: 5.9.3
rev: 7.0.0
hooks:
- id: isort
additional_dependencies: [toml]
# excludes all the init files from sorting
exclude: ^.*\/__init__\.py$
- repo: https://github.com/psf/black
rev: 21.9b0
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 26.1.0
hooks:
- id: black
- repo: https://github.com/PyCQA/flake8
rev: 4.0.1
rev: 7.3.0
hooks:
- id: flake8
8 changes: 4 additions & 4 deletions nata/backends/osiris/zdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def _dset_name(self) -> str:

def get_data(self=None, indexing=None):
# TODO: apply indexing here
(z_data, z_info) = read(str(self.location))
z_data, z_info = read(str(self.location))
return z_data.transpose()

@property
Expand Down Expand Up @@ -87,7 +87,7 @@ def shape(self):
@property
def dtype(self):
logging.info(f"Accessing '{self.location}' for 'dtype'")
(z_data, z_info) = read(str(self.location))
z_data, z_info = read(str(self.location))
return z_data.dtype

@property
Expand Down Expand Up @@ -215,7 +215,7 @@ def num_particles(self) -> int:

def get_data(self, indexing=None, fields=None) -> np.ndarray:
logging.info(f"Reading data in '{self.location}'")
(z_data, z_info) = read(str(self.location))
z_data, z_info = read(str(self.location))
if fields is None:
# create a structured array
dset = np.empty(self.num_particles, dtype=self.dtype)
Expand Down Expand Up @@ -265,7 +265,7 @@ def quantity_units(self) -> Sequence[str]:
@property
def dtype(self) -> np.dtype:
logging.info(f"Accessing '{self.location}' for 'dtype'")
(z_data, z_info) = read(str(self.location))
z_data, z_info = read(str(self.location))
fields = []
for quant in self.quantity_names:
fields.append((quant, z_data[quant].dtype))
Expand Down
3 changes: 1 addition & 2 deletions nata/containers/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ class BackendType(Protocol):
name: str

@staticmethod
def is_valid_backend(location: Path) -> bool:
... # pragma: no cover
def is_valid_backend(location: Path) -> bool: ... # pragma: no cover


class HasBackends:
Expand Down
9 changes: 3 additions & 6 deletions nata/containers/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,10 @@ class GridBackend(Protocol):
name: str
location: Path

def __init__(self, location: FileLocation) -> None:
...
def __init__(self, location: FileLocation) -> None: ...

@staticmethod
def is_valid_backend(location: FileLocation) -> bool:
...
def is_valid_backend(location: FileLocation) -> bool: ...

dataset_name: str
dataset_label: str
Expand All @@ -100,8 +98,7 @@ def is_valid_backend(location: FileLocation) -> bool:

@runtime_checkable
class GridDataReader(GridBackend, Protocol):
def get_data(self, indexing: Optional[BasicIndexing] = None) -> np.ndarray:
...
def get_data(self, indexing: Optional[BasicIndexing] = None) -> np.ndarray: ...


class GridArray(
Expand Down
13 changes: 4 additions & 9 deletions nata/containers/particle.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,10 @@ class ParticleBackend(Protocol):
name: str
location: Path

def __init__(self, location: FileLocation) -> None:
...
def __init__(self, location: FileLocation) -> None: ...

@staticmethod
def is_valid_backend(location: FileLocation) -> bool:
...
def is_valid_backend(location: FileLocation) -> bool: ...

dataset_name: str
dataset_label: str
Expand All @@ -111,8 +109,7 @@ class ParticleDataReader(ParticleBackend, Protocol):
def get_data(
self,
indexing: Optional[BasicIndexing] = None,
) -> np.ndarray:
...
) -> np.ndarray: ...


class Quantity(
Expand Down Expand Up @@ -800,9 +797,7 @@ def _decay_to_ParticleDataset(
time=self.time[index[0]],
)

def __getitem__(
self, key: Any
) -> Union[
def __getitem__(self, key: Any) -> Union[
"ParticleDataset",
"ParticleArray",
"Particle",
Expand Down
20 changes: 11 additions & 9 deletions nata/plots/figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,17 @@ def scatter(
s=size,
c=color if has_colors else None,
color=color if has_single_color else None,
norm=mpl_norm_from_scale(
colorscale,
(
colorrange[0] if colorrange else np.min(color),
colorrange[1] if colorrange else np.max(color),
),
)
if has_colors
else None,
norm=(
mpl_norm_from_scale(
colorscale,
(
colorrange[0] if colorrange else np.min(color),
colorrange[1] if colorrange else np.max(color),
),
)
if has_colors
else None
),
cmap=colormap,
alpha=alpha,
)
Expand Down
4 changes: 2 additions & 2 deletions nata/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
be used for typechecking and type annotation. In addition, type checking at
runtime is supported.
"""

import sys
from pathlib import Path
from typing import AbstractSet
Expand Down Expand Up @@ -86,8 +87,7 @@ class BackendType(Protocol):
#: point to data, either to open a file or to retrieve it.
location: Optional[FileLocation]

def __init__(self, location: FileLocation) -> None:
...
def __init__(self, location: FileLocation) -> None: ...

@staticmethod
def is_valid_backend(location: FileLocation) -> bool:
Expand Down
6 changes: 3 additions & 3 deletions nata/utils/zdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -738,9 +738,9 @@ def read_track_data(self, trackInfo):
for i in range(itermap.shape[0]):
trackID = itermap[i, 0] - 1
npoints = itermap[i, 1]
(trackData[trackID])[
trackNp[trackID] : trackNp[trackID] + npoints, :
] = data[idx : idx + npoints, :]
(trackData[trackID])[trackNp[trackID] : trackNp[trackID] + npoints, :] = (
data[idx : idx + npoints, :]
)
trackNp[trackID] += npoints
idx += npoints

Expand Down
8 changes: 4 additions & 4 deletions tests/backends/osiris/hdf5_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def test_Osiris_Hdf5_ParticleFile_isinstance_ParticleDataReader():


def test_Osiris_Hdf5_ParticleFile_is_valid_backend(
make_prt_file: Callable[[str, np.ndarray, Optional[str]], Path]
make_prt_file: Callable[[str, np.ndarray, Optional[str]], Path],
):
data = unstructured_to_structured(np.random.random((10, 4)))
data = rename_fields(data, {"f0": "q"})
Expand All @@ -122,7 +122,7 @@ def test_Osiris_Hdf5_ParticleFile_is_valid_backend(


def test_Osiris_Hdf5_ParticleFile_properties(
make_prt_file: Callable[[str, np.ndarray, Optional[str]], Path]
make_prt_file: Callable[[str, np.ndarray, Optional[str]], Path],
):
data = unstructured_to_structured(np.random.random((10, 4)))
data = rename_fields(data, {"f0": "q"})
Expand Down Expand Up @@ -175,7 +175,7 @@ def test_Osiris_Dev_Hdf5_ParticleFile_isinstance_ParticleDataReader():


def test_Osiris_Dev_Hdf5_ParticleFile_is_valid_backend(
make_prt_file: Callable[[str, np.ndarray, Optional[str]], Path]
make_prt_file: Callable[[str, np.ndarray, Optional[str]], Path],
):
data = unstructured_to_structured(np.random.random((10, 4)))
data = rename_fields(data, {"f0": "q"})
Expand All @@ -186,7 +186,7 @@ def test_Osiris_Dev_Hdf5_ParticleFile_is_valid_backend(


def test_Osiris_Dev_Hdf5_ParticleFile_properties(
make_prt_file: Callable[[str, np.ndarray, Optional[str]], Path]
make_prt_file: Callable[[str, np.ndarray, Optional[str]], Path],
):
data = unstructured_to_structured(np.random.random((10, 4)))
data = rename_fields(data, {"f0": "q"})
Expand Down
6 changes: 2 additions & 4 deletions tests/containers/core_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,9 @@ class ExtendedProtocol(Protocol):
some_other_prop: Tuple[int, ...]

@staticmethod
def is_valid_backend(location: Path) -> bool:
...
def is_valid_backend(location: Path) -> bool: ...

def some_other_method(self, foo: int) -> float:
...
def some_other_method(self, foo: int) -> float: ...

return ExtendedProtocol

Expand Down
3 changes: 1 addition & 2 deletions tests/containers/grid_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ def __init__(self, location: Union[str, Path]) -> None:
raise NotImplementedError

@staticmethod
def is_valid_backend(location: Union[str, Path]) -> bool:
...
def is_valid_backend(location: Union[str, Path]) -> bool: ...

dataset_name = str()
dataset_label = str()
Expand Down