Re: [Numpy-discussion] inconsistent mgrid results
Hello Andrew, Hello all, like Andrew, I had some strange experience with mgrid. Adrew writes: Am Dienstag, den 27.02.2007, 19:43 -0600 schrieb Andrew Corrigan:
I'm confused about the following:
print mgrid[2.45:2.6:0.05, 0:5:1] [[[ 2.45 2.45 2.45 2.45 2.45] [ 2.5 2.5 2.5 2.5 2.5 ]]
[[ 0. 1. 2. 3. 4. ] [ 0. 1. 2. 3. 4. ]]]
print mgrid[2.45:2.6:0.05] [ 2.45 2.5 2.55]
In the first case in the first dimension I get 2.45, 2.5. In the second case in the first dimension I get 2.45, 2.5, 2.55 In both cases I'm using 2.45:2.6:0.05 to specify the grid in the first dimension.
I think this is because for the one-dimensional case numpy.nd_grid relies on numpy.arange. This is basically a good idea, but the more-dimensional case behaves different, like Andrew states. My problem is the following:
mgrid[0.1:0.2:1, 0.2:0.3:1] gives array([], shape=(2, 0, 0), dtype=float64)
What I wanted to create was: array([[[ 0.1]], [[ 0.2]]]) which I finally got with
mgrid[0.1:1.2:1, 0.2:1.3:1]
Since this behaviour is different from arange, I think it is not very intentional. But maybe there is a good reason for this behaviour? I am using numpy, version 1.0.1. Maybe the behaviour was already changed in more recent versions? Thank you for any comment Lars Friedrich -- Dipl.-Ing. Lars Friedrich Optical Measurement Technology Department of Microsystems Engineering -- IMTEK University of Freiburg Georges-Köhler-Allee 102 D-79110 Freiburg Germany phone: +49-761-203-7531 fax: +49-761-203-7537 room: 01 088 email: lfriedri@imtek.de
participants (1)
-
Lars Friedrich