Skip to content

Commit

Permalink
Finish 0.20.2
Browse files Browse the repository at this point in the history
  • Loading branch information
jonas-eschle committed Apr 16, 2024
2 parents 25e7695 + 0be3c28 commit f286220
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ Thanks
0.20.2 (16 Apr 2024)
========================

Two small bugfixes
- fix backwards incompatible change of sampler
- detect if a RegularBinning has been transformed, raise error.

0.20.1 (14 Apr 2024)
========================
Expand Down
5 changes: 4 additions & 1 deletion tests/test_space.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Copyright (c) 2024 zfit
import hist.axis
import numpy as np
import pandas as pd
import pytest
Expand Down Expand Up @@ -94,7 +95,9 @@ def setup_teardown_vectors():
[{"multi": [limits1, limits2any]}, {"multi": [limits1any, limits2]}],
]


def test_no_binning_transform():
with pytest.raises(ValueError):
_ = zfit.Space("x",binning=hist.axis.Regular(1, 1, 2, name='x', transform=hist.axis.transform.log))
def test_illegal_bounds():
with pytest.raises(tf.errors.InvalidArgumentError):
_ = zfit.Space(["obs1", "obs2"], ([-1, 4], [2, 3]))
Expand Down
7 changes: 7 additions & 0 deletions zfit/_variables/axis.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,13 @@ def axis_to_histaxis(axis):
def new_from_axis(axis):
if isinstance(axis, hist.axis.Regular):
lower, upper = axis.edges[0], axis.edges[-1]
if axis.transform is not None:
msg = (
"Transformed axes are not supported. Please convert it explicitly to a Variable axis using the edges."
"Example: ax2 = hist.axis.Variable(ax1.edges, name='x')."
"If this is an issue or you prefer to have this automatically converted, please open an issue on github with zfit."
)
raise ValueError(msg)
return RegularBinning(axis.size, lower, upper, name=axis.name)
if isinstance(axis, hist.axis.Variable):
return VariableBinning(axis.edges, name=axis.name)
Expand Down
4 changes: 2 additions & 2 deletions zfit/core/space.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import zfit.z.numpy as znp

from .. import z
from .._variables.axis import Binnings, RegularBinning
from .._variables.axis import Binnings, RegularBinning, histaxes_to_binning
from ..settings import ztypes
from ..util import ztyping
from ..util.container import convert_to_container
Expand Down Expand Up @@ -1318,7 +1318,7 @@ def __init__(
if not isinstance(binning, Binnings):
binning = convert_to_container(binning)
if binning is not None:
binning = Binnings(binning)
binning = histaxes_to_binning(binning)
if not all(binning.name):
msg = f"Axes must have a name. Missing: {[axis for axis in binning if not hasattr(axis, 'name')]}"
raise TypeError(msg)
Expand Down

0 comments on commit f286220

Please sign in to comment.