Re: [Numpy-discussion] "official" binaries on web page.

2013-10-23 Thread jim vickroy

On 10/23/2013 8:51 AM, Chris Barker - NOAA Federal wrote:

  Ralf Gommers  wrote:

but the layout of that page is on
purpose. scipy.org is split into two parts: (a) a SciPy Stack part, and
(b)
a numpy & scipy library part. You're looking at the stack part, and the
preferred method to install that stack is a Python distribution.

OK, I'm not sure that's a great idea, but if we take that as a given:

That page could use some clarification about what the heck the "stack"
is, and what its relationship to the scipy and numpy packages is.

And I still think it wouldn't hurt to more obviously point people to
how to get either numpy or scipy themselves.

So maybe my section about the "official" binaries, but lower on the
page. I don't like "custom" as a title, as that makes it sound like
advanced numpy-fu, not where a newbie looking for just numpy is going
to look.

But it sounds like the real problem is with the surrounding
pages--that's the page you find when you try to figure out how to get
numpy--if that page is about the stack, it should not be linked to
directly from the numpy.org page without explanation.

We do have a branding problem: "scipy" is a package, a "stack" and a
ecosystem/community. It should be clear which one is being referred to
when.

-Chris
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion
Chris, thanks for taking this on!  You very clearly state  all of the 
confusion I have had with Numpy and Scipy distributions and branding.  I 
also agree that relying on a Python distribution to provide Scipy and 
Numpy is not a good idea.  --jv
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Shouldn't all in-place operations simply return self?

2013-01-17 Thread Jim Vickroy

On 1/16/2013 11:41 PM, Nathaniel Smith wrote:


On 16 Jan 2013 17:54, > wrote:

> >>> a = np.random.random_integers(0, 5, size=5)
> >>> b = a.sort()
> >>> b
> >>> a
> array([0, 1, 2, 5, 5])
>
> >>> b = np.random.shuffle(a)
> >>> b
> >>> b = np.random.permutation(a)
> >>> b
> array([0, 5, 5, 2, 1])
>
> How do I remember if shuffle shuffles or permutes ?
>
> Do we have a list of functions that are inplace?

I rather like the convention used elsewhere in Python of naming 
in-place operations with present tense imperative verbs, and 
out-of-place operations with past participles. So you have 
sort/sorted, reverse/reversed, etc.


Here this would suggest we name these two operations as either 
shuffle() and shuffled(), or permute() and permuted().




I like this (tense) suggestion.  It seems easy to remember.  --jv



-n



___
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] 2 greatest values, in a 3-d array, along one axis

2012-08-03 Thread Jim Vickroy
Thanks for each of the improved solutions.  The one using argsort took a 
little while for me to understand.  I have a long way to go to fully 
utilize fancy indexing!  -- jv



On 8/3/2012 10:02 AM, Angus McMorland wrote:
On 3 August 2012 11:18, Jim Vickroy <mailto:jim.vick...@noaa.gov>> wrote:


Hello everyone,

I'm trying to determine the 2 greatest values, in a 3-d array,
along one
axis.

Here is an approach:

# --
# procedure to determine greatest 2 values for 3rd dimension of 3-d
array ...
import numpy, numpy.ma <http://numpy.ma>
xcnt, ycnt, zcnt   = 2,3,4 # actual case is (1024, 1024, 8)
p0 = numpy.empty ((xcnt,ycnt,zcnt))
for z in range (zcnt) : p0[:,:,z] = z*z
zaxis  = 2  
 # max

values to be determined for 3rd axis
p0max  = numpy.max (p0, axis=zaxis)  
# max

values for zaxis
maxindices = numpy.argmax (p0, axis=zaxis)#
indices of max values
p1 = p0.copy()  
 # work

array to scan for 2nd highest values
j, i   = numpy.meshgrid (numpy.arange (ycnt), numpy.arange
(xcnt))
p1[i,j,maxindices] = numpy.NaN  
 # flag

all max values
p1 = numpy.ma.masked_where (numpy.isnan (p1), p1)
# hide
all max values
p1max  = numpy.max (p1, axis=zaxis)  
# 2nd

highest values for zaxis
# additional code to analyze p0max and p1max goes here
# --

I would appreciate feedback on a simpler approach -- e.g., one
that does
not require masked arrays and or use of magic values like NaN.

Thanks,
-- jv


Here's a way that only uses argsort and fancy indexing:

>>>a = np.random.randint(10, size=(3,3,3))
>>>print a

[[[0 3 8]
  [4 2 8]
  [8 6 3]]

 [[0 6 7]
  [0 3 9]
  [0 9 1]]

 [[7 9 7]
  [5 2 9]
  [9 3 3]]]

>>>am = a.argsort(axis=2)
>>>maxs = a[np.arange(a.shape[0])[:,None], 
np.arange(a.shape[1])[None], am[:,:,-1]]

>>>print maxs

[[8 8 8]
 [7 9 9]
 [9 9 9]]

>>>seconds = a[np.arange(a.shape[0])[:,None], 
np.arange(a.shape[1])[None], am[:,:,-2]]

>>>print seconds

[[3 4 6]
 [6 3 1]
 [7 5 3]]

And to double check:

>>>i, j = 0, 1
>>>l = a[i, j,:]
>>>print l

[4 2 8]

>>>print np.max(a[i,j,:]), maxs[i,j]

8 8

>>>print l[np.argsort(l)][-2], second[i,j]

4 4

Good luck.

Angus.
--
AJC McMorland
Post-doctoral research fellow
Neurobiology, University of Pittsburgh


___
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] 2 greatest values, in a 3-d array, along one axis

2012-08-03 Thread Jim Vickroy
Hello everyone,

I'm trying to determine the 2 greatest values, in a 3-d array, along one 
axis.

Here is an approach:

# --
# procedure to determine greatest 2 values for 3rd dimension of 3-d 
array ...
import numpy, numpy.ma
xcnt, ycnt, zcnt   = 2,3,4 # actual case is (1024, 1024, 8)
p0 = numpy.empty ((xcnt,ycnt,zcnt))
for z in range (zcnt) : p0[:,:,z] = z*z
zaxis  = 2# max 
values to be determined for 3rd axis
p0max  = numpy.max (p0, axis=zaxis)   # max 
values for zaxis
maxindices = numpy.argmax (p0, axis=zaxis)# 
indices of max values
p1 = p0.copy()# work 
array to scan for 2nd highest values
j, i   = numpy.meshgrid (numpy.arange (ycnt), numpy.arange 
(xcnt))
p1[i,j,maxindices] = numpy.NaN# flag 
all max values
p1 = numpy.ma.masked_where (numpy.isnan (p1), p1) # hide 
all max values
p1max  = numpy.max (p1, axis=zaxis)   # 2nd 
highest values for zaxis
# additional code to analyze p0max and p1max goes here
# --

I would appreciate feedback on a simpler approach -- e.g., one that does 
not require masked arrays and or use of magic values like NaN.

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


Re: [Numpy-discussion] f2py with allocatable arrays

2012-07-03 Thread Jim Vickroy

On 7/2/2012 7:17 PM, Casey W. Stark wrote:

Hi numpy.

Does anyone know if f2py supports allocatable arrays, allocated inside 
fortran subroutines? The old f2py docs seem to indicate that the 
allocatable array must be created with numpy, and dropped in the 
module. Here's more background to explain...


I have a fortran subroutine that returns allocatable positions and 
velocities arrays. I wish I could get rid of the allocatable part, but 
you don't know how many particles it will create until the subroutine 
does some work (it checks if each particle it perturbs ends up in the 
domain).


module zp
  implicit none
  contains
  subroutine ics(..., num_particles, particle_mass, positions, velocities)
use data_types, only : dp
implicit none
... inputs ...
integer, intent(out) :: num_particles
real (kind=dp), intent(out) :: particle_mass
real (kind=dp), intent(out), dimension(:, :), allocatable :: 
positions, velocities

...
  end subroutine
end module

I tested this with a fortran driver program and it looks good, but 
when I try with f2py, it cannot compile. It throws the error "Error: 
Actual argument for 'positions' must be ALLOCATABLE at (1)". I figure 
this has something to do with the auto-generated "*-f2pywrappers2.f90" 
file, but the build deletes the file.


If anyone knows an f2py friendly way to rework this, I would be happy 
to try. I'm also fine with using ctypes if it can handle this case.


Best,
Casey


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

Hi,

... not sure what version of numpy you are using but it can be done with 
the f2py included with numpy 1.6.x.  Here is a (hopefully intelligible) 
code fragment from a working application:




module Grid_
   ! a representation of a two-dimensional, rectangular, (image) sensor 
grid
   ! -- this component is used in the "smoothing" portion of the 
Thematic MaP solution algorithm (smoothness prior probabilities)


   use runtime_
   implicit none
   integer, private, parameter  :: begin_ = 1, end_ = 
2, row_ = 1, column_ = 2
   integer, private, dimension(begin_:end_) :: rows__ = (/0,0/), 
columns__ = (/0,0/) ! grid rows and columns extent

   integer, allocatable, dimension(:,:) :: pixel_neighbors
  ! the neighbors of a specified pixel -- ((row,column), ..., 
(row,column))
  !+ this array is managed (allocated, deallocated, populated) 
by the neighbors_of() procedure
  !+ when allocated, the first dimension is always 2 -- pixel 
(row,column)
  !+ it would be preferable for this array to be the return 
result, of procedure neighbors_of(),
  !  but F2PY does not seem to support an allocatable array as 
a function result


   contains

  [snip]

  function neighbors_of (pixel) result(completed)
 ! determines all second-order (grid) neighbors of *pixel*
 !-- returns .true. if successful
 !-- use the error_diagnostic() procedure if .false. is 
returned
 !-- upon successful completion of this procedure, 
Grid_.pixel_neighbors contains the neighbors of *pixel*
 !-- *pixel* may not be on the grid; in this case, 
Grid_.pixel_neighbors is not allocated and .false. is returned
 ! integer, dimension(row_:column_), intent(in) :: pixel ! 
pixel to be considered ... f2py does not support this
 integer, dimension(2), intent(in) :: pixel  ! pixel under 
consideration (row,column)

 logical   :: completed
 ! integer, dimension(begin_:end_) :: neighbor_rows, 
neighbor_columns ... f2py does not support this
 ! integer, dimension(row_:column_)   :: neighbor ... f2py does 
not support this
 integer, dimension(2) :: neighbor_rows, 
neighbor_columns ! each is: (begin,end)

 integer, dimension(2) :: neighbor ! (row,column)
 integer   :: row, column, code, count
 character (len=100)   :: diagnostic
 completed = .false.
 count = 0 ! *pixel* has no neighbors
 if (allocated (pixel_neighbors)) deallocate (pixel_neighbors)
 if (is_interior (pixel)) then
count = 8 ! interior pixels have eight, 
second-order neighbors

neighbor_rows(begin_) = pixel(row_)-1
neighbor_rows(end_)   = pixel(row_)+1
neighbor_columns (begin_) = pixel(column_)-1
neighbor_columns (end_)   = pixel(column_)+1
 else if (is_border (pixel)) then
count = 5 ! non-corner, border pixels have five, 
second-order neighbors, but ...
if (is_corner (pixel)) count = 3 ! corner pixels have 
three, second-order neighbors

neighbor_rows(begin_) = max (pixel(row_)-1, rows__(begin_))
neighbor_rows(end_)   = min (p

Re: [Numpy-discussion] Meta: help, devel and stackoverflow

2012-06-29 Thread Jim Vickroy
As a lurker and user, I too wish for a distinct numpy-users list.  -- jv

On 6/28/2012 1:42 PM, Matthew Brett wrote:
> Hi,
>
> On Thu, Jun 28, 2012 at 7:42 AM, Olivier Delalleau  wrote:
>> +1 for a numpy-users list without "dev noise".
> Moderately strong vote against splitting the mailing lists into devel and 
> user.
>
> As we know, this list can be unhappy and distracting, but I don't
> think splitting the lists is the right approach to that problem.
>
> Splitting the lists sends the wrong signal.  I'd rather that we show
> by example that the developers listen to all voices, and that the
> users should expect to become developers. In other words that the
> boundary between the user and developer is fluid and has no explicit
> boundaries.
>
> As data points, I make no distinction between scipy-devel and
> scipy-user, nor cython-devel and cython-user.  Policing the
> distinction ('please post this on the user mailing list') is a boring
> job and doesn't make anyone more cheerful.
>
> I don't believe help questions are getting lost any more than devel
> questions are, but I'm happy to be corrected if someone has some data.
>
> Cheers,
>
> Matthew
> ___
> 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] Enum type

2012-01-03 Thread Jim Vickroy
On 1/3/2012 10:46 AM, Ognen Duzlevski wrote:
> Hello,
>
> I am playing with adding an enum dtype to numpy (to get my feet wet in
> numpy really). I have looked at the
> https://github.com/martinling/numpy_quaternion and I feel comfortable
> with my understanding of adding a simple type to numpy in technical
> terms.
>
> I am mostly a C programmer and have programmed in Python but not at
> the level where my code wcould be considered "pretty" or maybe even
> "pythonic". I know enums from C and have browsed around a few python
> enum implementations online. Most of them use hash tables or lists to
> associate names to numbers - these approaches just feel "heavy" to me.
>
> What would be a proper "numpy approach" to this? I am looking mostly
> for direction and advice as I would like to do the work myself :-)
>
> Any input appreciated :-)
> Ognen

Does "enumerate" 
(http://docs.python.org/library/functions.html#enumerate) work for you?

> ___
> 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] Moving to gcc 4.* for win32 installers ?

2011-10-27 Thread Jim Vickroy
On 10/27/2011 7:02 AM, David Cournapeau wrote:
> Hi,
>
> I was wondering if we could finally move to a more recent version of
> compilers for official win32 installers. This would of course concern
> the next release cycle, not the ones where beta/rc are already in
> progress.
>
> Basically, the pros:
>- we will have to move at some point
>- gcc 4.* seem less buggy, especially C++ and fortran.
>- no need to maintain msvcr90 vodoo
> The cons:
>- it will most likely break the ABI
>- we need to recompile atlas (but I can take care of it)
>- the biggest: it is difficult to combine gfortran with visual
> studio (more exactly you cannot link gfortran runtime to a visual
> studio executable). The only solution I could think of would be to
> recompile the gfortran runtime with Visual Studio, which for some
> reason does not sound very appealing :)
>
> Thoughts ?
>
> cheers,
>
> David
> ___
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion

Hi David,

What is the "msvcr90 vodoo" you are referring to?

Thanks for your great efforts on this project.

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


Re: [Numpy-discussion] f2py : NotImplementedError: Only MS compiler supported with gfortran on win64

2011-09-12 Thread Jim Vickroy

On 9/12/2011 11:17 AM, Jonathan T. Niehof wrote:

Is anyone successfully using f2py and gfortran on a Windows machine
without relying on cygwin?

SpacePy uses mingw32 for both gcc and gfortran; I didn't have any trouble
with f2py. I haven't tried a build with 64-bit Python or with EPD; I just
build the installer against python.org's python and a bog-standard mingw32
and numpy install. Feel free to take a look at our setup.py
(http://spacepy.lanl.gov/). It runs f2py with:
--fcompiler=gnu95 --compiler=mingw32

(Note that gfortran normally refers to the new f90/95 chain, called gnu95
by f2py, and g77 is the old, f2c-derived chain, called gnu by f2py.)

Thanks for this information; that site certainly looks interesting.  I 
will look at it more carefully as I'm developing software at the NOAA 
Space Weather Prediction Center .


Christoph Gohlke determined that if I upgraded from numpy 1.3 to 1.4, 
f2py would successfully find and use the Intel Fortran compiler which 
was my preferred choice all along.



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


Re: [Numpy-discussion] f2py : NotImplementedError: Only MS compiler supported with gfortran on win64

2011-09-09 Thread Jim Vickroy
On 9/9/2011 1:59 PM, Christoph Gohlke wrote:
>
> On 9/9/2011 12:22 PM, Jim Vickroy wrote:
>> On 9/9/2011 1:14 PM, Christoph Gohlke wrote:
>>> On 9/9/2011 11:43 AM, Jim Vickroy wrote:
>>>> On 9/9/2011 11:46 AM, Christoph Gohlke wrote:
>>>>> On 9/9/2011 7:22 AM, Jim Vickroy wrote:
>>>>>> On 9/8/2011 10:44 AM, "V. Armando Solé" wrote:
>>>>>>> On 08/09/2011 16:16, Jim Vickroy wrote:
>>>>>>>> On 9/8/2011 6:09 AM, "V. Armando Solé" wrote:
>>>>>>>>> Have you tried to install Visual Studio 2008 Express edition (plus the
>>>>>>>>> windows SDK to be able to compile 64 bit code)?
>>>>>>>>>
>>>>>>>>> Armando
>>>>>>>> Armando, "Visual Studio 2008 Professional" is installed on the computer
>>>>>>>> as well as "Intel Visual Fortran Composer XE 2011".
>>>>>>>>
>>>>>>>> f2py was not finding the Intel compiler (f2py -c --help-fcompiler) so I
>>>>>>>> tried gfortran.
>>>>>>>>
>>>>>>>> The "Win64" reference, in the Exception, is puzzling to me since this 
>>>>>>>> is
>>>>>>>> a 32-bit computer.
>>>>>>>>
>>>>>>> Oh! I totally misunderstood the situation. I thought the problem was the
>>>>>>> missing compiler.
>>>>>>>
>>>>>>> All what I do with python and the intel fortran compiler is to compile
>>>>>>> numpy. Just in case it helps you, I set my environment from the console
>>>>>>> by running a bat file with the following content (I am on 64 bit but you
>>>>>>> could easily tailor it to your needs):
>>>>>>>
>>>>>>> "C:\Program Files\Microsoft SDKs\Windows\v7.0\Setup\WindowsSdkVer.exe"
>>>>>>> -version:v7.0
>>>>>>> call "C:\Program Files (x86)\Microsoft Visual Studio
>>>>>>> 9.0\VC\bin\vcvars64.bat"
>>>>>>> call "C:\Program Files
>>>>>>> (x86)\Intel\ComposerXE-2011\bin\ipsxe-comp-vars.bat" intel64 vs2008shell
>>>>>>> rem call "C:\Program Files (x86)\Microsoft Visual Studio
>>>>>>> 9.0\VC\bin\vcvars64"
>>>>>>> rem call "C:\Program Files\Microsoft SDKs\Windows\v7.0\Bin\setenv.cmd"
>>>>>>> /x64 /Release
>>>>>>> set PATH=C:\Python27;C:\Python27\Scripts;%PATH%
>>>>>>> set PATH="C:\Program Files
>>>>>>> (x86)\Intel\ComposerXE-2011\redist\intel64\mkl";"C:\Program Files
>>>>>>> (x86)\Intel\ComposerXE-2011\mkl\lib\intel64";%PATH%
>>>>>>>
>>>>>>> Perhaps that helps you to set a working environment. All what I can tell
>>>>>>> you is that with that environment, if I run "python f2py.py -c
>>>>>>> --help-fcompiler" it finds the intel compiler.
>>>>>>>
>>>>>>> Good luck,
>>>>>>>
>>>>>>> Armando
>>>>>> Thanks for the suggestion.  So far I have not been able to modify the
>>>>>> above for use on my 32-bit machine such that ifort is found by f2py.
>>>>>>
>>>>>>From the f2py documentation, I assumed this was going to be rather
>>>>>> straightforward, but it is not.
>>>>>>
>>>>>>
>>>>> There should be a file named "ifortvars.bat" in the Intel Compiler bin
>>>>> directory. Call it with the right arguments before using f2py. On my
>>>>> system it is:
>>>>>
>>>>> "C:\Program Files (x86)\Intel\Compiler\11.1\070\bin\ifortvars.bat"
>>>>> intel64 vs2008
>>>>>
>>>>> Christoph
>>>> Thanks Christoph.
>>>>
>>>> Unfortunately, this does not seem to enable f2py to find ifort.
>>>>
>>>> Here is the result of running ifortvars.bat immediately followed by f2py:
>>>>
>>>>
>>>>  >"C:\Program Files\Intel\ComposerXE-2011\bin\ifortvars.bat" ia32
>>>> Intel(R) Parallel Studio XE 2011 Update 1
>>>> Copyright (C) 1985-2011 Intel Corporation. All rights reserved.
>

Re: [Numpy-discussion] f2py : NotImplementedError: Only MS compiler supported with gfortran on win64

2011-09-09 Thread Jim Vickroy
On 9/9/2011 1:14 PM, Christoph Gohlke wrote:
>
> On 9/9/2011 11:43 AM, Jim Vickroy wrote:
>> On 9/9/2011 11:46 AM, Christoph Gohlke wrote:
>>> On 9/9/2011 7:22 AM, Jim Vickroy wrote:
>>>> On 9/8/2011 10:44 AM, "V. Armando Solé" wrote:
>>>>> On 08/09/2011 16:16, Jim Vickroy wrote:
>>>>>> On 9/8/2011 6:09 AM, "V. Armando Solé" wrote:
>>>>>>> Have you tried to install Visual Studio 2008 Express edition (plus the
>>>>>>> windows SDK to be able to compile 64 bit code)?
>>>>>>>
>>>>>>> Armando
>>>>>> Armando, "Visual Studio 2008 Professional" is installed on the computer
>>>>>> as well as "Intel Visual Fortran Composer XE 2011".
>>>>>>
>>>>>> f2py was not finding the Intel compiler (f2py -c --help-fcompiler) so I
>>>>>> tried gfortran.
>>>>>>
>>>>>> The "Win64" reference, in the Exception, is puzzling to me since this is
>>>>>> a 32-bit computer.
>>>>>>
>>>>> Oh! I totally misunderstood the situation. I thought the problem was the
>>>>> missing compiler.
>>>>>
>>>>> All what I do with python and the intel fortran compiler is to compile
>>>>> numpy. Just in case it helps you, I set my environment from the console
>>>>> by running a bat file with the following content (I am on 64 bit but you
>>>>> could easily tailor it to your needs):
>>>>>
>>>>> "C:\Program Files\Microsoft SDKs\Windows\v7.0\Setup\WindowsSdkVer.exe"
>>>>> -version:v7.0
>>>>> call "C:\Program Files (x86)\Microsoft Visual Studio
>>>>> 9.0\VC\bin\vcvars64.bat"
>>>>> call "C:\Program Files
>>>>> (x86)\Intel\ComposerXE-2011\bin\ipsxe-comp-vars.bat" intel64 vs2008shell
>>>>> rem call "C:\Program Files (x86)\Microsoft Visual Studio
>>>>> 9.0\VC\bin\vcvars64"
>>>>> rem call "C:\Program Files\Microsoft SDKs\Windows\v7.0\Bin\setenv.cmd"
>>>>> /x64 /Release
>>>>> set PATH=C:\Python27;C:\Python27\Scripts;%PATH%
>>>>> set PATH="C:\Program Files
>>>>> (x86)\Intel\ComposerXE-2011\redist\intel64\mkl";"C:\Program Files
>>>>> (x86)\Intel\ComposerXE-2011\mkl\lib\intel64";%PATH%
>>>>>
>>>>> Perhaps that helps you to set a working environment. All what I can tell
>>>>> you is that with that environment, if I run "python f2py.py -c
>>>>> --help-fcompiler" it finds the intel compiler.
>>>>>
>>>>> Good luck,
>>>>>
>>>>> Armando
>>>> Thanks for the suggestion.  So far I have not been able to modify the
>>>> above for use on my 32-bit machine such that ifort is found by f2py.
>>>>
>>>>  From the f2py documentation, I assumed this was going to be rather
>>>> straightforward, but it is not.
>>>>
>>>>
>>> There should be a file named "ifortvars.bat" in the Intel Compiler bin
>>> directory. Call it with the right arguments before using f2py. On my
>>> system it is:
>>>
>>> "C:\Program Files (x86)\Intel\Compiler\11.1\070\bin\ifortvars.bat"
>>> intel64 vs2008
>>>
>>> Christoph
>> Thanks Christoph.
>>
>> Unfortunately, this does not seem to enable f2py to find ifort.
>>
>> Here is the result of running ifortvars.bat immediately followed by f2py:
>>
>>
>>>"C:\Program Files\Intel\ComposerXE-2011\bin\ifortvars.bat" ia32
>> Intel(R) Parallel Studio XE 2011 Update 1
>> Copyright (C) 1985-2011 Intel Corporation. All rights reserved.
>> Intel(R) Composer XE 2011 Update 3 (package 175)
>> Setting environment for using Microsoft Visual Studio 2008 x86 tools.
>>
>>
>>>f2py.py -c --help-fcompiler
>> Gnu95FCompiler instance properties:
>>  archiver= ['C:\\Program Files\\gfortran\\bin\\gfortran.exe', '-
>>cr']
>>  compile_switch  = '-c'
>>  compiler_f77= ['C:\\Program Files\\gfortran\\bin\\gfortran.exe', '-
>>Wall', '-ffixed-form', '-fno-second-underscore', 
>> '-mno-
>>cygwin', '-O3', '-funr

Re: [Numpy-discussion] f2py : NotImplementedError: Only MS compiler supported with gfortran on win64

2011-09-09 Thread Jim Vickroy
On 9/9/2011 11:46 AM, Christoph Gohlke wrote:
>
> On 9/9/2011 7:22 AM, Jim Vickroy wrote:
>> On 9/8/2011 10:44 AM, "V. Armando Solé" wrote:
>>> On 08/09/2011 16:16, Jim Vickroy wrote:
>>>> On 9/8/2011 6:09 AM, "V. Armando Solé" wrote:
>>>>> Have you tried to install Visual Studio 2008 Express edition (plus the
>>>>> windows SDK to be able to compile 64 bit code)?
>>>>>
>>>>> Armando
>>>> Armando, "Visual Studio 2008 Professional" is installed on the computer
>>>> as well as "Intel Visual Fortran Composer XE 2011".
>>>>
>>>> f2py was not finding the Intel compiler (f2py -c --help-fcompiler) so I
>>>> tried gfortran.
>>>>
>>>> The "Win64" reference, in the Exception, is puzzling to me since this is
>>>> a 32-bit computer.
>>>>
>>> Oh! I totally misunderstood the situation. I thought the problem was the
>>> missing compiler.
>>>
>>> All what I do with python and the intel fortran compiler is to compile
>>> numpy. Just in case it helps you, I set my environment from the console
>>> by running a bat file with the following content (I am on 64 bit but you
>>> could easily tailor it to your needs):
>>>
>>> "C:\Program Files\Microsoft SDKs\Windows\v7.0\Setup\WindowsSdkVer.exe"
>>> -version:v7.0
>>> call "C:\Program Files (x86)\Microsoft Visual Studio
>>> 9.0\VC\bin\vcvars64.bat"
>>> call "C:\Program Files
>>> (x86)\Intel\ComposerXE-2011\bin\ipsxe-comp-vars.bat" intel64 vs2008shell
>>> rem call "C:\Program Files (x86)\Microsoft Visual Studio
>>> 9.0\VC\bin\vcvars64"
>>> rem call "C:\Program Files\Microsoft SDKs\Windows\v7.0\Bin\setenv.cmd"
>>> /x64 /Release
>>> set PATH=C:\Python27;C:\Python27\Scripts;%PATH%
>>> set PATH="C:\Program Files
>>> (x86)\Intel\ComposerXE-2011\redist\intel64\mkl";"C:\Program Files
>>> (x86)\Intel\ComposerXE-2011\mkl\lib\intel64";%PATH%
>>>
>>> Perhaps that helps you to set a working environment. All what I can tell
>>> you is that with that environment, if I run "python f2py.py -c
>>> --help-fcompiler" it finds the intel compiler.
>>>
>>> Good luck,
>>>
>>> Armando
>> Thanks for the suggestion.  So far I have not been able to modify the
>> above for use on my 32-bit machine such that ifort is found by f2py.
>>
>>From the f2py documentation, I assumed this was going to be rather
>> straightforward, but it is not.
>>
>>
> There should be a file named "ifortvars.bat" in the Intel Compiler bin
> directory. Call it with the right arguments before using f2py. On my
> system it is:
>
> "C:\Program Files (x86)\Intel\Compiler\11.1\070\bin\ifortvars.bat"
> intel64 vs2008
>
> Christoph

Thanks Christoph.

Unfortunately, this does not seem to enable f2py to find ifort.

Here is the result of running ifortvars.bat immediately followed by f2py:


 >"C:\Program Files\Intel\ComposerXE-2011\bin\ifortvars.bat" ia32
Intel(R) Parallel Studio XE 2011 Update 1
Copyright (C) 1985-2011 Intel Corporation. All rights reserved.
Intel(R) Composer XE 2011 Update 3 (package 175)
Setting environment for using Microsoft Visual Studio 2008 x86 tools.


 >f2py.py -c --help-fcompiler
Gnu95FCompiler instance properties:
   archiver= ['C:\\Program Files\\gfortran\\bin\\gfortran.exe', '-
 cr']
   compile_switch  = '-c'
   compiler_f77= ['C:\\Program Files\\gfortran\\bin\\gfortran.exe', '-
 Wall', '-ffixed-form', '-fno-second-underscore', '-mno-
 cygwin', '-O3', '-funroll-loops']
   compiler_f90= ['C:\\Program Files\\gfortran\\bin\\gfortran.exe', '-
 Wall', '-fno-second-underscore', '-mno-cygwin', 
'-O3', '-
 funroll-loops']
   compiler_fix= ['C:\\Program Files\\gfortran\\bin\\gfortran.exe', '-
 Wall', '-ffixed-form', '-fno-second-underscore', '-mno-
 cygwin', '-Wall', '-fno-second-underscore', 
'-mno-cygwin',
 '-O3', '-funroll-loops']
   libraries   = ['gfortran']
   library_dirs= ["gfortran.exe: error: unrecognized command line option
 '-mno-cygwin&#x

Re: [Numpy-discussion] f2py : NotImplementedError: Only MS compiler supported with gfortran on win64

2011-09-09 Thread Jim Vickroy




On 9/8/2011 5:56 AM, Jim Vickroy wrote:
> Hello All, I'm attempting to create a python wrapper, for a Fortran
> subroutine, using f2py.
>
> My system details are:
>
>   >>>  sys.version '2.6.4 (r264:75708, Oct 26 2009, 08:23:19) [MSC v.1500
> 32 bit (Intel)]'
>   >>>  sys.getwindowsversion() (5, 1, 2600, 2, 'Service Pack 3')
>   >>>  scipy.__version__ '0.7.1'
>   >>>  numpy.__version__ '1.4.0'
> C:\>gfortran -dumpversion
> 4.7.0
>
>
> C:\Python26\Lib\site-packages\numpy\f2py>f2py.py -c --help-fcompiler
> Traceback (most recent call last):
> File "C:\Python26\Scripts\f2py.py", line 24, in
>   main()
> File "C:\Python26\lib\site-packages\numpy\f2py\f2py2e.py", line 557,
> in main
>   run_compile()
> File "C:\Python26\lib\site-packages\numpy\f2py\f2py2e.py", line 543,
> in run_compile
>   setup(ext_modules = [ext])
> File "C:\Python26\lib\site-packages\numpy\distutils\core.py", line
> 186, in setup
>   return old_setup(**new_attr)
> File "C:\Python26\lib\distutils\core.py", line 138, in setup
>   ok = dist.parse_command_line()
> File "C:\Python26\lib\distutils\dist.py", line 460, in parse_command_line
>   args = self._parse_command_opts(parser, args)
> File "C:\Python26\lib\distutils\dist.py", line 574, in
> _parse_command_opts
>   func()
> File
> "C:\Python26\lib\site-packages\numpy\distutils\command\config_compiler.py",
> line 13, in show_fortran_compilers
>   show_fcompilers(dist)
> File
> "C:\Python26\lib\site-packages\numpy\distutils\fcompiler\__init__.py",
> line 855, in show_fcompilers
>   c.customize(dist)
> File
> "C:\Python26\lib\site-packages\numpy\distutils\fcompiler\__init__.py",
> line 525, in customize
>   self.set_libraries(self.get_libraries())
> File
> "C:\Python26\lib\site-packages\numpy\distutils\fcompiler\gnu.py", line
> 306, in get_libraries
>   raise NotImplementedError("Only MS compiler supported with gfortran
> on win64")
> NotImplementedError: Only MS compiler supported with gfortran on win64
>
>
> Could someone help me to resolve this?
>
> Thanks, -- jv

I eliminated the above NotImplementedError by replacing this raise 
exception line with a pass statement.  Now, gfortran is being found and 
used by f2py but subsequently fails as follows:

gfortran.exe: error: unrecognized command line option '-mno-cygwin'


Why is f2py invoking gfortran with a cygwin option on a Windows XP 
machine?  I supposedly installed the stand-alone version of gfortran and 
my take on the f2py documentation was that cygwin was not required.  
Note, gfortran can be used from a Windows commandline to successfully 
compile the code.

Is anyone successfully using f2py and gfortran on a Windows machine 
without relying on cygwin?

I'm not committed to gfortran; I also have the Intel Visual Fortran 
compiler (ifort) installed, but so far, I have been unable to get f2py 
to acknowledge that it exists.








> ___
> 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] f2py : NotImplementedError: Only MS compiler supported with gfortran on win64

2011-09-09 Thread Jim Vickroy
On 9/8/2011 10:44 AM, "V. Armando Solé" wrote:
> On 08/09/2011 16:16, Jim Vickroy wrote:
>> On 9/8/2011 6:09 AM, "V. Armando Solé" wrote:
>>> Have you tried to install Visual Studio 2008 Express edition (plus the
>>> windows SDK to be able to compile 64 bit code)?
>>>
>>> Armando
>> Armando, "Visual Studio 2008 Professional" is installed on the computer
>> as well as "Intel Visual Fortran Composer XE 2011".
>>
>> f2py was not finding the Intel compiler (f2py -c --help-fcompiler) so I
>> tried gfortran.
>>
>> The "Win64" reference, in the Exception, is puzzling to me since this is
>> a 32-bit computer.
>>
> Oh! I totally misunderstood the situation. I thought the problem was the
> missing compiler.
>
> All what I do with python and the intel fortran compiler is to compile
> numpy. Just in case it helps you, I set my environment from the console
> by running a bat file with the following content (I am on 64 bit but you
> could easily tailor it to your needs):
>
> "C:\Program Files\Microsoft SDKs\Windows\v7.0\Setup\WindowsSdkVer.exe"
> -version:v7.0
> call "C:\Program Files (x86)\Microsoft Visual Studio
> 9.0\VC\bin\vcvars64.bat"
> call "C:\Program Files
> (x86)\Intel\ComposerXE-2011\bin\ipsxe-comp-vars.bat" intel64 vs2008shell
> rem call "C:\Program Files (x86)\Microsoft Visual Studio
> 9.0\VC\bin\vcvars64"
> rem call "C:\Program Files\Microsoft SDKs\Windows\v7.0\Bin\setenv.cmd"
> /x64 /Release
> set PATH=C:\Python27;C:\Python27\Scripts;%PATH%
> set PATH="C:\Program Files
> (x86)\Intel\ComposerXE-2011\redist\intel64\mkl";"C:\Program Files
> (x86)\Intel\ComposerXE-2011\mkl\lib\intel64";%PATH%
>
> Perhaps that helps you to set a working environment. All what I can tell
> you is that with that environment, if I run "python f2py.py -c
> --help-fcompiler" it finds the intel compiler.
>
> Good luck,
>
> Armando

Thanks for the suggestion.  So far I have not been able to modify the 
above for use on my 32-bit machine such that ifort is found by f2py.

 From the f2py documentation, I assumed this was going to be rather 
straightforward, but it is not.




>
>
> ___
> 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] f2py : NotImplementedError: Only MS compiler supported with gfortran on win64

2011-09-08 Thread Jim Vickroy
On 9/8/2011 6:09 AM, "V. Armando Solé" wrote:
> Have you tried to install Visual Studio 2008 Express edition (plus the
> windows SDK to be able to compile 64 bit code)?
>
> Armando

Armando, "Visual Studio 2008 Professional" is installed on the computer 
as well as "Intel Visual Fortran Composer XE 2011".

f2py was not finding the Intel compiler (f2py -c --help-fcompiler) so I 
tried gfortran.

The "Win64" reference, in the Exception, is puzzling to me since this is 
a 32-bit computer.

>
> On 08/09/2011 13:56, Jim Vickroy wrote:
>> Hello All, I'm attempting to create a python wrapper, for a Fortran
>> subroutine, using f2py.
>>
>> My system details are:
>>
>>>>>   sys.version '2.6.4 (r264:75708, Oct 26 2009, 08:23:19) [MSC v.1500
>> 32 bit (Intel)]'
>>>>>   sys.getwindowsversion() (5, 1, 2600, 2, 'Service Pack 3')
>>>>>   scipy.__version__ '0.7.1'
>>>>>   numpy.__version__ '1.4.0'
>> C:\>gfortran -dumpversion
>> 4.7.0
>>
>>
>> C:\Python26\Lib\site-packages\numpy\f2py>f2py.py -c --help-fcompiler
>> Traceback (most recent call last):
>>  File "C:\Python26\Scripts\f2py.py", line 24, in
>>main()
>>  File "C:\Python26\lib\site-packages\numpy\f2py\f2py2e.py", line 557,
>> in main
>>run_compile()
>>  File "C:\Python26\lib\site-packages\numpy\f2py\f2py2e.py", line 543,
>> in run_compile
>>setup(ext_modules = [ext])
>>  File "C:\Python26\lib\site-packages\numpy\distutils\core.py", line
>> 186, in setup
>>return old_setup(**new_attr)
>>  File "C:\Python26\lib\distutils\core.py", line 138, in setup
>>ok = dist.parse_command_line()
>>  File "C:\Python26\lib\distutils\dist.py", line 460, in 
>> parse_command_line
>>args = self._parse_command_opts(parser, args)
>>  File "C:\Python26\lib\distutils\dist.py", line 574, in
>> _parse_command_opts
>>func()
>>  File
>> "C:\Python26\lib\site-packages\numpy\distutils\command\config_compiler.py",
>> line 13, in show_fortran_compilers
>>show_fcompilers(dist)
>>  File
>> "C:\Python26\lib\site-packages\numpy\distutils\fcompiler\__init__.py",
>> line 855, in show_fcompilers
>>c.customize(dist)
>>  File
>> "C:\Python26\lib\site-packages\numpy\distutils\fcompiler\__init__.py",
>> line 525, in customize
>>self.set_libraries(self.get_libraries())
>>  File
>> "C:\Python26\lib\site-packages\numpy\distutils\fcompiler\gnu.py", line
>> 306, in get_libraries
>>raise NotImplementedError("Only MS compiler supported with gfortran
>> on win64")
>> NotImplementedError: Only MS compiler supported with gfortran on win64
>>
>>
>> Could someone help me to resolve this?
>>
>> Thanks, -- jv
>> ___
>> 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] f2py : NotImplementedError: Only MS compiler supported with gfortran on win64

2011-09-08 Thread Jim Vickroy
Hello All, I'm attempting to create a python wrapper, for a Fortran 
subroutine, using f2py.

My system details are:

 >>> sys.version '2.6.4 (r264:75708, Oct 26 2009, 08:23:19) [MSC v.1500 
32 bit (Intel)]'
 >>> sys.getwindowsversion() (5, 1, 2600, 2, 'Service Pack 3')
 >>> scipy.__version__ '0.7.1'
 >>> numpy.__version__ '1.4.0'
C:\>gfortran -dumpversion
4.7.0


C:\Python26\Lib\site-packages\numpy\f2py>f2py.py -c --help-fcompiler
Traceback (most recent call last):
   File "C:\Python26\Scripts\f2py.py", line 24, in 
 main()
   File "C:\Python26\lib\site-packages\numpy\f2py\f2py2e.py", line 557, 
in main
 run_compile()
   File "C:\Python26\lib\site-packages\numpy\f2py\f2py2e.py", line 543, 
in run_compile
 setup(ext_modules = [ext])
   File "C:\Python26\lib\site-packages\numpy\distutils\core.py", line 
186, in setup
 return old_setup(**new_attr)
   File "C:\Python26\lib\distutils\core.py", line 138, in setup
 ok = dist.parse_command_line()
   File "C:\Python26\lib\distutils\dist.py", line 460, in parse_command_line
 args = self._parse_command_opts(parser, args)
   File "C:\Python26\lib\distutils\dist.py", line 574, in 
_parse_command_opts
 func()
   File 
"C:\Python26\lib\site-packages\numpy\distutils\command\config_compiler.py", 
line 13, in show_fortran_compilers
 show_fcompilers(dist)
   File 
"C:\Python26\lib\site-packages\numpy\distutils\fcompiler\__init__.py", 
line 855, in show_fcompilers
 c.customize(dist)
   File 
"C:\Python26\lib\site-packages\numpy\distutils\fcompiler\__init__.py", 
line 525, in customize
 self.set_libraries(self.get_libraries())
   File 
"C:\Python26\lib\site-packages\numpy\distutils\fcompiler\gnu.py", line 
306, in get_libraries
 raise NotImplementedError("Only MS compiler supported with gfortran 
on win64")
NotImplementedError: Only MS compiler supported with gfortran on win64


Could someone help me to resolve this?

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


Re: [Numpy-discussion] replace voids in 2d dat with nearest neighbour value

2009-04-06 Thread Jim Vickroy

Zachary Pincus wrote:

Hi Christian,

Check out this discussion from a little while ago on a very similar  
issue (but in 3d):

http://www.nabble.com/Help-with-interpolating-missing-values-from-a-3D-scanner-td21489413.html

Most of the suggestions should be directly applicable.

Zach
  

Hi Christian,

I'm in the early stages of testing the scipy.interpolate.Rbf(...) 
 
function (one of the approaches Robert Kern suggested in the discussion 
Zach mentioned) for a not too dissimilar application -- replacing the 
bad pixels regions in Solar X-ray images captured by a damaged 
detector.  Preliminary results look promising for this application.


-- jv


On Apr 6, 2009, at 9:01 AM, Christian K. wrote:

  

Hi,

I am looking for an elegant and fast way to fill the voids of a 2d  
array with
neighbouring values. The array's size can be up to (1000, 1000) and  
its values
are slowly varying around a mean value. What I call voids are values  
which are
far from the mean value (+- 80%). A void usually extends over some  
adjacent

coordinates.

Currently I am using

tmp = N.ma.array(tmp, tmpwhich moves the voids closer to the mean value but which is still  
far from

beeing a smooth interpolation.

Regards, Christian


___
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


Re: [Numpy-discussion] [Announce] Numpy 1.3.0b1

2009-03-19 Thread Jim Vickroy
Apologies for the spam, but I would suggest that the subject be changed 
to reflect the topic (i.e., Mac OS X problem with this release).


Thanks,
-- jv

Robert Pyle wrote:

On Mar 19, 2009, at 1:24 PM, Charles R Harris wrote:

  
Yep, that's it. Can you see what info.tiny/eps is in this case. Also  
info.tiny and eps separately.


Chuck



eps =  1.3817869701e-76
info.tiny =  -1.08420217274e-19
info.tiny/eps =  -7.84637716375e+56

Bob


___
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] puzzle: generate index with many ranges

2009-01-30 Thread Jim Vickroy

Raik Gruenberg wrote:

Jim Vickroy wrote:
  

Raik Gruenberg wrote:


Hi there,

perhaps someone has a bright idea for this one:

I want to concatenate ranges of numbers into a single array (for indexing). So I
have generated an array "a" with starting positions, for example:

a = [4, 0, 11]

I have an array b with stop positions:

b = [11, 4, 15]

and I would like to generate an index array that takes 4..11, then 0..4, then
11..15.
  
  
Does this help? 

Python 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit 
(Intel)] on win32

Type "help", "copyright", "credits" or "license" for more information.
 >>> a = [4, 0, 11]
 >>> b = [11, 4, 15]
 >>> zip(a,b)
[(4, 11), (0, 4), (11, 15)]
 >>>



Mhm, I got this far. But how do I get from here to a single index array

[ 4, 5, 6, ... 10, 0, 1, 2, 3, 11, 12, 13, 14 ] ?

  

not sure I understand your goal ... is this what you want:
>>> [range(i,j) for i,j in zip(a,b)]
[[4, 5, 6, 7, 8, 9, 10], [0, 1, 2, 3], [11, 12, 13, 14]]
>>>

Greetings
Raik

  




  

Apologies if I'm stating the obvious.

-- jv


In reality, a and b have 1+ elements and the arrays to be "sliced" are very
large so I want to avoid any for loops etc. Any idea how this could be done? I
thought some combination of *repeat* and adding of *arange* should do the trick
but just cannot nail it down.

Thanks in advance for any hints!

Greetings,
Raik


___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion
  
  

___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion





  


___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] puzzle: generate index with many ranges

2009-01-30 Thread Jim Vickroy
Raik Gruenberg wrote:
> Hi there,
>
> perhaps someone has a bright idea for this one:
>
> I want to concatenate ranges of numbers into a single array (for indexing). 
> So I
> have generated an array "a" with starting positions, for example:
>
> a = [4, 0, 11]
>
> I have an array b with stop positions:
>
> b = [11, 4, 15]
>
> and I would like to generate an index array that takes 4..11, then 0..4, then
> 11..15.
>   
Does this help? 

Python 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit 
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
 >>> a = [4, 0, 11]
 >>> b = [11, 4, 15]
 >>> zip(a,b)
[(4, 11), (0, 4), (11, 15)]
 >>>

Apologies if I'm stating the obvious.

-- jv
> In reality, a and b have 1+ elements and the arrays to be "sliced" are 
> very
> large so I want to avoid any for loops etc. Any idea how this could be done? I
> thought some combination of *repeat* and adding of *arange* should do the 
> trick
> but just cannot nail it down.
>
> Thanks in advance for any hints!
>
> Greetings,
> Raik
>
>
> ___
> Numpy-discussion mailing list
> Numpy-discussion@scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion
>   

___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Alternative to record array

2008-12-29 Thread Jim Vickroy

Jean-Baptiste Rudant wrote:

Hello,

I like to use record arrays to access fields by their name, and 
because they are esay to use with pytables. But I think it's not very 
effiicient for what I have to do. Maybe I'm misunderstanding something.


Example : 


import numpy as np
age = np.random.randint(0, 99, 10e6)
weight = np.random.randint(0, 200, 10e6)
data = np.rec.fromarrays((age, weight), names='age, weight')
# the kind of operations I do is :
data.age += data.age + 1
# but it's far less efficient than doing :
age += 1
# because I think the record array stores [(age_0, weight_0) 
...(age_n, weight_n)]

# and not [age0 ... age_n] then [weight_0 ... weight_n].
Sorry I am not able to answer your question; I am really a new user of 
numpy also.


It does seem the addition operation is more than 4 times slower, when 
using record arrays, based on the following:


>>> import numpy, sys, timeit
>>> sys.version
'2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)]'
>>> numpy.__version__
'1.2.1'
>>> count = 10e6
>>> ages  = numpy.random.randint(0,100,count)
>>> weights = numpy.random.randint(1,200,count)
>>> data = numpy.rec.fromarrays((ages,weights),names='ages,weights')
>>>
>>> timer = timeit.Timer('data.ages += 1','from __main__ import data')
>>> timer.timeit(number=100)
30.110649537860262
>>>
>>> timer = timeit.Timer('ages += 1','from __main__ import ages')
>>> timer.timeit(number=100)
6.9850710076280507
>>>


So I think I don't use record arrays for the right purpose. I only 
need something which would make me esasy to manipulate data by 
accessing fields by their name.


Am I wrong ? Is their something in numpy for my purpose ? Do I have to 
implement my own class, with something like :



class FieldArray:
def __init__(self, array_dict):
self.array_list = array_dict

def __getitem__(self, field):

return self.array_list[field]

def __setitem__(self, field, value):

self.array_list[field] = value

my_arrays = {'age': age, 'weight' : weight}

data = FieldArray(my_arrays)

data['age'] += 1

Thank you for the help,

Jean-Baptiste Rudant







___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion
  


___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Is it possible with numpy?

2008-12-24 Thread Jim Vickroy

olfa mraihi wrote:

Hello Numpy community,
I want to know if Numpy could deal with symbolic arrays and lists (by
symbolic I mean without specifying the concrete contents of list or
array)
For example I want to solve a system of equations containing lists and
arrays like this
solve(x+Sum[A[k],k=i..N]==y+Sum[B[k],k=m..N],
j-Length[C]==l-Length[D],
 z/(c ^ i)==t/(c ^ h),
u+1==2*v-3w,
v=f(f(w)))
(here A and B are arrays; C et D are lists;
x,y,z,t,j,l,i,h,u,v,w are variables that could be of type integer or 
real, c is a constant and f is a function):
 
Thank you very much.

Yours faithfully,
Olfa MRAIHI


If I understand you correctly, I believe the answer is no.  Have you 
considered PyDSTool  and SymPy 
?






___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion
  


___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Unexpected MaskedArray behavior

2008-12-17 Thread Jim Vickroy

Ryan May wrote:

Pierre GM wrote:
  

On Dec 16, 2008, at 1:57 PM, Ryan May wrote:


I just noticed the following and I was kind of surprised:

  

a = ma.MaskedArray([1,2,3,4,5], mask=[False,True,True,False,False])
b = a*5
b


masked_array(data = [5 -- -- 20 25],
  mask = [False  True  True False False],
  fill_value=99)
  

b.data


array([ 5, 10, 15, 20, 25])

I was expecting that the underlying data wouldn't get modified while  
masked.  Is

this actual behavior expected?
  
Meh. Masked data shouldn't be trusted anyway, so I guess it doesn't  
really matter one way or the other.
But I tend to agree, it'd make more sense leave masked data untouched  
(or at least, reset them to their original value after the operation),  
which would mimic the behavior of gimp/photoshop.
Looks like there's a relatively easy fix. I need time to check whether  
it doesn't break anything elsewhere, nor that it slows things down too  
much. I won't have time to test all that before next week, though. In  
any case, that would be for 1.3.x, not for 1.2.x.

In the meantime, if you need the functionality, use something like
ma.where(a.mask,a,a*5)



I agree that masked values probably shouldn't be trusted, I was just surprised to 
see the behavior.  I just assumed that no operations were taking place on masked 
values.


Just to clarify what I was doing here: I had a masked array of data, where the 
mask was set by a variety of different masked values.  Later on in the code, 
after doing some unit conversions, I went back to look at the raw data to find 
points that had one particular masked value set.  Instead, I was surprised to see 
all of the masked values had changed and I could no longer find any of the 
special values in the data.


Ryan

  
Sorry for being dense about this, but I really do not understand why 
masked values should not be trusted.  If I apply a procedure to an array 
with elements designated as untouchable, I would expect that contract to 
be honored.  What am I missing here?


Thanks for your patience!
-- jv
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] PIL.Image.fromarray bug in numpy interface

2008-11-24 Thread Jim Vickroy

Robert Kern wrote:

On Mon, Nov 24, 2008 at 11:26, Jim Vickroy <[EMAIL PROTECTED]> wrote:
  

Travis E. Oliphant wrote:

Jim Vickroy wrote:


Hello,

While using the PIL interface to numpy, I rediscovered a logic error
in the PIL.Image.fromarray() procedure.  The problem (and a solution)
was mentioned earlier at:

*
http://projects.scipy.org/pipermail/numpy-discussion/2006-December/024903.html

There does not seem to be a formal way to report errors to the PIL
project, and I was told that the PIL/numpy interface was contributed
by the numpy developers so I'm reporting it here.

Please let me know if there is something additional I should do.


I would suggest making a patch and submitting it to the PIL.


I did post a suggested patch (one-liner) to the PIL group, but a couple of
PIL respondents suggested that I submit the problem here.  I have followed
the PIL group postings for some time, and my impression is that it is
somewhat difficult to get reader-submitted patches acknowledged.



Tell them that we approve of the change. We don't have commit access
to PIL, so I believe that our approval is the only reason they could
possibly send you over here.

  

Thank-you, Robert.  I will do so.

___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] PIL.Image.fromarray bug in numpy interface

2008-11-24 Thread Jim Vickroy

Travis E. Oliphant wrote:

Jim Vickroy wrote:
  

Hello,

While using the PIL interface to numpy, I rediscovered a logic error 
in the PIL.Image.fromarray() procedure.  The problem (and a solution) 
was mentioned earlier at:


* 
http://projects.scipy.org/pipermail/numpy-discussion/2006-December/024903.html

There does not seem to be a formal way to report errors to the PIL 
project, and I was told that the PIL/numpy interface was contributed 
by the numpy developers so I'm reporting it here.


Please let me know if there is something additional I should do.

I would suggest making a patch and submitting it to the PIL.   
  
I did post a suggested patch (one-liner) to the PIL group, but a couple 
of PIL respondents suggested that I submit the problem here.  I have 
followed the PIL group postings for some time, and my impression is that 
it is somewhat difficult to get reader-submitted patches acknowledged.

-Travis

___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion
  


___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


[Numpy-discussion] PIL.Image.fromarray bug in numpy interface

2008-11-24 Thread Jim Vickroy

Hello,

While using the PIL interface to numpy, I rediscovered a logic error in 
the PIL.Image.fromarray() procedure.  The problem (and a solution) was 
mentioned earlier at:


   * 
http://projects.scipy.org/pipermail/numpy-discussion/2006-December/024903.html

There does not seem to be a formal way to report errors to the PIL 
project, and I was told that the PIL/numpy interface was contributed by 
the numpy developers so I'm reporting it here.


Please let me know if there is something additional I should do.

Thanks,
-- jv

P.S.
FWIW, I'm using:

   * Python version: 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC
 v.1310 32 bit (Intel)]
   * numpy version:  1.2.1
   * PIL version:1.1.6

___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] how to combine (stack) two masked arrays?

2007-03-01 Thread Jim Vickroy

Thanks for the quick response!
Please see my in-line comments below.

Pierre GM wrote:

Hello,
The simplest is:
rescaled[rescaled.mask]=clipped_mask[rescaled.mask]

But for this particular kind of operation, I don't think that you need masked 
array at all: this could do the trick
  

rescaled = clipped.copy()
inside = numpy.logical_and(clipped>=123, clipped<=354)
outside = numpy.logical_not(inside)
newrescaled[inside] = 5*clipped[inside]
newrescaled[outside] = clipped[outside]



  


Great; that is slick (replaced *newrescaled* with *rescaled* in the 
above code)!


I approached numpy with a preconceived notion of how to perform this 
task (i.e., masked arrays) and did not look at the broader set of 
package capabilities 


A side note: when using numpy.core.ma, it's more efficient to deal w/ the 
_data and _mask parts separately than at once.
  

Thanks for the tip.
 
You may want to try an alternative implementation of maskedarray, available in 
the sandbox of the scipy SVN. I'd be very happy to have your feedback


  
While browsing the archived discussions, I did see mention of this, but 
decided to avoid it because I was a newbie.

Let me know if this helps
P.
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion
  


___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


[Numpy-discussion] how to combine (stack) two masked arrays?

2007-03-01 Thread Jim Vickroy

Hello all,

I am stuck in my attempts to use masked arrays to combine the contents 
of two arrays (please see the masked-arrays.py attachment) such that 
missing values in one array are provided by the second array.  There are 
no ambiguities in the combination operation because each of the two 
arrays only has values where the other array does not.


Referring to masked-arrays.py, I want to apply some function/operator to 
the *clipped_mask* and *rescaled* arrays to obtain the following result:


[[0 0 0 0 0]
[0 1220 4095 1220 0]
[1220 4095 4095 4095 1220]
[0 1220 4095 1220 0]
[0 0 0 0 0]]

I am a new user of numpy so I would appreciate feedback on awkward areas 
in the code and/or the suitability of the approach.


Thanks,

-- jv

P.S.

Apologies if this is in the discussion archives; I was not able to find 
a similar discussion there nor in my copy of numpybook.pdf.


masked-arrays.py
Description: application/python
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion