Skip to content
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

Modern packaging + ruff + numpy 2 compat #187

Open
wants to merge 19 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
14 changes: 0 additions & 14 deletions .coveragerc

This file was deleted.

10 changes: 0 additions & 10 deletions .github/workflows/black.yml

This file was deleted.

24 changes: 13 additions & 11 deletions .github/workflows/python_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,47 @@ name: Python tests

on:
push:
branches: [master, develop]
branches: [master]
pull_request:
branches: [master, develop]
branches: [master]
raphaelvallat marked this conversation as resolved.
Show resolved Hide resolved

jobs:
build:
strategy:
fail-fast: false
matrix:
platform: [ubuntu-latest, windows-latest] # macos-latest
python-version: ["3.9", "3.10", "3.11"]
platform: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.9", "3.10", "3.11", "3.12"]

runs-on: ${{ matrix.platform }}

env:
FORCE_COLOR: true

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install libomp (macOS)
if: ${{ matrix.platform == 'macos-latest' }}
run: brew install libomp

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements-test.txt
pip install .
pip install ".[test]"
- name: Test with pytest
run: |
pytest --cov --cov-report=xml --cov-config=setup.cfg --verbose
pytest --cov --cov-report=xml --verbose
- name: Upload coverage report
if: ${{ matrix.platform == 'ubuntu-latest' && matrix.python-version == 3.9 }}
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v4
with:
token: a58a0c62-fb11-4429-977b-65bec01ecb44
file: ./coverage.xml
13 changes: 13 additions & 0 deletions .github/workflows/ruff.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Ruff
on: [push, pull_request]
jobs:
ruff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: "Linting"
uses: astral-sh/ruff-action@v1
- name: "Formatting"
uses: astral-sh/ruff-action@v1
with:
args: "format --check"
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -142,4 +142,6 @@ notebooks/20_catch_errors.ipynb
*.pptx

# Custom
*/.virtual_documents/
notebooks/debug*
notebooks/my_hypno.csv
19 changes: 2 additions & 17 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,21 +1,6 @@
# Add README, LICENSE and requirements :
# Add README and LICENSE :
include README.rst
include LICENSE
include requirements.txt

# Add trained classifiers
# v0.4.0
include yasa/classifiers/clf_eeg_lgb_0.4.0.joblib
include yasa/classifiers/clf_eeg+eog_lgb_0.4.0.joblib
include yasa/classifiers/clf_eeg+eog+emg_lgb_0.4.0.joblib
include yasa/classifiers/clf_eeg+eog+emg+demo_lgb_0.4.0.joblib

# v0.5.0
include yasa/classifiers/clf_eeg_lgb_0.5.0.joblib
include yasa/classifiers/clf_eeg+demo_lgb_0.5.0.joblib
include yasa/classifiers/clf_eeg+eog_lgb_0.5.0.joblib
include yasa/classifiers/clf_eeg+eog+demo_lgb_0.5.0.joblib
include yasa/classifiers/clf_eeg+emg_lgb_0.5.0.joblib
include yasa/classifiers/clf_eeg+emg+demo_lgb_0.5.0.joblib
include yasa/classifiers/clf_eeg+eog+emg_lgb_0.5.0.joblib
include yasa/classifiers/clf_eeg+eog+emg+demo_lgb_0.5.0.joblib
recursive-include yasa/classifiers/ *.joblib
13 changes: 13 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
.. image:: https://pepy.tech/badge/yasa
:target: https://pepy.tech/badge/yasa

.. image:: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json
:target: https://github.com/astral-sh/ruff
:alt: Ruff

----------------

.. figure:: /docs/pictures/yasa_logo.png
Expand Down Expand Up @@ -48,6 +52,15 @@ Alternatively, YASA can be installed with conda:
conda config --set channel_priority strict
conda install yasa

To build and install from source, clone this repository or download the source archive and decompress the files

.. code-block:: shell

cd yasa
pip install ".[test]" # install the package
pip install --editable ".[test]" # or editable install
pytest # test the package

**What are the prerequisites for using YASA?**

To use YASA, all you need is:
Expand Down
2 changes: 0 additions & 2 deletions codecov.yml

This file was deleted.

15 changes: 10 additions & 5 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,23 @@ which comes with several pre-built functions (aka methods) and attributes. See f
hyp.duration # Total duration of the hypnogram, in minutes
hyp.sampling_frequency # Sampling frequency of the hypnogram
hyp.mapping # Mapping from strings to integers
hyp.proba # Probability of each sleep stage, if specified
# Below are some class methods
hyp.sleep_statistics() # Calculate the sleep statistics
hyp.plot_hypnogram() # Plot the hypnogram
hyp.upsample_to_data() # Upsample to data

Please see the documentation of :py:class:`yasa.Hypnogram` for more details.
This brings along critical changes to several YASA function, for example:

.. important::
The adoption of object-oriented :py:class:`yasa.Hypnogram` usage brings along critical changes to several YASA function, for example:
* :py:class:`yasa.SleepStaging` now returns a :py:class:`yasa.Hypnogram` instead of a :py:class:`numpy.ndarray`. The probability of each sleep stage for each epoch can now be accessed with :py:attr:`yasa.Hypnogram.proba`.
* :py:func:`yasa.simulate_hypnogram` now returns a :py:class:`yasa.Hypnogram` instead of a :py:class:`numpy.ndarray`.
* The suggested approach to plotting hypnograms is through the :py:meth:`yasa.Hypnogram.plot_hypnogram` method. The old function :py:func:`yasa.plot_hypnogram` still exists, but now *requires* a :py:class:`yasa.Hypnogram` instance as input.

**Other improvements**

* :py:func:`yasa.simulate_hypnogram` now returns a :py:class:`yasa.Hypnogram` instead of a :py:class:`numpy.ndarray`.
* The suggested approach to plotting hypnograms is through the :py:meth:`yasa.Hypnogram.plot_hypnogram` method. The old function :py:func:`yasa.plot_hypnogram` still exists, but now *requires* a :py:class:`yasa.Hypnogram` instance as input.
* Added helpful string representation (__repr__) to :py:class:`yasa.SleepStaging`.
* :py:func:`yasa.simulate_hypnogram` now returns a :py:class:`yasa.Hypnogram` instead of a :py:class:`numpy.ndarray`.
* The suggested approach to plotting hypnograms is through the :py:meth:`yasa.Hypnogram.plot_hypnogram` method. The old function :py:func:`yasa.plot_hypnogram` still exists, but now *requires* a :py:class:`yasa.Hypnogram` instance as input.

----------------------------------------------------------------------------------------

Expand Down
4 changes: 3 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
import os
import sys
import time
import yasa

import sphinx_bootstrap_theme

import yasa

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
Expand Down
4 changes: 2 additions & 2 deletions docs/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ Code guidelines

Before starting new code, we highly recommend opening an issue on `GitHub <https://github.com/raphaelvallat/yasa>`_ to discuss potential changes.

* Please use standard `pep8 <https://pypi.python.org/pypi/pep8>`_ and `flake8 <http://flake8.pycqa.org/>`_ Python style guidelines. To test that your code complies with those, you can run:
* Please use standard `pep8 <https://pypi.python.org/pypi/pep8>`_ and `flake8 <http://flake8.pycqa.org/>`_ Python style guidelines. YASA uses `ruff <https://github.com/astral-sh/ruff>`_ for code formatting. Before submitting a PR, please make sure to run the following command in the root folder of YASA:

.. code-block:: bash
$ flake8
$ ruff format --line-length=100
* Use `NumPy style <https://numpydoc.readthedocs.io/en/latest/format.html>`_ for docstrings. Follow existing examples for simplest guidance.

Expand Down
13 changes: 13 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
.. image:: https://pepy.tech/badge/yasa
:target: https://pepy.tech/badge/yasa

.. image:: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json
:target: https://github.com/astral-sh/ruff
:alt: Ruff

----------------

.. figure:: /pictures/yasa_logo.png
Expand Down Expand Up @@ -48,6 +52,15 @@ Alternatively, YASA can be installed with conda:
conda config --set channel_priority strict
conda install yasa
To build and install from source, clone this repository or download the source archive and decompress the files

.. code-block:: shell
cd yasa
pip install ".[test]" # install the package
pip install -e ".[test]" # or editable install
pytest # test the package
**What are the prerequisites for using YASA?**

To use YASA, all you need is:
Expand Down
Loading
Loading