Skip to content
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

fixes #14, and added regression test #15

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion numtraits.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def validate(self, obj, value):
if self.ndim is not None:

if self.ndim == 0:
if not is_scalar:
if not is_scalar and num_value.ndim:
raise TraitError("{0} should be a scalar value".format(self.name))

if self.ndim > 0:
Expand Down
6 changes: 6 additions & 0 deletions test_numtraits.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ def test_range(self):
self.sp.f = 7
assert exc.value.args[0] == "f should be in the range [3:4]"

def test_scalar_quantities(self):
""" Tests for issue #14.
"""
quantities = pytest.importorskip("quantities")
self.sp.a = 1*quantities.m

class ArrayProperties(HasTraits):

Expand All @@ -90,6 +95,7 @@ class ArrayProperties(HasTraits):
f = NumericalTrait(domain=(3, 4), ndim=1)
g = NumericalTrait(shape=(3, 4))


class TestArray(object):

def setup_method(self, method):
Expand Down