Skip to content

Commit

Permalink
migrate to uv, update arf dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
dmeliza committed Jan 2, 2025
1 parent 8cc9efa commit 6b37ea9
Show file tree
Hide file tree
Showing 11 changed files with 696 additions and 138 deletions.
36 changes: 0 additions & 36 deletions .github/workflows/build_wheels.yml

This file was deleted.

32 changes: 13 additions & 19 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Python tests

on: [push, pull_request]
Expand All @@ -12,22 +9,19 @@ jobs:
matrix:
os: [macos-13, macos-14, ubuntu-latest, windows-latest]
# can't do pypy - no support for h5py
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
exclude:
- os: macos-14
python-version: "3.7"
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
pip install -e .[test]
- name: Test with pytest
run: |
pytest -v
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: uv sync --frozen
- name: Run tests
run: uv run pytest
7 changes: 6 additions & 1 deletion arfx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,10 @@
operations involving single channel datasets, though it can also be used to copy
entire entries between ARF files.
"""
try:
from importlib.metadata import version

__version__ = "2.6.16"
__version__ = version("arfx")
except Exception:
# If package is not installed (e.g. during development)
__version__ = "unknown"
9 changes: 8 additions & 1 deletion arfx/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,13 @@ def setup_log(log, debug=False):
log.addHandler(ch)


def datatype_list():
out = str(arf.DataTypes.__doc__)
for dtype in arf.DataTypes:
out += f"\n{dtype.name}:{dtype.value}"
return out


def arfx():
p = argparse.ArgumentParser(
description="copy data in and out of ARF files",
Expand All @@ -584,7 +591,7 @@ def arfx():
"--help-datatypes",
help="print available datatypes and exit",
action="version",
version=arf.DataTypes._doc(),
version=datatype_list(),
)
p.add_argument(
"--help-formats",
Expand Down
2 changes: 1 addition & 1 deletion arfx/lblio.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# -*- mode: python -*-
"""Read and write lbl format files.
"""Read and write lbl format files.
lbl is a format developed by the Margoliash lab. It's not a very good or
flexible format, but it's what the venerable data inspection and labeling
Expand Down
6 changes: 3 additions & 3 deletions arfx/oephys.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ def script(argv=None):
name=rec_name,
timestamp=timestamp,
entry_creator="org.meliza.arfx/arfx-oephys " + core.__version__,
**rec.attrs
**rec.attrs,
)
if args.attrs is not None:
arf.set_attributes(entry, **args.attrs)
Expand Down Expand Up @@ -371,7 +371,7 @@ def script(argv=None):
datatype=args.datatype,
offset=dset.offset,
sampling_rate=dset.sampling_rate,
**info
**info,
)
datasets.append((idx, tgt))
if len(datasets) == 0:
Expand All @@ -398,7 +398,7 @@ def script(argv=None):
datatype=arf.DataTypes.EVENT,
sampling_rate=dset.sampling_rate,
units=dset.units,
**dset.attrs
**dset.attrs,
)


Expand Down
2 changes: 1 addition & 1 deletion arfx/pcmio.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def __init__(
dtype="h",
nchannels=1,
byteorder="<",
**kwargs
**kwargs,
):
from numpy import dtype as ndtype

Expand Down
2 changes: 1 addition & 1 deletion arfx/select.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def main(argv=None):
name,
selected,
offset=offset + src_dset_offset,
**src_dset_attrs
**src_dset_attrs,
)
tgt_entry_index += 1

Expand Down
106 changes: 96 additions & 10 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,18 +1,104 @@
[build-system]
requires = ["setuptools", "wheel"]
requires = ["hatchling"]
build-backend = "hatchling.build"

build-backend = "setuptools.build_meta"
[project]
name = "arfx"
version = "2.7.0"
description = "Advanced Recording Format Tools"
readme = "README.rst"
requires-python = ">=3.8"
license = {text = "BSD 3-Clause License"}
authors = [
{name = "C Daniel Meliza", email = "[email protected]"},
]
maintainers = [
{name = "C Daniel Meliza", email = "[email protected]"},
]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: BSD License",
"Programming Language :: Python",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Scientific/Engineering",
"Operating System :: Unix",
"Operating System :: POSIX :: Linux",
"Operating System :: MacOS :: MacOS X",
"Operating System :: Microsoft :: Windows",
"Natural Language :: English"
]
dependencies = [
"arf>=2.7.0",
"ewave>=1.0.7",
"tqdm",
"natsort",
]

[project.urls]
Homepage = "https://github.com/melizalab/arfx"

[project.scripts]
arfx = "arfx.core:arfx"
arfx-split = "arfx.splitter:main"
arfx-select = "arfx.select:main"
arfx-collect-sampled = "arfx.collect:collect_sampled_script"
arfx-oephys = "arfx.oephys:script"

[project.entry-points."arfx.io"]
".pcm" = "arfx.pcmio:pcmfile"
".dat" = "arfx.pcmio:pcmfile"
".npy" = "arfx.npyio:npyfile"
".mda" = "arfx.mdaio:mdafile"
".wav" = "ewave:wavfile"


[dependency-groups]
dev = [
"pytest>=8.3.3,<9",
"pytest-cov >= 4.1.0",
"ruff>=0.7.0"
]

[tool.pytest.ini_options]
python_files = ["test_*.py", "*_test.py"]
addopts = "-v --cov=arfx --cov-report=term-missing"
testpaths = ["test"]

[tool.black]
line-length = 88
target-version = ["py38"]
include = '\.pyi?$'

[tool.ruff]
target-version = "py37"
line-length = 88
target-version = "py38"
extend-exclude = ["build", "attic"]

[tool.ruff.lint]
extend-select = [
"B", # flake8-bugbear
"I", # isort
"PGH", # pygrep-hooks
"RUF", # Ruff-specific
"NPY201", # numpy 2.0 migration
select = [
"E", # pycodestyle errors
"W", # pycodestyle warnings
"F", # pyflakes
"I", # isort
"B", # flake8-bugbear
]
preview = true
ignore = ["E221", "E501", "E701"]

[tool.ruff.lint.per-file-ignores]
"__init__.py" = ["F401"]

[tool.mypy]
python_version = "3.8"
ignore_missing_imports = true
strict_optional = true
check_untyped_defs = true

[tool.hatch.build]
include = ["arfx/**"]
exclude = ["*test*"]
artifacts = ["README.rst"]
65 changes: 0 additions & 65 deletions setup.cfg

This file was deleted.

Loading

0 comments on commit 6b37ea9

Please sign in to comment.