[Numpy-discussion] Array2 subset of array1

2014-08-05 Thread Jurgens de Bruin
Hi,

I am new to numpy so any help would be greatly appreciated.

I have two arrays:

array1 = np.arange(1,100+1)
array2 = np.arange(1,50+1)

How can I calculate/determine if array2 is a subset of array1 (falls within
array 1)

Something like : array2 in array1 = TRUE for the case above.

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


Re: [Numpy-discussion] Array2 subset of array1

2014-08-05 Thread Nathaniel Smith
On Tue, Aug 5, 2014 at 1:58 PM, Jurgens de Bruin debrui...@gmail.com wrote:
 Hi,

 I am new to numpy so any help would be greatly appreciated.

 I have two arrays:

 array1 = np.arange(1,100+1)
 array2 = np.arange(1,50+1)

 How can I calculate/determine if array2 is a subset of array1 (falls within
 array 1)

 Something like : array2 in array1 = TRUE for the case above.

Does this work?
  np.in1d(array2, array1)

See:
  http://docs.scipy.org/doc/numpy/reference/routines.set.html

(Note that while in1d does the best it can, set operations on arrays
will usually be slower than if you used a more appropriate data type
like 'set' or 'dict'.)

-n

-- 
Nathaniel J. Smith
Postdoctoral researcher - Informatics - University of Edinburgh
http://vorpus.org
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Array2 subset of array1

2014-08-05 Thread Eelco Hoogendoorn
np.all(np.in1d(array1,array2))


On Tue, Aug 5, 2014 at 2:58 PM, Jurgens de Bruin debrui...@gmail.com
wrote:

 Hi,

 I am new to numpy so any help would be greatly appreciated.

 I have two arrays:

 array1 = np.arange(1,100+1)
 array2 = np.arange(1,50+1)

 How can I calculate/determine if array2 is a subset of array1 (falls
 within array 1)

 Something like : array2 in array1 = TRUE for the case above.

 Thank

 ___
 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] Array2 subset of array1

2014-08-05 Thread Sebastian Berg
On Di, 2014-08-05 at 14:58 +0200, Jurgens de Bruin wrote:
 Hi,
 
 I am new to numpy so any help would be greatly appreciated. 
 
 I have two arrays:
 
 array1 = np.arange(1,100+1)
 array2 = np.arange(1,50+1)
 
 How can I calculate/determine if array2 is a subset of array1 (falls
 within array 1)
 
 Something like : array2 in array1 = TRUE for the case above.
 

Just to be clear. You are looking for the whole of array1 (as a
block/subarray) as far as I understand. And there is no obvious numpy
way to do this. Depending on your array sizes, you could blow up the
first array from (N,) to (N-M+1,M) and then check if any row matches
completely. There may be better tricks available though, especially if
array1 is large.

- Sebastian

 Thank
 ___
 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] Array2 subset of array1

2014-08-05 Thread Eelco Hoogendoorn
ah yes, that may indeed be what you want. depending on your datatype, you
could access the underlying raw data as a string.

b.tostring() in a.tostring() sort of works; but isn't entirely safe, as you
may have false positive matches which arnt aligned to your datatype
using str.find in combination with dtype.itemsize could solve that problem;
though it isn't the most elegant solution id say. also note that you need
to check for identical datatypes and memory layout for this to guarantee
correct results.


On Tue, Aug 5, 2014 at 6:33 PM, Sebastian Berg sebast...@sipsolutions.net
wrote:

 On Di, 2014-08-05 at 14:58 +0200, Jurgens de Bruin wrote:
  Hi,
 
  I am new to numpy so any help would be greatly appreciated.
 
  I have two arrays:
 
  array1 = np.arange(1,100+1)
  array2 = np.arange(1,50+1)
 
  How can I calculate/determine if array2 is a subset of array1 (falls
  within array 1)
 
  Something like : array2 in array1 = TRUE for the case above.
 

 Just to be clear. You are looking for the whole of array1 (as a
 block/subarray) as far as I understand. And there is no obvious numpy
 way to do this. Depending on your array sizes, you could blow up the
 first array from (N,) to (N-M+1,M) and then check if any row matches
 completely. There may be better tricks available though, especially if
 array1 is large.

 - Sebastian

  Thank
  ___
  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

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


[Numpy-discussion] ANN: NumPy 1.8.2 release candidate

2014-08-05 Thread Julian Taylor
Hello,

I am pleased to announce the first release candidate for numpy 1.8.2, a
pure bugfix release for the 1.8.x series.
https://sourceforge.net/projects/numpy/files/NumPy/1.8.2rc1/

If no regressions show up the final release is planned this weekend.
The upgrade is recommended for all users of the 1.8.x series.

Following issues have been fixed:
* gh-4836: partition produces wrong results for multiple selections in
equal ranges
* gh-4656: Make fftpack._raw_fft threadsafe
* gh-4628: incorrect argument order to _copyto in in np.nanmax, np.nanmin
* gh-4613: Fix lack of NULL check in array_richcompare
* gh-4642: Hold GIL for converting dtypes types with fields
* gh-4733: fix np.linalg.svd(b, compute_uv=False)
* gh-4853: avoid unaligned simd load on reductions on i386
* gh-4774: avoid unaligned access for strided byteswap
* gh-650: Prevent division by zero when creating arrays from some buffers
* gh-4602: ifort has issues with optimization flag O2, use O1

Source tarballs, windows installers and release notes can be found at
https://sourceforge.net/projects/numpy/files/NumPy/1.8.2rc1/

Cheers,
Julian Taylor



signature.asc
Description: OpenPGP digital signature
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] ANN: NumPy 1.8.2 release candidate

2014-08-05 Thread Christoph Gohlke
On 8/5/2014 12:45 PM, Julian Taylor wrote:
 Hello,

 I am pleased to announce the first release candidate for numpy 1.8.2, a
 pure bugfix release for the 1.8.x series.
 https://sourceforge.net/projects/numpy/files/NumPy/1.8.2rc1/

 If no regressions show up the final release is planned this weekend.
 The upgrade is recommended for all users of the 1.8.x series.

 Following issues have been fixed:
 * gh-4836: partition produces wrong results for multiple selections in
 equal ranges
 * gh-4656: Make fftpack._raw_fft threadsafe
 * gh-4628: incorrect argument order to _copyto in in np.nanmax, np.nanmin
 * gh-4613: Fix lack of NULL check in array_richcompare
 * gh-4642: Hold GIL for converting dtypes types with fields
 * gh-4733: fix np.linalg.svd(b, compute_uv=False)
 * gh-4853: avoid unaligned simd load on reductions on i386
 * gh-4774: avoid unaligned access for strided byteswap
 * gh-650: Prevent division by zero when creating arrays from some buffers
 * gh-4602: ifort has issues with optimization flag O2, use O1

 Source tarballs, windows installers and release notes can be found at
 https://sourceforge.net/projects/numpy/files/NumPy/1.8.2rc1/

 Cheers,
 Julian Taylor


Hello,

thank you. Looks good. All builds and tests pass on Windows (using 
msvc/MKL).

Any chance gh-4722 can make it into the release?
Fix seg fault converting empty string to object
https://github.com/numpy/numpy/pull/4722

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


Re: [Numpy-discussion] ANN: NumPy 1.8.2 release candidate

2014-08-05 Thread Julian Taylor
On 05.08.2014 22:32, Christoph Gohlke wrote:
 On 8/5/2014 12:45 PM, Julian Taylor wrote:
 Hello,

 I am pleased to announce the first release candidate for numpy 1.8.2, a
 pure bugfix release for the 1.8.x series.
 https://sourceforge.net/projects/numpy/files/NumPy/1.8.2rc1/

 If no regressions show up the final release is planned this weekend.
 The upgrade is recommended for all users of the 1.8.x series.

 Following issues have been fixed:
 * gh-4836: partition produces wrong results for multiple selections in
 equal ranges
 * gh-4656: Make fftpack._raw_fft threadsafe
 * gh-4628: incorrect argument order to _copyto in in np.nanmax, np.nanmin
 * gh-4613: Fix lack of NULL check in array_richcompare
 * gh-4642: Hold GIL for converting dtypes types with fields
 * gh-4733: fix np.linalg.svd(b, compute_uv=False)
 * gh-4853: avoid unaligned simd load on reductions on i386
 * gh-4774: avoid unaligned access for strided byteswap
 * gh-650: Prevent division by zero when creating arrays from some buffers
 * gh-4602: ifort has issues with optimization flag O2, use O1

 Source tarballs, windows installers and release notes can be found at
 https://sourceforge.net/projects/numpy/files/NumPy/1.8.2rc1/

 Cheers,
 Julian Taylor

 
 Hello,
 
 thank you. Looks good. All builds and tests pass on Windows (using 
 msvc/MKL).
 
 Any chance gh-4722 can make it into the release?
 Fix seg fault converting empty string to object
 https://github.com/numpy/numpy/pull/4722
 

thanks, I missed that one, pretty simple, I'll add it to the final release.




signature.asc
Description: OpenPGP digital signature
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] ANN: NumPy 1.8.2 release candidate

2014-08-05 Thread Matthew Brett
Hi,

On Tue, Aug 5, 2014 at 1:57 PM, Julian Taylor
jtaylor.deb...@googlemail.com wrote:
 On 05.08.2014 22:32, Christoph Gohlke wrote:
 On 8/5/2014 12:45 PM, Julian Taylor wrote:
 Hello,

 I am pleased to announce the first release candidate for numpy 1.8.2, a
 pure bugfix release for the 1.8.x series.
 https://sourceforge.net/projects/numpy/files/NumPy/1.8.2rc1/

 If no regressions show up the final release is planned this weekend.
 The upgrade is recommended for all users of the 1.8.x series.

 Following issues have been fixed:
 * gh-4836: partition produces wrong results for multiple selections in
 equal ranges
 * gh-4656: Make fftpack._raw_fft threadsafe
 * gh-4628: incorrect argument order to _copyto in in np.nanmax, np.nanmin
 * gh-4613: Fix lack of NULL check in array_richcompare
 * gh-4642: Hold GIL for converting dtypes types with fields
 * gh-4733: fix np.linalg.svd(b, compute_uv=False)
 * gh-4853: avoid unaligned simd load on reductions on i386
 * gh-4774: avoid unaligned access for strided byteswap
 * gh-650: Prevent division by zero when creating arrays from some buffers
 * gh-4602: ifort has issues with optimization flag O2, use O1

 Source tarballs, windows installers and release notes can be found at
 https://sourceforge.net/projects/numpy/files/NumPy/1.8.2rc1/

 Cheers,
 Julian Taylor


 Hello,

 thank you. Looks good. All builds and tests pass on Windows (using
 msvc/MKL).

 Any chance gh-4722 can make it into the release?
 Fix seg fault converting empty string to object
 https://github.com/numpy/numpy/pull/4722


 thanks, I missed that one, pretty simple, I'll add it to the final release.

OSX wheels built and tested and uploaded OK :

http://wheels.scikit-image.org

https://travis-ci.org/matthew-brett/numpy-atlas-binaries/builds/31747958

Will test against the scipy stack later on today.

Cheers,

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


Re: [Numpy-discussion] ANN: NumPy 1.8.2 release candidate

2014-08-05 Thread Derek Homeier
On 5 Aug 2014, at 11:27 pm, Matthew Brett matthew.br...@gmail.com wrote:

 OSX wheels built and tested and uploaded OK :
 
 http://wheels.scikit-image.org
 
 https://travis-ci.org/matthew-brett/numpy-atlas-binaries/builds/31747958
 
 Will test against the scipy stack later on today.

Built and tested against the Fink Python installation under OSX.
Seems to resolve one of a couple of f2py test errors appearing with 1.8.1 on 
Python 3.3 and 3.4:

==
ERROR: test_return_real.TestCReturnReal.test_all
--
Traceback (most recent call last):
  File /sw/lib/python3.4/site-packages/nose/case.py, line 382, in setUp
try_run(self.inst, ('setup', 'setUp'))
  File /sw/lib/python3.4/site-packages/nose/util.py, line 470, in try_run
return func()
  File /sw/lib/python3.4/site-packages/numpy/f2py/tests/util.py, line 348, in 
setUp
module_name=self.module_name)
  File /sw/lib/python3.4/site-packages/numpy/f2py/tests/util.py, line 74, in 
wrapper
memo[key] = func(*a, **kw)
  File /sw/lib/python3.4/site-packages/numpy/f2py/tests/util.py, line 163, in 
build_code
module_name=module_name)
  File /sw/lib/python3.4/site-packages/numpy/f2py/tests/util.py, line 74, in 
wrapper
memo[key] = func(*a, **kw)
  File /sw/lib/python3.4/site-packages/numpy/f2py/tests/util.py, line 144, in 
build_module
__import__(module_name)
ImportError: No module named ‘c_ext_return_real'

is gone on 3.4 now but still present on 3.3. Two errors of this kind (with 
different numbers) remain:

ERROR: test_return_real.TestF90ReturnReal.test_all
--
Traceback (most recent call last):
  File /sw/lib/python3.4/site-packages/nose/case.py, line 382, in setUp
try_run(self.inst, ('setup', 'setUp'))
  File /sw/lib/python3.4/site-packages/nose/util.py, line 470, in try_run
return func()
  File /sw/lib/python3.4/site-packages/numpy/f2py/tests/util.py, line 348, in 
setUp
module_name=self.module_name)
  File /sw/lib/python3.4/site-packages/numpy/f2py/tests/util.py, line 74, in 
wrapper
memo[key] = func(*a, **kw)
  File /sw/lib/python3.4/site-packages/numpy/f2py/tests/util.py, line 163, in 
build_code
module_name=module_name)
  File /sw/lib/python3.4/site-packages/numpy/f2py/tests/util.py, line 74, in 
wrapper
memo[key] = func(*a, **kw)
  File /sw/lib/python3.4/site-packages/numpy/f2py/tests/util.py, line 144, in 
build_module
__import__(module_name)
ImportError: No module named ‘_test_ext_module_5415'

NumPy version 1.8.2rc1
NumPy is installed in /sw/lib/python3.4/site-packages/numpy
Python version 3.4.1 (default, Aug  3 2014, 21:02:44) [GCC 4.2.1 Compatible 
Apple LLVM 5.1 (clang-503.0.40)]
nose version 1.3.3

Cheers,
Derek

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


Re: [Numpy-discussion] ANN: NumPy 1.8.2 release candidate

2014-08-05 Thread Matthew Brett
Hi,

On Tue, Aug 5, 2014 at 2:27 PM, Matthew Brett matthew.br...@gmail.com wrote:
 Hi,

 On Tue, Aug 5, 2014 at 1:57 PM, Julian Taylor
 jtaylor.deb...@googlemail.com wrote:
 On 05.08.2014 22:32, Christoph Gohlke wrote:
 On 8/5/2014 12:45 PM, Julian Taylor wrote:
 Hello,

 I am pleased to announce the first release candidate for numpy 1.8.2, a
 pure bugfix release for the 1.8.x series.
 https://sourceforge.net/projects/numpy/files/NumPy/1.8.2rc1/

 If no regressions show up the final release is planned this weekend.
 The upgrade is recommended for all users of the 1.8.x series.

 Following issues have been fixed:
 * gh-4836: partition produces wrong results for multiple selections in
 equal ranges
 * gh-4656: Make fftpack._raw_fft threadsafe
 * gh-4628: incorrect argument order to _copyto in in np.nanmax, np.nanmin
 * gh-4613: Fix lack of NULL check in array_richcompare
 * gh-4642: Hold GIL for converting dtypes types with fields
 * gh-4733: fix np.linalg.svd(b, compute_uv=False)
 * gh-4853: avoid unaligned simd load on reductions on i386
 * gh-4774: avoid unaligned access for strided byteswap
 * gh-650: Prevent division by zero when creating arrays from some buffers
 * gh-4602: ifort has issues with optimization flag O2, use O1

 Source tarballs, windows installers and release notes can be found at
 https://sourceforge.net/projects/numpy/files/NumPy/1.8.2rc1/

 Cheers,
 Julian Taylor


 Hello,

 thank you. Looks good. All builds and tests pass on Windows (using
 msvc/MKL).

 Any chance gh-4722 can make it into the release?
 Fix seg fault converting empty string to object
 https://github.com/numpy/numpy/pull/4722


 thanks, I missed that one, pretty simple, I'll add it to the final release.

 OSX wheels built and tested and uploaded OK :

 http://wheels.scikit-image.org

 https://travis-ci.org/matthew-brett/numpy-atlas-binaries/builds/31747958

OSX wheel tested OK against current scipy stack for system Python,
python.org Python, homebrew, macports:

https://travis-ci.org/matthew-brett/scipy-stack-osx-testing/builds/31756325

Cheers,

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


[Numpy-discussion] Preliminary thoughts on implementing __matmul__

2014-08-05 Thread Charles R Harris
Hi All,

I've been looking to implement the @ operator from Python 3.5. Looking at
the current implementation of the dot function, it only uses a vector inner
product, which is either that defined in arraytypes.c.src or a version
using cblas defined in _dotblas for the float, cfloat, double, cdouble
types. I note that the versions defined in arraytypes.c.src include all the
numeric types plus boolean, datetime, timedelta, and object. I'm not clear
why datetime and timedelta should have dot products, except perhaps for
scalar multiplication. The boolean version has the advantage that it can
short circuit. I also note that all the operations proposed for @ can
easily be done with einsum except for objects. So I'm wondering if one easy
way to implement the functions is to extend einsum to work with objects and
make it use blas when available.

Another thing that may be worth looking into would be some way to multiply
by the complex conjugate, as that is easy to implement at the low level.
I'd welcome any thoughts as to how that might be done.

Anyway, I'm just looking for a discussion and ideas here. Any input is
welcome.

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