Skip to content

Commit

Permalink
Merge pull request #129 from BEL-Public/chg-version-311
Browse files Browse the repository at this point in the history
Chg(gha): python version to matrix of 3.6-11
  • Loading branch information
damian5710 authored Aug 19, 2024
2 parents 7e6bcc6 + 391b40b commit 3c78748
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 31 deletions.
19 changes: 11 additions & 8 deletions .github/workflows/lint_and_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,20 @@ jobs:
test_mffpy:
# Name the job
name: Lint and Test
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@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
Expand All @@ -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-dev.txt

- name: Linting
run: flake8
Expand Down
5 changes: 3 additions & 2 deletions mffpy/bin_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -85,7 +85,8 @@ 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)
Expand Down
4 changes: 2 additions & 2 deletions mffpy/mffdir.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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 `<self.filename>/file.xml` else
Expand Down
6 changes: 3 additions & 3 deletions mffpy/raw_bin_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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: float = None, block_slice: 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
Expand Down
13 changes: 7 additions & 6 deletions mffpy/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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`
Expand All @@ -263,8 +263,9 @@ 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]]:
"""
Expand Down
2 changes: 1 addition & 1 deletion mffpy/tests/test_devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion mffpy/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.9.0-develop"
__version__ = "0.9.0"
16 changes: 8 additions & 8 deletions mffpy/xml_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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**
Expand Down

0 comments on commit 3c78748

Please sign in to comment.