Skip to content

Commit 65e389e

Browse files
committed
Merge branch 'master' into mdpiper/update-examples
2 parents bd09d79 + 143800a commit 65e389e

16 files changed

+182
-110
lines changed

.github/workflows/format.yml

Lines changed: 0 additions & 21 deletions
This file was deleted.

.github/workflows/lint.yml

Lines changed: 0 additions & 23 deletions
This file was deleted.

.github/workflows/test.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,8 @@ jobs:
3535
conda info
3636
conda list
3737
38-
- name: Install requirements
39-
run: |
40-
conda install --file=requirements.txt --file=requirements-testing.txt
41-
4238
- name: Build and install package
43-
run: pip install -e .
39+
run: pip install -e .[testing]
4440

4541
- name: Test
4642
run: |

.gitignore

Lines changed: 4 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,7 @@
1-
# Byte-compiled / optimized / DLL files
2-
__pycache__/
1+
*.egg-info/
32
*.py[cod]
4-
5-
# C extensions
6-
*.so
7-
8-
# Distribution / packaging
9-
.Python
10-
env/
3+
.coverage
4+
.ipynb_checkpoints/
5+
__pycache__/
116
build/
12-
develop-eggs/
137
dist/
14-
downloads/
15-
eggs/
16-
lib/
17-
lib64/
18-
parts/
19-
sdist/
20-
var/
21-
*.egg-info/
22-
.installed.cfg
23-
*.egg
24-
25-
# PyInstaller
26-
# Usually these files are written by a python script from a template
27-
# before PyInstaller builds the exe, so as to inject date/other infos into it.
28-
*.manifest
29-
*.spec
30-
31-
# Installer logs
32-
pip-log.txt
33-
pip-delete-this-directory.txt
34-
35-
# Unit test / coverage reports
36-
htmlcov/
37-
.tox/
38-
.coverage
39-
.cache
40-
nosetests.xml
41-
coverage.xml
42-
43-
# Translations
44-
*.mo
45-
*.pot
46-
47-
# Django stuff:
48-
*.log
49-
50-
# Sphinx documentation
51-
docs/_build/
52-
53-
# PyBuilder
54-
target/

.pre-commit-config.yaml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
repos:
2+
- repo: https://github.com/psf/black
3+
rev: 23.12.1
4+
hooks:
5+
- id: black
6+
name: black
7+
description: "Black: The uncompromising Python code formatter"
8+
entry: black
9+
language: python
10+
language_version: python3
11+
minimum_pre_commit_version: 2.9.2
12+
require_serial: true
13+
types_or: [python, pyi]
14+
15+
- repo: https://github.com/pycqa/flake8
16+
rev: 7.0.0
17+
hooks:
18+
- id: flake8
19+
additional_dependencies:
20+
- flake8-bugbear
21+
- flake8-comprehensions
22+
- flake8-simplify
23+
args: [--max-line-length=88]
24+
25+
- repo: https://github.com/asottile/pyupgrade
26+
rev: v3.15.0
27+
hooks:
28+
- id: pyupgrade
29+
args: [--py310-plus]
30+
31+
- repo: https://github.com/pycqa/isort
32+
rev: 5.13.2
33+
hooks:
34+
- id: isort
35+
36+
- repo: https://github.com/pre-commit/pre-commit-hooks
37+
rev: v4.5.0
38+
hooks:
39+
- id: check-builtin-literals
40+
- id: check-added-large-files
41+
- id: check-case-conflict
42+
- id: check-toml
43+
- id: check-yaml
44+
- id: debug-statements
45+
- id: end-of-file-fixer
46+
- id: forbid-new-submodules
47+
- id: mixed-line-ending
48+
- id: trailing-whitespace
49+
- id: name-tests-test
50+
- id: file-contents-sorter
51+
files: |
52+
(?x)^(
53+
.*requirements(-\w+)?.(in|txt)|
54+
requirements/.*\.txt|
55+
.gitignore
56+
)
57+
58+
- repo: https://github.com/pre-commit/mirrors-mypy
59+
rev: v1.8.0
60+
hooks:
61+
- id: mypy
62+
language_version: python3.12
63+
files: heat/.*\.py$
64+
additional_dependencies:
65+
- types-PyYAML

CHANGES.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Changelog for bmi-example-python
3131
- Match bmipy (#12)
3232
- Use GitHub Actions for continuous integration (#15)
3333
- Dimensionalize flattened values passed into set_value (#17)
34-
- Update CI (#18)
34+
- Update CI (#18)
3535
- Switch from versioneer to zest.releaser
3636
- Remove obsolete docs directory
3737

@@ -46,4 +46,3 @@ Changelog for bmi-example-python
4646
------------------
4747

4848
- Initial release
49-

LICENSE

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1919
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2020
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121
SOFTWARE.
22-

heat/bmi_heat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def initialize(self, filename=None):
3838
if filename is None:
3939
self._model = Heat()
4040
elif isinstance(filename, str):
41-
with open(filename, "r") as file_obj:
41+
with open(filename) as file_obj:
4242
self._model = Heat.from_file_like(file_obj.read())
4343
else:
4444
self._model = Heat.from_file_like(filename)

heat/heat.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ def solve_2d(temp, spacing, out=None, alpha=1.0, time_step=1.0):
5353
return np.add(temp, out, out=out)
5454

5555

56-
class Heat(object):
56+
class Heat:
57+
5758
"""Solve the Heat equation on a grid.
5859
5960
Examples

noxfile.py

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
from __future__ import annotations
2+
3+
import os
4+
import pathlib
5+
import shutil
6+
7+
import nox
8+
9+
PROJECT = "heat"
10+
ROOT = pathlib.Path(__file__).parent
11+
12+
13+
@nox.session
14+
def test(session: nox.Session) -> None:
15+
"""Run the tests."""
16+
session.install(".[testing]")
17+
18+
args = ["--cov", PROJECT, "-vvv"] + session.posargs
19+
20+
if "CI" in os.environ:
21+
args.append(f"--cov-report=xml:{ROOT.absolute()!s}/coverage.xml")
22+
session.run("pytest", *args)
23+
24+
if "CI" not in os.environ:
25+
session.run("coverage", "report", "--ignore-errors", "--show-missing")
26+
27+
28+
@nox.session
29+
def lint(session: nox.Session) -> None:
30+
"""Look for lint."""
31+
session.install("pre-commit")
32+
session.run("pre-commit", "run", "--all-files")
33+
34+
35+
@nox.session
36+
def build(session: nox.Session) -> None:
37+
session.install("pip")
38+
session.install("build")
39+
session.run("python", "--version")
40+
session.run("pip", "--version")
41+
session.run("python", "-m", "build", "--outdir", "./build/wheelhouse")
42+
43+
44+
@nox.session(name="publish-testpypi")
45+
def publish_testpypi(session):
46+
"""Publish wheelhouse/* to TestPyPI."""
47+
session.run("twine", "check", "build/wheelhouse/*")
48+
session.run(
49+
"twine",
50+
"upload",
51+
"--skip-existing",
52+
"--repository-url",
53+
"https://test.pypi.org/legacy/",
54+
"build/wheelhouse/*.tar.gz",
55+
)
56+
57+
58+
@nox.session(name="publish-pypi")
59+
def publish_pypi(session):
60+
"""Publish wheelhouse/* to PyPI."""
61+
session.run("twine", "check", "build/wheelhouse/*")
62+
session.run(
63+
"twine",
64+
"upload",
65+
"--skip-existing",
66+
"build/wheelhouse/*.tar.gz",
67+
)
68+
69+
70+
@nox.session(python=False)
71+
def clean(session):
72+
"""Remove all .venv's, build files and caches in the directory."""
73+
folders = (
74+
(ROOT,) if not session.posargs else (pathlib.Path(f) for f in session.posargs)
75+
)
76+
for folder in folders:
77+
if not str(folder.resolve()).startswith(str(ROOT.resolve())):
78+
session.log(f"skipping {folder}: folder is outside of repository")
79+
continue
80+
81+
with session.chdir(folder):
82+
session.log(f"cleaning {folder}")
83+
84+
shutil.rmtree("build", ignore_errors=True)
85+
shutil.rmtree("dist", ignore_errors=True)
86+
shutil.rmtree(f"src/{PROJECT}.egg-info", ignore_errors=True)
87+
shutil.rmtree(".pytest_cache", ignore_errors=True)
88+
shutil.rmtree(".venv", ignore_errors=True)
89+
90+
for pattern in ["*.py[co]", "__pycache__"]:
91+
_clean_rglob(pattern)
92+
93+
94+
def _clean_rglob(pattern):
95+
nox_dir = pathlib.Path(".nox")
96+
97+
for p in pathlib.Path(".").rglob(pattern):
98+
if nox_dir in p.parents:
99+
continue
100+
if p.is_dir():
101+
p.rmdir()
102+
else:
103+
p.unlink()

requirements-testing.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
black
2+
bmi-tester
13
coveralls
4+
isort
25
pytest
36
pytest-cov
4-
black
5-
isort
67
ruff
7-
bmi-tester

requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1+
bmipy
12
numpy
2-
scipy
33
pyyaml
4-
bmipy
4+
scipy
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)