Re: [Numpy-discussion] [OT: MATLAB] Any way to globally make Matlab struct attributes Python-property-like
On Mon, Sep 13, 2010 at 10:24 PM, David Goldsmith d.l.goldsm...@gmail.com wrote: I.e., I'd, at minimum, like to globally replace get(Handel, 'Property') with object.Property and set(Handel, 'Property', value) with object.Property = value to an arbitrary level of composition. Both structures and objects of both handle and value types work exactly like you're asking for. You're probably talking about handle graphics objects (which are just opaque numeric values representing things related to the UI), which do still require the get/set functions. They're just doubles, after all. It should be feasible to write a class that wraps them for ease of use, but that wouldn't be a topic for here. If that intrigues you, try asking about it on StackOverflow. ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Boolean arrays
On Fri, Aug 27, 2010 at 3:58 PM, Brett Olsen brett.ol...@gmail.com wrote: Hello, I have an array of non-numeric data, and I want to create a boolean array denoting whether each element in this array is a valid value or not. This is straightforward if there's only one possible valid value: import numpy as N ar = N.array((a, b, c, b, b, a, d, c, a)) ar == a array([ True, False, False, False, False, True, False, False, True], dtype=bool) If there's multiple possible valid values, I've come up with a couple possible methods, but they all seem to be inefficient or kludges: valid = N.array((a, c)) (ar == valid[0]) | (ar == valid[1]) array([ True, False, True, False, False, True, False, True, True], dtype=bool) N.array(map(lambda x: x in valid, ar)) array([ True, False, True, False, False, True, False, True, True], dtype=bool) Is there a numpy-appropriate way to do this? Thanks, Brett Olsen amap: Like Map, but for arrays. ar = numpy.array((a, b, c, b, b, a, d, c, a)) valid = ('a', 'c') numpy.amap(lambda x: x in valid, ar) array([ True, False, True, False, False, True, False, True, True], dtype=bool) ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Boolean arrays
On Fri, Aug 27, 2010 at 4:17 PM, Robert Kern robert.k...@gmail.com wrote: On Fri, Aug 27, 2010 at 15:10, Ken Watford kwatford+sc...@gmail.com wrote: On Fri, Aug 27, 2010 at 3:58 PM, Brett Olsen brett.ol...@gmail.com wrote: Hello, I have an array of non-numeric data, and I want to create a boolean array denoting whether each element in this array is a valid value or not. This is straightforward if there's only one possible valid value: import numpy as N ar = N.array((a, b, c, b, b, a, d, c, a)) ar == a array([ True, False, False, False, False, True, False, False, True], dtype=bool) If there's multiple possible valid values, I've come up with a couple possible methods, but they all seem to be inefficient or kludges: valid = N.array((a, c)) (ar == valid[0]) | (ar == valid[1]) array([ True, False, True, False, False, True, False, True, True], dtype=bool) N.array(map(lambda x: x in valid, ar)) array([ True, False, True, False, False, True, False, True, True], dtype=bool) Is there a numpy-appropriate way to do this? Thanks, Brett Olsen amap: Like Map, but for arrays. ar = numpy.array((a, b, c, b, b, a, d, c, a)) valid = ('a', 'c') numpy.amap(lambda x: x in valid, ar) array([ True, False, True, False, False, True, False, True, True], dtype=bool) I'm not sure what version of numpy this would be in; I've never seen it. Ah, my fault. I started ipython in pylab mode, expected to find something like amap, found it, and assumed it was in numpy. It's actually in matplotlib.mlab, strangely enough. ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Making MATLAB and Python play nice
On Fri, Aug 20, 2010 at 3:25 PM, David Goldsmith d.l.goldsm...@gmail.com wrote: Hi! Please forgive the re-post: I forgot to change the subject line and I haven't seen a response to this yet, so I'm assuming the former might be the cause of the latter. My question follows the quoted posts. Thanks! *snip* Thanks for the ideas; are any/all of these solutions freely/easily redistributable? DG The one Robin suggested is mine. It uses the MIT license, so basically you can do whatever you want with it. I haven't really been maintaining it, as I've been busy with other things, though I have been pondering a rewrite in Cython. If someone else wants to take charge of it, though, feel free. (It's amusing that both are called pymex. I spoke with the other guy once, and apparently we picked names at around the same time. I guess for what it is, that's the most obvious name one could pick.) ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] floating point arithmetic issue
2010/7/30 Guillaume Chérel guillaume.c.che...@gmail.com: Hello, I ran into a difficulty with floating point arithmetic in python. Namely that: 0.001 + 1 - 1 0.00088987 And, as a consequence, in python: 0.001 + 1 - 1 == 0.001 False In more details, my problem is that I have a fonction which needs to compute (a + b - c) % a. And for b == c, you would expect the result to be 0 whatever the value of a. But it isn't... (0.001 + 1 - 1) % 0.001 0.00088987 Is there any way to solve this? You can do slightly better than normal floating point arithmetic using some special algorithms that compensate in one way or another for the error. See math.fsum: http://docs.python.org/library/math.html#math.fsum sum([.1, .1, .1, .1, .1, .1, .1, .1, .1, .1]) 0. fsum([.1, .1, .1, .1, .1, .1, .1, .1, .1, .1]) 1.0 fsum([0.001, +1, -1]) 0.001 It won't be as fast, and naturally it won't always work, but it's something. ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Is there anyway to read raw binary file via pytable?
2010/7/28 脑关生命科学仪器 braingate...@gmail.com: it seems like pytable only support HDF5. I had some 500GB numerical arrays to process. Pytable claims to have some advance feature to enhance processing speed and largely reduce physical memory requirement. However, I do not wanna touch the raw data I had. Simply because I do not have doubled diskspace to covert all 10TB data into HDF5. Is there any way to let pytable read raw binary files or alternatively to package raw files into HDF5 format without change the files themselves.? Thanks Brain Gateway HDF5 does support datasets with an external contiguous binary file as the storage area. For documentation on this, see: http://www.hdfgroup.org/HDF5/doc/UG/10_Datasets.html#Allocation Whether or not you can easily use this fact from Python is another issue. You might check h5py's documentation to see if it can modify the necessary properties. ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] OT: request help building pymex win64
That's an excellent point. I've noticed on my (Linux) workstation that pymex works fine, but PyCUDA fails to import properly, because PyCUDA is a Boost::Python project and expects a different libstdc++ than the one that MATLAB jams into its LD_LIBRARY_PATH. (I got around this using an evil LD_PRELOAD, but that's another story) So yeah. Robin has been converting my C99isms C++-isms to get the Visual Studio compiler to accept it - and in the process, I suppose, adding a libstdc++ dependency that wasn't there to begin with that MATLAB doesn't like. Anyone know if there's a switch somewhere to get VS 2008 to accept some semblance of C99 source? Otherwise you might need to convert those bits into valid C89. I really need to convert this thing into Cython some day. On Fri, Jul 2, 2010 at 12:47 PM, David Cournapeau courn...@gmail.com wrote: On Sat, Jul 3, 2010 at 1:37 AM, Robin robi...@gmail.com wrote: Hi, Sorry for the offtopic post but I wondered if any Windows experts who are familiar with topics like linking python on windows and visual studio runtimes etc. might be able to help. I'm on a bit of a mission to get pymex built for 64 bit windows. Pymex ( http://github.com/kw/pymex ) is a matlab package that embeds the Python interpreter in a mex file and provides a very elegant interface for manipulating python objects from matlab, as well as converting between data times when necessary. It builds easily on mac, linux and win32 with mingw, but I really need it also for 64 bit windows. (It works very well with numpy as well so not completely OT). I have looked at trying to get a 64bit mingw working to build mex files, but that seemed quite difficult, so instead I am trying to build with VS 2008 Express Edition + Windows 7 SDK (for 64 bit support). As far as I can tell this is installed OK as I can build the example mex64 files OK. I have made some modifications to pymex to get it to build under vs 2008 ( http://github.com/robince/pymex/tree/win64 ). And I can get it to build and link (I believe using the implicit dll method of linking against C:\Python26\libs\python26.lib of the amd64 python.org python) without errors, but when I run it seems to segfaults whenever a pointer is passed between the mex side and python26.dll. I asked this stackoverflow question which has some more details (build log) http://stackoverflow.com/questions/3167134/trying-to-embed-python-into-matlab-mex-win64 Anyway I'm completely in the dark but wondered if some of the experts on here would be able to spot something (perhaps to do with incompatible C runtimes - I am not sure what runtime Python is built with but I thought it was VS 2008). The problem may be that matlab is built with one runtime, and Python with another Unless your matlab is very recent, it is actually quite likely to be compiled with VS 2005, which means you should use python 2.5 instead (or built python2.6 with VS 2005, but I am not sure it is even possible without herculean efforts). David ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion