Re: [Numpy-discussion] find appropriate dtype based on a set of values

2013-09-03 Thread Gregorio Bastardo
Thanks Stéfan, your script works well. There's a small typo on line
12. I also discovered the functions 'np.iinfo' and 'np.finfo' for
machine limits on integer/float types (a note for myself, you might be
already familiar with them).

After having read the docstring, I was only curious why this feature
is not provided by the function itself, as returning the input array's
dtype seems not so useful (can't imagine such a use case).

Gregorio

2013/9/2 Stéfan van der Walt ste...@sun.ac.za:
 On Mon, Sep 2, 2013 at 4:21 PM, Gregorio Bastardo
 gregorio.basta...@gmail.com wrote:
 np.min_scalar_type([-1,256]) # int16 expected
 dtype('int32')

 Am I missing something? Anyone knows how to achieve the desired operation?

 The docstring states explicitly that this use case is not supported.

 Here's one way of doing it: https://gist.github.com/stefanv/6413742

 Stéfan
 ___
 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


Re: [Numpy-discussion] find appropriate dtype based on a set of values

2013-09-03 Thread Robert Kern
On Mon, Sep 2, 2013 at 3:55 PM, Stéfan van der Walt ste...@sun.ac.za
wrote:

 On Mon, Sep 2, 2013 at 4:21 PM, Gregorio Bastardo
 gregorio.basta...@gmail.com wrote:
  np.min_scalar_type([-1,256]) # int16 expected
  dtype('int32')
 
  Am I missing something? Anyone knows how to achieve the desired
operation?

 The docstring states explicitly that this use case is not supported.

 Here's one way of doing it: https://gist.github.com/stefanv/6413742

You can probably reduce the amount of work by only comparing a.min() and
a.max() instead of the whole array.

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


Re: [Numpy-discussion] find appropriate dtype based on a set of values

2013-09-03 Thread Stéfan van der Walt
On Tue, Sep 3, 2013 at 2:47 PM, Robert Kern robert.k...@gmail.com wrote:
 Here's one way of doing it: https://gist.github.com/stefanv/6413742

 You can probably reduce the amount of work by only comparing a.min() and
 a.max() instead of the whole array.

Thanks, fixed.

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


Re: [Numpy-discussion] ANN: Numpy 1.8.0 beta 1 release

2013-09-03 Thread Christoph Gohlke

On 9/1/2013 9:54 AM, Charles R Harris wrote:

Hi all,

I'm happy to announce the first beta release of Numpy 1.8.0. Please try
this beta and report any issues on the numpy-dev mailing list.

Source tarballs and release notes can be found at
https://sourceforge.net/projects/numpy/files/NumPy/1.8.0b1/. The Windows
and OS X installers will follow when the infrastructure issues are dealt
with.

Chuck



Hello,

I tried numpy-1.8.0.dev-86a6e6c with msvc9 and MKL 11.1 on 
win-amd64-py2.7. It builds OK but there are 23 test errors and 6 
failures (attached).


Some 3rd party packages (e.g. scipy, numexpr, pytables, bottleneck, 
pandas and matplotlib) that were built against numpy-MKL 1.7 fail tests 
when used with numpy-MKL 1.8. Other packages test OK (e.g. skimage, 
sklearn, statsmodels, mahotas, pygame). See 
http://www.lfd.uci.edu/~gohlke/pythonlibs/tests/20130902-win-amd64-py2.7-numpy-1.8.0.dev-86a6e6c/ 
compared to 
http://www.lfd.uci.edu/~gohlke/pythonlibs/tests/20130902-win-amd64-py2.7/. 



I have not looked in more detail or at other Python versions yet.

Christoph

Re: [Numpy-discussion] ANN: Numpy 1.8.0 beta 1 release

2013-09-03 Thread Charles R Harris
On Tue, Sep 3, 2013 at 3:23 PM, Christoph Gohlke cgoh...@uci.edu wrote:

 On 9/1/2013 9:54 AM, Charles R Harris wrote:

 Hi all,

 I'm happy to announce the first beta release of Numpy 1.8.0. Please try
 this beta and report any issues on the numpy-dev mailing list.

 Source tarballs and release notes can be found at
 https://sourceforge.net/**projects/numpy/files/NumPy/1.**8.0b1/https://sourceforge.net/projects/numpy/files/NumPy/1.8.0b1/.
 The Windows
 and OS X installers will follow when the infrastructure issues are dealt
 with.

 Chuck


 Hello,

 I tried numpy-1.8.0.dev-86a6e6c with msvc9 and MKL 11.1 on
 win-amd64-py2.7. It builds OK but there are 23 test errors and 6 failures
 (attached).

 Some 3rd party packages (e.g. scipy, numexpr, pytables, bottleneck, pandas
 and matplotlib) that were built against numpy-MKL 1.7 fail tests when used
 with numpy-MKL 1.8. Other packages test OK (e.g. skimage, sklearn,
 statsmodels, mahotas, pygame). See http://www.lfd.uci.edu/~**
 gohlke/pythonlibs/tests/**20130902-win-amd64-py2.7-**
 numpy-1.8.0.dev-86a6e6c/http://www.lfd.uci.edu/~gohlke/pythonlibs/tests/20130902-win-amd64-py2.7-numpy-1.8.0.dev-86a6e6c/
 compared to http://www.lfd.uci.edu/~**gohlke/pythonlibs/tests/**
 20130902-win-amd64-py2.7/http://www.lfd.uci.edu/~gohlke/pythonlibs/tests/20130902-win-amd64-py2.7/.


 I have not looked in more detail or at other Python versions yet.


Thanks Christoph,

Looks like some work to do. I wonder what is different between windows and
linux here?

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


Re: [Numpy-discussion] ANN: Numpy 1.8.0 beta 1 release

2013-09-03 Thread Charles R Harris
On Tue, Sep 3, 2013 at 3:23 PM, Christoph Gohlke cgoh...@uci.edu wrote:

 On 9/1/2013 9:54 AM, Charles R Harris wrote:

 Hi all,

 I'm happy to announce the first beta release of Numpy 1.8.0. Please try
 this beta and report any issues on the numpy-dev mailing list.

 Source tarballs and release notes can be found at
 https://sourceforge.net/**projects/numpy/files/NumPy/1.**8.0b1/https://sourceforge.net/projects/numpy/files/NumPy/1.8.0b1/.
 The Windows
 and OS X installers will follow when the infrastructure issues are dealt
 with.

 Chuck


 Hello,

 I tried numpy-1.8.0.dev-86a6e6c with msvc9 and MKL 11.1 on
 win-amd64-py2.7. It builds OK but there are 23 test errors and 6 failures
 (attached).

 Some 3rd party packages (e.g. scipy, numexpr, pytables, bottleneck, pandas
 and matplotlib) that were built against numpy-MKL 1.7 fail tests when used
 with numpy-MKL 1.8. Other packages test OK (e.g. skimage, sklearn,
 statsmodels, mahotas, pygame). See http://www.lfd.uci.edu/~**
 gohlke/pythonlibs/tests/**20130902-win-amd64-py2.7-**
 numpy-1.8.0.dev-86a6e6c/http://www.lfd.uci.edu/~gohlke/pythonlibs/tests/20130902-win-amd64-py2.7-numpy-1.8.0.dev-86a6e6c/
 compared to http://www.lfd.uci.edu/~**gohlke/pythonlibs/tests/**
 20130902-win-amd64-py2.7/http://www.lfd.uci.edu/~gohlke/pythonlibs/tests/20130902-win-amd64-py2.7/.


 I have not looked in more detail or at other Python versions yet.


It's pretty clear that I will need a windows environment to debug this. I
have windows 7 running in a virtual machine, and have downloaded the vsc9
express compiler and isos. Do I need to burn those guys to a disk in order
to install or is there some windows magic that will let me install them
directly from the isos? That done, I assume I can just download python 2.7
for windows, clone the repository, and do the usual python setup.py install
thing. Anything I need to be wary about, any pointers?

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


Re: [Numpy-discussion] ANN: Numpy 1.8.0 beta 1 release

2013-09-03 Thread Christoph Gohlke
On 9/3/2013 2:51 PM, Charles R Harris wrote:



 On Tue, Sep 3, 2013 at 3:23 PM, Christoph Gohlke cgoh...@uci.edu
 mailto:cgoh...@uci.edu wrote:

 On 9/1/2013 9:54 AM, Charles R Harris wrote:

 Hi all,

 I'm happy to announce the first beta release of Numpy 1.8.0.
 Please try
 this beta and report any issues on the numpy-dev mailing list.

 Source tarballs and release notes can be found at
 https://sourceforge.net/__projects/numpy/files/NumPy/1.__8.0b1/
 https://sourceforge.net/projects/numpy/files/NumPy/1.8.0b1/.
 The Windows
 and OS X installers will follow when the infrastructure issues
 are dealt
 with.

 Chuck


 Hello,

 I tried numpy-1.8.0.dev-86a6e6c with msvc9 and MKL 11.1 on
 win-amd64-py2.7. It builds OK but there are 23 test errors and 6
 failures (attached).

 Some 3rd party packages (e.g. scipy, numexpr, pytables, bottleneck,
 pandas and matplotlib) that were built against numpy-MKL 1.7 fail
 tests when used with numpy-MKL 1.8. Other packages test OK (e.g.
 skimage, sklearn, statsmodels, mahotas, pygame). See
 
 http://www.lfd.uci.edu/~__gohlke/pythonlibs/tests/__20130902-win-amd64-py2.7-__numpy-1.8.0.dev-86a6e6c/
 
 http://www.lfd.uci.edu/%7Egohlke/pythonlibs/tests/20130902-win-amd64-py2.7-numpy-1.8.0.dev-86a6e6c/
 compared to
 
 http://www.lfd.uci.edu/~__gohlke/pythonlibs/tests/__20130902-win-amd64-py2.7/
 
 http://www.lfd.uci.edu/%7Egohlke/pythonlibs/tests/20130902-win-amd64-py2.7/.


 I have not looked in more detail or at other Python versions yet.


 Thanks Christoph,

 Looks like some work to do. I wonder what is different between windows
 and linux here?

 Chuck


Looks like the fundamental PyArray_PyIntAsIntp function is broken on 64 
bit Windows. 64 bit PyLong values are intermediately stored in a 32 bit 
C long variable. But maybe I am missing something...
https://github.com/numpy/numpy/blob/maintenance/1.8.x/numpy/core/src/multiarray/conversion_utils.c#L729
https://github.com/numpy/numpy/blob/maintenance/1.8.x/numpy/core/src/multiarray/conversion_utils.c#L767

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


Re: [Numpy-discussion] ANN: Numpy 1.8.0 beta 1 release

2013-09-03 Thread Charles R Harris
On Tue, Sep 3, 2013 at 5:40 PM, Christoph Gohlke cgoh...@uci.edu wrote:

 On 9/3/2013 2:51 PM, Charles R Harris wrote:
 
 
 
  On Tue, Sep 3, 2013 at 3:23 PM, Christoph Gohlke cgoh...@uci.edu
  mailto:cgoh...@uci.edu wrote:
 
  On 9/1/2013 9:54 AM, Charles R Harris wrote:
 
  Hi all,
 
  I'm happy to announce the first beta release of Numpy 1.8.0.
  Please try
  this beta and report any issues on the numpy-dev mailing list.
 
  Source tarballs and release notes can be found at
  https://sourceforge.net/__projects/numpy/files/NumPy/1.__8.0b1/
  https://sourceforge.net/projects/numpy/files/NumPy/1.8.0b1/.
  The Windows
  and OS X installers will follow when the infrastructure issues
  are dealt
  with.
 
  Chuck
 
 
  Hello,
 
  I tried numpy-1.8.0.dev-86a6e6c with msvc9 and MKL 11.1 on
  win-amd64-py2.7. It builds OK but there are 23 test errors and 6
  failures (attached).
 
  Some 3rd party packages (e.g. scipy, numexpr, pytables, bottleneck,
  pandas and matplotlib) that were built against numpy-MKL 1.7 fail
  tests when used with numpy-MKL 1.8. Other packages test OK (e.g.
  skimage, sklearn, statsmodels, mahotas, pygame). See
  
 http://www.lfd.uci.edu/~__gohlke/pythonlibs/tests/__20130902-win-amd64-py2.7-__numpy-1.8.0.dev-86a6e6c/
  
 http://www.lfd.uci.edu/%7Egohlke/pythonlibs/tests/20130902-win-amd64-py2.7-numpy-1.8.0.dev-86a6e6c/
 
  compared to
  
 http://www.lfd.uci.edu/~__gohlke/pythonlibs/tests/__20130902-win-amd64-py2.7/
  
 http://www.lfd.uci.edu/%7Egohlke/pythonlibs/tests/20130902-win-amd64-py2.7/
 .
 
 
  I have not looked in more detail or at other Python versions yet.
 
 
  Thanks Christoph,
 
  Looks like some work to do. I wonder what is different between windows
  and linux here?
 
  Chuck
 

 Looks like the fundamental PyArray_PyIntAsIntp function is broken on 64
 bit Windows. 64 bit PyLong values are intermediately stored in a 32 bit
 C long variable. But maybe I am missing something...
 
 https://github.com/numpy/numpy/blob/maintenance/1.8.x/numpy/core/src/multiarray/conversion_utils.c#L729
 
 
 https://github.com/numpy/numpy/blob/maintenance/1.8.x/numpy/core/src/multiarray/conversion_utils.c#L767
 

 My, that does look suspicious. That function is new in 1.8 I believe.
Looks like it needs fixing whatever else it fixes.

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


Re: [Numpy-discussion] ANN: Numpy 1.8.0 beta 1 release

2013-09-03 Thread Christoph Gohlke
On 9/3/2013 4:32 PM, Charles R Harris wrote:



 On Tue, Sep 3, 2013 at 3:23 PM, Christoph Gohlke cgoh...@uci.edu
 mailto:cgoh...@uci.edu wrote:

 On 9/1/2013 9:54 AM, Charles R Harris wrote:

 Hi all,

 I'm happy to announce the first beta release of Numpy 1.8.0.
 Please try
 this beta and report any issues on the numpy-dev mailing list.

 Source tarballs and release notes can be found at
 https://sourceforge.net/__projects/numpy/files/NumPy/1.__8.0b1/
 https://sourceforge.net/projects/numpy/files/NumPy/1.8.0b1/.
 The Windows
 and OS X installers will follow when the infrastructure issues
 are dealt
 with.

 Chuck


 Hello,

 I tried numpy-1.8.0.dev-86a6e6c with msvc9 and MKL 11.1 on
 win-amd64-py2.7. It builds OK but there are 23 test errors and 6
 failures (attached).

 Some 3rd party packages (e.g. scipy, numexpr, pytables, bottleneck,
 pandas and matplotlib) that were built against numpy-MKL 1.7 fail
 tests when used with numpy-MKL 1.8. Other packages test OK (e.g.
 skimage, sklearn, statsmodels, mahotas, pygame). See
 
 http://www.lfd.uci.edu/~__gohlke/pythonlibs/tests/__20130902-win-amd64-py2.7-__numpy-1.8.0.dev-86a6e6c/
 
 http://www.lfd.uci.edu/%7Egohlke/pythonlibs/tests/20130902-win-amd64-py2.7-numpy-1.8.0.dev-86a6e6c/
 compared to
 
 http://www.lfd.uci.edu/~__gohlke/pythonlibs/tests/__20130902-win-amd64-py2.7/
 
 http://www.lfd.uci.edu/%7Egohlke/pythonlibs/tests/20130902-win-amd64-py2.7/.


 I have not looked in more detail or at other Python versions yet.


 It's pretty clear that I will need a windows environment to debug this.
 I have windows 7 running in a virtual machine, and have downloaded the
 vsc9 express compiler and isos. Do I need to burn those guys to a disk
 in order to install or is there some windows magic that will let me
 install them directly from the isos? That done, I assume I can just
 download python 2.7 for windows, clone the repository, and do the usual
 python setup.py install thing. Anything I need to be wary about, any
 pointers?

 Chuck


I would not recommend the VS Express version. Instead use the Microsoft 
Windows SDK for Windows 7 and .NET Framework 3.5 SP1 
http://www.microsoft.com/en-us/download/details.aspx?id=3138, which 
contains compatible 32 and 64 bit compilers for Python 2.6 to 3.2. Use 
the web installer or mount the ISO with VirtualCloneDrive 
http://www.slysoft.com/en/virtual-clonedrive.html. Then, on a command 
prompt in the numpy source directory type (not tested, but should work 
for 64 bit Python 2.7):

setlocal EnableDelayedExpansion
call %ProgramFiles%\Microsoft SDKs\Windows\v7.0\Bin\SetEnv.Cmd 
/Release /x64 /vista
set DISTUTILS_USE_SDK=1
C:\Python27\python.exe setup.py build


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


Re: [Numpy-discussion] ANN: Numpy 1.8.0 beta 1 release

2013-09-03 Thread Charles R Harris
On Tue, Sep 3, 2013 at 5:45 PM, Charles R Harris
charlesr.har...@gmail.comwrote:




 On Tue, Sep 3, 2013 at 5:40 PM, Christoph Gohlke cgoh...@uci.edu wrote:

 On 9/3/2013 2:51 PM, Charles R Harris wrote:
 
 
 
  On Tue, Sep 3, 2013 at 3:23 PM, Christoph Gohlke cgoh...@uci.edu
  mailto:cgoh...@uci.edu wrote:
 
  On 9/1/2013 9:54 AM, Charles R Harris wrote:
 
  Hi all,
 
  I'm happy to announce the first beta release of Numpy 1.8.0.
  Please try
  this beta and report any issues on the numpy-dev mailing list.
 
  Source tarballs and release notes can be found at
  https://sourceforge.net/__projects/numpy/files/NumPy/1.__8.0b1/
  https://sourceforge.net/projects/numpy/files/NumPy/1.8.0b1/.
  The Windows
  and OS X installers will follow when the infrastructure issues
  are dealt
  with.
 
  Chuck
 
 
  Hello,
 
  I tried numpy-1.8.0.dev-86a6e6c with msvc9 and MKL 11.1 on
  win-amd64-py2.7. It builds OK but there are 23 test errors and 6
  failures (attached).
 
  Some 3rd party packages (e.g. scipy, numexpr, pytables, bottleneck,
  pandas and matplotlib) that were built against numpy-MKL 1.7 fail
  tests when used with numpy-MKL 1.8. Other packages test OK (e.g.
  skimage, sklearn, statsmodels, mahotas, pygame). See
  
 http://www.lfd.uci.edu/~__gohlke/pythonlibs/tests/__20130902-win-amd64-py2.7-__numpy-1.8.0.dev-86a6e6c/
  
 http://www.lfd.uci.edu/%7Egohlke/pythonlibs/tests/20130902-win-amd64-py2.7-numpy-1.8.0.dev-86a6e6c/
 
  compared to
  
 http://www.lfd.uci.edu/~__gohlke/pythonlibs/tests/__20130902-win-amd64-py2.7/
  
 http://www.lfd.uci.edu/%7Egohlke/pythonlibs/tests/20130902-win-amd64-py2.7/
 .
 
 
  I have not looked in more detail or at other Python versions yet.
 
 
  Thanks Christoph,
 
  Looks like some work to do. I wonder what is different between windows
  and linux here?
 
  Chuck
 

 Looks like the fundamental PyArray_PyIntAsIntp function is broken on 64
 bit Windows. 64 bit PyLong values are intermediately stored in a 32 bit
 C long variable. But maybe I am missing something...
 
 https://github.com/numpy/numpy/blob/maintenance/1.8.x/numpy/core/src/multiarray/conversion_utils.c#L729
 
 
 https://github.com/numpy/numpy/blob/maintenance/1.8.x/numpy/core/src/multiarray/conversion_utils.c#L767
 

 My, that does look suspicious. That function is new in 1.8 I believe.
 Looks like it needs fixing whatever else it fixes.


BTW, do the tests pass with a 32 build?

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


Re: [Numpy-discussion] ANN: Numpy 1.8.0 beta 1 release

2013-09-03 Thread Christoph Gohlke
On 9/3/2013 4:45 PM, Charles R Harris wrote:



 On Tue, Sep 3, 2013 at 5:40 PM, Christoph Gohlke cgoh...@uci.edu
 mailto:cgoh...@uci.edu wrote:

 On 9/3/2013 2:51 PM, Charles R Harris wrote:
 
 
 
  On Tue, Sep 3, 2013 at 3:23 PM, Christoph Gohlke cgoh...@uci.edu 
 mailto:cgoh...@uci.edu
  mailto:cgoh...@uci.edu mailto:cgoh...@uci.edu wrote:
 
  On 9/1/2013 9:54 AM, Charles R Harris wrote:
 
  Hi all,
 
  I'm happy to announce the first beta release of Numpy 1.8.0.
  Please try
  this beta and report any issues on the numpy-dev mailing list.
 
  Source tarballs and release notes can be found at
 https://sourceforge.net/__projects/numpy/files/NumPy/1.__8.0b1/
  https://sourceforge.net/projects/numpy/files/NumPy/1.8.0b1/.
  The Windows
  and OS X installers will follow when the infrastructure issues
  are dealt
  with.
 
  Chuck
 
 
  Hello,
 
  I tried numpy-1.8.0.dev-86a6e6c with msvc9 and MKL 11.1 on
  win-amd64-py2.7. It builds OK but there are 23 test errors and 6
  failures (attached).
 
  Some 3rd party packages (e.g. scipy, numexpr, pytables, bottleneck,
  pandas and matplotlib) that were built against numpy-MKL 1.7 fail
  tests when used with numpy-MKL 1.8. Other packages test OK (e.g.
  skimage, sklearn, statsmodels, mahotas, pygame). See
  
 http://www.lfd.uci.edu/~__gohlke/pythonlibs/tests/__20130902-win-amd64-py2.7-__numpy-1.8.0.dev-86a6e6c/
 
 http://www.lfd.uci.edu/%7E__gohlke/pythonlibs/tests/__20130902-win-amd64-py2.7-__numpy-1.8.0.dev-86a6e6c/
  
 http://www.lfd.uci.edu/%7Egohlke/pythonlibs/tests/20130902-win-amd64-py2.7-numpy-1.8.0.dev-86a6e6c/
  compared to
  
 http://www.lfd.uci.edu/~__gohlke/pythonlibs/tests/__20130902-win-amd64-py2.7/
 
 http://www.lfd.uci.edu/%7E__gohlke/pythonlibs/tests/__20130902-win-amd64-py2.7/
  
 http://www.lfd.uci.edu/%7Egohlke/pythonlibs/tests/20130902-win-amd64-py2.7/.
 
 
  I have not looked in more detail or at other Python versions yet.
 
 
  Thanks Christoph,
 
  Looks like some work to do. I wonder what is different between windows
  and linux here?
 
  Chuck
 

 Looks like the fundamental PyArray_PyIntAsIntp function is broken on 64
 bit Windows. 64 bit PyLong values are intermediately stored in a 32 bit
 C long variable. But maybe I am missing something...
 
 https://github.com/numpy/numpy/blob/maintenance/1.8.x/numpy/core/src/multiarray/conversion_utils.c#L729
 
 https://github.com/numpy/numpy/blob/maintenance/1.8.x/numpy/core/src/multiarray/conversion_utils.c#L767

 My, that does look suspicious. That function is new in 1.8 I believe.
 Looks like it needs fixing whatever else it fixes.

 Chuck


In fact, using a npy_longlong instead of npy_long fixes all numpy test 
errors and failures. But it probably foils the recent optimizations.

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


[Numpy-discussion] (no subject)

2013-09-03 Thread Carl Canuck
Hello,

I'm new to numpy, and I'm a stuck on my first real project with it.

I am trying to take the rfft of a numpy array, like this:
 my_rfft = numpy.fft.rfft(my_numpy_array)

and replace the amplitudes that can be obtained with:

 my_amplitudes = numpy.abs(my_rfft)

with amplitudes from an arbitrary numpy array's rFFT, which is to then be
converted back using numpy.fft.irfft .  Alternately, some future plans will
involve having to modify individual array element amplitudes directly based
on other parameters.  I would think that modifying and re-synthesizing
signals using FFT is a fairly common use-case, but my attempts at Googling
example code have been fruitless.

I'm not sure if my rudimentary knowledge of FFT is failing me, or if I'm
just not understanding how numpy represents and exposes the data, but I
would really appreciate any help I can get :)

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


Re: [Numpy-discussion] ANN: Numpy 1.8.0 beta 1 release

2013-09-03 Thread Charles R Harris
On Tue, Sep 3, 2013 at 6:09 PM, Christoph Gohlke cgoh...@uci.edu wrote:

 On 9/3/2013 4:45 PM, Charles R Harris wrote:
 
 
 
  On Tue, Sep 3, 2013 at 5:40 PM, Christoph Gohlke cgoh...@uci.edu
  mailto:cgoh...@uci.edu wrote:
 
  On 9/3/2013 2:51 PM, Charles R Harris wrote:
  
  
  
   On Tue, Sep 3, 2013 at 3:23 PM, Christoph Gohlke 
  cgoh...@uci.edumailto:
 cgoh...@uci.edu
   mailto:cgoh...@uci.edu mailto:cgoh...@uci.edu wrote:
  
   On 9/1/2013 9:54 AM, Charles R Harris wrote:
  
   Hi all,
  
   I'm happy to announce the first beta release of Numpy
 1.8.0.
   Please try
   this beta and report any issues on the numpy-dev mailing
 list.
  
   Source tarballs and release notes can be found at
  https://sourceforge.net/__projects/numpy/files/NumPy/1.__8.0b1/
   
 https://sourceforge.net/projects/numpy/files/NumPy/1.8.0b1/.
   The Windows
   and OS X installers will follow when the infrastructure
 issues
   are dealt
   with.
  
   Chuck
  
  
   Hello,
  
   I tried numpy-1.8.0.dev-86a6e6c with msvc9 and MKL 11.1 on
   win-amd64-py2.7. It builds OK but there are 23 test errors and
 6
   failures (attached).
  
   Some 3rd party packages (e.g. scipy, numexpr, pytables,
 bottleneck,
   pandas and matplotlib) that were built against numpy-MKL 1.7
 fail
   tests when used with numpy-MKL 1.8. Other packages test OK
 (e.g.
   skimage, sklearn, statsmodels, mahotas, pygame). See
   
 http://www.lfd.uci.edu/~__gohlke/pythonlibs/tests/__20130902-win-amd64-py2.7-__numpy-1.8.0.dev-86a6e6c/
  
 http://www.lfd.uci.edu/%7E__gohlke/pythonlibs/tests/__20130902-win-amd64-py2.7-__numpy-1.8.0.dev-86a6e6c/
 
   
 http://www.lfd.uci.edu/%7Egohlke/pythonlibs/tests/20130902-win-amd64-py2.7-numpy-1.8.0.dev-86a6e6c/
 
   compared to
   
 http://www.lfd.uci.edu/~__gohlke/pythonlibs/tests/__20130902-win-amd64-py2.7/
  
 http://www.lfd.uci.edu/%7E__gohlke/pythonlibs/tests/__20130902-win-amd64-py2.7/
 
   
 http://www.lfd.uci.edu/%7Egohlke/pythonlibs/tests/20130902-win-amd64-py2.7/
 .
  
  
   I have not looked in more detail or at other Python versions
 yet.
  
  
   Thanks Christoph,
  
   Looks like some work to do. I wonder what is different between
 windows
   and linux here?
  
   Chuck
  
 
  Looks like the fundamental PyArray_PyIntAsIntp function is broken on
 64
  bit Windows. 64 bit PyLong values are intermediately stored in a 32
 bit
  C long variable. But maybe I am missing something...
  
 https://github.com/numpy/numpy/blob/maintenance/1.8.x/numpy/core/src/multiarray/conversion_utils.c#L729
 
  
 https://github.com/numpy/numpy/blob/maintenance/1.8.x/numpy/core/src/multiarray/conversion_utils.c#L767
 
 
  My, that does look suspicious. That function is new in 1.8 I believe.
  Looks like it needs fixing whatever else it fixes.
 
  Chuck
 

 In fact, using a npy_longlong instead of npy_long fixes all numpy test
 errors and failures. But it probably foils the recent optimizations.


Great! I think the function is not used for numeric things so I'm not sure
what optimizations could be affected. I'll put up a PR and backport it.

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


Re: [Numpy-discussion] ANN: Numpy 1.8.0 beta 1 release

2013-09-03 Thread Christoph Gohlke
On 9/3/2013 4:52 PM, Charles R Harris wrote:



 On Tue, Sep 3, 2013 at 5:45 PM, Charles R Harris
 charlesr.har...@gmail.com mailto:charlesr.har...@gmail.com wrote:




 On Tue, Sep 3, 2013 at 5:40 PM, Christoph Gohlke cgoh...@uci.edu
 mailto:cgoh...@uci.edu wrote:

 On 9/3/2013 2:51 PM, Charles R Harris wrote:
 
 
 
  On Tue, Sep 3, 2013 at 3:23 PM, Christoph Gohlke cgoh...@uci.edu 
 mailto:cgoh...@uci.edu
  mailto:cgoh...@uci.edu mailto:cgoh...@uci.edu wrote:
 
  On 9/1/2013 9:54 AM, Charles R Harris wrote:
 
  Hi all,
 
  I'm happy to announce the first beta release of Numpy 1.8.0.
  Please try
  this beta and report any issues on the numpy-dev mailing 
 list.
 
  Source tarballs and release notes can be found at
 https://sourceforge.net/__projects/numpy/files/NumPy/1.__8.0b1/
  
 https://sourceforge.net/projects/numpy/files/NumPy/1.8.0b1/.
  The Windows
  and OS X installers will follow when the infrastructure 
 issues
  are dealt
  with.
 
  Chuck
 
 
  Hello,
 
  I tried numpy-1.8.0.dev-86a6e6c with msvc9 and MKL 11.1 on
  win-amd64-py2.7. It builds OK but there are 23 test errors and 6
  failures (attached).
 
  Some 3rd party packages (e.g. scipy, numexpr, pytables, 
 bottleneck,
  pandas and matplotlib) that were built against numpy-MKL 1.7 
 fail
  tests when used with numpy-MKL 1.8. Other packages test OK (e.g.
  skimage, sklearn, statsmodels, mahotas, pygame). See
  
 http://www.lfd.uci.edu/~__gohlke/pythonlibs/tests/__20130902-win-amd64-py2.7-__numpy-1.8.0.dev-86a6e6c/
 
 http://www.lfd.uci.edu/%7E__gohlke/pythonlibs/tests/__20130902-win-amd64-py2.7-__numpy-1.8.0.dev-86a6e6c/
  
 http://www.lfd.uci.edu/%7Egohlke/pythonlibs/tests/20130902-win-amd64-py2.7-numpy-1.8.0.dev-86a6e6c/
  compared to
  
 http://www.lfd.uci.edu/~__gohlke/pythonlibs/tests/__20130902-win-amd64-py2.7/
 
 http://www.lfd.uci.edu/%7E__gohlke/pythonlibs/tests/__20130902-win-amd64-py2.7/
  
 http://www.lfd.uci.edu/%7Egohlke/pythonlibs/tests/20130902-win-amd64-py2.7/.
 
 
  I have not looked in more detail or at other Python versions 
 yet.
 
 
  Thanks Christoph,
 
  Looks like some work to do. I wonder what is different between 
 windows
  and linux here?
 
  Chuck
 

 Looks like the fundamental PyArray_PyIntAsIntp function is
 broken on 64
 bit Windows. 64 bit PyLong values are intermediately stored in a
 32 bit
 C long variable. But maybe I am missing something...
 
 https://github.com/numpy/numpy/blob/maintenance/1.8.x/numpy/core/src/multiarray/conversion_utils.c#L729
 
 https://github.com/numpy/numpy/blob/maintenance/1.8.x/numpy/core/src/multiarray/conversion_utils.c#L767

 My, that does look suspicious. That function is new in 1.8 I
 believe. Looks like it needs fixing whatever else it fixes.


 BTW, do the tests pass with a 32 build?

 Chuck


The 32 bit build fails two tests (unrelated to the above 64 bit issue):

==
FAIL: test_invalid (test_errstate.TestErrstate)
--
Traceback (most recent call last):
   File X:\Python27\lib\site-packages\numpy\testing\decorators.py, 
line 146, in skipper_func
 return f(*args, **kwargs)
   File 
X:\Python27\lib\site-packages\numpy\core\tests\test_errstate.py, line 
23, in test_invalid
 self.fail(Did not raise an invalid error)
AssertionError: Did not raise an invalid error

==
FAIL: simd tests on max/min
--
Traceback (most recent call last):
   File X:\Python27\lib\site-packages\numpy\core\tests\test_umath.py, 
line 678, in test_minmax_blocked
 msg=repr(inp) + '\n' + msg)
AssertionError: array([  0.,   1.,  nan,   3.,   4.,   5.,   6.,   7., 
  8.,   9.,  10.], dtype=float32)
unary offset=(0, 0), size=11, dtype=type 'numpy.float32', out of place

--

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


Re: [Numpy-discussion] ANN: Numpy 1.8.0 beta 1 release

2013-09-03 Thread Chris Barker - NOAA Federal
FWIW,

You all may know this already, but a long is 64 bit on most 64 bit
platforms, but 32 bit on Windows.

Can we start using stdint.h and int32_t and friends?

-CHB

On Sep 3, 2013, at 5:18 PM, Charles R Harris charlesr.har...@gmail.com
wrote:




On Tue, Sep 3, 2013 at 6:09 PM, Christoph Gohlke cgoh...@uci.edu wrote:

 On 9/3/2013 4:45 PM, Charles R Harris wrote:
 
 
 
  On Tue, Sep 3, 2013 at 5:40 PM, Christoph Gohlke cgoh...@uci.edu
  mailto:cgoh...@uci.edu wrote:
 
  On 9/3/2013 2:51 PM, Charles R Harris wrote:
  
  
  
   On Tue, Sep 3, 2013 at 3:23 PM, Christoph Gohlke 
  cgoh...@uci.edumailto:
 cgoh...@uci.edu
   mailto:cgoh...@uci.edu mailto:cgoh...@uci.edu wrote:
  
   On 9/1/2013 9:54 AM, Charles R Harris wrote:
  
   Hi all,
  
   I'm happy to announce the first beta release of Numpy
 1.8.0.
   Please try
   this beta and report any issues on the numpy-dev mailing
 list.
  
   Source tarballs and release notes can be found at
  https://sourceforge.net/__projects/numpy/files/NumPy/1.__8.0b1/
   
 https://sourceforge.net/projects/numpy/files/NumPy/1.8.0b1/.
   The Windows
   and OS X installers will follow when the infrastructure
 issues
   are dealt
   with.
  
   Chuck
  
  
   Hello,
  
   I tried numpy-1.8.0.dev-86a6e6c with msvc9 and MKL 11.1 on
   win-amd64-py2.7. It builds OK but there are 23 test errors and
 6
   failures (attached).
  
   Some 3rd party packages (e.g. scipy, numexpr, pytables,
 bottleneck,
   pandas and matplotlib) that were built against numpy-MKL 1.7
 fail
   tests when used with numpy-MKL 1.8. Other packages test OK
 (e.g.
   skimage, sklearn, statsmodels, mahotas, pygame). See
   
 http://www.lfd.uci.edu/~__gohlke/pythonlibs/tests/__20130902-win-amd64-py2.7-__numpy-1.8.0.dev-86a6e6c/
  
 http://www.lfd.uci.edu/%7E__gohlke/pythonlibs/tests/__20130902-win-amd64-py2.7-__numpy-1.8.0.dev-86a6e6c/
 
   
 http://www.lfd.uci.edu/%7Egohlke/pythonlibs/tests/20130902-win-amd64-py2.7-numpy-1.8.0.dev-86a6e6c/
 
   compared to
   
 http://www.lfd.uci.edu/~__gohlke/pythonlibs/tests/__20130902-win-amd64-py2.7/
  
 http://www.lfd.uci.edu/%7E__gohlke/pythonlibs/tests/__20130902-win-amd64-py2.7/
 
   
 http://www.lfd.uci.edu/%7Egohlke/pythonlibs/tests/20130902-win-amd64-py2.7/
 .
  
  
   I have not looked in more detail or at other Python versions
 yet.
  
  
   Thanks Christoph,
  
   Looks like some work to do. I wonder what is different between
 windows
   and linux here?
  
   Chuck
  
 
  Looks like the fundamental PyArray_PyIntAsIntp function is broken on
 64
  bit Windows. 64 bit PyLong values are intermediately stored in a 32
 bit
  C long variable. But maybe I am missing something...
  
 https://github.com/numpy/numpy/blob/maintenance/1.8.x/numpy/core/src/multiarray/conversion_utils.c#L729
 
  
 https://github.com/numpy/numpy/blob/maintenance/1.8.x/numpy/core/src/multiarray/conversion_utils.c#L767
 
 
  My, that does look suspicious. That function is new in 1.8 I believe.
  Looks like it needs fixing whatever else it fixes.
 
  Chuck
 

 In fact, using a npy_longlong instead of npy_long fixes all numpy test
 errors and failures. But it probably foils the recent optimizations.


Great! I think the function is not used for numeric things so I'm not sure
what optimizations could be affected. I'll put up a PR and backport it.

Chuck

___
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


Re: [Numpy-discussion] ANN: Numpy 1.8.0 beta 1 release

2013-09-03 Thread Charles R Harris
On Tue, Sep 3, 2013 at 6:18 PM, Charles R Harris
charlesr.har...@gmail.comwrote:




 On Tue, Sep 3, 2013 at 6:09 PM, Christoph Gohlke cgoh...@uci.edu wrote:

 On 9/3/2013 4:45 PM, Charles R Harris wrote:
 
 
 
  On Tue, Sep 3, 2013 at 5:40 PM, Christoph Gohlke cgoh...@uci.edu
  mailto:cgoh...@uci.edu wrote:
 
  On 9/3/2013 2:51 PM, Charles R Harris wrote:
  
  
  
   On Tue, Sep 3, 2013 at 3:23 PM, Christoph Gohlke 
  cgoh...@uci.edumailto:
 cgoh...@uci.edu
   mailto:cgoh...@uci.edu mailto:cgoh...@uci.edu wrote:
  
   On 9/1/2013 9:54 AM, Charles R Harris wrote:
  
   Hi all,
  
   I'm happy to announce the first beta release of Numpy
 1.8.0.
   Please try
   this beta and report any issues on the numpy-dev mailing
 list.
  
   Source tarballs and release notes can be found at
  https://sourceforge.net/__projects/numpy/files/NumPy/1.__8.0b1/
   
 https://sourceforge.net/projects/numpy/files/NumPy/1.8.0b1/.
   The Windows
   and OS X installers will follow when the infrastructure
 issues
   are dealt
   with.
  
   Chuck
  
  
   Hello,
  
   I tried numpy-1.8.0.dev-86a6e6c with msvc9 and MKL 11.1 on
   win-amd64-py2.7. It builds OK but there are 23 test errors
 and 6
   failures (attached).
  
   Some 3rd party packages (e.g. scipy, numexpr, pytables,
 bottleneck,
   pandas and matplotlib) that were built against numpy-MKL 1.7
 fail
   tests when used with numpy-MKL 1.8. Other packages test OK
 (e.g.
   skimage, sklearn, statsmodels, mahotas, pygame). See
   
 http://www.lfd.uci.edu/~__gohlke/pythonlibs/tests/__20130902-win-amd64-py2.7-__numpy-1.8.0.dev-86a6e6c/
  
 http://www.lfd.uci.edu/%7E__gohlke/pythonlibs/tests/__20130902-win-amd64-py2.7-__numpy-1.8.0.dev-86a6e6c/
 
   
 http://www.lfd.uci.edu/%7Egohlke/pythonlibs/tests/20130902-win-amd64-py2.7-numpy-1.8.0.dev-86a6e6c/
 
   compared to
   
 http://www.lfd.uci.edu/~__gohlke/pythonlibs/tests/__20130902-win-amd64-py2.7/
  
 http://www.lfd.uci.edu/%7E__gohlke/pythonlibs/tests/__20130902-win-amd64-py2.7/
 
   
 http://www.lfd.uci.edu/%7Egohlke/pythonlibs/tests/20130902-win-amd64-py2.7/
 .
  
  
   I have not looked in more detail or at other Python versions
 yet.
  
  
   Thanks Christoph,
  
   Looks like some work to do. I wonder what is different between
 windows
   and linux here?
  
   Chuck
  
 
  Looks like the fundamental PyArray_PyIntAsIntp function is broken
 on 64
  bit Windows. 64 bit PyLong values are intermediately stored in a 32
 bit
  C long variable. But maybe I am missing something...
  
 https://github.com/numpy/numpy/blob/maintenance/1.8.x/numpy/core/src/multiarray/conversion_utils.c#L729
 
  
 https://github.com/numpy/numpy/blob/maintenance/1.8.x/numpy/core/src/multiarray/conversion_utils.c#L767
 
 
  My, that does look suspicious. That function is new in 1.8 I believe.
  Looks like it needs fixing whatever else it fixes.
 
  Chuck
 

 In fact, using a npy_longlong instead of npy_long fixes all numpy test
 errors and failures. But it probably foils the recent optimizations.


 Great! I think the function is not used for numeric things so I'm not sure
 what optimizations could be affected. I'll put up a PR and backport it.


Looks like there are several errors in that function.

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


Re: [Numpy-discussion] (no subject)

2013-09-03 Thread Cera, Tim
 I am trying to take the rfft of a numpy array, like this:
 my_rfft = numpy.fft.rfft(my_numpy_array)

 and replace the amplitudes that can be obtained with:

 my_amplitudes = numpy.abs(my_rfft)

 with amplitudes from an arbitrary numpy array's rFFT, which is to then be
 converted back using numpy.fft.irfft .  Alternately, some future plans will
 involve having to modify individual array element amplitudes directly based
 on other parameters.  I would think that modifying and re-synthesizing
 signals using FFT is a fairly common use-case, but my attempts at Googling
 example code have been fruitless.

I have FFT transform filter in my tidal analysis package.   See
http://sourceforge.net/apps/mediawiki/tappy/index.php?title=CompareTidalFilters
for a comparison and short description.

See my function below.  My earlier self made some poor variable name
choices.  The 'low_bound' variable is actually where frequencies
greater are set to zero ('factor[freq  low_bound] = 0.0'), then
factor is ramped from 0 at 'low_bound' to 1 at 'high_bound'.  To
filter out tidal signals if your water elevations are hourly then
'low_bound' = 1/30.0 and 'high_bound' = 1/40.0.  Having this gradual
change in the frequency domain rather than an abrupt change makes a
better filter.

def fft_lowpass(nelevation, low_bound, high_bound):
  Performs a low pass filter on the nelevation series.
 low_bound and high_bound specifies the boundary of the filter.
 
 import numpy.fft as F
 if len(nelevation) % 2:
 result = F.rfft(nelevation, len(nelevation))
 else:
 result = F.rfft(nelevation)
 freq = F.fftfreq(len(nelevation))[:len(nelevation)/2]
 factor = np.ones_like(result)
 factor[freq  low_bound] = 0.0

 sl = np.logical_and(high_bound  freq, freq  low_bound)

 a = factor[sl]
 # Create float array of required length and reverse
 a = np.arange(len(a) + 2).astype(float)[::-1]

 # Ramp from 1 to 0 exclusive
 a = (a/a[0])[1:-1]

 # Insert ramp into factor
 factor[sl] = a

 result = result * factor
 print 'result=', len(result)
 relevation = F.irfft(result, len(nelevation))
 print 'result=', len(relevation)
 return relevation


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


Re: [Numpy-discussion] (no subject)

2013-09-03 Thread Carl Canuck
Hi Tim,

Brilliant!  Many thanks...  I think this is exactly what I need, I owe you
a beer (or other beverage of your choice).

I'm now going to lock myself in the basement until I can work out an
implementation of this for my use-case :)

/Carl


On Tue, Sep 3, 2013 at 9:05 PM, Cera, Tim t...@cerazone.net wrote:

  I am trying to take the rfft of a numpy array, like this:
  my_rfft = numpy.fft.rfft(my_numpy_array)
 
  and replace the amplitudes that can be obtained with:
 
  my_amplitudes = numpy.abs(my_rfft)
 
  with amplitudes from an arbitrary numpy array's rFFT, which is to then be
  converted back using numpy.fft.irfft .  Alternately, some future plans
 will
  involve having to modify individual array element amplitudes directly
 based
  on other parameters.  I would think that modifying and re-synthesizing
  signals using FFT is a fairly common use-case, but my attempts at
 Googling
  example code have been fruitless.

 I have FFT transform filter in my tidal analysis package.   See

 http://sourceforge.net/apps/mediawiki/tappy/index.php?title=CompareTidalFilters
 for a comparison and short description.

 See my function below.  My earlier self made some poor variable name
 choices.  The 'low_bound' variable is actually where frequencies
 greater are set to zero ('factor[freq  low_bound] = 0.0'), then
 factor is ramped from 0 at 'low_bound' to 1 at 'high_bound'.  To
 filter out tidal signals if your water elevations are hourly then
 'low_bound' = 1/30.0 and 'high_bound' = 1/40.0.  Having this gradual
 change in the frequency domain rather than an abrupt change makes a
 better filter.

 def fft_lowpass(nelevation, low_bound, high_bound):
   Performs a low pass filter on the nelevation series.
  low_bound and high_bound specifies the boundary of the filter.
  
  import numpy.fft as F
  if len(nelevation) % 2:
  result = F.rfft(nelevation, len(nelevation))
  else:
  result = F.rfft(nelevation)
  freq = F.fftfreq(len(nelevation))[:len(nelevation)/2]
  factor = np.ones_like(result)
  factor[freq  low_bound] = 0.0

  sl = np.logical_and(high_bound  freq, freq  low_bound)

  a = factor[sl]
  # Create float array of required length and reverse
  a = np.arange(len(a) + 2).astype(float)[::-1]

  # Ramp from 1 to 0 exclusive
  a = (a/a[0])[1:-1]

  # Insert ramp into factor
  factor[sl] = a

  result = result * factor
  print 'result=', len(result)
  relevation = F.irfft(result, len(nelevation))
  print 'result=', len(relevation)
  return relevation


 Kindest regards,
 Tim
 ___
 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