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

Adding non-negative value check for input data objects #73

Merged
merged 6 commits into from May 30, 2018

Conversation

zhampel
Copy link
Collaborator

@zhampel zhampel commented May 29, 2018

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.

@zhampel zhampel requested a review from jrbourbeau May 29, 2018 11:47
@zhampel zhampel self-assigned this May 29, 2018
@zhampel zhampel added enhancement New feature or request in progress labels May 29, 2018
Copy link
Owner

@jrbourbeau jrbourbeau left a 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 :)

@@ -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.):
Copy link
Owner

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 ndarrays, then they aren't copied.

Copy link
Owner

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?

Copy link
Collaborator Author

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 :)

@jrbourbeau jrbourbeau merged commit 5f33444 into jrbourbeau:master May 30, 2018
@zhampel zhampel mentioned this pull request May 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request in progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants