Skip to content

Commit 0298d7d

Browse files
committed
tests: add pickle for 1.1, noxfile
1 parent 536e127 commit 0298d7d

File tree

6 files changed

+74
-7
lines changed

6 files changed

+74
-7
lines changed

.gitignore

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
# Build directories
3535
/*build*
3636
/docs/_build/*
37+
/examples/*/*build*
3738
/pip-wheel-metadata/*
3839

3940
# Outputs
@@ -56,6 +57,7 @@
5657
*.swp
5758
*~
5859
*.clangd
60+
/.cache/*
5961
compile_commands.json
6062

6163
# Venvs such as /.env
@@ -68,12 +70,15 @@ compile_commands.json
6870
/node_modules/*
6971
/yarn.lock
7072
/package.json
73+
/package-lock.json
7174

7275
# Testing
7376
/.benchmarks/*
77+
/.hypothesis/*
7478

7579
# PyCharm
76-
.idea
80+
/.idea/*
81+
82+
# VSCode
83+
/.vscode/*
7784

78-
# All-contributors
79-
package-lock.json

docs/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@
1818
#### Developer changes
1919
* Support NumPy 1.21 for static type checking [#625][]
2020
* Use newer Boost 1.77 and Boost.Histogram 1.77+1 [#594][]
21+
* Provide nox support [#647][]
2122

2223
[#594]: https://github.com/scikit-hep/boost-histogram/pull/594
2324
[#604]: https://github.com/scikit-hep/boost-histogram/pull/604
2425
[#625]: https://github.com/scikit-hep/boost-histogram/pull/625
2526
[#627]: https://github.com/scikit-hep/boost-histogram/pull/627
2627
[#631]: https://github.com/scikit-hep/boost-histogram/pull/631
2728
[#636]: https://github.com/scikit-hep/boost-histogram/pull/636
29+
[#647]: https://github.com/scikit-hep/boost-histogram/pull/647
2830

2931
### Version 1.1.0
3032

noxfile.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import nox
2+
3+
ALL_PYTHONS = ["3.6", "3.7", "3.8", "3.9"]
4+
5+
nox.options.sessions = ["lint", "tests"]
6+
7+
8+
@nox.session(python=ALL_PYTHONS)
9+
def tests(session):
10+
"""
11+
Run the unit and regular tests.
12+
"""
13+
session.install(".[test]")
14+
session.run("pytest")
15+
16+
17+
@nox.session
18+
def docs(session):
19+
"""
20+
Build the docs. Pass "serve" to serve.
21+
"""
22+
23+
session.chdir("docs")
24+
session.install("-r", "requirements.txt")
25+
session.run("sphinx-build", "-M", "html", ".", "_build")
26+
27+
if session.posargs:
28+
if "serve" in session.posargs:
29+
session.log("Launching docs at http://localhost:8000/ - use Ctrl-C to quit")
30+
session.run("python", "-m", "http.server", "8000", "-d", "_build/html")
31+
else:
32+
session.error("Unsupported argument to docs")
33+
34+
35+
@nox.session
36+
def lint(session):
37+
"""
38+
Run the linter.
39+
"""
40+
session.install("pre-commit")
41+
session.run("pre-commit", "run", "--all-files")
42+
43+
44+
@nox.session
45+
def make_pickle(session):
46+
"""
47+
Make a pickle file for this version
48+
"""
49+
session.install(".[dev]")
50+
session.run("python", "tests/pickles/make_pickle.py", *session.posargs)

tests/pickles/bh_1.1.0.pkl

1.36 KB
Binary file not shown.

tests/pickles/make_pickle.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,30 @@
33

44
import pickle
55
from pathlib import Path
6+
from typing import Optional
67

78
import typer
89

910
import boost_histogram as bh
1011

12+
DIR = Path(__file__).parent.resolve()
13+
1114

1215
def make_pickle(
13-
output: Path = typer.Argument(..., exists=False), *, protocol: int = 2 # noqa: B008
16+
output: Optional[Path] = typer.Argument(None, exists=False), # noqa: B008
17+
*,
18+
protocol: int = 2,
1419
):
1520
"""
1621
Make a pickle file with the current boost-histogram for use in tests.
1722
"""
1823

1924
VER = tuple(map(int, bh.__version__.split(".")))
2025

21-
h1 = bh.Histogram(bh.axis.Regular(31, -15, 15))
26+
if output is None:
27+
output = DIR / f"bh_{bh.__version__}.pkl"
28+
29+
h1 = bh.Histogram(bh.axis.Regular(31, -15, 15), storage=bh.storage.Int64())
2230
h2 = bh.Histogram(
2331
bh.axis.Integer(0, 5, metadata={"hello": "world"}), storage=bh.storage.Weight()
2432
)

tests/test_pickles.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
DIR = os.path.abspath(os.path.dirname(__file__))
99

1010

11-
@pytest.mark.parametrize("version", ["0.10.2", "0.6.2", "0.11.1"])
11+
@pytest.mark.parametrize("version", ["0.10.2", "0.6.2", "0.11.1", "1.1.0"])
1212
def test_read_pickle(version):
1313

1414
filename = os.path.join(DIR, "pickles", f"bh_{version}.pkl")
@@ -21,7 +21,9 @@ def test_read_pickle(version):
2121
h2 = d["h2"]
2222
h3 = d["h3"]
2323

24-
assert h1._storage_type == bh.storage.Double
24+
assert h1._storage_type == (
25+
bh.storage.Double if version[0] == "0" else bh.storage.Int64
26+
)
2527
assert h2._storage_type == bh.storage.Weight
2628
assert h3._storage_type == bh.storage.Double
2729

0 commit comments

Comments
 (0)