Demand axisRanges is given when extrapolate is True

This commit is contained in:
Just van Rossum 2022-10-13 12:27:46 +02:00
parent e02e9dc295
commit b073fb8f6f
2 changed files with 3 additions and 1 deletions

View File

@ -150,7 +150,7 @@ def supportScalar(location, support, ot=True, extrapolate=False, axisRanges=None
-0.5
"""
if extrapolate and axisRanges is None:
axisRanges = {}
raise TypeError("axisRanges must be passed when extrapolate is True")
scalar = 1.0
for axis, (lower, peak, upper) in support.items():
if ot:

View File

@ -42,6 +42,8 @@ def test_supportScalar():
assert supportScalar({"wght": 3}, {"wght": (0, 1, 2)}, extrapolate=True, axisRanges={"wght": (0, 2)}) == -1.0
assert supportScalar({"wght": -1}, {"wght": (0, 1, 2)}, extrapolate=True, axisRanges={"wght": (0, 2)}) == -1.0
assert supportScalar({"wght": 2}, {"wght": (0, 0.75, 1)}, extrapolate=True, axisRanges={"wght": (0, 1)}) == -4.0
with pytest.raises(TypeError):
supportScalar({"wght": 2}, {"wght": (0, 0.75, 1)}, extrapolate=True, axisRanges=None)
@pytest.mark.parametrize(