From 45dcca68df6cd8e88993f33526813eaf1674317b Mon Sep 17 00:00:00 2001 From: "Dr. rer. nat. Justus Schwabedal" Date: Fri, 16 Aug 2024 09:16:50 +0200 Subject: [PATCH 1/4] Chg(gha): python version to matrix of 3.6-11 --- .github/workflows/lint_and_test.yaml | 19 +++++++++++-------- mffpy/version.py | 2 +- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/.github/workflows/lint_and_test.yaml b/.github/workflows/lint_and_test.yaml index d995d59..701a305 100644 --- a/.github/workflows/lint_and_test.yaml +++ b/.github/workflows/lint_and_test.yaml @@ -16,15 +16,18 @@ jobs: name: Lint and Test # Set the type of machine to run on runs-on: ubuntu-20.04 + strategy: + matrix: + python-version: ["3.6.7", "3.8", "3.9", "3.10", "3.11"] steps: # Check out the latest commit from the current branch - name: Checkout Current Branch - uses: actions/checkout@v2 + uses: actions/checkout@v4 - - name: Setup Python 3.6.7 - uses: actions/setup-python@v2 + - name: Setup Python { { matrix.python-version } } + uses: actions/setup-python@v5 with: - python-version: '3.6.7' + python-version: ${{ matrix.python-version }} - name: Cache Dependencies uses: actions/cache@v2 @@ -33,11 +36,11 @@ jobs: key: v1-dependencies-${{ hashFiles('**/requirements.txt') }} restore-keys: v1-dependencies- - - name: Install Dependences - run: pip install -r requirements.txt -r requirements-dev.txt + - name: Install Package + run: pip install . - - name: Run Setup Script - run: python setup.py install + - name: Install Development Dependences + run: pip install -r requirements.txt -r requirements-dev.txt - name: Linting run: flake8 diff --git a/mffpy/version.py b/mffpy/version.py index 206a177..3e2f46a 100644 --- a/mffpy/version.py +++ b/mffpy/version.py @@ -1 +1 @@ -__version__ = "0.9.0-develop" +__version__ = "0.9.0" From 0498395a31d1482625ae37746b2e8518ddf7e11f Mon Sep 17 00:00:00 2001 From: "Dr. rer. nat. Justus Schwabedal" Date: Fri, 16 Aug 2024 09:26:46 +0200 Subject: [PATCH 2/4] Fix(test): from version updates / rm np.float --- mffpy/bin_files.py | 4 ++-- mffpy/mffdir.py | 4 ++-- mffpy/raw_bin_files.py | 4 ++-- mffpy/reader.py | 12 ++++++------ mffpy/tests/test_devices.py | 2 +- mffpy/xml_files.py | 16 ++++++++-------- 6 files changed, 21 insertions(+), 21 deletions(-) diff --git a/mffpy/bin_files.py b/mffpy/bin_files.py index 37266e8..5db126e 100644 --- a/mffpy/bin_files.py +++ b/mffpy/bin_files.py @@ -12,7 +12,7 @@ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. """ -from typing import Tuple, Dict, IO +from typing import Tuple, Dict, IO, Optional import numpy as np @@ -85,7 +85,7 @@ def scale(self) -> float: return self._scale def get_physical_samples(self, t0: float = 0.0, - dt: float = None, block_slice: slice = None, + dt: Optional[float] = None, block_slice: Optional[slice] = None, dtype=np.float32) -> Tuple[np.ndarray, float]: samples, start_time = self.read_raw_samples( t0, dt, block_slice=block_slice) diff --git a/mffpy/mffdir.py b/mffpy/mffdir.py index 17f923d..b206dfe 100644 --- a/mffpy/mffdir.py +++ b/mffpy/mffdir.py @@ -16,7 +16,7 @@ from os import listdir from os.path import join, exists, splitext, basename, isdir from collections import defaultdict, namedtuple -from typing import Dict, List, Tuple, IO +from typing import Dict, List, Tuple, IO, Optional from . import zipfile @@ -67,7 +67,7 @@ def _find_files_by_type(self) -> None: for fbase, ext in (splitext(it) for it in self.listdir()): self.files_by_type[ext].append(fbase) - def info(self, i: int = None) -> IO[bytes]: + def info(self, i: Optional[int] = None) -> IO[bytes]: """return file or data info If `i is None`, it returns `/file.xml` else diff --git a/mffpy/raw_bin_files.py b/mffpy/raw_bin_files.py index caf442b..1443a1a 100644 --- a/mffpy/raw_bin_files.py +++ b/mffpy/raw_bin_files.py @@ -14,7 +14,7 @@ """ import itertools from os import SEEK_SET, SEEK_CUR, SEEK_END -from typing import Tuple, Dict, IO, Union +from typing import Tuple, Dict, IO, Union, Optional from warnings import warn from collections import namedtuple @@ -57,7 +57,7 @@ def __init__(self, filepointer: IO[bytes]): self.buffering: bool = False def read_raw_samples(self, t0: float = 0.0, - dt: float = None, block_slice: slice = None + dt: Optional[float] = None, block_slice: Optional[slice] = None ) -> Tuple[np.ndarray, float]: """return `(channels, samples)`-array and `start_time` of data diff --git a/mffpy/reader.py b/mffpy/reader.py index bca0b1d..79a1c2f 100644 --- a/mffpy/reader.py +++ b/mffpy/reader.py @@ -13,7 +13,7 @@ ANY KIND, either express or implied. """ from datetime import datetime -from typing import Tuple, Dict, List +from typing import Tuple, Dict, List, Optional from deprecated import deprecated import numpy as np @@ -246,9 +246,9 @@ def set_calibration(self, channel_type: str, cal: str): """set calibration of a channel type""" self._blobs[channel_type].calibration = cal - def get_physical_samples(self, t0: float = 0.0, dt: float = None, - channels: List[str] = None, - block_slice: slice = None + def get_physical_samples(self, t0: float = 0.0, dt: Optional[float] = None, + channels: Optional[List[str]] = None, + block_slice: Optional[slice] = None ) -> Dict[str, Tuple[np.ndarray, float]]: """return signal data in the range `(t0, t0+dt)` in seconds from `channels` @@ -263,8 +263,8 @@ def get_physical_samples(self, t0: float = 0.0, dt: float = None, } def get_physical_samples_from_epoch(self, epoch: xml_files.Epoch, - t0: float = 0.0, dt: float = None, - channels: List[str] = None + t0: float = 0.0, dt: Optional[float] = None, + channels: Optional[List[str]] = None ) -> Dict[str, Tuple[np.ndarray, float]]: """ diff --git a/mffpy/tests/test_devices.py b/mffpy/tests/test_devices.py index 0df8901..f00bf62 100644 --- a/mffpy/tests/test_devices.py +++ b/mffpy/tests/test_devices.py @@ -46,7 +46,7 @@ def test_devices(device): locs = np.array([ np.array([props['x'], props['y'], props['z']]) for i, (_, props) in enumerate(coords.sensors.items()) - ], dtype=np.float) + ], dtype=np.float32) device = basename(splitext(device)[0]) if exists(device) else device expected = np.load(join(resources_dir, 'testing', device+'.npy'), allow_pickle=True) diff --git a/mffpy/xml_files.py b/mffpy/xml_files.py index a2b1382..3dc06e1 100644 --- a/mffpy/xml_files.py +++ b/mffpy/xml_files.py @@ -4,7 +4,7 @@ from datetime import datetime from collections import defaultdict import numpy as np -from typing import Tuple, Dict, List, Any, Union, IO +from typing import Tuple, Dict, List, Any, Union, IO, Optional from .cached_property import cached_property from .dict2xml import TEXT, ATTR from .epoch import Epoch @@ -202,10 +202,10 @@ def recordTime(self): @classmethod def content(cls, recordTime: datetime, # type: ignore mffVersion: str = '3', - acquisitionVersion: str = None, - ampType: str = None, - ampSerialNumber: str = None, - ampFirmwareVersion: str = None) -> dict: + acquisitionVersion: Optional[str] = None, + ampType: Optional[str] = None, + ampSerialNumber: Optional[str] = None, + ampFirmwareVersion: Optional[str] = None) -> dict: """returns MFF file information Only Version '3' is supported. @@ -337,9 +337,9 @@ def _parse_channels_element(self, element: ET.Element) -> Dict[str, Any]: @classmethod def content(cls, fileDataType: str, # type: ignore - dataTypeProps: dict = None, - filters: List[dict] = None, - calibrations: List[dict] = None) -> dict: + dataTypeProps: Optional[dict] = None, + filters: Optional[List[dict]] = None, + calibrations: Optional[List[dict]] = None) -> dict: """returns info on the associated (data) .bin file **Parameters** From d0f69b185dc88198e7716605b398827b033c944c Mon Sep 17 00:00:00 2001 From: "Dr. rer. nat. Justus Schwabedal" Date: Fri, 16 Aug 2024 09:28:58 +0200 Subject: [PATCH 3/4] Fix(test): lint long lines --- mffpy/bin_files.py | 3 ++- mffpy/raw_bin_files.py | 4 ++-- mffpy/reader.py | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/mffpy/bin_files.py b/mffpy/bin_files.py index 5db126e..6c8f9d9 100644 --- a/mffpy/bin_files.py +++ b/mffpy/bin_files.py @@ -85,7 +85,8 @@ def scale(self) -> float: return self._scale def get_physical_samples(self, t0: float = 0.0, - dt: Optional[float] = None, block_slice: Optional[slice] = None, + dt: Optional[float] = None, + block_slice: Optional[slice] = None, dtype=np.float32) -> Tuple[np.ndarray, float]: samples, start_time = self.read_raw_samples( t0, dt, block_slice=block_slice) diff --git a/mffpy/raw_bin_files.py b/mffpy/raw_bin_files.py index 1443a1a..4abf161 100644 --- a/mffpy/raw_bin_files.py +++ b/mffpy/raw_bin_files.py @@ -56,8 +56,8 @@ def __init__(self, filepointer: IO[bytes]): assert not self.filepointer.closed self.buffering: bool = False - def read_raw_samples(self, t0: float = 0.0, - dt: Optional[float] = None, block_slice: Optional[slice] = None + def read_raw_samples(self, t0: float = 0.0, dt: Optional[float] = None, + block_slice: Optional[slice] = None ) -> Tuple[np.ndarray, float]: """return `(channels, samples)`-array and `start_time` of data diff --git a/mffpy/reader.py b/mffpy/reader.py index 79a1c2f..6090c77 100644 --- a/mffpy/reader.py +++ b/mffpy/reader.py @@ -263,7 +263,8 @@ def get_physical_samples(self, t0: float = 0.0, dt: Optional[float] = None, } def get_physical_samples_from_epoch(self, epoch: xml_files.Epoch, - t0: float = 0.0, dt: Optional[float] = None, + t0: float = 0.0, + dt: Optional[float] = None, channels: Optional[List[str]] = None ) -> Dict[str, Tuple[np.ndarray, float]]: From 391b40befd16773767ca7820d8abeb12bc8adc7b Mon Sep 17 00:00:00 2001 From: "Dr. rer. nat. Justus Schwabedal" Date: Fri, 16 Aug 2024 09:37:06 +0200 Subject: [PATCH 4/4] Chg(gha): rm dbl install of dependencies --- .github/workflows/lint_and_test.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/lint_and_test.yaml b/.github/workflows/lint_and_test.yaml index 701a305..b9674f4 100644 --- a/.github/workflows/lint_and_test.yaml +++ b/.github/workflows/lint_and_test.yaml @@ -14,17 +14,17 @@ jobs: test_mffpy: # Name the job name: Lint and Test - # Set the type of machine to run on - runs-on: ubuntu-20.04 strategy: matrix: python-version: ["3.6.7", "3.8", "3.9", "3.10", "3.11"] + # Set the type of machine to run on + runs-on: ubuntu-20.04 steps: # Check out the latest commit from the current branch - name: Checkout Current Branch uses: actions/checkout@v4 - - name: Setup Python { { matrix.python-version } } + - name: Setup Python ${{ matrix.python-version }} uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} @@ -40,7 +40,7 @@ jobs: run: pip install . - name: Install Development Dependences - run: pip install -r requirements.txt -r requirements-dev.txt + run: pip install -r requirements-dev.txt - name: Linting run: flake8