Re: [Numpy-discussion] Extract subset from an array

2010-02-17 Thread Francesc Alted
A Wednesday 17 February 2010 08:34:06 Nicola Creati escrigué:
 Any kind of improvement is really appreciated.

Well, if you cannot really transpose your matrix, numexpr can also serve as a 
good accelerator:

In [1]: import numpy as np

In [2]: import numexpr as ne

In [3]: x_min, x_max, y_min, y_max = .3, .5, .4, .7

In [4]: array = np.random.random((1000, 3))

In [5]: time (array[:,0]x_min)  (array[:,0]x_max)  (array[:,1]y_min)  
(array[:,1]y_max)
CPU times: user 0.23 s, sys: 0.03 s, total: 0.26 s
Wall time: 0.27 s
Out[6]: array([False, False, False, ..., False, False, False], dtype=bool)

In [9]: time ne.evaluate((ax_min)  (ax_max)  (by_min)  (by_max), 
{'a': array[:,0], 'b': array[:,1]})
CPU times: user 0.16 s, sys: 0.00 s, total: 0.16 s
Wall time: 0.16 s
Out[10]: array([False, False, False, ..., False, False, False], dtype=bool)

Again, an 1.7x of improvement, but without the need for transposing.

-- 
Francesc Alted
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Extract subset from an array

2010-02-17 Thread Nicola Creati
Francesc Alted wrote:
 A Wednesday 17 February 2010 08:34:06 Nicola Creati escrigué:
   
 Any kind of improvement is really appreciated.
 

 Well, if you cannot really transpose your matrix, numexpr can also serve as a 
 good accelerator:

 In [1]: import numpy as np

 In [2]: import numexpr as ne

 In [3]: x_min, x_max, y_min, y_max = .3, .5, .4, .7

 In [4]: array = np.random.random((1000, 3))

 In [5]: time (array[:,0]x_min)  (array[:,0]x_max)  (array[:,1]y_min)  
 (array[:,1]y_max)
 CPU times: user 0.23 s, sys: 0.03 s, total: 0.26 s
 Wall time: 0.27 s
 Out[6]: array([False, False, False, ..., False, False, False], dtype=bool)

 In [9]: time ne.evaluate((ax_min)  (ax_max)  (by_min)  (by_max), 
 {'a': array[:,0], 'b': array[:,1]})
 CPU times: user 0.16 s, sys: 0.00 s, total: 0.16 s
 Wall time: 0.16 s
 Out[10]: array([False, False, False, ..., False, False, False], dtype=bool)

 Again, an 1.7x of improvement, but without the need for transposing.

   
Hi,
this morning I tried numexpr and I got a good speed improvement as you 
just suggest.
Thanks for keep helping me. :)

Nicola


-- 
Nicola Creati
Istituto Nazionale di Oceanografia e di Geofisica Sperimentale - OGS 
www.inogs.it Dipartimento di Geofisica della Litosfera Geophysics of 
Lithosphere Department CARS (Cartography and Remote Sensing) Research Group 
http://www.inogs.it/Cars/ Borgo Grotta Gigante 42/c 34010 Sgonico - Trieste - 
ITALY ncre...@ogs.trieste.it
off.   +39 040 2140 213
fax.   +39 040 327307

_
This communication, that may contain confidential and/or legally privileged 
information, is intended solely for the use of the intended addressees. 
Opinions, conclusions and other information contained in this message, that do 
not relate to the official business of OGS, shall be considered as not given or 
endorsed by it. Every opinion or advice contained in this communication is 
subject to the terms and conditions provided by the agreement governing the 
engagement with such a client. Any use, disclosure, copying or distribution of 
the contents of this communication by a not-intended recipient or in violation 
of the purposes of this communication is strictly prohibited and may be 
unlawful. For Italy only: Ai sensi del D.Lgs.196/2003 - T.U. sulla Privacy si 
precisa che le informazioni contenute in questo messaggio sono riservate ed a 
uso esclusivo del destinatario.
_ 

___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] ndarray of complex-like data

2010-02-17 Thread Brecht Machiels
Robert Kern wrote:
 2) Subclass the ndarray to do what you want.
 I have subclassed ndarray, but I'm not sure how to continue from there.
 I was thinking of overriding __getitem__ and casting the complex to my
 complex subclass. Would that be the way to go? How would that work with
 slices?
 
 I strongly recommend simply implementing an arg() function that works
 on both arrays and and complex objects. Then just use abs() and arg()
 instead of trying to get instances of your class and using their
 attributes.

Hmm. I hadn't thought of that option. I guess this makes more sense as 
this can than also operate on arrays like you say.

Still, it would be interesting to know whether it's possible to have an 
ndarray subclass return instances of my complex subclass, preferably 
without having to copy the complex data (which would occur if I were to 
implement this behaviour by overriding __getitem__ as described above). 
But I assume that would require a user-defined type written in C?

Regards,
Brecht

___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


[Numpy-discussion] doc wiki merge request

2010-02-17 Thread Ralf Gommers
Hi,

Can we have a doc wiki merge before the next release? I reviewed everything,
there's changes to about 150 docstrings. See
http://docs.scipy.org/numpy/patch/

Thanks,
Ralf
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


[Numpy-discussion] Unit Tests failing daily for 2 months

2010-02-17 Thread Christopher Hanley
Hi,

I've been informed by our build/installation person that 3 unit tests
have been failing in the daily numpy svn installation for the last 2
months.  The most recent output from the tests is as follows:

==
FAIL: Test generic loops.
--
Traceback (most recent call last):
  File /usr/stsci/pyssgdev/2.5.4/numpy/core/tests/test_ufunc.py,
line 86, in test_generic_loops
assert_almost_equal(fone(x), fone_val, err_msg=msg)
  File /usr/stsci/pyssgdev/2.5.4/numpy/testing/utils.py, line 435,
in assert_almost_equal
raise AssertionError(msg)
AssertionError:
Arrays are not almost equal PyUFunc_F_F
 ACTUAL: array([ 0.+0.j,  0.+0.j,  0.+0.j,  0.+0.j,  0.+0.j], dtype=complex64)
 DESIRED: 1

==
FAIL: test_umath.TestComplexFunctions.test_loss_of_precision(type
'numpy.complex64',)
--
Traceback (most recent call last):
  File /usr/stsci/pyssgdev/2.5.4/nose/case.py, line 183, in runTest
self.test(*self.arg)
  File /usr/stsci/pyssgdev/2.5.4/numpy/core/tests/test_umath.py,
line 721, in check_loss_of_precision
check(x_basic, 2*eps/1e-3)
  File /usr/stsci/pyssgdev/2.5.4/numpy/core/tests/test_umath.py,
line 691, in check
'arcsinh')
AssertionError: (0, 0.0010023052, 0.9987238, 'arcsinh')

==
FAIL: test_umath.TestComplexFunctions.test_precisions_consistent
--
Traceback (most recent call last):
  File /usr/stsci/pyssgdev/2.5.4/nose/case.py, line 183, in runTest
self.test(*self.arg)
  File /usr/stsci/pyssgdev/2.5.4/numpy/core/tests/test_umath.py,
line 602, in test_precisions_consistent
assert_almost_equal(fcf, fcd, decimal=6, err_msg='fch-fcd %s'%f)
  File /usr/stsci/pyssgdev/2.5.4/numpy/testing/utils.py, line 435,
in assert_almost_equal
raise AssertionError(msg)
AssertionError:
Arrays are not almost equal fch-fcd ufunc 'arcsin'
 ACTUAL: 2.3561945j
 DESIRED: (0.66623943249251527+1.0612750619050355j)

--
Ran 2512 tests in 18.753s

FAILED (KNOWNFAIL=4, failures=3)
Running unit tests for numpy
NumPy version 2.0.0.dev8116
NumPy is installed in /usr/stsci/pyssgdev/2.5.4/numpy
Python version 2.5.4 (r254:67916, Oct 26 2009, 14:36:20) [GCC 3.4.6
20060404 (Red Hat 3.4.6-11)]
nose version 0.11.1
errors:
failures:
(Test(test_ufunc.TestUfunc testMethod=test_generic_loops),
'Traceback (most recent call last):\n  File
/usr/stsci/pyssgdev/2.5.4/numpy/core/tests/test_ufunc.py, line 86,
in test_generic_loops\nassert_almost_equal(fone(x), fone_val,
err_msg=msg)\n  File
/usr/stsci/pyssgdev/2.5.4/numpy/testing/utils.py, line 435, in
assert_almost_equal\nraise AssertionError(msg)\nAssertionError:
\nArrays are not almost equal PyUFunc_F_F\n ACTUAL: array([ 0.+0.j,
0.+0.j,  0.+0.j,  0.+0.j,  0.+0.j], dtype=complex64)\n DESIRED: 1\n')
(Test(test_umath.TestComplexFunctions.test_loss_of_precision(type
'numpy.complex64',)), 'Traceback (most recent call last):\n  File
/usr/stsci/pyssgdev/2.5.4/nose/case.py, line 183, in runTest\n
self.test(*self.arg)\n  File
/usr/stsci/pyssgdev/2.5.4/numpy/core/tests/test_umath.py, line 721,
in check_loss_of_precision\ncheck(x_basic, 2*eps/1e-3)\n  File
/usr/stsci/pyssgdev/2.5.4/numpy/core/tests/test_umath.py, line 691,
in check\n\'arcsinh\')\nAssertionError: (0, 0.0010023052,
0.9987238, \'arcsinh\')\n')
(Test(test_umath.TestComplexFunctions.test_precisions_consistent),
'Traceback (most recent call last):\n  File
/usr/stsci/pyssgdev/2.5.4/nose/case.py, line 183, in runTest\n
self.test(*self.arg)\n  File
/usr/stsci/pyssgdev/2.5.4/numpy/core/tests/test_umath.py, line 602,
in test_precisions_consistent\nassert_almost_equal(fcf, fcd,
decimal=6, err_msg=\'fch-fcd %s\'%f)\n  File
/usr/stsci/pyssgdev/2.5.4/numpy/testing/utils.py, line 435, in
assert_almost_equal\nraise AssertionError(msg)\nAssertionError:
\nArrays are not almost equal fch-fcd ufunc \'arcsin\'\n ACTUAL:
2.3561945j\n DESIRED: (0.66623943249251527+1.0612750619050355j)\n')



--

These failing tests are logged in Trac ticket numbers 1323, 1324, and
1325 respectively.

Is anyone else seeing these failures?  Any idea what the problem may be?

It appears this problem is limited to 64-bit RHE 4 systems.

Thank you for your time and help,
Chris


-- 
Christopher Hanley
Senior Systems Software Engineer
Space Telescope Science Institute
3700 San Martin Drive
Baltimore MD, 21218
(410) 338-4338
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Unit Tests failing daily for 2 months

2010-02-17 Thread Charles R Harris
On Wed, Feb 17, 2010 at 8:33 AM, Christopher Hanley chan...@stsci.eduwrote:

 Hi,

 I've been informed by our build/installation person that 3 unit tests
 have been failing in the daily numpy svn installation for the last 2
 months.  The most recent output from the tests is as follows:


I don't see these here. What architecture/compiler/os ?


 ==
 FAIL: Test generic loops.
 --
 Traceback (most recent call last):
  File /usr/stsci/pyssgdev/2.5.4/numpy/core/tests/test_ufunc.py,
 line 86, in test_generic_loops
assert_almost_equal(fone(x), fone_val, err_msg=msg)
  File /usr/stsci/pyssgdev/2.5.4/numpy/testing/utils.py, line 435,
 in assert_almost_equal
raise AssertionError(msg)
 AssertionError:
 Arrays are not almost equal PyUFunc_F_F
  ACTUAL: array([ 0.+0.j,  0.+0.j,  0.+0.j,  0.+0.j,  0.+0.j],
 dtype=complex64)
  DESIRED: 1


That's new to me.


 ==
 FAIL: test_umath.TestComplexFunctions.test_loss_of_precision(type
 'numpy.complex64',)
 --
 Traceback (most recent call last):
  File /usr/stsci/pyssgdev/2.5.4/nose/case.py, line 183, in runTest
self.test(*self.arg)
  File /usr/stsci/pyssgdev/2.5.4/numpy/core/tests/test_umath.py,
 line 721, in check_loss_of_precision
check(x_basic, 2*eps/1e-3)
  File /usr/stsci/pyssgdev/2.5.4/numpy/core/tests/test_umath.py,
 line 691, in check
'arcsinh')
 AssertionError: (0, 0.0010023052, 0.9987238, 'arcsinh')

 ==
 FAIL: test_umath.TestComplexFunctions.test_precisions_consistent
 --
 Traceback (most recent call last):
  File /usr/stsci/pyssgdev/2.5.4/nose/case.py, line 183, in runTest
self.test(*self.arg)
  File /usr/stsci/pyssgdev/2.5.4/numpy/core/tests/test_umath.py,
 line 602, in test_precisions_consistent
assert_almost_equal(fcf, fcd, decimal=6, err_msg='fch-fcd %s'%f)
  File /usr/stsci/pyssgdev/2.5.4/numpy/testing/utils.py, line 435,
 in assert_almost_equal
raise AssertionError(msg)
 AssertionError:
 Arrays are not almost equal fch-fcd ufunc 'arcsin'
  ACTUAL: 2.3561945j
  DESIRED: (0.66623943249251527+1.0612750619050355j)

 --


These two also fail on the buildbot Mac and have for some time. If you are
able to reproduce them on an available machine that will be helpful in
tracking them down.

snip

Chuck
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Unit Tests failing daily for 2 months

2010-02-17 Thread Christopher Hanley

 I don't see these here. What architecture/compiler/os ?


The system architecture is 2 * Intel Xeon with hyperthreading.  The OS
is Red Hat Enterprise (RHE) 4 64-bit running Python 2.5.4.  The C
compiler being used is GCC 3.4.6.  No Fortran compiler is being used.


 That's new to me.

Darn.  I was hoping this was old news.


 These two also fail on the buildbot Mac and have for some time. If you are
 able to reproduce them on an available machine that will be helpful in
 tracking them down.


We can reproduce these problems on our RHE machine.  A quick check of
our logs from last night doesn't seem to indicate a problem on our
Intel Mac 10.5 systems.  However if there is something you want me to
try just let me know what you need.

Thanks,
Chris



--
Christopher Hanley
Senior Systems Software Engineer
Space Telescope Science Institute
3700 San Martin Drive
Baltimore MD, 21218
(410) 338-4338
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] ndarray of complex-like data

2010-02-17 Thread Robert Kern
On Wed, Feb 17, 2010 at 02:43, Brecht Machiels
brecht.machi...@esat.kuleuven.be wrote:
 Robert Kern wrote:
 2) Subclass the ndarray to do what you want.
 I have subclassed ndarray, but I'm not sure how to continue from there.
 I was thinking of overriding __getitem__ and casting the complex to my
 complex subclass. Would that be the way to go? How would that work with
 slices?

 I strongly recommend simply implementing an arg() function that works
 on both arrays and and complex objects. Then just use abs() and arg()
 instead of trying to get instances of your class and using their
 attributes.

 Hmm. I hadn't thought of that option. I guess this makes more sense as
 this can than also operate on arrays like you say.

 Still, it would be interesting to know whether it's possible to have an
 ndarray subclass return instances of my complex subclass, preferably
 without having to copy the complex data (which would occur if I were to
 implement this behaviour by overriding __getitem__ as described above).
 But I assume that would require a user-defined type written in C?

Well, when numpy indexes to get a scalar, the data is always copied
(apart from object arrays, of course). It's not something you can or
should try to avoid.

-- 
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
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Unit Tests failing daily for 2 months

2010-02-17 Thread Charles R Harris
On Wed, Feb 17, 2010 at 9:07 AM, Christopher Hanley chan...@stsci.eduwrote:

 
  I don't see these here. What architecture/compiler/os ?
 

 The system architecture is 2 * Intel Xeon with hyperthreading.  The OS
 is Red Hat Enterprise (RHE) 4 64-bit running Python 2.5.4.  The C
 compiler being used is GCC 3.4.6.  No Fortran compiler is being used.


My mistake on the buildbot os, it was FreeBSD.


 
  That's new to me.

 Darn.  I was hoping this was old news.

 
  These two also fail on the buildbot Mac and have for some time. If you
 are
  able to reproduce them on an available machine that will be helpful in
  tracking them down.
 

 We can reproduce these problems on our RHE machine.  A quick check of
 our logs from last night doesn't seem to indicate a problem on our
 Intel Mac 10.5 systems.  However if there is something you want me to
 try just let me know what you need.


It doesn't seem related to python version, but may be related to compiler
version. For FreeBSD:

Python version 2.5.2 (r252:60911, Dec 15 2008, 12:04:33) [GCC 3.4.6
[FreeBSD] 20060305]

Chuck
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


[Numpy-discussion] 1.4 still the candidate for easy_install

2010-02-17 Thread David Warde-Farley
Hi,

I'm pretty sure this is unintentional but I tried easy_install numpy  
the other day and it pulled down a 1.4 tarball from PyPI.

David
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] 1.4 still the candidate for easy_install

2010-02-17 Thread Jarrod Millman
Good catch.  I just removed the 1.4.0 tarball from PyPI.

Thanks,

-- 
Jarrod Millman
Helen Wills Neuroscience Institute
10 Giannini Hall, UC Berkeley
http://cirl.berkeley.edu/
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


[Numpy-discussion] Sun Studio Compilers on Linux / atan2 regression

2010-02-17 Thread Christian Marquardt
Hi,

when compiling numpy-1.40 with the Sun Studio Compilers (v12 Update 1) on Linux 
(an OpenSUSE 11.1 in my case), about 30 tests in numpy.test() fail; all 
failures are related to the arctan2 function. 

I've found that in r7732 a patch was applied to 
trunk/numpy/core/src/private/npy_config.h in response to #1201, #1202, and 
#1203, #undef'ing the HAVE_ATAN2 variable in order to fix a broken atan2() 
implementation on Solaris. It seems that this does no good with the most recent 
Sun compiler on Linux...

The attached patch ensures that the original patch is only applied on Solaris 
platforms; with this applied, all tests are completed successfully under Linux. 
BTW, I did not observe #1204 or #1205... As I have no access to a Solaris 
machine, I also don't know if the original patch is required with Sun Studio 
12.1 at all.


Something different - I would've loved to enter this in the numpy-Trac, but 
registration didn't work (I was asked for another username/password at 
scipy.org during the registration process) :-((

Thanks,

  Christian.
diff -r -C5 numpy-1.4.0.orig/numpy/core/src/private/npy_config.h numpy-1.4.0/numpy/core/src/private/npy_config.h
*** numpy-1.4.0.orig/numpy/core/src/private/npy_config.h	2009-12-22 11:59:52.0 +
--- numpy-1.4.0/numpy/core/src/private/npy_config.h	2010-02-17 17:47:12.080101518 +
***
*** 7,18 
  #if defined(_MSC_VER) || defined(__MINGW32_VERSION)
  #undef HAVE_ATAN2
  #undef HAVE_HYPOT
  #endif
  
! /* Disable broken Sun Workshop Pro math functions */
! #ifdef __SUNPRO_C
  #undef HAVE_ATAN2
  #endif
  
  /* 
   * On Mac OS X, because there is only one configuration stage for all the archs
--- 7,18 
  #if defined(_MSC_VER) || defined(__MINGW32_VERSION)
  #undef HAVE_ATAN2
  #undef HAVE_HYPOT
  #endif
  
! /* Disable broken Sun Workshop Pro math functions on Solaris */
! #if defined(__SUNPRO_C)  defined(__sun)
  #undef HAVE_ATAN2
  #endif
  
  /* 
   * On Mac OS X, because there is only one configuration stage for all the archs
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


[Numpy-discussion] f2py: variable number of arguments of variable lengths

2010-02-17 Thread Fabrice Silva
I previously coded a fortran function that needs a variable number of
scalar arguments. This number is not known at compile time, but at call
time. So I used to pass them within a vector, passing also the length of
this vector

  subroutine systeme(inc,t,nm,Dinc,sn)
C
C  evaluate the derivative of vector x at time t
C  with complex modes (sn). Used for the calculation
C  of auto-oscillations in resonator-valve coupled system.
C
  integer nm,np,ny,ind 
  double precision inc(1:2*nm+2), Dinc(1:2*nm+2)
  complex*16 sn(1:nm)
  
Cf2py double precision, intent(in) :: t
Cf2py integer, intent(in), optional :: nm
Cf2py double precision, intent(in), dimension(2*nm+2) :: inc
Cf2py double precision, intent(out), dimension(2*nm+2) :: Dinc
Cf2py complex, intent(in), dimension(nm) :: sn


I do now want to pass, not nm float values, but nm arrays of variables
lengths. I expect to pass the following objects :
- nm: number of arrays
- L : a 1d-array (dimension nm) containing the lengths of each array
- np: the sum of lengths
- X : a 1d-array (dimension np) containing the concatenated arrays.

Does anyone have an alternative to this suggestion ? any tip or example?
Regards

-- 
Fabrice Silva
LMA UPR CNRS 7051

___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] f2py: variable number of arguments of variable lengths

2010-02-17 Thread Robert Kern
On Wed, Feb 17, 2010 at 15:29, Fabrice Silva si...@lma.cnrs-mrs.fr wrote:
 I previously coded a fortran function that needs a variable number of
 scalar arguments. This number is not known at compile time, but at call
 time. So I used to pass them within a vector, passing also the length of
 this vector

              subroutine systeme(inc,t,nm,Dinc,sn)
        C
        C      evaluate the derivative of vector x at time t
        C      with complex modes (sn). Used for the calculation
        C      of auto-oscillations in resonator-valve coupled system.
        C
              integer nm,np,ny,ind
              double precision inc(1:2*nm+2), Dinc(1:2*nm+2)
              complex*16 sn(1:nm)

        Cf2py double precision, intent(in) :: t
        Cf2py integer, intent(in), optional :: nm
        Cf2py double precision, intent(in), dimension(2*nm+2) :: inc
        Cf2py double precision, intent(out), dimension(2*nm+2) :: Dinc
        Cf2py complex, intent(in), dimension(nm) :: sn


 I do now want to pass, not nm float values, but nm arrays of variables
 lengths. I expect to pass the following objects :
 - nm: number of arrays
 - L : a 1d-array (dimension nm) containing the lengths of each array
 - np: the sum of lengths
 - X : a 1d-array (dimension np) containing the concatenated arrays.

Yeah, that's pretty much what you would have to do.

-- 
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
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] f2py: variable number of arguments of variable lengths

2010-02-17 Thread Fabrice Silva
Le mercredi 17 février 2010 à 15:43 -0600, Robert Kern a écrit :
 On Wed, Feb 17, 2010 at 15:29, Fabrice Silva si...@lma.cnrs-mrs.fr wrote:
  I previously coded a fortran function that needs a variable number of
  scalar arguments. This number is not known at compile time, but at call
  time. So I used to pass them within a vector, passing also the length of
  this vector
 
   subroutine systeme(inc,t,nm,Dinc,sn)
 C
 C  evaluate the derivative of vector x at time t
 C  with complex modes (sn). Used for the calculation
 C  of auto-oscillations in resonator-valve coupled system.
 C
   integer nm,np,ny,ind
   double precision inc(1:2*nm+2), Dinc(1:2*nm+2)
   complex*16 sn(1:nm)
 
 Cf2py double precision, intent(in) :: t
 Cf2py integer, intent(in), optional :: nm
 Cf2py double precision, intent(in), dimension(2*nm+2) :: inc
 Cf2py double precision, intent(out), dimension(2*nm+2) :: Dinc
 Cf2py complex, intent(in), dimension(nm) :: sn
 
 
  I do now want to pass, not nm float values, but nm arrays of variables
  lengths. I expect to pass the following objects :
  - nm: number of arrays
  - L : a 1d-array (dimension nm) containing the lengths of each array
  - np: the sum of lengths
  - X : a 1d-array (dimension np) containing the concatenated arrays.
 
 Yeah, that's pretty much what you would have to do.

What about the next step: a variable number of arguments that are
2d-arrays with different shapes ?

-- 
Fabrice Silva
LMA UPR CNRS 7051

___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] f2py: variable number of arguments of variable lengths

2010-02-17 Thread Robert Kern
On Wed, Feb 17, 2010 at 15:55, Fabrice Silva si...@lma.cnrs-mrs.fr wrote:
 Le mercredi 17 février 2010 à 15:43 -0600, Robert Kern a écrit :
 On Wed, Feb 17, 2010 at 15:29, Fabrice Silva si...@lma.cnrs-mrs.fr wrote:
  I previously coded a fortran function that needs a variable number of
  scalar arguments. This number is not known at compile time, but at call
  time. So I used to pass them within a vector, passing also the length of
  this vector
 
               subroutine systeme(inc,t,nm,Dinc,sn)
         C
         C      evaluate the derivative of vector x at time t
         C      with complex modes (sn). Used for the calculation
         C      of auto-oscillations in resonator-valve coupled system.
         C
               integer nm,np,ny,ind
               double precision inc(1:2*nm+2), Dinc(1:2*nm+2)
               complex*16 sn(1:nm)
 
         Cf2py double precision, intent(in) :: t
         Cf2py integer, intent(in), optional :: nm
         Cf2py double precision, intent(in), dimension(2*nm+2) :: inc
         Cf2py double precision, intent(out), dimension(2*nm+2) :: Dinc
         Cf2py complex, intent(in), dimension(nm) :: sn
 
 
  I do now want to pass, not nm float values, but nm arrays of variables
  lengths. I expect to pass the following objects :
  - nm: number of arrays
  - L : a 1d-array (dimension nm) containing the lengths of each array
  - np: the sum of lengths
  - X : a 1d-array (dimension np) containing the concatenated arrays.

 Yeah, that's pretty much what you would have to do.

 What about the next step: a variable number of arguments that are
 2d-arrays with different shapes ?

- nm: number of arrays
- ncols : a 1d-array (dimension nm) containing the number of columns
in each array
- nrows : a 1d-array (dimension nm) containing the number of rows in each array
- np: the sum of array sizes [(ncols * nrows).sum() in numpy terms]
- X : a 1d-array (dimension np) containing the concatenated arrays.

-- 
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
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] f2py: variable number of arguments of variable lengths

2010-02-17 Thread Fabrice Silva
Le mercredi 17 février 2010 à 16:21 -0600, Robert Kern a écrit :
  What about the next step: a variable number of arguments that are
  2d-arrays with different shapes ?
 
 - nm: number of arrays
 - ncols : a 1d-array (dimension nm) containing the number of columns
 in each array
 - nrows : a 1d-array (dimension nm) containing the number of rows in each 
 array
 - np: the sum of array sizes [(ncols * nrows).sum() in numpy terms]
 - X : a 1d-array (dimension np) containing the concatenated arrays.
 

I guess I will need to be careful when building the arrays from X.
Thanks!

-- 
Fabrice Silva
LMA UPR CNRS 7051

___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


[Numpy-discussion] Unable to install numpy-1.3.0 on WinXP (without Administrative rights)

2010-02-17 Thread Touisteur EmporteUneVache
Hi,

I'm trying to install numpy on a WinXP system, on which I have no
administrative rights.

Installation of Python-2.6 went OK, but the windows installer that I
downloaded on sourceforge for numpy (numpy-1.3.0-win32
-superpack-python2.6.exe) gives me an error pop-up window Executing numpy
installer failed.

And when I ask the installer for the details, here's the displayed log :

Output folder: C:\Windows\Temp
   Install dir for actual installers is C:\DOCUME~1\user1\LOCALS~1\Temp
   Target CPU handles SSE2
   Target CPU handles SSE3
   native install (arch value: native)
   Install SSE 3
   Extract: *numpy*-1.3.0-sse3.exe... 100%
   Execute: C:\Windows\Temp\*numpy*-1.3.0-sse3.exe
   Completed

And of course then, typing import numpy in a python shell will just give
ImportError: No module named numpy.

Seems I'm not the only one that encountered the problem ( see
http://old.nabble.com/Failed-installation-on-Windows-XP-td26316987.html#a26316987).

I'm wondering if this is known and/or fixed issue (my search on the
mailing-list and tickets archives has been fruitless, but I might have not
looked at the right places), and if so, what can I do to solve it ?

Cheers,
T.
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Updating Packages in 2.5 (win/numpy) and Related Matters

2010-02-17 Thread Wayne Watson
I don't think I'm on the current version. Does it make sense to move ahead?
Is there a way to suppress the messages?

On 2/16/2010 9:25 PM, josef.p...@gmail.com wrote:
 On Wed, Feb 17, 2010 at 12:10 AM, Wayne Watson
 sierra_mtnv...@sbcglobal.net  wrote:

 Hi, I'm working on a 1800+ line program that uses tkinter. Here are the
 messages I started getting recently. (I finally figured out how to copy
 them.). The program goes merrily on its way despite them.


 s\sentusersentuser_20080716NoiseStudy7.py
 C:\Python25\lib\site-packages\scipy\misc\__init__.py:25:
 DeprecationWarning: Num
 pyTest will be removed in the next release; please update your code to
 use nose
 or unittest
test = NumpyTest().test
 C:\Python25\lib\site-packages\scipy\special\__init__.py:23:
 DeprecationWarning:
 NumpyTest will be removed in the next release; please update your code
 to use no
 se or unittest
test = NumpyTest().test
 C:\Python25\lib\site-packages\scipy\linalg\__init__.py:32:
 DeprecationWarning: N
 umpyTest will be removed in the next release; please update your code to
 use nos
 e or unittest
test = NumpyTest().test
 C:\Python25\lib\site-packages\scipy\optimize\__init__.py:19:
 DeprecationWarning:
   NumpyTest will be removed in the next release; please update your code
 to use n
 ose or unittest
test = NumpyTest().test
 C:\Python25\lib\site-packages\scipy\stats\__init__.py:15:
 DeprecationWarning: Nu
 mpyTest will be removed in the next release; please update your code to
 use nose
   or unittest
test = NumpyTest().test
 Traceback (most recent call last):
File
 C:\Users\Wayne\Sandia_Meteors\Sentinel_Development\Development_Sentuser+
 Utilities\sentuser\sentuser_20080716NoiseStudy7.py, line 1993, inmodule
  Process()
File
 C:\Users\Wayne\Sandia_Meteors\Sentinel_Development\Development_Sentuser+
 Utilities\sentuser\sentuser_20080716NoiseStudy7.py, line 1990, in Process
  root.mainloop()
File C:\Python25\lib\lib-tk\Tkinter.py, line 1023, in mainloop
  
 DeprecationWarnings mean some some functionality in numpy (or scipy)
 has changed and the old way of doing things will be removed and be
 invalid in the next version.

 During depreciation the old code still works, but before you upgrade
 you might want to check whether and how much you use these functions
 and switch to the new behavior.

 In the case of numpy.test, it means that if you have tests written
 that use the numpy testing module, then you need to switch them to the
 new nose based numpy.testing. And you need to install nose for running
 numpy.test()


- What is win32-p3 updates ?

 Josef



 On 2/16/2010 4:32 PM, David Cournapeau wrote:
  
 Hi Wayne,

 Wayne Watson wrote:


 I normally use IDLE on Win, but recently needed to go to command prompt
 to see all error messages. When I did, I was greeted by a host of
 deprecation and Numpy messages before things got running. The program
 otherwise functioned OK, after I found the problem I was after. Are
 these messages a warning to get to the next update of numpy?

 I would guess that updating to a higher update does not mean I need to
 remove the old one, correct?

 In general for libraries like numpy or scipy, I use win32 updates, but I
 see win32-p3 updates too on download pages. Since I may be distributing
 this program to p3 machines, will I need to provide the win32-p3 updates
 to those users?

  
 I am not familiar with IDLE, so I don't really understand your problem:
- what triggers numpy warnings ? You talked about a program, but
 without knowing which program, we can't really help you.
- What warnings do you get ?
- What is win32-p3 updates ?

 cheers,

 David
 ___
 NumPy-Discussion mailing list
 NumPy-Discussion@scipy.org
 http://mail.scipy.org/mailman/listinfo/numpy-discussion



 --
  There is nothing so annoying as to have two people
   talking when you're busy interrupting. -- Mark Twain

 ___
 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



-- 
 There is nothing so annoying as to have two people
  talking when you're busy interrupting. -- Mark Twain

___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Unable to install numpy-1.3.0 on WinXP (without Administrative rights)

2010-02-17 Thread David Cournapeau
On Thu, Feb 18, 2010 at 8:24 AM, Touisteur EmporteUneVache
touist...@gmail.com wrote:
 Hi,

 I'm trying to install numpy on a WinXP system, on which I have no
 administrative rights.

I think it is not possible to install NumPy for python 2.6 if you
don't have admin priviledges. I believe the root of the problem is the
lack of a right C runtime, and there is no easy way to install it
without admin priviledges, and I have no idea how to fix this. The
problem is specific to python 2.6 (more exactly because it was built
with visual studio 2008), so using python 2.5 or 2.4 should not cause
any issue if that's an option for you.

The other solution is to ask your administrator to install the
redistributable runtime from VS 2008,

cheers,

David
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Updating Packages in 2.5 (win/numpy) and Related Matters

2010-02-17 Thread Wayne Watson


On 2/16/2010 10:01 PM, Scott Sinclair wrote:
 On 17 February 2010 07:25,josef.p...@gmail.com  wrote:
 On Wed, Feb 17, 2010 at 12:10 AM, Wayne Watson
 sierra_mtnv...@sbcglobal.net  wrote:
  
 Hi, I'm working on a 1800+ line program that uses tkinter. Here are the
 messages I started getting recently. (I finally figured out how to copy
 them.). The program goes merrily on its way despite them.


 s\sentusersentuser_20080716NoiseStudy7.py
 C:\Python25\lib\site-packages\scipy\misc\__init__.py:25:
 DeprecationWarning: Num
 pyTest will be removed in the next release; please update your code to
 use nose
 or unittest
test = NumpyTest().test

 DeprecationWarnings mean some some functionality in numpy (or scipy)
 has changed and the old way of doing things will be removed and be
 invalid in the next version.

 During depreciation the old code still works, but before you upgrade
 you might want to check whether and how much you use these functions
 and switch to the new behavior.

 In the case of numpy.test, it means that if you have tests written
 that use the numpy testing module, then you need to switch them to the
 new nose based numpy.testing. And you need to install nose for running
 numpy.test()
  
 Wayne - The DeprecationWarnings are being raised by SciPy, not by your
 code. You probably don't have a recent version of SciPy installed. The
 most recent release of SciPy is 0.7.1 and works with NumPy 1.3.0. I
 don't think you will see the warnings if you upgrade SciPy and NumPy
 on your system.

 Check your NumPy and SciPy versions at a python prompt as follows:


 import numpy as np
 print np.__version__
 import scipy as sp
 print sp.__version__
  
 You will need to completely remove the old versions if you choose to
 upgrade. You should be able to do this from Add/Remove Programs.



You just answered the question I posted to joef moments ago. 
Interestingly, I'm on win7's Add/Remove numpy. No scipy. I just checked 
the version via import and it's 0.6.0. These are some of my imports. 
Note from scipy below.
from Tkinter import *
from numpy import *
import Image
import ImageChops
import ImageTk
import time
import binascii
import tkMessageBox
import tkSimpleDialog
from pylab import plot, xlabel, ylabel, title, show, xticks, bar
from scipy import stats as stats # scoreatpercentile 
from matplotlib.pyplot import figure, show
#from matplotlib.lines import Line2D
#from matplotlib.patches import Patch, Rectangle
#from matplotlib.text import Text
from matplotlib.image import AxesImage


-- 
 There is nothing so annoying as to have two people
  talking when you're busy interrupting. -- Mark Twain

___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Unable to install numpy-1.3.0 on WinXP (without Administrative rights)

2010-02-17 Thread Christoph Gohlke
On 2/17/2010 7:30 PM, David Cournapeau wrote:
 On Thu, Feb 18, 2010 at 8:24 AM, Touisteur EmporteUneVache
 touist...@gmail.com wrote:
 Hi,

 I'm trying to install numpy on a WinXP system, on which I have no
 administrative rights.
 
 I think it is not possible to install NumPy for python 2.6 if you
 don't have admin priviledges. I believe the root of the problem is the
 lack of a right C runtime, and there is no easy way to install it
 without admin priviledges, and I have no idea how to fix this. The
 problem is specific to python 2.6 (more exactly because it was built
 with visual studio 2008), so using python 2.5 or 2.4 should not cause
 any issue if that's an option for you.
 
 The other solution is to ask your administrator to install the
 redistributable runtime from VS 2008,
 


If everything else fails you can try to install numpy manually: the file
numpy-1.3.0-sse3.exe, which is created in the %TEMP% directory during
the numpy-1.3.0-win32-superpack-python2.6.exe installation, is a
executable ZIP file and can be opened with any decent archive program,
e.g. WinRAR. From numpy-1.3.0-sse3.exe copy PLATLIB\numpy\* to
C:\Python26\sitepackages\numpy\ and SCRIPTS\* to C:\Python26\Scripts\.
Unlike many other packages, Numpy does not need to have the Microsoft
Visual C++ 2008 redistributable package installed to work.

To avoid the problem, numpy-1.3.0-sse3.exe could probably be linked
statically to MSVCRT9 like the bdist_wininst installers created by
Python distutils.

Christoph
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Unable to install numpy-1.3.0 on WinXP (without Administrative rights)

2010-02-17 Thread Touisteur EmporteUneVache

On 2/18/2010 at 15:04, Christoph Gohlke wrote:

 On 2/17/2010 7:30 PM, David Cournapeau wrote:
 On Thu, Feb 18, 2010 at 8:24 AM, Touisteur EmporteUneVache
 touist...@gmail.com wrote:
 Hi,

 I'm trying to install numpy on a WinXP system, on which I have no
 administrative rights.

 I think it is not possible to install NumPy for python 2.6 if you
 don't have admin priviledges. I believe the root of the problem is  
 the
 lack of a right C runtime, and there is no easy way to install it
 without admin priviledges, and I have no idea how to fix this. The
 problem is specific to python 2.6 (more exactly because it was built
 with visual studio 2008), so using python 2.5 or 2.4 should not cause
 any issue if that's an option for you.

 The other solution is to ask your administrator to install the
 redistributable runtime from VS 2008,



 If everything else fails you can try to install numpy manually: the  
 file
 numpy-1.3.0-sse3.exe, which is created in the %TEMP% directory during
 the numpy-1.3.0-win32-superpack-python2.6.exe installation, is a
 executable ZIP file and can be opened with any decent archive program,
 e.g. WinRAR. From numpy-1.3.0-sse3.exe copy PLATLIB\numpy\* to
 C:\Python26\sitepackages\numpy\ and SCRIPTS\* to C:\Python26\Scripts\.
 Unlike many other packages, Numpy does not need to have the Microsoft
 Visual C++ 2008 redistributable package installed to work.

 To avoid the problem, numpy-1.3.0-sse3.exe could probably be linked
 statically to MSVCRT9 like the bdist_wininst installers created by
 Python distutils.

 Christoph

Hi David and Christoph,

Thank you both very much for your suggestions. I went for Christoph's  
workaround (manual installation) and it seems to work like a charm.

Thanks again.
Cheers!

___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Updating Packages in 2.5 (win/numpy) and Related Matters

2010-02-17 Thread Scott Sinclair
On 18 February 2010 05:30, Wayne Watson sierra_mtnv...@sbcglobal.net wrote:

 On 2/16/2010 10:01 PM, Scott Sinclair wrote:

 Wayne - The DeprecationWarnings are being raised by SciPy, not by your
 code. You probably don't have a recent version of SciPy installed. The
 most recent release of SciPy is 0.7.1 and works with NumPy 1.3.0. I
 don't think you will see the warnings if you upgrade SciPy and NumPy
 on your system.

 Check your NumPy and SciPy versions at a python prompt as follows:



 import numpy as np
 print np.__version__
 import scipy as sp
 print sp.__version__


 You will need to completely remove the old versions if you choose to
 upgrade. You should be able to do this from Add/Remove Programs.

 I'm on win7's Add/Remove numpy. No scipy. I just checked the version via
 import and it's 0.6.0.

You can download the latest NumPy and SciPy installers from:

http://sourceforge.net/projects/numpy/files/

and

http://sourceforge.net/projects/scipy/files/

You want the win32-superpack for your Python version.

Use Add/Remove to remove your current NumPy install (if your version
is not already 1.3.0). I'm not sure how SciPy was installed and why it
doesn't appear in Add/Remove. You should look in
C:\Python25\Lib\site-packages for directories named numpy or scipy
(numpy should have been removed already). It is safe to delete
C:\Python25\Lib\site-packages\scipy.

Then run the superpack installers and you should be good to go. Good luck.

Cheers,
Scott
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


[Numpy-discussion] Accessing fields of the object stored in numpy array

2010-02-17 Thread Vishal Rana
Hi,

I have a numpy arrays with datetime objects as:

a = np.array([dt.datetime(2010, 2, 17), dt.datetime(2010, 2, 16),
dt.datetime(2010, 2, 15)])
b = np.array([dt.datetime(2010, 2, 14), dt.datetime(2010, 2, 13),
dt.datetime(2010, 2, 12)])

I want doing a-b should give me days difference as numpy array but I get as:
array([3 days, 0:00:00, 3 days, 0:00:00, 3 days, 0:00:00], dtype=object)
which is a numpy array of timedelta! I can extract days out by using
property days of each, but how I do it in a numpy way may like:
c=a-b
c.days (a numpy array of days difference) like:
array([3, 3, 3])

Any pointers?

Thanks
Vishal Rana
Joan Crawfordhttp://www.brainyquote.com/quotes/authors/j/joan_crawford.html
- I, Joan Crawford, I believe in the dollar. Everything I earn, I
spend.
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion