Skip to content

Commit

Permalink
Modernize package structure
Browse files Browse the repository at this point in the history
  • Loading branch information
PicoCentauri committed Mar 28, 2023
1 parent 997720f commit fd944ec
Show file tree
Hide file tree
Showing 81 changed files with 585 additions and 585 deletions.
27 changes: 10 additions & 17 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,24 @@
name: Check documentation
name: Documentation

on:
push:
branches: [main]
tags: ["*"]
pull_request:
# Check all PR

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10"]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
- uses: actions/checkout@v3
- name: setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
python-version: "3.10"
- name: install dependencies
run: |
python -m pip install --upgrade pip
pip install -r docs/requirements.txt
pip install .
python -m pip install tox
sudo apt install pandoc
- name: Build the documentation
run: |
cd docs
make html
- name: build documentation
run: tox -e docs
17 changes: 17 additions & 0 deletions .github/workflows/documentation-links.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: readthedocs/actions

on:
pull_request_target:
types:
- opened

permissions:
pull-requests: write

jobs:
documentation-links:
runs-on: ubuntu-latest
steps:
- uses: readthedocs/actions/preview@v1
with:
project-slug: scikit-matter
38 changes: 11 additions & 27 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,20 @@
name: Lint

on:
push:
branches: [main]
pull_request:
# Check all PR
branches: [main]

jobs:
build:
lint:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10"]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 black isort
- name: Lint with flake8
run: |
# ignore formatting, it will be checked by black
export FORMATTING_RULES="E101,E111,E114,E115,E116,E117,E12,E13,E2,E3,E401,E5,E70,W1,W2,W3,W5"
flake8 --ignore=$FORMATTING_RULES .
- name: Lint with black
run: |
black --check .
- name: Check imports
run: |
isort skmatter/*/*py -m 3 --tc --fgw --up -e -l 88 --check
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
- run: pip install tox

- name: Test Lint
run: tox -e lint
44 changes: 24 additions & 20 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,35 @@
name: Test
name: Tests

on:
push:
branches: [main]
pull_request:
# Check all PR
branches: [main]

jobs:
build:
runs-on: ubuntu-latest
tests:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10"]
os: ['ubuntu-latest']
python-version: ['3.8', '3.9', '3.10', '3.11']
include:
- os: macos-latest
python-version: '3.10'
- os: windows-latest
python-version: '3.10'

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install tox
- name: Run tests
run: |
tox -e tests,examples
- uses: codecov/codecov-action@v1
with:
file: ./tests/coverage.xml
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- run: pip install tox

- name: run Python tests
run: tox -e tests,examples
- uses: codecov/codecov-action@v3
with:
files: ./tests/coverage.xml
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ __pycache__
.tox/
build/
dist/
docs/source/read-only-examples
docs/src/read-only-examples
9 changes: 7 additions & 2 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,22 @@
# Required
version: 2

# Set the version of Python and other tools we need
build:
os: ubuntu-22.04
tools:
python: "3.10"

# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: docs/source/conf.py
configuration: docs/src/conf.py

# Optionally build your docs in additional formats such as PDF
formats:
- pdf

# Optionally set the version of Python and requirements required to build your docs
python:
version: 3.8
install:
- requirements: docs/requirements.txt
- method: pip
Expand Down
6 changes: 4 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
recursive-include skmatter/datasets/data/ *
recursive-include skmatter/datasets/descr/ *
recursive-include src/skmatter/datasets/data/ *
recursive-include src/skmatter/datasets/descr/ *

prune tests
1 change: 1 addition & 0 deletions contributors.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ Guillaume Fraux
Sergei Kliavinek
Alexander Goscinski
Benjamin A. Helfrecht
Victor P. Principe
Michele Ceriotti
20 changes: 0 additions & 20 deletions docs/Makefile

This file was deleted.

35 changes: 0 additions & 35 deletions docs/make.bat

This file was deleted.

6 changes: 3 additions & 3 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
ipykernel
jinja2 < 3.1
matplotlib
nbsphinx==0.8.12
nbconvert
nbsphinx==0.8.12
numpy
pandas
scikit-learn >=0.24.0
sphinx >=3.3
sphinx_rtd_theme
tqdm
traitlets>=5.0
jinja2 < 3.1
pandas
11 changes: 0 additions & 11 deletions docs/source/datasets.rst

This file was deleted.

File renamed without changes.
File renamed without changes.
11 changes: 6 additions & 5 deletions docs/source/conf.py → docs/src/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@
import sphinx_rtd_theme
from nbconvert import NotebookExporter
from traitlets.config import Config
from datetime import datetime

ROOT = os.path.abspath(os.path.join("..", ".."))
sys.path.insert(0, ROOT)

# Copying and Compiling of Examples
if not os.path.exists(os.path.join(ROOT, "docs/source/read-only-examples")):
os.mkdir(os.path.join(ROOT, "docs/source/read-only-examples"))
if not os.path.exists(os.path.join(ROOT, "docs/src/read-only-examples")):
os.mkdir(os.path.join(ROOT, "docs/src/read-only-examples"))

# Set up nbconvert configuration to strip empty cells and tables of contents
c = Config()
Expand All @@ -45,15 +46,15 @@
# Skip any non-notebooks
if nb.endswith("ipynb") and "no-doc" not in nb:
nb_in = os.path.join(ROOT, "examples", nb)
nb_out = os.path.join(ROOT, "docs/source/read-only-examples", nb)
nb_out = os.path.join(ROOT, "docs/src/read-only-examples", nb)

# Skip any notebooks which already exist
if not os.path.exists(nb_out):
with open(nb_out, "w") as out_stream:
converted = exporter.from_filename(nb_in)[0]
out_stream.write(converted)

import skmatter # noqa
import skmatter # NoQa

# -- Project information -----------------------------------------------------

Expand All @@ -62,7 +63,7 @@

project = "scikit-matter"
author = ", ".join(open(os.path.join(ROOT, "contributors.txt")))
copyright = "2020, " + author
copyright = f"{datetime.now().date().year}, {author}"

# The full version, including alpha/beta/rc tags
release = skmatter.__version__
Expand Down
28 changes: 14 additions & 14 deletions docs/source/contributing.rst → docs/src/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,9 @@ Running the tests
.. code-block:: bash
cd <scikit-matter PATH>
# run unit tests
tox
# run the code formatter
black --check .
# run the linter
flake8
tox -e tests # unit tests
tox -e lint # code style
tox -e format # format all files
You may want to setup your editor to automatically apply the
`black <https://black.readthedocs.io/en/stable/>`_ code formatter when saving your
Expand All @@ -43,9 +40,11 @@ editors <https://black.readthedocs.io/en/stable/editor_integration.html>`_.
Issues and Pull Requests
########################

Having a problem with scikit-matter? Please let us know by `submitting an issue <https://github.com/lab-cosmo/scikit-matter/issues>`_.
Having a problem with scikit-matter? Please let us know by
`submitting an issue <https://github.com/lab-cosmo/scikit-matter/issues>`_.

Submit new features or bug fixes through a `pull request <https://github.com/lab-cosmo/scikit-matter/pulls>`_.
Submit new features or bug fixes through a `pull request
<https://github.com/lab-cosmo/scikit-matter/pulls>`_.


Contributing Datasets
Expand All @@ -54,9 +53,10 @@ Contributing Datasets
Have an example dataset that would fit into scikit-matter?

Contributing a dataset is easy. First, copy your numpy file into
``skmatter/datasets/data/`` with an informative name. Here, we'll call it ``my-dataset.npz``.
``src/skmatter/datasets/data/`` with an informative name. Here, we'll call it
``my-dataset.npz``.

Next, create a documentation file in ``skmatter/datasets/data/my-dataset.rst``.
Next, create a documentation file in ``src/skmatter/datasets/data/my-dataset.rst``.
This file should look like this:

.. code-block::
Expand Down Expand Up @@ -132,9 +132,9 @@ Then, show ``scikit-matter`` how to load your data by adding a loader function t
return Bunch(data=data, DESCR=fdescr)
Add this function to ``skmatter/datasets/__init__.py``.
Add this function to ``src/skmatter/datasets/__init__.py``.

Finally, add a test to ``skmatter/tests/test_datasets.py`` to see that your dataset
Finally, add a test to ``tests/test_datasets.py`` to see that your dataset
loads properly. It should look something like this:

.. code-block:: python
Expand All @@ -158,5 +158,5 @@ You're good to go! Time to submit a `pull request. <https://github.com/lab-cosmo
License
#######

This project is distributed under the BSD-3-Clauses license. By contributing to
it you agree to distribute your changes under the same license.
This project is distributed under the BSD-3-Clauses license. By contributing to it you
agree to distribute your changes under the same license.
Loading

0 comments on commit fd944ec

Please sign in to comment.