I'm trying to enter a 2-D array and np.array() is returning a 1-D array of lists. I'm using Python (x,y) on Windows 7 with numpy 1.7.1. Here's the code that is giving me issues.
f1 = [[15.207, 15.266, 15.181, 15.189, 15.215, 15.198], [-45, -57, -62, -70, -72, -73.5, -77]] f1a = np.array(f1) f1a array([[15.207, 15.266, 15.181, 15.189, 15.215, 15.198], [-45, -57, -62, -70, -72, -73.5, -77]], dtype=object)
What am I missing?
The two lists are of different sizes. Had to count twice to catch that. Ben Root On Mon, Sep 9, 2013 at 9:46 AM, Chad Kidder <cckidder@gmail.com> wrote:
I'm trying to enter a 2-D array and np.array() is returning a 1-D array of lists. I'm using Python (x,y) on Windows 7 with numpy 1.7.1. Here's the code that is giving me issues.
f1 = [[15.207, 15.266, 15.181, 15.189, 15.215, 15.198], [-45, -57, -62, -70, -72, -73.5, -77]] f1a = np.array(f1) f1a array([[15.207, 15.266, 15.181, 15.189, 15.215, 15.198], [-45, -57, -62, -70, -72, -73.5, -77]], dtype=object)
What am I missing?
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
One list has 6 entries and one has 7, so they can't be aligned into a single array. Possibly it would be better to raise an error here instead of returning an object array, but that's what's going on. -n On 9 Sep 2013 14:49, "Chad Kidder" <cckidder@gmail.com> wrote:
I'm trying to enter a 2-D array and np.array() is returning a 1-D array of lists. I'm using Python (x,y) on Windows 7 with numpy 1.7.1. Here's the code that is giving me issues.
f1 = [[15.207, 15.266, 15.181, 15.189, 15.215, 15.198], [-45, -57, -62, -70, -72, -73.5, -77]] f1a = np.array(f1) f1a array([[15.207, 15.266, 15.181, 15.189, 15.215, 15.198], [-45, -57, -62, -70, -72, -73.5, -77]], dtype=object)
What am I missing?
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Oh, so there was a bug in the user... On Mon, Sep 9, 2013 at 7:52 AM, Nathaniel Smith <njs@pobox.com> wrote:
One list has 6 entries and one has 7, so they can't be aligned into a single array. Possibly it would be better to raise an error here instead of returning an object array, but that's what's going on.
-n On 9 Sep 2013 14:49, "Chad Kidder" <cckidder@gmail.com> wrote:
I'm trying to enter a 2-D array and np.array() is returning a 1-D array of lists. I'm using Python (x,y) on Windows 7 with numpy 1.7.1. Here's the code that is giving me issues.
f1 = [[15.207, 15.266, 15.181, 15.189, 15.215, 15.198], [-45, -57, -62, -70, -72, -73.5, -77]] f1a = np.array(f1) f1a array([[15.207, 15.266, 15.181, 15.189, 15.215, 15.198], [-45, -57, -62, -70, -72, -73.5, -77]], dtype=object)
What am I missing?
_______________________________________________ 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
On Mon, Sep 9, 2013 at 9:52 AM, Nathaniel Smith <njs@pobox.com> wrote:
One list has 6 entries and one has 7, so they can't be aligned into a single array. Possibly it would be better to raise an error here instead of returning an object array, but that's what's going on.
It did at some point (and I relied on the exception to catch bugs, since I'm still using mainly numpy 1.5)
f1 = [[15.207, 15.266, 15.181, 15.189, 15.215, 15.198], [-45, -57, -62, -70, -72, -73.5, -77]] np.array(f1) Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: setting an array element with a sequence. np.__version__ '1.5.1'
now we get object arrays (in scipy.stats, and I didn't know what to do with them) I don't remember any discussion on this. Josef
-n
On 9 Sep 2013 14:49, "Chad Kidder" <cckidder@gmail.com> wrote:
I'm trying to enter a 2-D array and np.array() is returning a 1-D array of lists. I'm using Python (x,y) on Windows 7 with numpy 1.7.1. Here's the code that is giving me issues.
f1 = [[15.207, 15.266, 15.181, 15.189, 15.215, 15.198], [-45, -57, -62, -70, -72, -73.5, -77]] f1a = np.array(f1) f1a array([[15.207, 15.266, 15.181, 15.189, 15.215, 15.198], [-45, -57, -62, -70, -72, -73.5, -77]], dtype=object)
What am I missing?
_______________________________________________ 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
On 9 Sep 2013 15:50, <josef.pktd@gmail.com> wrote:
On Mon, Sep 9, 2013 at 9:52 AM, Nathaniel Smith <njs@pobox.com> wrote:
One list has 6 entries and one has 7, so they can't be aligned into a
single
array. Possibly it would be better to raise an error here instead of returning an object array, but that's what's going on.
It did at some point (and I relied on the exception to catch bugs, since I'm still using mainly numpy 1.5)
f1 = [[15.207, 15.266, 15.181, 15.189, 15.215, 15.198], [-45, -57, -62, -70, -72, -73.5, -77]] np.array(f1) Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: setting an array element with a sequence. np.__version__ '1.5.1'
now we get object arrays (in scipy.stats, and I didn't know what to do with them)
I don't remember any discussion on this.
There may not have been any. Feel free to submit a PR and we can argue about which way is better... (I also prefer the 1.5 approach personally.) -n
On Mon, Sep 9, 2013 at 11:35 AM, Nathaniel Smith <njs@pobox.com> wrote:
On 9 Sep 2013 15:50, <josef.pktd@gmail.com> wrote:
On Mon, Sep 9, 2013 at 9:52 AM, Nathaniel Smith <njs@pobox.com> wrote:
One list has 6 entries and one has 7, so they can't be aligned into a single array. Possibly it would be better to raise an error here instead of returning an object array, but that's what's going on.
It did at some point (and I relied on the exception to catch bugs, since I'm still using mainly numpy 1.5)
f1 = [[15.207, 15.266, 15.181, 15.189, 15.215, 15.198], [-45, -57, -62, -70, -72, -73.5, -77]] np.array(f1) Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: setting an array element with a sequence. np.__version__ '1.5.1'
now we get object arrays (in scipy.stats, and I didn't know what to do with them)
I don't remember any discussion on this.
There may not have been any.
Isn't it too late now?
Feel free to submit a PR and we can argue about which way is better... (I also prefer the 1.5 approach personally.)
I'm just a balcony muppet (and user) (and I lost the argument against object arrays in scipy.stats) Josef
-n
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
participants (4)
-
Benjamin Root
-
Chad Kidder
-
josef.pktd@gmail.com
-
Nathaniel Smith