I think that I finally figured it out. See code below.
Phillip
*** Start of myarray.py ***
import numpy
def array(*args, **kwargs):
"""This function acts as an interface to numpy.array, accepting
multi-row matrices with or without an outer set of enclosing brackets.
Usage examples:
On 16-Jul-09, at 9:34 PM, Phillip M. Feldman wrote:
> This does the right thing sometimes, but not always. Out[2] and
> Out[4]
> are fine, but Out[3] is not (note the extra set of braces). Probably
> the only right way to fix this is to modify numpy itself.
yes, to achieve out[3] you'd need
On Thu, Jul 16, 2009 at 20:34, Phillip M. Feldman wrote:
> This does the right thing sometimes, but not always. Out[2] and Out[4]
> are fine, but Out[3] is not (note the extra set of braces). Probably
> the only right way to fix this is to modify numpy itself.
Modifying numpy.array() would have
This does the right thing sometimes, but not always. Out[2] and Out[4]
are fine, but Out[3] is not (note the extra set of braces). Probably
the only right way to fix this is to modify numpy itself.
Phillip
In [1]: def myarray(*args, **kwargs): return np.array([z for z in args],
**kwargs) .
On Thu, Jul 16, 2009 at 1:49 PM, David Warde-Farley wrote:
> On 16-Jul-09, at 3:09 PM, Keith Goodman wrote:
>
>> def myarray(*args, **kwargs):
>> return np.array([z for z in args], **kwargs)
>
>
> This version is better IMHO, because then you can still specify the
> dtype by keyword. although (j
On 16-Jul-09, at 3:09 PM, Keith Goodman wrote:
> def myarray(*args, **kwargs):
>return np.array([z for z in args], **kwargs)
This version is better IMHO, because then you can still specify the
dtype by keyword. although (just to be a pedant)
> return np.array(args, **kwargs)
works as wel
On Thu, Jul 16, 2009 at 11:43 AM, Phillip M.
Feldman wrote:
> numpy.array understands
>
> V= array([[1,2,3,4],[4,3,2,1]])
>
> but not
>
> V= array([1,2,3,4],[4,3,2,1])
>
> It would be more convenient if it could handle either form.
You could do something like this:
def myarray(*args):
return
On 16-Jul-09, at 2:43 PM, Phillip M. Feldman wrote:
> numpy.array understands
>
> V= array([[1,2,3,4],[4,3,2,1]])
>
> but not
>
> V= array([1,2,3,4],[4,3,2,1])
>
> It would be more convenient if it could handle either form.
That may be so, but the second argument is dtype. This would break that.
numpy.array understands
V= array([[1,2,3,4],[4,3,2,1]])
but not
V= array([1,2,3,4],[4,3,2,1])
It would be more convenient if it could handle either form.
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listi