Hi folks,
I need an efficient way to get both the min and argmin of a 2-d
array along one axis. It seemed to me that the way to do this was to
get the argmin and then use it to index into the array to get the min,
but I can't figure out how to do it. Here's my toy example:
>>> x = np.ar
Dear folks,
I have some code that stopped working with 1.6.0 and I'm wondering if
there's a better way to replace it than what I came up with. Here's a
condensed version:
x = [()] # list containing an empty tuple; this isn't the only case,
but it's one that must be handled correctly
y = np
I think this does what you want:
def dim_weight(x):
weights = x[0]
volumes = x[1]*x[2]*x[3]
return np.where(volumes>5184, volumes / 194.0, weights)
Best,
Ken
On 4/17/11 1:00 PM, Laszlo Nagy wrote:
> Message: 1
> Date: Sat, 16 Apr 2011 21:08:55 +0200
> From: Laszlo Nagy
> Su
Ken
On 12/2/10 8:14 AM, Robert Kern wrote:
> On Wed, Dec 1, 2010 at 13:18, Ken Basye wrote:
>> Hi Numpy folks,
>> ? ? When working with floats, I prefer to have exact string
>> representations in doctests and other reference-based testing; I find it
>> helps a lot t
Hi Numpy folks,
When working with floats, I prefer to have exact string
representations in doctests and other reference-based testing; I find it
helps a lot to avoid chasing cross-platform differences that are really
about the string conversion rather than about numerical differences.
Sin
Anne says:
This is a tricky one. The current behaviour of rollaxis is to remove
the requested axis from the list of axes and then insert it before the
axis specified. This is exactly how python's list insertion works:
In [1]: a = range(10)
In [3]: a.insert(-1,'a')
In [4]
that seems to fit
what the function does better - 'rollaxis' suggests a behavior like the
roll() function which affects other axes, which isn't what happens.
Thanks for listening; I'm a big fan of Numpy.
Best,
Ken Basye
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion
Hi,
Is there a simple way to get a cumsum in reverse order? So far, the
best I've come up with is to use fancy indexing twice to reverse things:
>>> x = np.arange(10)
>>> np.cumsum(x[np.arange(9, -1, -1)])[np.arange(9, -1, -1)]
array([45, 45, 44, 42, 39, 35, 30, 24, 17, 9])
If it matters,
Folks,
Apologies for asking here, but I ran across this problem yesterday
and probably need to file a bug. The problem is I don't know if this is
a Numpy bug, a Python bug, or both. Here's an illustration, platform
information follows.
TIA,
Ken
##
From: Anne Archibald
On 6 April 2010 15:42, Ken Basye wrote:
> Folks,
> I hope this is a simple question. When I created a ufunc with
> np.frompyfunc(), I got an error when I called the result with an 'out'
> argument:
In fact, ordinary ufuncs do not accept nam
Folks,
I hope this is a simple question. When I created a ufunc with
np.frompyfunc(), I got an error when I called the result with an 'out'
argument:
>>> def foo(x): return x * x + 1
>>> ufoo = np.frompyfunc(foo, 1, 1)
>>> arr = np.arange(9).reshape(3,3)
>>> ufoo(arr, out=arr)
Traceback (
From: Vincent Schut
On 04/05/2010 06:06 PM, Keith Goodman wrote:
On Mon, Apr 5, 2010 at 8:44 AM, Ken Basye wrote:
Hi Folks,
I have two arrays, A and B, with the same shape. I want to find the
highest values in A along some axis, then extract the corresponding
values from B. I can
Hi Folks,
I have two arrays, A and B, with the same shape. I want to find the
highest values in A along some axis, then extract the corresponding
values from B. I can get the highest values in A with A.max(axis=0) and
the indices of these highest values with A.argmax(axis=0). I'm trying
to
Hi Mathew,
Here are some things to think about: First, is there a way to decompose
'f' so that it computes only one or a subset of K values, but in 1/N ( K/N)
time? If so, you can decompose your problem into N single optimizations.
Presumably not, but I think it's worth asking. Second, what
I ran into something like this a couple weeks ago. I use Firefox 3 on MacOS.
My work-around was to clear all the cookies from scipy.org, clear all
authenticated sessions, then register a completely new account name. I
never could get my existing account to stop looping.
HTH,
Ken
Thoma
m, and/or does anyone know how I can fix my side
> of things to get me to the site?
I don't see this. Can you try emptying your browser's cache?
-- Pauli Virtanen
Wed, 15 Apr 2009 17:21:59 -0400, Ken Basye wrote:
___
Numpy-discussion ma
Hi all,
Just now when I tried to access http://projects.scipy.org/numpy,
Firefox complains (after a bit) that there's a redirect loop. Is anyone
else seeing this problem, and/or does anyone know how I can fix my side
of things to get me to the site?
Thanks,
Ken
on of Numerical Python
Message-ID:
Content-Type: text/plain; charset="iso-8859-1"
On Tue, Feb 17, 2009 at 8:30 AM, Ken Basye wrote:
Hi,
My current code looks like this:
(k,d) = m.shape
sq = np.zeros((k, d, d), dtype=float)
for i in xrange(k):
Hi,
My current code looks like this:
(k,d) = m.shape
sq = np.zeros((k, d, d), dtype=float)
for i in xrange(k):
sq[i] = np.outer(m[i], m[i])
That is, m is treated as a sequence of k vectors of length d; the k dXd
outer products are found and st
Hi List,
I need to compute multiple outer products from 2-d data in the
following way:
Given a and b with shape, e.g, (10, 4), compute the 10 outer products
of shape (4, 4) and get them into an array of shape (10, 4, 4).
Currently I do this with a loop, but I'd really like some way to do it
Hi Folks,
I wonder if there's a way to fill an existing array from an iterator
without creating a temporary array. That is, I'm looking for something
that has the effect of
>>> target = np.array(xrange(9), dtype = float)
>>> target[:] = np.fromiter(repeat(3.14159, 9), dtype=float)
withou
about introducing a new
print setting that forced
dtypes to be printed always. Is there any support for that?
Any other ideas would also be most welcome.
Thanks,
Ken Basye
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http
bits = (sign << 63) + (exponent << 52) + mantissa
return _double.longBitsToDouble(bits)
Hans Meine wrote:
Am Dienstag, 08. April 2008 17:22:33 schrieb Ken Basye:
I've had this happen
often enough that I found the first thing I did when an output
difference arose was to pr
Hi,
Thanks, but it's been my experience that formatting FP numbers into
decimal causes a lot of false alarms
all by itself; that is, you get different decimal representations of the
same FP memory value. I've had this happen
often enough that I found the first thing I did when an output
diffe
re, but I now
have at least one example of
a difference. I should clarify that I'm not talking about
processor-family dependency; all my machines
are x86 at this point. Indeed, the differences appear across virtual
machines running different OSs on
the same physical machine.
Thanks in
25 matches
Mail list logo