forked from numpy/numpy
-
Notifications
You must be signed in to change notification settings - Fork 0
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
MAINT: Check numpy version in C-API #1
Merged
Merged
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using this to get the major version is a bit overloaded IMO, since we also have it available as a C function in the API table.
So, I think this helper should just import
_multiarray_umath
, that will also simplify all other code anyway and separate the concern of what the major version is.Maybe
PyObject_HasAttr(numpy, "_core")
is enough for a check?That said, we can probably probably add such a helper, although I think it should also be called
_npy_...
to more clearly signal that it is off-limits and a NumPy implementation detail.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, using
PyObject_HasAttr(numpy, "_core")
looks way simpler and it does the same job.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since I am not sure it was clear: I would suggest if we have a helper, it should be
_npy_import_numpy_multiarray_umath()
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@seberg How about
_npy_import_from_numpy_core(submodule_name)
?In autogenerated headers
_multiarray_umath
is imported, but there's also_internal
being imported from_core
insrc/common/npy_ctypes.h
. This header is defined as a dependency forlibnpymath.a
so it's sourcecode ends up in downstream library (if I understand it correctly).(A downstream lib could use
libnpymath.a
when compiling and then run with NumPy 1.x - this could cause import error onnumpy._core._internal
).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I am not seeing/understanding this. Those should be private headers, and even if the function exposed there isn't used in
libmpymath.a
? Where do you see them being a dependency?I would be surprised to find any use of this in public API accidentally or not. But, it wouldn't be the first surprise like this :).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought
common/npy_ctypes.h
is included here https://github.com/numpy/numpy/blob/d676a1fe2d495f9d8a86103644bed141c2e69787/numpy/core/meson.build#L544, but it only defines where to search for header files, right?Then sorry for confusion!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I finished refactoring - I ended up with a simpler version.
For some reason I couldn't import numpy in this initialization function (
PyImport_ImportModule("numpy")
returns null, maybe due to some a circular import?)