Skip to content

BUG: polynomial: Handle non-array inputs in polynomial class __call__ method. #24349

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 6, 2023
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
3 changes: 1 addition & 2 deletions numpy/polynomial/_polybase.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,8 +508,7 @@ def __setstate__(self, dict):
# Call

def __call__(self, arg):
off, scl = pu.mapparms(self.domain, self.window)
arg = off + scl*arg
arg = pu.mapdomain(arg, self.domain, self.window)
return self._val(arg, self.coef)

def __iter__(self):
Expand Down
7 changes: 7 additions & 0 deletions numpy/polynomial/tests/test_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,13 @@ def test_call(Poly):
assert_almost_equal(res, tgt)


def test_call_with_list(Poly):
p = Poly([1, 2, 3])
x = [-1, 0, 2]
res = p(x)
assert_equal(res, p(np.array(x)))


def test_cutdeg(Poly):
p = Poly([1, 2, 3])
assert_raises(ValueError, p.cutdeg, .5)
Expand Down