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
Adding non-negative value check for input data objects #73
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great @zhampel. Just one comment and one question :)
pyunfold/unfold.py
Outdated
@@ -121,6 +121,8 @@ def iterative_unfold(data=None, data_err=None, response=None, | |||
for name in inputs: | |||
if inputs[name] is None: | |||
raise ValueError('The input for "{}" must not be None.'.format(name)) | |||
if np.any(np.array(inputs[name]) < 0.): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you use np.asarray
instead of np.array
? That way, if the input data are already ndarray
s, then they aren't copied.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just wondering, is there a reason to use 0.
here instead of just 0
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used 0.
to ensure floating point comparison. I used np.array()
because it merely copies and the cast_to_array
method is used just after, so I thought it would be redundant. Either way it should be fine of course :)
Added quick value error check to ensure all input data objects have non-negative values. Initial issue #72 implements ValueError check, but need a unit test to check failure mode.