diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000..a4288c3 --- /dev/null +++ b/.flake8 @@ -0,0 +1,16 @@ +[flake8] +exclude = + .git, + __pycache__, + env, + venv, + build, + dist +docstring-convention = numpy +max-line-length = 100 +max_complexity = 15 +max_function_length = 100 +ignore = D100, D102, D103, D104, W503 +# for compatibility with black +# https://black.readthedocs.io/en/stable/guides/using_black_with_other_tools.html#flake8 +extend-ignore = E203 diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..c2e4f53 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,14 @@ +--- +# Documentation +# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file +version: 2 +updates: +- package-ecosystem: github-actions + directory: / + schedule: + interval: weekly + +- package-ecosystem: gitsubmodule + directory: / + schedule: + interval: weekly diff --git a/.github/workflows/system_test.yml b/.github/workflows/system_test.yml new file mode 100644 index 0000000..c396c85 --- /dev/null +++ b/.github/workflows/system_test.yml @@ -0,0 +1,33 @@ +--- +name: system test + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +on: + push: + branches: [main] + pull_request: + branches: ['*'] + +jobs: + test: + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + python-version: ['3.11'] + + runs-on: ${{ matrix.os }} + + steps: + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - name: Install dev + run: | + python -m pip install --upgrade pip + pip install .[dev] diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..06c4d02 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,42 @@ +--- +name: test + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +on: + push: + branches: [main] + pull_request: + branches: ['*'] + +jobs: + test: + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + python-version: ['3.8', '3.9', '3.10', '3.11'] + + runs-on: ${{ matrix.os }} + + steps: + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - name: Install + run: | + python -m pip install --upgrade pip + pip install -e .[tests] + - name: Run tests and coverage + run: make coverage + - name: Code coverage + uses: codecov/codecov-action@v3 + with: + file: coverage.xml + flags: ${{ matrix.os }}-${{ matrix.python-version }} + name: codecov + fail_ci_if_error: false diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bc7e60c --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.pt +archive \ No newline at end of file diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..3caa31d --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,72 @@ +--- +repos: + +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + - id: check-added-large-files + +- repo: https://github.com/pre-commit/pygrep-hooks + rev: v1.10.0 + hooks: + - id: rst-backticks # Detect common mistake of using single backticks when writing rst + - id: rst-inline-touching-normal # Detect mistake of inline code touching normal text in rst + +- repo: https://github.com/asottile/pyupgrade + rev: v3.9.0 + hooks: + - id: pyupgrade + args: [--py38-plus] + +- repo: https://github.com/ikamensh/flynt/ + rev: 1.0.0 + hooks: + - id: flynt + +- repo: https://github.com/asottile/reorder-python-imports + rev: v3.10.0 + hooks: + - id: reorder-python-imports + args: [--py38-plus, --add-import, from __future__ import annotations] + +# - repo: https://github.com/pre-commit/mirrors-mypy +# rev: v1.3.0 +# hooks: +# - id: mypy +# additional_dependencies: [types-all] +# files: bidspm +# args: [--config-file, setup.cfg] + +- repo: https://github.com/MarcoGorelli/auto-walrus + rev: v0.2.2 + hooks: + - id: auto-walrus + +- repo: https://github.com/jumanjihouse/pre-commit-hook-yamlfmt + rev: 0.2.3 + hooks: + - id: yamlfmt + args: [--mapping, '2', --sequence, '2', --offset, '0'] + +- repo: https://github.com/codespell-project/codespell + rev: v2.2.5 + hooks: + - id: codespell + args: [--toml, pyproject.toml] + additional_dependencies: [tomli] + +- repo: https://github.com/psf/black + rev: 23.7.0 + hooks: + - id: black + args: [--config, pyproject.toml] + +- repo: https://github.com/pycqa/flake8 + rev: 6.0.0 + hooks: + - id: flake8 + args: [--config, .flake8] + additional_dependencies: [flake8-docstrings] diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..aa595af --- /dev/null +++ b/Makefile @@ -0,0 +1,6 @@ +coverage: + coverage erase + coverage run -m pytest + coverage report + coverage html + coverage xml diff --git a/DatasetTokenizer.py b/NumGI/DatasetTokenizer.py similarity index 100% rename from DatasetTokenizer.py rename to NumGI/DatasetTokenizer.py diff --git a/EquationCreator.py b/NumGI/EquationCreator.py similarity index 100% rename from EquationCreator.py rename to NumGI/EquationCreator.py diff --git a/EquationTokenizer.py b/NumGI/EquationTokenizer.py similarity index 99% rename from EquationTokenizer.py rename to NumGI/EquationTokenizer.py index 2ed249c..09b97cb 100644 --- a/EquationTokenizer.py +++ b/NumGI/EquationTokenizer.py @@ -220,4 +220,4 @@ def defaultTokenizer(): dict_size = len(tokenize_dict) - return tokenize_dict, decode_dict, tokenize, decode \ No newline at end of file + return tokenize_dict, decode_dict, tokenize, decode diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..631976c --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,48 @@ +[build-system] +requires = ["hatchling", "hatch-vcs"] +build-backend = "hatchling.build" + +[project] +name = "NumGI" +description = "Differential equation solver." +readme = "README.md" +requires-python = ">=3.8" +license = { file = "LICENSE.txt" } +authors = [{ name = "Arnaud Bergeron", email = "bergerona62@gmail.com" }] +dynamic = ["version"] +dependencies = ["sympy", "torch", "NumGI", "Numba"] + +[project.optional-dependencies] +doc = [ + "sphinx", + "sphinx-argparse", + "sphinx-copybutton", + "sphinx_rtd_theme", + "myst-parser", + "rstcheck", +] + + + +[tool.hatch.build.targets.wheel] +packages = ["NumGI"] + +[tool.hatch.version] +source = "vcs" + +[tool.hatch.build.hooks.vcs] +version-file = "NumGI/_version.py" + +[tool.pytest.ini_options] +addopts = "-ra -vv" + +[tool.coverage.run] +branch = true +source = ["NumGI/"] + + +[tool.codespell] +skip = "./.git,.mypy_cache,env,venv,tests,*bval,*bvec" + +[tool.black] +line-length = 100