Thanks to visit codestin.com
Credit goes to github.com

Skip to content

BUG: test all ufunc.types for return type, fix for exp, log #13495

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

Merged
merged 1 commit into from
May 8, 2019

Conversation

mattip
Copy link
Member

@mattip mattip commented May 7, 2019

Fixes #13493 by registering a non-simd loop for 'e' (half) before the 'f' (float) one.

Also added a test that all ufuncs respect the types they declare

@charris
Copy link
Member

charris commented May 7, 2019

I don't see any types with ',', or that need to be stripped.

EDIT1: Otherwise LGTM.

EDIT2: Might even be best to fail for cases like that if they are errors. (Don't know if they are)

@mattip
Copy link
Member Author

mattip commented May 7, 2019

I don't see any types with ',', or that need to be stripped.

It seems I got confused with gufunc signature, which has richer syntax than type signature. The latter contains only type letters and ->. Fixing

continue
inp, out = typ.split('->')
args = [np.ones((3, 3), t) for t in inp]
with warnings.catch_warnings(record=True):
Copy link
Member

Choose a reason for hiding this comment

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

What happens to all the recorded warnings?

Copy link
Member

Choose a reason for hiding this comment

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

Could get the same effect by just ignoring them :)

Copy link
Member Author

Choose a reason for hiding this comment

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

made the ignore explicit in the next line. Without record=True the test passes but all the warnings are printed out

Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't be printed out if they are ignored.

Copy link
Member Author

Choose a reason for hiding this comment

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

hmm, filterwarnings('ignore') is not supported by pytest. @charris what change are you suggesting?

Copy link
Member

Choose a reason for hiding this comment

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

The failing test is one of ours that looks for "ignore" because using that used to mess up the warnings module.

Copy link
Member Author

Choose a reason for hiding this comment

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

The code in this PR follows the pattern in other places in the tests. Maybe we can accept this PR as-is and explore best practices for warnings in a separate issue/PR

Copy link
Member

Choose a reason for hiding this comment

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

Catch warnings is OK, it just catches all warnings, which is not ideal (and suppress_warnings can be nested and works reasonable then). Should double check, but the doc I put on suppress_warnings indeed suggests that "ignore" filters should be fine in numpy 1.17. I remember there were still some oddities, but I do not think they were relevant for this.

Copy link
Member

Choose a reason for hiding this comment

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

@seberg Sounds like we can disable the test and clean things up after we drop 1.16 support.

Copy link
Member

Choose a reason for hiding this comment

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

@charris do you mean the "no ignore warnings test"? This here should work in any case, maybe not the prettiest, but suppress_warnings is also not perfect.

@charris charris merged commit 62694bd into numpy:master May 8, 2019
@charris
Copy link
Member

charris commented May 8, 2019

Thanks Matti.

@mattip mattip deleted the float32-exp branch June 8, 2020 06:58
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.

BUG: exp and log cast float16 to float32
3 participants