Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

BUG: Fix weird behavior with mask and units (Fixes #8908)#9049

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
dstansby merged 4 commits intomatplotlib:masterfromdopplershift:fix-8908
Aug 29, 2017

Conversation

dopplershift
Copy link
Contributor

Refactor many places that check for masked arrays, and fill the masked
values with nans, with a helper to accomplish that. In the helper,
replace the isinstance check with a attribute check for 'mask'. This
allows libraries, like pint, that wrap mask arrays to pass the check and
be converted appropriately.

Also fix one spot usingatleast_1d with_check_1d.

@dopplershiftdopplershift added this to the2.1 (next point release) milestoneAug 17, 2017
if hasattr(x, 'mask'):
return np.ma.asarray(x, float).filled(np.nan)
else:
return np.asarray(x, float)
Copy link
Member

Choose a reason for hiding this comment

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

isasanyarray better here?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

The existing code was always going to a straight-up numpy array, and since that part of the behavior didn't seem to be causing any unit-related problems, it seemed best to be conservative and keep it asasarray.

@tacaswell
Copy link
Member

Is there a way to test this without picking up a pint dependency?

@dopplershift
Copy link
ContributorAuthor

Looks like I already started a small pint knock-off intest_units.py. I'll add a test in there.

@dopplershift
Copy link
ContributorAuthor

Added a test. Also rolled back changes tocollections.py; these were adding a conversion toarray that isn't appropriate given that things likeset_verts take lists of arrays--causing broken tests.

@dopplershift
Copy link
ContributorAuthor

IMO, this is good to go.

@dopplershift
Copy link
ContributorAuthor

I went ahead and added the test I developed for#8910. The only outstanding question on that is whether the call toautoscale_view() should really be necessary.

Refactor many places that check for masked arrays, and fill the maskedvalues with nans, with a helper to accomplish that. In the helper,replace the isinstance check with a attribute check for 'mask'. Thisallows libraries, like pint, that wrap mask arrays to pass the check andbe converted appropriately.Also fix one spot using atleast_1d with _check_1d.
This tests that unit libraries that wrap arrays, like pint, workproperly. This adds an image test that checks current behavior, whichseems to be fully correct.
@dopplershift
Copy link
ContributorAuthor

Went ahead and added a new callback for the'units finalize' event that calls bothrelim andautoscale_view (was justrelim before). Also rebased on lastest master and fixed a pep8 violation.

This adds a independent callback for units changes that both updates thedata limits (relim) as well as the view limits (autoscale_view).
@dopplershift
Copy link
ContributorAuthor

Fixed tests by making sure to only autoscale relevant axis.

@dopplershiftdopplershift added the Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. labelAug 23, 2017
@tacaswell
Copy link
Member

I suspect that this will make@TD22057 happy.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@tacaswelltacaswelltacaswell approved these changes

@dstansbydstansbydstansby approved these changes

Assignees
No one assigned
Labels
Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.topic: units and array ducktypes
Projects
None yet
Milestone
v2.1
Development

Successfully merging this pull request may close these issues.

3 participants
@dopplershift@tacaswell@dstansby

[8]ページ先頭

©2009-2025 Movatter.jp