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

Minimal requirements #61

Merged
merged 6 commits into from
Apr 5, 2017
Merged

Minimal requirements #61

merged 6 commits into from
Apr 5, 2017

Conversation

weaverba137
Copy link
Member

This PR:

@weaverba137 weaverba137 requested a review from dkirkby April 4, 2017 22:09
@weaverba137 weaverba137 self-assigned this Apr 4, 2017
Copy link
Member

@dkirkby dkirkby left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few minor questions, but overall this looks good, thanks!

need:

* `matplotlib <http://matplotlib.org/>`_
* `healpy <https://healpy.readthedocs.io/en/latest/>`_
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

healpy is only required for one type of plot, so its doubly optional.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it might be two plots, or at least healpy appears in two functions.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, healpy is required by both plot_healpix_map() and plot_sky_binned().

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you're right. But healpix-deniers can still make pretty plots without installing healpy if they insist.

numpy.ma.MaskedArray.__array_finalize__(self, obj)
self.vmin = getattr(obj, 'vmin', None)
self.vmax = getattr(obj, 'vmax', None)
# def __array_finalize__(self, obj):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess you checked this dunder method isn't actually needed? (I just copied the example)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what a "dunder" method is, but I do know that the original code was not working as expected, and the new code is. Please see the unit tests.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, thanks. (dunder ~ "double underscore").

if mask.shape != data.shape:
#
# Make every effort to ensure that modifying the mask of the output
# does not modify the input mask.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does renaming mask to cmask accomplish this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not a renaming, it's a copy. That function was modifying its inputs in unexpected ways. In the original code, if you input a masked array, and then input the same masked array into the function again, the inputs will not be the same.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: np.asarray(x) will not make a copy if x is already an array, while np.array(x) will make a copy. Both will promote lists to arrays if needed (thus giving more input flexibility than x.copy()). i.e. I think the code below could have been implemented as simply cmask = np.array(mask) without needing try/except.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, the simplified cmask = np.array(mask) appears to work, and is simpler.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!

@weaverba137
Copy link
Member Author

Will merge as soon as the last round of tests pass.

@weaverba137 weaverba137 merged commit 9b2df14 into master Apr 5, 2017
@weaverba137 weaverba137 deleted the minimal-requirements branch April 5, 2017 22:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants