Thanks, Thierry! I already found an alternative way to do what I wanted, using
from scipy.stats.mstats import mquantiles However, I thought that the examples in the documentation should work in the sage notebook without fundamentally changing the syntax, and hence I considered this a bug. Otherwise I would have asked the question on ask.sagemath, as you suggested. I think I have run into similar problems when using sage functions on numpy objects or vice versa before. If preparser(False) is a general solution to avoid similar problems, should this be included in the documentation somewhere? Cheers, Stan On Wednesday, February 25, 2015 at 5:19:27 PM UTC+1, Thierry (sage-googlesucks@xxx) wrote: > > Hi, > > The reason is that 75 is preparsed into a Sage integer. If you want to use > Python int, just do: > > sage: np.percentile(a, 75r) > 6.25 > > or > > sage: np.percentile(a, int(75)) > 6.25 > > If you want to turn Sage preparser off, just do > > sage: preparser(False) > sage: np.percentile(a, 75) > 6.25 > > Note that http://ask.sagemath.org is more appropriate for such questions. > > Ciao, > Thierry > > > > On Wed, Feb 25, 2015 at 08:13:35AM -0800, Stan wrote: > > Dear all, > > > > I just ran into a bug in sage, which is reproducible both in my local > Sage > > 6.3, 6.5 and on sage-cloud using the sage notebook but not when using > > iPython, i.e. it seems to really be a sage bug, not a numpy bug. > > Any ideas what might be the reason? > > > > Just using the syntax from the numpy.percentile docstring gives: > > ┌────────────────────────────────────────────────────────────────────┐ > > │ Sage Version 6.3, Release Date: 2014-08-10 │ > > │ Type "notebook()" for the browser-based notebook interface. │ > > │ Type "help()" for help. │ > > └────────────────────────────────────────────────────────────────────┘ > > sage: import numpy as np > > sage: a = np.array([[10, 7, 4], [3, 2, 1]]) > > sage: np.percentile(a, 75) > > > --------------------------------------------------------------------------- > > TypeError Traceback (most recent call > last) > > <ipython-input-4-54a2b61d0a48> in <module>() > > ----> 1 np.percentile(a, Integer(75)) > > > > > /home/sschyman/Programs/sage/local/lib/python2.7/site-packages/numpy/lib/function_base.py > > > > in percentile(a, q, axis, out, overwrite_input) > > 2818 axis = 0 > > 2819 > > -> 2820 return _compute_qth_percentile(sorted, q, axis, out) > > 2821 > > 2822 # handle sequence of q's without calling sort multiple times > > > > > /home/sschyman/Programs/sage/local/lib/python2.7/site-packages/numpy/lib/function_base.py > > > > in _compute_qth_percentile(sorted, q, axis, out) > > 2824 if not isscalar(q): > > 2825 p = [_compute_qth_percentile(sorted, qi, axis, None) > > -> 2826 for qi in q] > > 2827 > > 2828 if out is not None: > > > > TypeError: 'sage.rings.integer.Integer' object is not iterable > > > > Cheers > > Stan > > > > -- > > You received this message because you are subscribed to the Google > Groups "sage-devel" group. > > To unsubscribe from this group and stop receiving emails from it, send > an email to [email protected] <javascript:>. > > To post to this group, send email to [email protected] > <javascript:>. > > Visit this group at http://groups.google.com/group/sage-devel. > > For more options, visit https://groups.google.com/d/optout. > > -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
