[Numpy-discussion] Newbie MA question
Reggie Dugard
reggie at merfinllc.com
Thu Aug 8 10:10:03 CDT 2002
Cath,
The simple answer to your question is to use MA.set_print_limit(0) to
change the behavior of str and repr back to the standard Numeric
behavior of always printing the entire array. Then you will get the
whole array, with the masked values as '--'.
Reggie
> Hi,
>
> I'm not sure this is the right list - looking at the archives you guys
> look more like developers more than users.
>
> Any pointers to the proper place, or TFMs to R, are welcome. (Yes, I
> have & have read the Numerical Python documentation.)
>
> That said, I'm trying to use masked arrays (for a bioinformatics app
> calculating stats on distances between pairs of amino acids, if you want
> to know) and am having a little trouble printing.
>
> One possible bug - "x.__str__()" and "x.__repr__()" show different
> typecodes.
> Example:
> >>> import MA
> >>> id = MA.identity(20)
> >>> r = MA.ones((20,20))*1.0
> >>> rm = MA.MaskedArray(r, mask=id)
> >>> rm # ie, call x.__repr__()
> array(data =
> array (20,20) , type = d, has 400 elements,
> mask =
> array (20,20) , type = 1, has 400 elements,
> fill_value=[ 1.00000002e+20,])
>
> >>> print rm # ie, call x.__str__()
> array (20,20) , type = O, has 400 elements
> >>>
>
> Secondly, I can't see how to make this print the whole thing if I want
> it. Which I do; all my matrices are 20*20 'cause there are 20 amino
> acids.
>
> The Numeric.array2string method can't be used because the data is always
> masked.
> The best I've found so far is to make a Numeric array by filling with an
> impossible number like -1, then use array2string. But visually it would
> be nicer to see the masked values as "--".
>
> Thanks for any help,
> regards,
> Cath
> Cath Lawrence, Cath.Lawrence at anu.edu.au
> Scientific Programmer, Centre for Bioinformation Science,
> John Curtin School of Medical Research
> Australian National University, Canberra ACT 0200
> ph: Maths (02) 6125 2904; JCSMR (02) 6125 0417;
> mobile: 0421-902694 fax: (02) 61254712
>
>
>
> -------------------------------------------------------
> This sf.net email is sponsored by:ThinkGeek
> Welcome to geek heaven.
> http://thinkgeek.com/sf
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/numpy-discussion
More information about the Numpy-discussion
mailing list