Giter Site home page Giter Site logo

Comments (9)

JohannesBuchner avatar JohannesBuchner commented on August 31, 2024

Hi Stevens,

try making it a pointer. In the cuba manual (cuba.pdf) it is defined as a (void *)
For instance

n = 0.5
p = ctypes.POINTER(c_int)(n)

Avoid this trap: #5 and this is the appropriate manual for ctypes: http://python.net/crew/theller/ctypes/tutorial.html
For debugging it can also useful to set the environment variable CUBACORES=1 disabling parallel execution.

Regarding separating pycuba out, I don't really see a benefit. Its a tiny package, and separation would triple the maintenance effort (e.g. creating the documentation) although the package might be more visible. I don't see the harm in having the other packages installed. Combining the packages also means that people might like to try out the other algorithms or switch between them. I see the package similar to scipy.integrate or a kind of scikit-integrate.

Cheers, Johannes

from pymultinest.

steven-murray avatar steven-murray commented on August 31, 2024

Hi Johannes,

Sorry it has been a while for me to get back to this project. I have tried what you suggest (except that I use c_double rather than c_int), and neither does it work. I think the problem is that when the userdata variable is passed to the Integrand function, in which it should be of type c_void_p, it is actually of type "int". I'm assuming this int is the address of the memory at which the userdata is stored, but I can't quite figure out more than that.

Cheers,
Steven

from pymultinest.

JohannesBuchner avatar JohannesBuchner commented on August 31, 2024

That is correct. Hopefully I will have time to look into the problem. I usually put my extra variables into a global variable and access them from the function. Maybe you can do that in the meantime?

from pymultinest.

steven-murray avatar steven-murray commented on August 31, 2024

Yes if you have time it would be nice to have this sorted. In the meantime I have been doing as you suggest and putting my extra variables as globals.

Cheers,
Steven

from pymultinest.

JohannesBuchner avatar JohannesBuchner commented on August 31, 2024

If you or someone else seriously needs this functionality in python, please re-open.

from pymultinest.

farnikn avatar farnikn commented on August 31, 2024

Hi Johannes,

I'm dealing with the same problem by putting my extra variables into a global variable, but I was wondering if there is any update for this issue and passing the userdata as a ctype variable?

Best,
Farnik

from pymultinest.

JohannesBuchner avatar JohannesBuchner commented on August 31, 2024

I don't really see the need to mangle it into C and then back out. You don't even need a global variable either, you can use a class with a method that accesses the classes attributes, or you could create a function that returns a function.

from pymultinest.

steven-murray avatar steven-murray commented on August 31, 2024

I agree with the approach @JohannesBuchner suggests -- wrapped functions or classes would be much easier.

from pymultinest.

farnikn avatar farnikn commented on August 31, 2024

Yeah I got it, thanks a lot!

from pymultinest.

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.