Boolean array formatting poll
Now that Python has a bool type, I have received a patch for numarray's arrayprint module which alters the formatting of Boolean arrays from:
a=numarray.arange(6, type=numarray.Bool); a[::2] = 0; a array([0, 1, 0, 1, 0, 1], type=Bool)
to:
a=numarray.arange(6, type=numarray.Bool); a[::2] = 0; a array([False, True, False, True, False, True], type=Bool)
Which format do you prefer? Please vote for or against changing the format: +1 (for) or -1 (against). -- Todd Miller jmiller@stsci.edu STSCI / ESS / SSB
Todd Miller wrote:
a=numarray.arange(6, type=numarray.Bool); a[::2] = 0; a array([False, True, False, True, False, True], type=Bool)
Which format do you prefer? Please vote for or against changing the format: +1 (for) or -1 (against).
-1 It just makes it harder to read, particularly for a large array -Chris -- Christopher Barker, Ph.D. Oceanographer NOAA/OR&R/HAZMAT (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception Chris.Barker@noaa.gov
Chris Barker wrote:
Todd Miller wrote:
a=numarray.arange(6, type=numarray.Bool); a[::2] = 0; a
array([False, True, False, True, False, True], type=Bool)
Which format do you prefer? Please vote for or against changing the format: +1 (for) or -1 (against).
-1
It just makes it harder to read, particularly for a large array
-Chris
Perhaps the important thing is to facilitate visual comparison between one row and another or between one array and another. Maybe 'False' and 'True ' (with a trailing space) could be used as representations of the Boolean values. If a compressed representation is desired then 'F' and 'T' might be used. This could be specified in a site constant which, for the distribution, would default to one of ('0, '1'), ('False', 'True'), ('False', 'True ') or ('F', 'T'). My feeling is that, since it can easily be done, it is desirable to distinguish between Integer and Boolean values. Colin W.
Vote +1 Todd Miller wrote:
Now that Python has a bool type, I have received a patch for numarray's arrayprint module which alters the formatting of Boolean arrays from:
a=numarray.arange(6, type=numarray.Bool); a[::2] = 0; a
array([0, 1, 0, 1, 0, 1], type=Bool)
to:
a=numarray.arange(6, type=numarray.Bool); a[::2] = 0; a
array([False, True, False, True, False, True], type=Bool)
Which format do you prefer? Please vote for or against changing the format: +1 (for) or -1 (against).
-1, because of readability Gerard On 09 Sep 2003 16:15:36 -0400 Todd Miller <jmiller@stsci.edu> wrote:
Now that Python has a bool type, I have received a patch for numarray's arrayprint module which alters the formatting of Boolean arrays from:
a=numarray.arange(6, type=numarray.Bool); a[::2] = 0; a array([0, 1, 0, 1, 0, 1], type=Bool)
to:
a=numarray.arange(6, type=numarray.Bool); a[::2] = 0; a array([False, True, False, True, False, True], type=Bool)
Which format do you prefer? Please vote for or against changing the format: +1 (for) or -1 (against).
-- Todd Miller jmiller@stsci.edu STSCI / ESS / SSB
------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
-1, for readability. 1's and 0's can be distinguished more easily visually than T's and F's. Michiel, U Tokyo. Pearu Peterson wrote:
Considering the number of `-1`s, how about
a=numarray.arange(6, type=numarray.Bool); a[::2] = 0; a
array([F, T, F, T, F, T], type=Bool)
which is short and readable.
Pearu
------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
-- Michiel de Hoon Assistant Professor University of Tokyo, Institute of Medical Science Human Genome Center 4-6-1 Shirokane-dai, Minato-ku Tokyo 108-8639 Japan http://bonsai.ims.u-tokyo.ac.jp/~mdehoon
Pearu Peterson wrote:
a=numarray.arange(6, type=numarray.Bool); a[::2] = 0; a array([F, T, F, T, F, T], type=Bool)
That's better. However, I"m still inclined to prefer [1, 0, 0, 1, .... Someone mentioned making clear the distiction between bool and int arrays. HOw distict are they? In Python, the bool type is really just a pretty wrapper around an Int anway. I like it, but if in NumArray, a bool is really and int in disguise, I'd be just as happy to ahve it be 0, 1, 0, .... If however, a bool really is a totally different beast (or will be in a future version), then maybe it's worth making the clear distiction. -Chris For what I mean, note in Python 2.3:
a = True a True a * 5 5
Can you do this in NumArray? -- Christopher Barker, Ph.D. Oceanographer NOAA/OR&R/HAZMAT (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception Chris.Barker@noaa.gov
Todd Miller wrote:
numarray.ones((10,), type=numarray.Bool)*5 array([5, 5, 5, 5, 5, 5, 5, 5, 5, 5])
So, yes.
In that case, definately -1: if the data really are integers, that might as well be clear from the display -Chris -- Christopher Barker, Ph.D. Oceanographer NOAA/OR&R/HAZMAT (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception Chris.Barker@noaa.gov
Pearu Peterson wrote:
Considering the number of `-1`s, how about
a=numarray.arange(6, type=numarray.Bool); a[::2] = 0; a
array([F, T, F, T, F, T], type=Bool)
Somehow I seem to parse faster 0/1 arrays than F/T (the symbols are visually more different). -0.5, but better than the change to True/False. Cheers, f
+1 for consistency and clarity. Todd Miller wrote:
Now that Python has a bool type, I have received a patch for numarray's arrayprint module which alters the formatting of Boolean arrays from:
a=numarray.arange(6, type=numarray.Bool); a[::2] = 0; a
array([0, 1, 0, 1, 0, 1], type=Bool)
to:
a=numarray.arange(6, type=numarray.Bool); a[::2] = 0; a
array([False, True, False, True, False, True], type=Bool)
Which format do you prefer? Please vote for or against changing the format: +1 (for) or -1 (against).
-- Paul Barrett, PhD Space Telescope Science Institute Phone: 410-338-4475 ESS/Science Software Group FAX: 410-338-4767 Baltimore, MD 21218
On Tue, Sep 09, 2003 at 04:15:36PM -0400, Todd Miller wrote:
Now that Python has a bool type, I have received a patch for numarray's arrayprint module which alters the formatting of Boolean arrays from:
a=numarray.arange(6, type=numarray.Bool); a[::2] = 0; a array([0, 1, 0, 1, 0, 1], type=Bool)
to:
a=numarray.arange(6, type=numarray.Bool); a[::2] = 0; a array([False, True, False, True, False, True], type=Bool)
Which format do you prefer? Please vote for or against changing the format: +1 (for) or -1 (against).
-1 If I'm using those kinds of values in arrays, I'm more likely to be thinking in terms of 1's and 0's not True's and False's anyways. E.g. frequency = float(sum(a)) / len(a) -- Robert Kern kern@caltech.edu "In the fields of hell where the grass grows high Are the graves of dreams allowed to die." -- Richard Harter
participants (10)
-
Chris Barker
-
Colin J. Williams
-
Fernando Perez
-
Francesc Alted
-
Gerard Vermeulen
-
Michiel Jan Laurens de Hoon
-
Paul Barrett
-
Pearu Peterson
-
Robert Kern
-
Todd Miller