Comments (14)
Could you show the exact command you used to compile your module ?
I wasn't able to compile your code, as with Python 3 it is wrong: the import_array()
function on Python 3 returns NULL
, while the BOOST_PYTHON_MODULE(create)
macro call generates a function returning void
. To fix this I wrapped the import_array()
call into its own function:
#if PY_VERSION_HEX >= 0x03000000
void *
#else
void
#endif
initialize()
{
import_array();
}
BOOST_PYTHON_MODULE(create) {
initialize();
numeric::array::set_module_and_type("numpy", "ndarray");
def("numpy_array", &create_numpy_array);
}
And with that change, the module didn't produce a segmentation fault when I called the create.numpy_array()
function. (I'd suspect that due to the above error, you managed to compile the code in a way that NumPy was never actually initialized properly, which produces the symptoms you observe.)
Let me know whether you still observe an issue after applying the change I suggest.
(I should note that I only tested this on GNU/Linux (Fedora 24) using g++ 6.1.)
from python.
Yes, I indeed created a wrapper as you suggested, but I still get the same
error.
I've actually found an issue addressing this:
On Thu, Aug 4, 2016 at 3:04 PM, Stefan Seefeld [email protected]
wrote:
Could you show the exact command you used to compile your module ?
I wasn't able to compile your code, as with Python 3 it is wrong: the
import_array() function on Python 3 returns NULL, while the
BOOST_PYTHON_MODULE(create) macro call generates a function returning void.
To fix this I wrapped the import_array() call into its own function:#if PY_VERSION_HEX >= 0x03000000
void *
#else
void
#endif
initialize()
{
import_array();
}BOOST_PYTHON_MODULE(create) {
initialize();
numeric::array::set_module_and_type("numpy", "ndarray");
def("numpy_array", &create_numpy_array);
}And with that change, the module didn't produce a segmentation fault when
I called the create.numpy_array() function. (I'd suspect that due to the
above error, you managed to compile the code in a way that NumPy was never
actually initialized properly, which produces the symptoms you observe.)Let me know whether you still observe an issue after applying the change I
suggest.—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#79 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AHlt-3cWJ7qp90HApDCxpuIcKh0M30wzks5qcje_gaJpZM4Jc7R3
.
from python.
On 04.08.2016 15:20, Matthew wrote:
Yes, I indeed created a wrapper as you suggested, but I still get the same
error.
That's unfortunate, as that implies I can't reproduce the issue. I'm
still interested in knowing exactly how you built your extension module
(both on Linux as well as Windows), and what exact versions of libraries
(Python, Boost, NumPy) and tools (compilers) you are using.
...ich hab' noch einen Koffer in Berlin...
from python.
Both versions used:
python 3.5.2
boost 1.60
numpy 1.11.1
Windows used the Visual Studio 2014 compiler.
Ubuntu used the standard gnu g++ compiler that came with it.
Also, try to run the program several times, eventually it will crash (at
least it did for me).
The issue I provided the link for explains that writing a simple wrapper
for the boost numeric array will resolve the issue:
He included a link to resolve it here:
On Thu, Aug 4, 2016 at 3:24 PM, Stefan Seefeld [email protected]
wrote:
On 04.08.2016 15:20, Matthew wrote:
Yes, I indeed created a wrapper as you suggested, but I still get the
same
error.That's unfortunate, as that implies I can't reproduce the issue. I'm
still interested in knowing exactly how you built your extension module
(both on Linux as well as Windows), and what exact versions of libraries
(Python, Boost, NumPy) and tools (compilers) you are using....ich hab' noch einen Koffer in Berlin...
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#79 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AHlt-0teCmledgstfZP4F7XIRmJJQ3Jlks5qcjxjgaJpZM4Jc7R3
.
from python.
Thanks. Please note that I have plans to add proper support for NumPy to Boost.Python, which will obsolete the current "numeric" API.
from python.
That's awesome! Are you referring to the Boost.Numpy extension?
https://github.com/ndarray/Boost.NumPy
and may I ask what date or version of Boost this may be released?
On Thu, Aug 4, 2016 at 3:41 PM, Stefan Seefeld [email protected]
wrote:
Thanks. Please note that I have plans to add proper support for NumPy to
Boost.Python, which will obsolete the current "numeric" API.—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#79 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AHlt-yJ9y7v4i0f-v8pTF8ztKohP4eYMks5qckBlgaJpZM4Jc7R3
.
from python.
Yes, that's the code base I'm talking about. I don't have any specific plans / time frame yet, as there are a couple of other high priority tasks I intend to address (such as C++ 11 support).
Needless to say, any help would be more than welcome !
from python.
How could I help?
On Aug 5, 2016 09:17, "Stefan Seefeld" [email protected] wrote:
Yes, that's the code base I'm talking about. I don't have any specific
plans / time frame yet, as there are a couple of other high priority tasks
I intend to address (such as C++ 11 support).
Needless to say, any help would be more than welcome !—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#79 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AHlt-zHur34IqjJbYHEU-LYQsKmP9wSPks5qczfrgaJpZM4Jc7R3
.
from python.
Good question. Right now my highest priority is to wrap up the work on the new SCons-based build system (which allows me to build Boost.Python stand-alone, against a pre-installed Boost). This is almost complete, but it would be good to have some additional eyes / hands on it.
With that fixed, it should be relatively easy to incrementally pull in chunks from https://github.com/ndarray/Boost.NumPy.
from python.
Just as a FYI: I have just merged a new NumPy C++ API extension into the development branch, and plan to release that with Boost 1.63. (It still lacks integration with Boost's own build system, as I'm mostly just working with Boost.Python's SCons-based build logic nowadays.)
I encourage you to give that a try, as I also plan to deprecate the original "numeric" API.
from python.
Note that the numeric
module (namespace, header, etc.) have just been removed as they were obsoleted by the recent addition of proper NumPy support. Please update your code to use that instead.
from python.
when you say
Please update your code to use that instead
can you please give a link? thanks for all your work on boost python!
from python.
Please follow the instructions from the current Boost NumPy documentation (e.g., http://boostorg.github.io/python/doc/html/numpy/index.html). This has been in the last couple Boost releases, so you should be able to use the Boost.NumPy API with one of these.
from python.
thankyou!!!
from python.
Related Issues (20)
- warning: missing field 'tp_version_tag' initializer [-Wmissing-field-initializers]
- `no_proxy_helper` should not access `Container::value_type`
- Boost.Python doesn't build under MSVC... HOT 4
- NULL ptr deref in instance_dealloc
- About `No Python class registered for C++ class`,throw errors. HOT 1
- Is it possible to programmatically retrieve C++ class name / Python class name mapping ? HOT 1
- __qualname__ on embedded/inner classes is wrong
- Outdated reference to bjam in examples dir
- Broken URL in build/Jamfile HOT 2
- Qt binding to python - undefined symbol HOT 2
- Compilation failure using numpy 2.0.0b1 HOT 4
- Is Boost.Python is bound to specific python version? HOT 1
- Jupyter Kernel Notebook Dies After Starting Threaded Class HOT 4
- Cannot import Boost.Python from Python 3.11 HOT 4
- Minimal Boost Python example not working HOT 7
- Segfault when importing Python Module HOT 1
- How to Properly Expose Enum Comparison Operators to Python Using Boost.Python? HOT 1
- Expose shared_ptr to const
- missing lib boost_numpy312-vc143-mt-x64-1_85.lib HOT 1
- Boost Python 1.83.0 doesn't support NumPy 2.0
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python.