[Numpy-discussion] what files to include with compiled fortran extension on Mac

2015-04-09 Thread Mark Bakker
Hello list, I want to send somebody my compiled fortran extension on a Mac (compiled with f2py and gfortran). Problem is that it doesn't work on other Macs unless they also instal xcode (2 GB, yikes!) and gfortran. So apparently there are some additional files missing when I just send the compile

Re: [Numpy-discussion] shape is (3,4) or (3L,4L) ?

2013-09-13 Thread Mark Bakker
Now that you mention it, (3L,4L) probably indeed occurs on Windows 64 bit installations. Not sure about Mac 64 bit. I haven't tried that. So, is it desirable that the 32bit returns different integers than the 64bit? I would guess not. Thanks, Mark Are they all using the same platform ? I susp

Re: [Numpy-discussion] can argmax be used to return row and column indices?

2013-09-13 Thread Mark Bakker
Thanks, Gregorio. I would like it if argmax had a keyword option to return the row,column index automatically (or whatever the dimension of the array). Afterall, argmax already knows the shape of the array. Calling np.unravel_index( np.argmax( A ) ) seems unnecessarily long. But it works well thoug

[Numpy-discussion] can argmax be used to return row and column indices?

2013-09-13 Thread Mark Bakker
Hello list, I am trying to find the indices of the maximum value in a 2D array. argmax works fine, but returns the index in the flattened array. That is often not very convenient. Is there a function that returns the index of the row and column? Or can the index of the flattened array easily be co

[Numpy-discussion] shape is (3,4) or (3L,4L) ?

2013-09-13 Thread Mark Bakker
Hello List, I am teaching a Python programming class where students use their own computer. When I create an array with 3 rows and 4 columns, a = zeros((3,4)), and ask for the shape, shape(a), then some students get (3,4), while others get (3L,4L). I guess the 3L and 4L are long integers. I wond

Re: [Numpy-discussion] how do I specify maximum line length when using savetxt?

2012-12-05 Thread Mark Bakker
I guess I wasn't explicit enough. Say I have an array with 100 numbers and I want to write it to a file with 6 numbers on each line (and hence, only 4 on the last line). Can I use savetxt to do that? What other easy tool does numpy have to do that? Thanks, Mark On 5. des. 2012, at 22:35,

[Numpy-discussion] turn off square brackets in set_print_options?

2012-12-05 Thread Mark Bakker
Hello List, Is it possible to turn off printing the square brackets in set_print_options? Am I overlooking something? Thanks, Mark ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion

[Numpy-discussion] how do I specify maximum line length when using savetxt?

2012-12-05 Thread Mark Bakker
Hello List, I want to write a large array to file, and each line can only be 80 characters long. Can I use savetxt to do that? Where would I specify the maximum line length? Or is there a better way to do this? Thanks, Mark ___ NumPy-Discussion mailing

[Numpy-discussion] status of 'present' to use optional parameters in f2py

2012-09-11 Thread Mark Bakker
Hello List, I searched the list whether it is possible to use optional arguments in fortran functions that are compiled with f2py. In 2008, this feature was not yet included and appeared to be non-trivial. Does anybody know the status of putting that feature in f2py? Thanks, Mark __

Re: [Numpy-discussion] Second try: possible bug in assignment to complex array

2012-08-11 Thread Mark Bakker
wrote: > >> > >> > > >> > > >> > On 10. aug. 2012, at 09:54, Mark Bakker wrote: > >> > > >> >> I am giving this a second try. Can anybody help me out? > >> >> > >> >> I think there is a problem w

[Numpy-discussion] Second try: possible bug in assignment to complex array

2012-08-10 Thread Mark Bakker
I am giving this a second try. Can anybody help me out? > > I think there is a problem with assigning a 1D complex array of length one > to a position in another complex array. > > Example: > > a = ones(1,'D') > b = ones(1,'D') > a[0] = b > -

[Numpy-discussion] possible bug in assignment to complex array

2012-08-08 Thread Mark Bakker
Dear List, I think there is a problem with assigning a 1D complex array of length one to a position in another complex array. Example: a = ones(1,'D') b = ones(1,'D') a[0] = b --- TypeError Tr

[Numpy-discussion] silly isscalar question

2012-05-29 Thread Mark Bakker
Why does isscalar('hello') return True? I thought it would check for a number? Numpy 1.6.1 Silly question? ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion

Re: [Numpy-discussion] problem with dot for complex matrices

2012-03-28 Thread Mark Bakker
Have you tried to create your arrays with the numpy.zeros functions rather than the scipy.zeros functions? I can imagine that something may get confused here. Maybe some version mismatch or what not. Mark From: Ryan Krauss gmail.com> Subject: Re: problem with dot for complex matrices

Re: [Numpy-discussion] distributing pre-compiled f2py extensions on OSX

2012-02-25 Thread Mark Bakker
e-compiled f2py >extensions on OSX > To: Discussion of Numerical Python > Message-ID: > > > Content-Type: text/plain; charset="iso-8859-1" > > On Fri, Feb 24, 2012 at 3:39 PM, Mark Bakker wrote: > > > Two short questions: > > > > 1. When I

[Numpy-discussion] distributing pre-compiled f2py extensions on OSX

2012-02-24 Thread Mark Bakker
Two short questions: 1. When I distribute pre-compiled f2py extensions for OSX, it seems that the users need gfortran installed, else it cannot find libgfortran.3.dylib. Is there a way to link that file with the extension? 2. Should extensions compiled on Snowleopard work on Lion? Thanks, Mark

[Numpy-discussion] combination of list of indices and newaxis not allowed?

2012-02-01 Thread Mark Bakker
Hello list, I am trying to specify the indices of an array with a list and add a newaxis, but that combination doesn't seem to be allowed. Any reason why? Here's an example: a = arange(3) This works: a[[0,2]][:,newaxis] Out[445]: array([[0], [2]]) This is more elegant syntax (and, I tho

[Numpy-discussion] swaxes(0, 1) 10% faster than transpose on 2D matrix?

2012-01-19 Thread Mark Bakker
Hello List, I noticed that swapaxes(0,1) is consistently (on my system) 10% faster than transpose on a 2D matrix. Any reason why? Any reason why the swapaxes algorithm is not used in transpose? Just wondering. Thanks, Mark ___ NumPy-Discussion mailing

Re: [Numpy-discussion] how to do this efficiently?

2011-02-09 Thread Mark Bakker
I recently needed a find_first function and searched the list. It has been discussed a few times before. And I haven't seen an elegant solution yet. Maybe we should file a feature request, as it would be awfully nice to have? Mark > > > Still, I wonder if numpy would benefit from a 'find_first' fu

[Numpy-discussion] question on use of newaxis

2011-02-09 Thread Mark Bakker
Hello List, I have a simple array a = array([1,2,3]) I want to take the last two terms and make it a column vector: a[[1,2],newaxis] But I get a funny error: TypeError: long() argument must be a string or a number, not 'NoneType' It does work if I do a[[1,2]][:,newaxis] But I don't understa

Re: [Numpy-discussion] Error in tanh for large complex argument

2011-01-28 Thread Mark Bakker
Follow up: The behavior is correct for real argument: In [20]: sinh(1000) Out[20]: inf In [21]: cosh(1000) Out[21]: inf In [22]: tanh(1000) Out[22]: 1.0 So maybe we should look there for good logic, Mark On Fri, Jan 28, 2011 at 11:45 AM, Mark Bakker wrote: > Good point, so we nee

[Numpy-discussion] incorrect behavior when complex number with zero imaginary part is multiplied by inf

2011-01-28 Thread Mark Bakker
When I multiply a complex number with inf, I get inf + inf*j: In [17]: inf * (1+1j) Out[17]: (inf+inf*j) Even when the imaginary part is really small: In [18]: inf * (1+1e-100j) Out[18]: (inf+inf*j) Yet when the imaginary part is zero (and it really is a real number), the imaginary part is nan:

Re: [Numpy-discussion] Error in tanh for large complex argument

2011-01-28 Thread Mark Bakker
Good point, so we need a better solution that fixes all cases >> I'll file a ticket. >> >> Incidentally, if tanh(z) is simply programmed as >> >> (1.0 - exp(-2.0*z)) / (1.0 + exp(-2.0*z)) >This will overflow as z -> -\infty. The solution is probably to use a >different expression for Re(z) < 0, a

Re: [Numpy-discussion] Error in tanh for large complex argument

2011-01-28 Thread Mark Bakker
I'll file a ticket. Incidentally, if tanh(z) is simply programmed as (1.0 - exp(-2.0*z)) / (1.0 + exp(-2.0*z)) the problem is fixed. Thanks, Mark [clip] > > Not for large complex values: > > > > In [85]: tanh(1000+0j) > > Out[85]: (nan+nan*j) > > Yep, it's a bug. Care to file a ticket? > > The

[Numpy-discussion] Error in tanh for large complex argument

2011-01-27 Thread Mark Bakker
Hello list, When computing tanh for large complex argument I get unexpected nans: tanh works fine for large real values: In [84]: tanh(1000) Out[84]: 1.0 Not for large complex values: In [85]: tanh(1000+0j) Out[85]: (nan+nan*j) While the correct answer is: In [86]: (1.0-exp(-2.0*(1000+0j)))/

[Numpy-discussion] status of date-times

2010-12-10 Thread Mark Bakker
Hello List, Can someone update us on the status of the date-times datatype? Is it working yet? If not, what are the plans? I really appreciate all the work and am looking forward to using the new date-times, Best regards, Mark ___ NumPy-Discussion mai

[Numpy-discussion] can savetxt write arrays with ndim > 2 ?

2010-09-28 Thread Mark Bakker
Hello list, I tried to savetxt an array with ndim = 3, but I get an error: In [252]: savetxt('test.dat',a) /Library/Frameworks/Python.framework/Versions/6.2/lib/python2.6/site-packages/numpy/lib/io.py in savetxt(fname, X, fmt, delimiter) 784 785 for row in X: --> 786 fh.write

Re: [Numpy-discussion] common significant diigits

2010-09-15 Thread Mark Bakker
10*np.floor(a/10).min() ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion

Re: [Numpy-discussion] ANN: OpenOpt 0.31, FuncDesigner 0.21, DerApproximator 0.21

2010-09-15 Thread Mark Bakker
Dmitrey, Great to hear OpenOpt development is moving forward. I tried to easy_install on both a Mac and on Windows, but both installations crashed. With similar (maybe identical) errors on "atexit" commands. Any solution? Mark ___ NumPy-Discussion mailing

[Numpy-discussion] array view with different shape

2010-09-15 Thread Mark Bakker
Hello List, Can I make a view of an entire array but with a different shape? For example: a = zeros((2,3,4)) Now I want array b to be identical to a, but with shape (2,12). b = a; b.shape = (2,12) This doesn't work, of course, as also the shape of a changes. I know I can simply make a copy of

[Numpy-discussion] conversion to 1D array of specified dtype

2010-08-31 Thread Mark Bakker
Hello list, What is the easiest way to convert a function argument to at least a 1D array of specified dtype? atleast_1d(3,dtype='d') doesn't work (numpy 1.3.0) array(atleast_1d(3),dtype='d') works but seems cumbersome Thanks, Mark ___ NumPy-Discussi

Re: [Numpy-discussion] inconsistency in 10**(-2) or 10**array([-2])

2010-08-18 Thread Mark Bakker
is also an array of integers. It works fine with array([-2.0]). On Wed, Aug 18, 2010 at 2:42 PM, Mark Bakker wrote: > Hello list, > > When I do 10**-2, Python nicely returns 0.02 > > But with numpy (version 1.3.0), I get zero: > > In [492]: 10**array([-2]) > Out[492]:

[Numpy-discussion] inconsistency in 10**(-2) or 10**array([-2])

2010-08-18 Thread Mark Bakker
Hello list, When I do 10**-2, Python nicely returns 0.02 But with numpy (version 1.3.0), I get zero: In [492]: 10**array([-2]) Out[492]: array([0]) Is this the intended behavior? Thanks, Mark ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.o

[Numpy-discussion] ceil returns real ?

2010-07-28 Thread Mark Bakker
Hello list, I don't understand why ceil and floor return real values, while the doc string says: The ceil of the scalar `x` is the smallest integer `i` Wouldn't an integer make more sense? Numpy version 1.3.0. Thanks, Mark ___ NumPy-Discussion maili

Re: [Numpy-discussion] doc string linalg.solve --> works for b is matrix

2010-07-21 Thread Mark Bakker
I am using 1.3.0. Glad to hear it is correct in 1.4.0 Sorry for bothering you with an old version, but I am very happy with this feature! Mark > What version of numpy are you using? That docstring was updated in that > fashion about 8 mo. ago (at least in the Wiki; I'm not sure exactly when it >

[Numpy-discussion] doc string linalg.solve --> works for b is matrix

2010-07-21 Thread Mark Bakker
Hello list, I am using linalg.solve to solve a system of linear equations. As I have to solve multiple systems with the same matrix, but different right-hand sides, I tried to make the right-hand side a matrix and that works fine. So the docstring should say: Solve the equation ``a x = b`` fo

Re: [Numpy-discussion] f2py problem with complex inout in subroutine

2010-07-19 Thread Mark Bakker
7/09/2010 02:03 PM, Mark Bakker wrote: >> Hello list. The following subroutine fails to compile with f2py. >> I use a complex variable with intent(inout). It works fine with two real >> variables, so I have a workaround, but it would be nicer with a complex >> variable. &

[Numpy-discussion] f2py problem with complex inout in subroutine

2010-07-09 Thread Mark Bakker
Hello list. The following subroutine fails to compile with f2py. I use a complex variable with intent(inout). It works fine with two real variables, so I have a workaround, but it would be nicer with a complex variable. Any thoughts on what I am doing wrong? Thanks, Mark module bessel contains

[Numpy-discussion] partial autocorrelation function

2010-03-25 Thread Mark Bakker
Anybody know of a partial autocorrelation function in numpy? Maybe in scipy? Thanks, Mark ps. I know, not too difficult, but if it is around I'd be happy to use it. ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mail

Re: [Numpy-discussion] why does b[:-0] not work, and is there an elegant solution?

2009-08-19 Thread Mark Bakker
The winner so far: x[: -n or None] works fine when n = 0, relatively elegant, even pretty slick I think. And I expect it to be quick. Thanks for all the replys, Mark ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/m

[Numpy-discussion] why does b[:-0] not work, and is there an elegant solution?

2009-08-19 Thread Mark Bakker
Hello list, I compute the index of the last term in an array that I need and call the index n. I can then call the array b as b[:-n] If I need all terms in the array, the logical syntax would be: b[:-0] but that doesn't work. Any reason why that has not been implemented? Any elegant workaroun

[Numpy-discussion] finding range of values below threshold in sorted array

2009-08-14 Thread Mark Bakker
Hello List, I am trying to find a quick way to do the following: I have a *sorted* array of real numbers, say array A, sorted in ascending order (but easy to store descending if that would help) I want to find all numbers below a certain value, say b Sure, I can do A < b and I will get back a

[Numpy-discussion] speed of atleast_1d and friends

2009-08-04 Thread Mark Bakker
Hello all, I am making a lot of use of atleast_1d and atleast_2d in my routines. Does anybody know whether this will slow down my code significantly? Thanks, Mark ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailma

[Numpy-discussion] array 2 string

2009-03-10 Thread Mark Bakker
Hello, I want to convert an array to a string. I like array2string, but it puts these annoying square brackets around the array, like [[1 2 3], [3 4 5]] Anyway we can suppress the square brackets and get (this is what is written with savetxt, but I cannot get it to store in a variable) 1 2 3 4

Re: [Numpy-discussion] Another question on reading from binary FORTRAN file

2009-03-10 Thread Mark Bakker
Thanks, Mike. This seems to be a really easy way. One more question. It turns out my file also contains a character string of 16 characters. I tried np.fromfile(fd,np.str,16) But that gives an error. Can I read a characterstring with fromfile? I know, I can read with fd.read, but I am wondering if

[Numpy-discussion] Another question on reading from binary FORTRAN file

2009-03-09 Thread Mark Bakker
Hello - I tried to figure this out from the list, but haven't succeeded yet. I have a simple FORTRAN binary file. It contains: 1 integer 1 float 1 array with 16 numbers (float) How do I read these into Python? Thanks, Mark ___ Numpy-discussion mailing

[Numpy-discussion] poly1d with complex coefficients doesn't integrate

2008-10-27 Thread Mark Bakker
I seem to be able to create a poly1d instance with complex coefficients, and it works correctly. But I cannot integrate it. Does poly1d not support complex coefficients? Any reason why not, that shouldn't be too difficult, should it? Thanks, Mark >>> p = poly1d([1+1j,2+2j]) >>> p(2) (4+4j) >>> q=p

[Numpy-discussion] problems multiplying poly1d with number from array

2008-10-27 Thread Mark Bakker
Hello list - I can multiply a poly1d instance with a number, but when I multiply with a number from an array, the order matters. That seems a bug: >>> a = array([2]) >>> p = poly1d([1,2]) >>> print 2*p # Works 2 x + 4 >>> print a[0]*p # Doesn't work, returns an array [2 4] >>> print p*a[0] #

[Numpy-discussion] converting scalar to array with dimension 1

2007-03-30 Thread Mark Bakker
Hello list - I have a function that normally accepts an array as input, but sometimes a scalar. I figured the easiest way to make sure the input is an array, is to make it an array. But if I make a float an array, it has 0 dimension, and I can still not do array manipulation on it. a = 3 a = ar