Re: [Python-ideas] Python multi-dimensional array constructor

2016-10-21 Thread Ethan Furman
On 10/19/2016 12:08 PM, Todd wrote: At least in my opinion, this sort of approach really shines when making higher-dimensional arrays. These would all be equivalent (the | at the beginning and end are just to make it easier to align indentation, they aren't required): a = [ 48, 11, 141,

Re: [Python-ideas] Python multi-dimensional array constructor

2016-10-21 Thread Sven R. Kunze
On 19.10.2016 21:08, Todd wrote: a= [ 48, 11, 141, 13, -60, -37, 58, -52, -29, 134 || -6, 96, -66, 137, -59, -147, -118, -104, -123, -7 ||| -103, 50, -89, -12, 28, -12, 119, -131, -73, 21 || -58, 105, 25, -138, -106, -118, -29, -49, -63, -56 -43, -34, 101, -115

Re: [Python-ideas] Python multi-dimensional array constructor

2016-10-20 Thread Chris Barker
On Wed, Oct 19, 2016 at 5:32 PM, Todd wrote: > If there is a problem with the current options (and I'm not convinced >> there is) it's that it in'st a literal for multidimensional array, but >> rather a literal for a bunch of nested lists -- the list themselves are >> created, and so are all the

Re: [Python-ideas] Python multi-dimensional array constructor

2016-10-20 Thread David Mertz
I find the proposed syntax worse than the existing square brackets. The way the NumPy does a repr of an array is a good model of clarity, and it's correct current Python (except for larger arrays where visual ellipses are used). On Oct 20, 2016 12:01 AM, "Greg Ewing" wrote: > Matt Gilson wrote:

Re: [Python-ideas] Python multi-dimensional array constructor

2016-10-20 Thread Greg Ewing
Todd wrote: ||| is the delimiter for the third dimension, || is the delimiter for the second dimension. This seems a bit inconsistent. It appears the rule is "n vertical bars is the delimiter for the nth dimension". By that rule, the delimiter for the first dimension should be a single vertical

Re: [Python-ideas] Python multi-dimensional array constructor

2016-10-20 Thread Greg Ewing
Matt Gilson wrote: I think that it was mentioned that it might be possible for a user to _register_ a callable that would then be used when this syntax was envoked -- But having a global setting like that leads to contention. I think for that to fly it would have to be a per-module thing. The

Re: [Python-ideas] Python multi-dimensional array constructor

2016-10-19 Thread Steven D'Aprano
On Wed, Oct 19, 2016 at 03:08:21PM -0400, Todd wrote: [taking your later comment out of the order it was written] > If this sort of thing doesn't interest you I won't be offended if you stop > reading now, and I apologize if it is considered off-topic for this ML. No problem Todd, we shouldn't be

Re: [Python-ideas] Python multi-dimensional array constructor

2016-10-19 Thread Todd
On Wed, Oct 19, 2016 at 7:48 PM, Chris Barker wrote: > a few thoughts: > > On Wed, Oct 19, 2016 at 12:08 PM, Todd wrote: > >> I have been thinking about how to go about having a multidimensional >> array constructor in python. I know that Python doesn't have a built-in >> multidimensional array

Re: [Python-ideas] Python multi-dimensional array constructor

2016-10-19 Thread Alexander Belopolsky
On Wed, Oct 19, 2016 at 7:48 PM, Chris Barker wrote: > > > However, if you really don't like it, then you can pass a string to aconfsturctor function instead: > > a = arr_from_string(" | 0, 1, 2 || 3, 4, 5 | ") > > yeah, you need to type the extra quotes, but that's not much. > > NOTE: I'm pretty

Re: [Python-ideas] Python multi-dimensional array constructor

2016-10-19 Thread Chris Barker
a few thoughts: On Wed, Oct 19, 2016 at 12:08 PM, Todd wrote: > I have been thinking about how to go about having a multidimensional array > constructor in python. I know that Python doesn't have a built-in > multidimensional array class and won't for the foreseeable future. > no but it does h

Re: [Python-ideas] Python multi-dimensional array constructor

2016-10-19 Thread Todd
On Wed, Oct 19, 2016 at 4:47 PM, Matt Gilson wrote: > FWIW, you probably _don't_ want to use `ndarray` directly. Normally, you > want to use the `np.array` factory function... > > >>> import numpy as np > >>> a = np.ndarray([0, 1, 2]) > >>> a > array([], shape=(0, 1, 2), dtype=float64) > > Aside

Re: [Python-ideas] Python multi-dimensional array constructor

2016-10-19 Thread Matt Gilson
FWIW, you probably _don't_ want to use `ndarray` directly. Normally, you want to use the `np.array` factory function... >>> import numpy as np >>> a = np.ndarray([0, 1, 2]) >>> a array([], shape=(0, 1, 2), dtype=float64) Aside from that, my main problem with this proposal is that it seems to onl

Re: [Python-ideas] Python multi-dimensional array constructor

2016-10-19 Thread Mikhail V
On 19 October 2016 at 21:08, Todd wrote: > > a = np.ndarray(48, 11, 141, 13, -60, -37, 58, -52, -29, 134], > [-6, 96, -66, 137, -59, -147, -118, -104, -123, -7]], > [[-103, 50, -89, -12, 28, -12, 119, -131, -73, 21], > [-58, 105, 25, -138,

Re: [Python-ideas] Python multi-dimensional array constructor

2016-10-19 Thread Todd
On Wed, Oct 19, 2016 at 3:55 PM, Joseph Jevnik wrote: > You could add or prototype this with quasiquotes (http://quasiquotes. > readthedocs.io/en/latest/). You just need to be able to parse the body of > your expression as a string into an array. Here is a quick example with a > parser that only

Re: [Python-ideas] Python multi-dimensional array constructor

2016-10-19 Thread Joseph Jevnik
You could add or prototype this with quasiquotes ( http://quasiquotes.readthedocs.io/en/latest/). You just need to be able to parse the body of your expression as a string into an array. Here is a quick example with a parser that only accepts 2d arrays: ``` # coding: quasiquotes import numpy as n

Re: [Python-ideas] Python multi-dimensional array constructor

2016-10-19 Thread Todd
On Wed, Oct 19, 2016 at 3:24 PM, Thomas Nyberg wrote: > Personally I like the way that numpy does it now better (even for > multidimensional arrays). Being able to index into the different sub > dimension using just [] iteratively matches naturally with the data > structure itself in my mind. Thi

Re: [Python-ideas] Python multi-dimensional array constructor

2016-10-19 Thread Thomas Nyberg
Personally I like the way that numpy does it now better (even for multidimensional arrays). Being able to index into the different sub dimension using just [] iteratively matches naturally with the data structure itself in my mind. This may also just be my fear of change though... Here is an

[Python-ideas] Python multi-dimensional array constructor

2016-10-19 Thread Todd
I have been thinking about how to go about having a multidimensional array constructor in python. I know that Python doesn't have a built-in multidimensional array class and won't for the foreseeable future. However, some projects have come up with their own ways of making it simpler to create suc