Coder Social home page Coder Social logo

Comments (14)

stefanseefeld avatar stefanseefeld commented on July 18, 2024 1

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.

mpconte avatar mpconte commented on July 18, 2024

Yes, I indeed created a wrapper as you suggested, but I still get the same
error.

I've actually found an issue addressing this:

#75

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.

stefanseefeld avatar stefanseefeld commented on July 18, 2024

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.

mpconte avatar mpconte commented on July 18, 2024

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:

mantidproject/mantid@7371d12

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.

stefanseefeld avatar stefanseefeld commented on July 18, 2024

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.

mpconte avatar mpconte commented on July 18, 2024

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.

stefanseefeld avatar stefanseefeld commented on July 18, 2024

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.

mpconte avatar mpconte commented on July 18, 2024

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.

stefanseefeld avatar stefanseefeld commented on July 18, 2024

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.

stefanseefeld avatar stefanseefeld commented on July 18, 2024

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.

stefanseefeld avatar stefanseefeld commented on July 18, 2024

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.

ofloveandhate avatar ofloveandhate commented on July 18, 2024

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.

stefanseefeld avatar stefanseefeld commented on July 18, 2024

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.

ofloveandhate avatar ofloveandhate commented on July 18, 2024

thankyou!!!

from python.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.