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

ENH: Make layout order an initialization parameter of ArrayProxy#1131

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
effigies merged 8 commits intonipy:masterfromeffigies:enh/arrayproxy_order
Sep 7, 2022

Conversation

@effigies
Copy link
Member

For#1090, it's been useful to set the proxy order dynamically, rather than subclassingArrayProxy. This makes it an initialization argument. I've left it as a class variable on the off-chance that somebody actually uses something like:

classCArrayProxy(ArrayProxy):order='C'

Minor in-passing cleanups, such as removing the explicit(object) superclass and moving the test loops to parametrizations.

@codecov
Copy link

codecovbot commentedAug 20, 2022
edited
Loading

Codecov Report

Merging#1131 (cff42d6) intomaster (fd5c84b) willincrease coverage by0.00%.
The diff coverage is100.00%.

@@           Coverage Diff           @@##           master    #1131   +/-   ##=======================================  Coverage   91.80%   91.80%           =======================================  Files         101      101             Lines       12445    12454    +9       Branches     2430     2433    +3     =======================================+ Hits        11425    11434    +9  Misses        693      693             Partials      327      327
Impacted FilesCoverage Δ
nibabel/arrayproxy.py100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell ushow you rate us. Have a feature suggestion?Share it here.

@effigies
Copy link
MemberAuthor

Anybody up for a review?

@matthew-brett
Copy link
Member

Will do, tomorrow ...

Copy link
Member

@matthew-brettmatthew-brett left a comment

Choose a reason for hiding this comment

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

Hmm - I see what you mean, but the interface is now a bit clunky, because there are two ways to override the order. I guess the most direct interface would be to make the class variable bedefault_order. Is there a good way of going there without breaking people's code?

assert_array_equal(arr[sliceobj]*2.0+1.0,prox[sliceobj])


@pytest.mark.parametrize("order", ("C","F"))

Choose a reason for hiding this comment

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

Also testorder=None?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Does not work forfobj.write(arr.tobytes(order=order)) (currently L198). This is testing override specifically, so I'm not sure "use default" is really relevant.

@effigies
Copy link
MemberAuthor

Hmm - I see what you mean, but the interface is now a bit clunky, because there are two ways to override the order. I guess the most direct interface would be to make the class variable bedefault_order. Is there a good way of going there without breaking people's code?

Could changeorder todefault_order, and then look for anorder class variable (hasattr(self.__class__, "order")) in__init__ and raise aDeprecationWarning.

@matthew-brett
Copy link
Member

Could changeorder todefault_order, and then look for anorder class variable (hasattr(self.__class__, "order")) in__init__ and raise aDeprecationWarning.

Nice idea.

@effigies
Copy link
MemberAuthor

Matthew, any further comments?

Copy link
Member

@matthew-brettmatthew-brett left a comment

Choose a reason for hiding this comment

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

Oops - sorry - some of these I forgot to add in another review.

'to avoid conflict with instance variables.\n'
'* deprecated in version: 5.0\n'
'* will raise error in version: 7.0\n',
DeprecationWarning,stacklevel=2)

Choose a reason for hiding this comment

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

I forget the mechanism to time out the deprecation warning ... but shouldn't we put that in here?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

It's a decorator that works for deprecating an entire function/method/class. It does not work for cases like this. This is why I added the check below:

_default_order='C'


classDeprecatedCArrayProxy(ArrayProxy):
Copy link
Member

Choose a reason for hiding this comment

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

Timed out depraction again (as above)?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

This is specifically for testing. The warning/expiration will show up intest_deprecated_order_classvar. When we remove that function, we can remove this class. I'll add a comment...

Co-authored-by: Matthew Brett <matthew.brett@gmail.com>
'to avoid conflict with instance variables.\n'
'* deprecated in version: 5.0\n'
'* will raise error in version: 7.0\n',
DeprecationWarning,stacklevel=2)
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

It's a decorator that works for deprecating an entire function/method/class. It does not work for cases like this. This is why I added the check below:

Comment on lines +230 to +234
# Start raising errors when we crank the dev version
ifVersion(__version__)>=Version('7.0.0.dev0'):
cm=pytest.raises(ExpiredDeprecationError)
else:
cm=pytest.deprecated_call()
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

... here.

_default_order='C'


classDeprecatedCArrayProxy(ArrayProxy):
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

This is specifically for testing. The warning/expiration will show up intest_deprecated_order_classvar. When we remove that function, we can remove this class. I'll add a comment...

Copy link
Member

@matthew-brettmatthew-brett left a comment

Choose a reason for hiding this comment

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

LGTM ...

@effigies
Copy link
MemberAuthor

Thanks!

@effigieseffigies merged commit2838c06 intonipy:masterSep 7, 2022
@effigieseffigies deleted the enh/arrayproxy_order branchSeptember 7, 2022 13:50
@effigieseffigies added this to the5.0.0 milestoneJan 3, 2023
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@matthew-brettmatthew-brettmatthew-brett left review comments

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

5.0.0

Development

Successfully merging this pull request may close these issues.

2 participants

@effigies@matthew-brett

[8]ページ先頭

©2009-2025 Movatter.jp