Skip to content

Update proposal for phylib #49

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
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
70 changes: 70 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: CI

on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]

jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ["3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v3
with:
version: "latest"

- name: Set up Python ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}

- name: Install dependencies
run: uv sync --dev

- name: Lint with ruff
run: uv run ruff check .

- name: Check formatting with ruff
run: uv run ruff format --check .

- name: Test with pytest
run: uv run pytest --cov=phylib --cov-report=xml

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
file: ./coverage.xml
fail_ci_if_error: true
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

build:
runs-on: ubuntu-latest
needs: test

steps:
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v3
with:
version: "latest"

- name: Set up Python
run: uv python install 3.9

- name: Build package
run: uv build

- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/
48 changes: 40 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,61 @@ clean-build:
rm -fr build/
rm -fr dist/
rm -fr *.egg-info
rm -fr .eggs/

clean-pyc:
find . -name '*.pyc' -exec rm -f {} +
find . -name '*.pyo' -exec rm -f {} +
find . -name '*~' -exec rm -f {} +
find . -name '__pycache__' -exec rm -fr {} +

clean: clean-build clean-pyc
clean-test:
rm -fr .tox/
rm -f .coverage
rm -fr htmlcov/
rm -fr .pytest_cache/
rm -fr .ruff_cache/

clean: clean-build clean-pyc clean-test

install:
uv sync --dev

lint:
flake8 phylib
uv run ruff check phylib

format:
uv run ruff format phylib

format-check:
uv run ruff format --check phylib

lint-fix:
uv run ruff check --fix phylib

test: lint
py.test --cov-report term-missing --cov=phylib phylib
test: lint format-check
uv run pytest --cov-report term-missing --cov=phylib phylib

test-fast:
uv run pytest phylib

coverage:
coverage --html
uv run coverage html

apidoc:
python tools/api.py
uv run python tools/api.py

build:
python setup.py sdist --formats=zip
uv build

upload:
python setup.py sdist --formats=zip upload
uv publish

upload-test:
uv publish --publish-url https://test.pypi.org/legacy/

dev: install lint format test

ci: lint format-check test build

.PHONY: clean-build clean-pyc clean-test clean install lint format format-check lint-fix test test-fast coverage apidoc build upload upload-test dev ci
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
34 changes: 23 additions & 11 deletions setup.py → deprecated/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"""Installation script."""


#------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# Imports
#------------------------------------------------------------------------------
# ------------------------------------------------------------------------------

import os
import os.path as op
Expand All @@ -16,15 +16,18 @@
from setuptools import setup


#------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# Setup
#------------------------------------------------------------------------------
# ------------------------------------------------------------------------------


def _package_tree(pkgroot):
path = op.dirname(__file__)
subdirs = [op.relpath(i[0], path).replace(op.sep, '.')
for i in os.walk(op.join(path, pkgroot))
if '__init__.py' in i[2]]
subdirs = [
op.relpath(i[0], path).replace(op.sep, '.')
for i in os.walk(op.join(path, pkgroot))
if '__init__.py' in i[2]
]
return subdirs


Expand All @@ -41,7 +44,7 @@ def _package_tree(pkgroot):
setup(
name='phylib',
version=version,
license="BSD",
license='BSD',
description='Ephys data analysis for thousands of channels',
long_description=readme,
long_description_content_type='text/markdown',
Expand All @@ -52,8 +55,17 @@ def _package_tree(pkgroot):
package_dir={'phylib': 'phylib'},
package_data={
'phylib': [
'*.vert', '*.frag', '*.glsl', '*.npy', '*.gz', '*.txt',
'*.html', '*.css', '*.js', '*.prb'],
'*.vert',
'*.frag',
'*.glsl',
'*.npy',
'*.gz',
'*.txt',
'*.html',
'*.css',
'*.js',
'*.prb',
],
},
include_package_data=True,
keywords='phy,data analysis,electrophysiology,neuroscience',
Expand All @@ -62,7 +74,7 @@ def _package_tree(pkgroot):
'Intended Audience :: Developers',
'License :: OSI Approved :: BSD License',
'Natural Language :: English',
"Framework :: IPython",
'Framework :: IPython',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.7',
],
Expand Down
13 changes: 7 additions & 6 deletions phylib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"""Utilities for large-scale ephys data analysis."""


#------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# Imports
#------------------------------------------------------------------------------
# ------------------------------------------------------------------------------

import atexit
import logging
Expand All @@ -16,9 +16,9 @@
from .utils.event import connect, unconnect, emit


#------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# Global variables and functions
#------------------------------------------------------------------------------
# ------------------------------------------------------------------------------

__author__ = 'Cyrille Rossant'
__email__ = 'cyrille.rossant at gmail.com'
Expand All @@ -43,10 +43,10 @@ def format(self, record):
# Only keep the first character in the level name.
record.levelname = record.levelname[0]
filename = op.splitext(op.basename(record.pathname))[0]
record.caller = '{:s}:{:d}'.format(filename, record.lineno).ljust(20)
record.caller = f'{filename:s}:{record.lineno:d}'.ljust(20)
message = super(_Formatter, self).format(record)
color_code = self.color_codes.get(record.levelname, '90')
message = '\33[%sm%s\33[0m' % (color_code, message)
message = f'\x1b[{color_code}m{message}\x1b[0m'
return message


Expand Down Expand Up @@ -80,4 +80,5 @@ def on_exit(): # pragma: no cover
def test(): # pragma: no cover
"""Run the full testing suite of phylib."""
import pytest

pytest.main()
19 changes: 8 additions & 11 deletions phylib/conftest.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,24 @@
# -*- coding: utf-8 -*-

"""py.test utilities."""

#------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# Imports
#------------------------------------------------------------------------------
# ------------------------------------------------------------------------------

import logging
import os
from pathlib import Path
import tempfile
import shutil
import tempfile
import warnings
from pathlib import Path

import numpy as np
from pytest import fixture

from phylib import add_default_handler


#------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# Common fixtures
#------------------------------------------------------------------------------
# ------------------------------------------------------------------------------

logger = logging.getLogger('phylib')
logger.setLevel(10)
Expand All @@ -30,8 +27,8 @@
# Fix the random seed in the tests.
np.random.seed(2015)

warnings.filterwarnings("ignore", message="numpy.dtype size changed")
warnings.filterwarnings("ignore", message="numpy.ufunc size changed")
warnings.filterwarnings('ignore', message='numpy.dtype size changed')
warnings.filterwarnings('ignore', message='numpy.ufunc size changed')


@fixture
Expand Down
Loading