Re: [Numpy-discussion] picking elements with boolean masks

2013-03-25 Thread Neal Becker
Neal Becker wrote:

 starting with a NxM array, I want to select elements of the array using a set
 of
 boolean masks.  The masks are simply where the indexes have a 0 or 1 in the
 corresponding bit position.  For example, consider the case where M = 4.
 
 all_syms = np.arange (4)
 all_bits = np.arange (2)
 bit_mask = (all_syms[:,np.newaxis]  all_bits)  1
 mask0 = bit_mask == 0
 mask1 = bit_mask == 1
 
 Maybe there's a more straightforward way to generate these masks.  That's not
 my question.
 
 In [331]: mask1
 Out[331]:
 array([[False, False],
[ True, False],
[False,  True],
[ True,  True]], dtype=bool)
 
 OK, now I want to use this mask on D
 In [333]: D.shape
 Out[333]: (32400, 4)
 
 Just to simplify, let's just try the first row of D
 
 In [336]: D[0]
 Out[336]: array([ 0.,  2.,  2.,  4.])
 
 In [335]: D[0][mask1[...,0]]
 Out[335]: array([ 2.,  4.])
 
 that worked fine.  But I want not just to apply one of the masks in the set
 (mask1 is [4,2], it has 2 masks), I want the results of applying all the masks
 (2 in this case)
 
 
 In [334]: D[0][mask1]
 ---
 ValueErrorTraceback (most recent call last)
 ipython-input-334-243c7a5e45a4 in module()
  1 D[0][mask1]
 
 ValueError: boolean index array should have 1 dimension
 
 Any ideas what's the best approach here?

Perhaps what I need is to use integer indexing, rather than boolean.

all_syms = np.arange (const.size)
all_bits = np.arange (BITS_PER_SYM)
bit_mask = (all_syms[:,np.newaxis]  all_bits)  1

ind = np.array ([np.nonzero (bit_mask[...,i])[0] for i in range (BITS_PER_SYM)])
In [366]: ind
Out[366]: 
array([[1, 3],
   [2, 3]])

So now we have the 1-d indexes of the elements we want to select from D.
D = np.arange (4)+1

In [376]: D
Out[376]: array([1, 2, 3, 4])

In [377]: D[ind]
Out[377]: 
array([[2, 4],
   [3, 4]])

Looks like that does the job

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


Re: [Numpy-discussion] numpy array to C API

2013-03-25 Thread Gaël Varoquaux
On Thu, Mar 21, 2013 at 05:34:51PM +0100, Valentin Haenel wrote:
  I got currious about the Ctypes approach as well as Gaël Varoquaux’s 
  blog post about avoiding data copies, but the link in the article 
  didn't seem to work. (Under Further Reading and References)

 There seems to be something wrong with Gaël's website. I have CC him,
 maybe he can fix it.

Thanks Valentin! I believe that I have fixed the problem. Soren, if you
still have difficulties accessing the material, please complain.

Cheers,

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


Re: [Numpy-discussion] Unable to building numpy with openblas usingbento or distutils

2013-03-25 Thread Dinesh B Vadhia
Caveat: Not tested but it did look interesting: 
http://osdf.github.com/blog/numpyscipy-with-openblas-for-ubuntu-1204-second-try.html.
Would be interested to know if it worked out as want to try out OpenBlas in the 
future.___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Unable to building numpy with openblas usingbento or distutils

2013-03-25 Thread Skipper Seabold
On Mon, Mar 25, 2013 at 2:40 PM, Dinesh B Vadhia
dineshbvad...@hotmail.comwrote:

 **
 Caveat: Not tested but it did look interesting:
 http://osdf.github.com/blog/numpyscipy-with-openblas-for-ubuntu-1204-second-try.html
 .
 Would be interested to know if it worked out as want to try out OpenBlas
 in the future.


Yes, this is one of the sources I used. I needed to change the c_check file
in openblas as described up thread, and I didn't like the
half-distutils/half-bento hack, but with Ake's patch to numpy's distutils,
and my site.cfg, this works as described for me (Kubuntu 12.10) using just
the usual setup.py.

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


[Numpy-discussion] Growing the contributor base of Numpy

2013-03-25 Thread Jonathan Rocher
Dear all,

One recurring question is how to *grow the contributor base* to NumPy and
provide help and relief to core developers and maintainers.

 One way to do this would be to *leverage the upcoming SciPy conference* in
2 ways:

   1. Provide an intermediate or advanced level tutorial on NumPy focusing
   on teaching the C-API and the architecture of the package to help people
   navigate the source code, and find answers to precise deep questions. I
   think that many users would be interested in being better able to
   understand the underlayers to become powerful users (and contributors if
   they want to).

   2. Organize a Numpy sprint to leverage all this freshly graduated
   students apply what they learned to tackle some of the work under the
   guidance of core developers.

 This would be a great occasion to share and grow knowledge that is
fundamental to our community. And the fact that the underlayers are in C is
fine IMHO: SciPy is about scientific programming in Python and that is done
with a lot of C.

*Thoughts? Anyone interested in leading a tutorial (can be a team of
people)? Anyone willing to coordinate the sprint? Who would be willing to
be present and help during the sprint? *

Note that there is less than 1 week left until the tutorial submission
deadline. I am happy to help brainstorm on this to make it happen.

Thanks,
Jonathan and Andy, for the SciPy2013 organizers

-- 
Jonathan Rocher, PhD
Scientific software developer
SciPy2013 conference co-chair
Enthought, Inc.
jroc...@enthought.com
1-512-536-1057
http://www.enthought.com
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] variables not defined in numpy.random __init.py__ ?

2013-03-25 Thread Ralf Gommers
On Mon, Mar 25, 2013 at 4:23 PM, Dinesh B Vadhia
dineshbvad...@hotmail.comwrote:

 **
 Using PyInstaller, the following error occurs:

 Traceback (most recent call last):
   File string, line 9, in module
   File //usr/lib/python2.7/dist-packages/PIL/Image.py, line 355, in init
 __import__(f, globals(), locals(), [])
   File //usr/lib/python2.7/dist-packages/PIL/IptcImagePlugin.py, line
 23, in module
 import os, tempfile
   File /usr/lib/python2.7/tempfile.py, line 34, in module
 from random import Random as _Random
   File //usr/lib/python2.7/dist-packages/numpy/random/__init__.py, line
 90, in module
 ranf = random = sample = random_sample
 NameError: name 'random_sample' is not defined

 Is line 90 in __init.py__ valid?


It is.

Above the failing you see a line from info import __all__, and in
random/info.py you'll see that `random_sample` is in the __all__ dict.
Somehow it disappeared for you, you'll need to do some debugging to find
out why.

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


Re: [Numpy-discussion] variables not defined in numpy.random __init.py__ ?

2013-03-25 Thread Bradley M. Froehle
On Mon, Mar 25, 2013 at 12:51 PM, Ralf Gommers ralf.gomm...@gmail.comwrote:

 On Mon, Mar 25, 2013 at 4:23 PM, Dinesh B Vadhia 
 dineshbvad...@hotmail.com wrote:

 **
 Using PyInstaller, the following error occurs:

 Traceback (most recent call last):
   File string, line 9, in module
   File //usr/lib/python2.7/dist-packages/PIL/Image.py, line 355, in init
 __import__(f, globals(), locals(), [])
   File //usr/lib/python2.7/dist-packages/PIL/IptcImagePlugin.py, line
 23, in module
 import os, tempfile
   File /usr/lib/python2.7/tempfile.py, line 34, in module
 from random import Random as _Random
   File //usr/lib/python2.7/dist-packages/numpy/random/__init__.py, line
 90, in module
 ranf = random = sample = random_sample
 NameError: name 'random_sample' is not defined

 Is line 90 in __init.py__ valid?


 It is.


In my reading of this the main problem is that `tempfile` is trying to
import `random` from the Python standard library but instead is importing
the one from within NumPy (i.e., `numpy.random`).  I suspect that somehow
`sys.path` is being set incorrectly --- perhaps because of the `PYTHONPATH`
environment variable.

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


Re: [Numpy-discussion] NumPy/SciPy participation in GSoC 2013

2013-03-25 Thread Ralf Gommers
On Thu, Mar 21, 2013 at 10:20 PM, Ralf Gommers ralf.gomm...@gmail.comwrote:

 Hi all,

 It is the time of the year for Google Summer of Code applications. If we
 want to participate with Numpy and/or Scipy, we need two things: enough
 mentors and ideas for projects. If we get those, we'll apply under the PSF
 umbrella. They've outlined the timeline they're working by and guidelines
 at
 http://pyfound.blogspot.nl/2013/03/get-ready-for-google-summer-of-code.html.


 We should be able to come up with some interesting project ideas I'd
 think, let's put those at
 http://projects.scipy.org/scipy/wiki/SummerofCodeIdeas. Preferably with
 enough detail to be understandable for people new to the projects and a
 proposed mentor.

 We need at least 3 people willing to mentor a student. Ideally we'd have
 enough mentors this week, so we can apply to the PSF on time. If you're
 willing to be a mentor, please send me the following: name, email address,
 phone nr, and what you're interested in mentoring. If you have time
 constaints and have doubts about being able to be a primary mentor, being a
 backup mentor would also be helpful.


So far we've only got one primary mentor (thanks Chuck!), most core devs do
not seem to have the bandwidth this year. If there are other people
interested in mentoring please let me know. If not, then it looks like
we're not participating this year.

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