Skip to content
Merged
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
10 changes: 7 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
# Build directories
/*build*
/docs/_build/*
/examples/*/*build*
/pip-wheel-metadata/*

# Outputs
Expand All @@ -56,6 +57,7 @@
*.swp
*~
*.clangd
/.cache/*
compile_commands.json

# Venvs such as /.env
Expand All @@ -68,12 +70,14 @@ compile_commands.json
/node_modules/*
/yarn.lock
/package.json
/package-lock.json

# Testing
/.benchmarks/*
/.hypothesis/*

# PyCharm
.idea
/.idea/*

# All-contributors
package-lock.json
# VSCode
/.vscode/*
2 changes: 2 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@
#### Developer changes
* Support NumPy 1.21 for static type checking [#625][]
* Use newer Boost 1.77 and Boost.Histogram 1.77+1 [#594][]
* Provide nox support [#647][]

[#594]: https://github.com/scikit-hep/boost-histogram/pull/594
[#604]: https://github.com/scikit-hep/boost-histogram/pull/604
[#625]: https://github.com/scikit-hep/boost-histogram/pull/625
[#627]: https://github.com/scikit-hep/boost-histogram/pull/627
[#631]: https://github.com/scikit-hep/boost-histogram/pull/631
[#636]: https://github.com/scikit-hep/boost-histogram/pull/636
[#647]: https://github.com/scikit-hep/boost-histogram/pull/647

### Version 1.1.0

Expand Down
50 changes: 50 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import nox

ALL_PYTHONS = ["3.6", "3.7", "3.8", "3.9"]

nox.options.sessions = ["lint", "tests"]


@nox.session(python=ALL_PYTHONS)
def tests(session):
"""
Run the unit and regular tests.
"""
session.install(".[test]")
session.run("pytest")


@nox.session
def docs(session):
"""
Build the docs. Pass "serve" to serve.
"""

session.chdir("docs")
session.install("-r", "requirements.txt")
session.run("sphinx-build", "-M", "html", ".", "_build")

if session.posargs:
if "serve" in session.posargs:
session.log("Launching docs at http://localhost:8000/ - use Ctrl-C to quit")
session.run("python", "-m", "http.server", "8000", "-d", "_build/html")
else:
session.error("Unsupported argument to docs")


@nox.session
def lint(session):
"""
Run the linter.
"""
session.install("pre-commit")
session.run("pre-commit", "run", "--all-files")


@nox.session
def make_pickle(session):
"""
Make a pickle file for this version
"""
session.install(".[dev]")
session.run("python", "tests/pickles/make_pickle.py", *session.posargs)
Binary file added tests/pickles/bh_1.1.0.pkl
Binary file not shown.
12 changes: 10 additions & 2 deletions tests/pickles/make_pickle.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,30 @@

import pickle
from pathlib import Path
from typing import Optional

import typer

import boost_histogram as bh

DIR = Path(__file__).parent.resolve()


def make_pickle(
output: Path = typer.Argument(..., exists=False), *, protocol: int = 2 # noqa: B008
output: Optional[Path] = typer.Argument(None, exists=False), # noqa: B008
*,
protocol: int = 2,
):
"""
Make a pickle file with the current boost-histogram for use in tests.
"""

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

h1 = bh.Histogram(bh.axis.Regular(31, -15, 15))
if output is None:
output = DIR / f"bh_{bh.__version__}.pkl"

h1 = bh.Histogram(bh.axis.Regular(31, -15, 15), storage=bh.storage.Int64())
h2 = bh.Histogram(
bh.axis.Integer(0, 5, metadata={"hello": "world"}), storage=bh.storage.Weight()
)
Expand Down
6 changes: 4 additions & 2 deletions tests/test_pickles.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
DIR = os.path.abspath(os.path.dirname(__file__))


@pytest.mark.parametrize("version", ["0.10.2", "0.6.2", "0.11.1"])
@pytest.mark.parametrize("version", ["0.10.2", "0.6.2", "0.11.1", "1.1.0"])
def test_read_pickle(version):

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

assert h1._storage_type == bh.storage.Double
assert h1._storage_type == (
bh.storage.Double if version[0] == "0" else bh.storage.Int64
)
assert h2._storage_type == bh.storage.Weight
assert h3._storage_type == bh.storage.Double

Expand Down