473,396 Members | 1,936 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Wrap Numpy with Cython?

Hi! I'm trying to wrap numpy with Cython and I've tried to use this
guide to manage this: http://wiki.cython.org/WrappingNumpy
However when I send an array to mysum() it gives me the right answer
only when dtype of the array is float, otherwise it gives me random
answers. The problem may be that the array is converted to a C double
which is just as long as float for Numpyarrays and therefore it works
only when the dtype is float. How do I make a Numpywrapper that works
with an arbitrary dtype?

I've also tried to convert a tuple or list with only numbers in it to
a C array with Cython but I've failed. Does anyone have an example of
how to do this?

Thanks!
Martin
Jun 27 '08 #1
1 2179
ma****************@gmail.com wrote:
Hi! I'm trying to wrap numpy with Cython and I've tried to use this
guide to manage this: http://wiki.cython.org/WrappingNumpy
However when I send an array to mysum() it gives me the right answer
only when dtype of the array is float, otherwise it gives me random
answers. The problem may be that the array is converted to a C double
which is just as long as float for Numpyarrays and therefore it works
only when the dtype is float. How do I make a Numpywrapper that works
with an arbitrary dtype?
You will need a Cython function for each dtype and dispatch based on the dtype.

You will want to ask further numpy questions on the numpy mailing list:

http://www.scipy.org/Mailing_Lists

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco

Jun 27 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Gary Wessle | last post by:
Hi I am trying to install NumPy in my debian/testing linux 2.6.15-1-686. with no numpy for debian/testing, I am left alone, since the experimental version available by debian will result in a...
2
by: Chris Smith | last post by:
Howdy, I'm a college student and for one of we are writing programs to numerically compute the parameters of antenna arrays. I decided to use Python to code up my programs. Up to now I haven't...
5
by: robert | last post by:
Turning algs for old NumPy modules into numpy code I suffer from this: Upon further processing of returns of numpy calculations, lots of data in an apps object tree will become elementary numpy...
2
by: danfan1981 | last post by:
Hi, I am learning Numpy and using it for a course project. Suppose x = , I know that x would give , and x give , is there a way that I can get . I try x, but it returns an empty array. I am...
5
by: David Lees | last post by:
August 31, 2007 I just downloaded the current Cython release and have no problem running the cpython.py translator on the demo code. But when I try compiling, I get an error complaining that my...
0
by: Stefan Behnel | last post by:
Hi, just a quick announcement that I finished the port of the Cython compiler to the Py3 target platform. While you cannot currently run Cython itself in Py3, you can build the generated C...
2
by: Travis Oliphant | last post by:
I wanted to point anybody interested to a blog post that describes a useful pattern for having a NumPy array that points to the memory created by a different memory manager than the standard one...
4
by: Tommy Grav | last post by:
I am trying to learn how to use cython, and while I am following the cython-dev mailing list I didn't feel like this question was totally appropriate for its audience so I am trying here first. ...
1
by: Srijit Kumar Bhadra | last post by:
Cython Installation on Windows documentation (http://wiki.cython.org/ InstallingOnWindows) needs a minor but important change. Under section "MinGW Compiler" compiler = mingw32 should be...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.