Skip to content

MAINT: Remove any promotion-state switching logic - #27156

Merged
seberg merged 4 commits into
numpy:mainfrom
seberg:delete-promotion-state
Aug 31, 2024
Merged

seberg merged 4 commits into
numpy:mainfrom
seberg:delete-promotion-state

Conversation

@seberg

@seberg seberg commented Aug 9, 2024

Copy link
Copy Markdown
Member

This is the first level, no following code simplifications, just straight up deletions of any branching.

I kept a UserWarning, in case someone had the bad idea to permanently set the environment variable and think they can rely on it. Although would be happy to just delete that as well.


I don't really think this interferes with regularly touched code, so think we might as well do it now and not worry about backports (the diff isn't huge anyway)

This is the first level, no following code simplifications, just
straight up deletions of any branching.

I kept a UserWarning, in case someone had the bad idea to permanently
set the environment variable and think they can rely on it.
Although would be happy to just delete that as well.
I think we can just do that, but maybe it's prudent to just point
it out anyway...

@ngoldbaum ngoldbaum left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Always love deleting almost a thousand lines of sort of complicated C code. I left a few minor comments but this looks good.

Comment thread numpy/_core/tests/test_numeric.py Resolved

@mattip mattip left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, and the documentation changes make sense. I will leave this for a bit if anyone else wants to take a look.

@mhvk mhvk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good, but there are quite a few comments by @ngoldbaum that are unresolved (though most/all are addressed?), so just approving, not merging.

Also one tiny nitpick - not worth running CI on its own, but can be done if there are other changes to be made still.

Comment thread numpy/_core/tests/test_dtype.py Outdated
if weak_promotion and expected_weak is not None:
expected = expected_weak

other, expected):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Bring back to one line?

@ngoldbaum

Copy link
Copy Markdown
Member

Sorry for not giving this another pass! Looks good to me now. @seberg feel free to merge along with Marten's suggested fixup.

Comment thread numpy/__init__.py
# TODO: Remove the environment variable entirely now that it is "weak"
_core._set_promotion_state(
os.environ.get("NPY_PROMOTION_STATE", "weak"))
if (os.environ.get("NPY_PROMOTION_STATE", "weak") != "weak"):

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Assign "weak" to a variable like DEFAULT_PROMOTION_STATE for better maintainability and readability.

@seberg
seberg merged commit b3ddf2f into numpy:main Aug 31, 2024
charris pushed a commit to charris/numpy that referenced this pull request Sep 15, 2024
This is the first level, no following code simplifications, just
straight up deletions of any branching.

I kept a UserWarning, in case someone had the bad idea to permanently
set the environment variable and think they can rely on it.
Although would be happy to just delete that as well.

* DOC: Add release note for promotion state removal

I think we can just do that, but maybe it's prudent to just point
it out anyway...

* DOC: Mention semi-private removed functions and tweak docs

* Adress Marten's last comment
@charris

charris commented Sep 15, 2024

Copy link
Copy Markdown
Member

@seberg I put up a backport for this (#27397) in order to simplify some other backports.

@seberg

seberg commented Sep 16, 2024

Copy link
Copy Markdown
Member Author

Hmmm, this removes the ability to use the env variable, so not sure about back-porting.

@charris

charris commented Sep 16, 2024

Copy link
Copy Markdown
Member

@seberrg OK, I'll skip a backport for now.

ArvidJB pushed a commit to ArvidJB/numpy that referenced this pull request Nov 1, 2024
This is the first level, no following code simplifications, just
straight up deletions of any branching.

I kept a UserWarning, in case someone had the bad idea to permanently
set the environment variable and think they can rely on it.
Although would be happy to just delete that as well.

* DOC: Add release note for promotion state removal

I think we can just do that, but maybe it's prudent to just point
it out anyway...

* DOC: Mention semi-private removed functions and tweak docs

* Adress Marten's last comment
@seberg
seberg deleted the delete-promotion-state branch November 14, 2024 12:06
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.

6 participants