Re: [Numpy-discussion] Reading String type to find long magic word

2013-04-19 Thread Val Kalatsky
Here's a seed for your function: s = 'ThesampletextthatcouldbereadedthesameinbothordersArozaupalanalapuazorA' f = np.array(list(s)).view('int8').astype(float) f -= f.mean() maybe_here = np.argmax(np.convolve(f,f))/2 magic = 10 print s[maybe_here - magic:maybe_here + magic + 1] Let us now how to

Re: [Numpy-discussion] np.unique for one bi-dimensional array

2012-07-24 Thread Val Kalatsky
There are various ways to repack the pair of arrays into one array. The most universal is probably to use structured array (can repack more than a pair): x = np.array(zip(a, b), dtype=[('a',int), ('b',int)]) After repacking you can use unique and other numpy methods: xu = np.unique(x)

Re: [Numpy-discussion] fast access and normalizing of ndarray slices

2012-05-31 Thread Val Kalatsky
+length_data]) /= factor. and that for every star_point and length data. How to do this fast? Cheers Wolfgang On 2012-05-31, at 1:43 AM, Val Kalatsky wrote: What do you mean by normalized it? Could you give the output of your procedure for the sample input data. Val On Thu, May 31, 2012

Re: [Numpy-discussion] Bus error when using flat on sliced, memmap'd array

2012-05-30 Thread Val Kalatsky
Confirmed on Ubuntu, np.__version__ 1.5.1 and 1.6.1 (backtraces are bellow). Something seems to be broken before it comes to memcpy and/or _aligned_contig_to_strided_size1. Val - np.__version__ 1.6.1 Program received signal SIGSEGV,

Re: [Numpy-discussion] fast access and normalizing of ndarray slices

2012-05-30 Thread Val Kalatsky
What do you mean by normalized it? Could you give the output of your procedure for the sample input data. Val On Thu, May 31, 2012 at 12:36 AM, Wolfgang Kerzendorf wkerzend...@gmail.com wrote: Dear all, I have an ndarray which consists of many arrays stacked behind each other (only

Re: [Numpy-discussion] numpy.random.gamma returns 0 for small shape parameters

2012-05-28 Thread Val Kalatsky
You'll need some patience to get non-zeros, especially for k=1e-5 In [84]: np.sum(np.random.gamma(1e-5,size=100)!=0.0) Out[84]: 7259 that's less than 1%. For k=1e-4 it's ~7% Val On Mon, May 28, 2012 at 10:33 PM, Uri Laserson uri.laser...@gmail.comwrote: I am trying to sample from a

Re: [Numpy-discussion] Quaternion data type

2012-05-05 Thread Val Kalatsky
Hi Tod, Would you consider bundling the quaternion dtype with your package. I think everybody wins: your package would become stronger and Martin's dtype would become easily available. Thanks Val On Sat, May 5, 2012 at 6:27 AM, Tom Aldcroft aldcr...@head.cfa.harvard.eduwrote: On Fri, May 4,

Re: [Numpy-discussion] Slice specified axis

2012-04-05 Thread Val Kalatsky
The only slicing short-cut I can think of is the Ellipsis object, but it's not going to help you much here. The alternatives that come to my mind are (1) manipulation of shape directly and (2) building a string and running eval on it. Your solution is better than (1), and (2) is a horrible hack,

Re: [Numpy-discussion] One question about the numpy.linalg.eig() routine

2012-04-03 Thread Val Kalatsky
:53 PM, Matthew Brett matthew.br...@gmail.comwrote: Hi, On Mon, Apr 2, 2012 at 5:38 PM, Val Kalatsky kalat...@gmail.com wrote: Both results are correct. There are 2 factors that make the results look different: 1) The order: the 2nd eigenvector of the numpy solution corresponds

Re: [Numpy-discussion] One question about the numpy.linalg.eig() routine

2012-04-02 Thread Val Kalatsky
Both results are correct. There are 2 factors that make the results look different: 1) The order: the 2nd eigenvector of the numpy solution corresponds to the 1st eigenvector of your solution, note that the vectors are written in columns. 2) The phase: an eigenvector can be multiplied by an

Re: [Numpy-discussion] One question about the numpy.linalg.eig() routine

2012-04-02 Thread Val Kalatsky
in my 1st email should be negated: 0.99887305445887753+0.047461785427773337j On Mon, Apr 2, 2012 at 8:53 PM, Matthew Brett matthew.br...@gmail.comwrote: Hi, On Mon, Apr 2, 2012 at 5:38 PM, Val Kalatsky kalat...@gmail.com wrote: Both results are correct. There are 2 factors that make

Re: [Numpy-discussion] float96 on windows32 is float64?

2012-03-15 Thread Val Kalatsky
I just happened to have an xp64 VM running: My version of numpy (1.6.1) does not have float128 (see more below what I get in ipython session). If you need to test something else please let me know. Val --- Enthought Python Distribution -- www.enthought.com Python 2.7.2 |EPD 7.2-2 (64-bit)|

Re: [Numpy-discussion] float96 on windows32 is float64?

2012-03-15 Thread Val Kalatsky
+308 nexp =11 min=-max - On Thu, Mar 15, 2012 at 11:38 PM, Matthew Brett matthew.br...@gmail.comwrote: Hi, On Thu, Mar 15, 2012 at 9:33 PM, Val Kalatsky kalat...@gmail.com wrote: I just happened to have an xp64

Re: [Numpy-discussion] about sympy

2012-03-10 Thread Val Kalatsky
Can you? The question should be: Why sympy does not have Fresnel integrals? On Sun, Mar 11, 2012 at 1:06 AM, aa telukp...@gmail.com wrote: why sympy cannot integrate sin(x**2)?? ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org

Re: [Numpy-discussion] subclassing array in c

2012-03-08 Thread Val Kalatsky
26 org.python.python 0x0001000b0286 Py_Main + 2718 27 org.python.python.app 0x00010e6c start + 52 Am 08.03.2012 um 02:36 schrieb Val Kalatsky: Tried it on my Ubuntu 10.10 box, no problem: 1) Saved as spampub.c 2) Compiled with (setup.py attached): python

Re: [Numpy-discussion] subclassing array in c

2012-03-07 Thread Val Kalatsky
Seeing the backtrace would be helpful. Can you do whatever leads to the segfault from python run from gdb? Val On Wed, Mar 7, 2012 at 7:04 PM, Christoph Gohle christoph.go...@mpq.mpg.dewrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi, I have been struggeling for quite some time now.

Re: [Numpy-discussion] subclassing array in c

2012-03-07 Thread Val Kalatsky
Out[4]: 'liter' On Wed, Mar 7, 2012 at 7:15 PM, Val Kalatsky kalat...@gmail.com wrote: Seeing the backtrace would be helpful. Can you do whatever leads to the segfault from python run from gdb? Val On Wed, Mar 7, 2012 at 7:04 PM, Christoph Gohle christoph.go...@mpq.mpg.de wrote

Re: [Numpy-discussion] Determining the 'viewness' of an array, and flags.owndata confusion

2012-02-28 Thread Val Kalatsky
Viewness is in the eyes of the beholder. You have to use indirect methods to figure it out. Probably the most robust approach is to go up the base chain until you get None. In [71]: c1=np.arange(16) In [72]: c2=c1[::2] In [73]: c4=c2[::2] In [74]: c8=c4[::2] In [75]: id(c8.base)==id(c4) Out[75]:

Re: [Numpy-discussion] is there an efficient way to get a random set of subsets/combinations?

2012-02-20 Thread Val Kalatsky
Hi Slava, Since your k is only 10, here is a quickie: import numpy as np arr = np.arange(n) for i in range(k): np.random.shuffle(arr) print np.sort(arr[:p]) If your ever get non-unique entries in a set of k=10 for your n and p, consider yourself lucky:) Val On Mon, Feb 20, 2012 at

Re: [Numpy-discussion] Strange PyArray_FromObject() behavior

2012-02-16 Thread Val Kalatsky
Hi Bill, Looks like you are running a very fresh version of numpy. Without knowing the build version and what's going on in the extension module I can't tell you much. The usual suspects would be: 1) Numpy bug, not too likely. 2) Incorrect use of PyArray_FromObject, you'll need to send more info.

Re: [Numpy-discussion] matrix indexing

2012-02-07 Thread Val Kalatsky
Aronne made good suggestions. Here is another weapon for your arsenal: 1) I assume that the shape of your array is irrelevant (reshape if needed) 2) Depending on the structure of your data np.unique can be handy: arr_unique, idx = np.unique(arr1d, return_inverse=True) then search arr_unique

Re: [Numpy-discussion] need advice on installing NumPy onto a Windows 7 with Python2.7 (32-bit)

2012-01-26 Thread Val Kalatsky
To avoid all the hassle I suggest getting EPD: http://enthought.com/products/epd.php You'd get way more than just NumPy, which may or may not be what you need. I have installed various NumPy's on linux only and from source only which did require compilation (gcc), so I am not a good help for your

Re: [Numpy-discussion] array metadata

2012-01-25 Thread Val Kalatsky
I believe there are no provisions made for that in ndarray. But you can subclass ndarray. Val On Wed, Jan 25, 2012 at 12:10 PM, Emmanuel Mayssat emays...@gmail.comwrote: Is there a way to store metadata for an array? For example, date the samples were collected, name of the operator, etc.

Re: [Numpy-discussion] bug in numpy.mean() ?

2012-01-24 Thread Val Kalatsky
Just what Bruce said. You can run the following to confirm: np.mean(data - data.mean()) If for some reason you do not want to convert to float64 you can add the result of the previous line to the bad mean: bad_mean = data.mean() good_mean = bad_mean + np.mean(data - bad_mean) Val On Tue, Jan

Re: [Numpy-discussion] Ufuncs and flexible types, CAPI

2012-01-10 Thread Val Kalatsky
or not. This has to be evaluated quite a lot. Oh well ... and 1.3.0 is pretty old :-) cheers, Samuel On 31.12.2011, at 07:48, Val Kalatsky wrote: Hi folks, First post, may not follow the standards, please bear with me. Need to define a ufunc that takes care of various type. Fixed

[Numpy-discussion] Ufuncs and flexible types, CAPI

2011-12-30 Thread Val Kalatsky
OnFail: the resolution took place and did not succeed, the user is given a chance to fix it. In most of the case these callbacks are NULLs. I could patch numpy with a generic method that does it, but it's a shame not to use the good ufunc machine. Thanks for tips and suggestions. Val Kalatsky