#11787: error in creating graphics with numpy arrays
-----------------------------------------+----------------------------------
Reporter: jason | Owner: jason, was
Type: enhancement | Status: needs_review
Priority: major | Milestone: sage-5.6
Component: graphics | Resolution:
Keywords: | Work issues:
Report Upstream: N/A | Reviewers:
Authors: Punarbasu Purkayastha | Merged in:
Dependencies: | Stopgaps:
-----------------------------------------+----------------------------------
Changes (by {'newvalue': u'Punarbasu Purkayastha', 'oldvalue': ''}):
* status: new => needs_review
* author: => Punarbasu Purkayastha
Old description:
> #7570 should have been implemented by doing a len()==0 test, rather than
> a direct comparison to empty lists/dicts/etc. That allows things like
> numpy arrays, etc.
>
> I guess technically, numpy arrays aren't documented as being supported by
> list_plot, for example, so this might technically be an enhancement.
>
> See http://groups.google.com/group/sage-
> support/browse_thread/thread/fb53b9d908acfb4 for a discussion of this
> bug.
New description:
#7570 should have been implemented by doing a len()==0 test, rather than a
direct comparison to empty lists/dicts/etc. That allows things like numpy
arrays, etc.
I guess technically, numpy arrays aren't documented as being supported by
list_plot, for example, so this might technically be an enhancement.
See http://groups.google.com/group/sage-
support/browse_thread/thread/fb53b9d908acfb4 for a discussion of this bug.
----
Apply [attachment:trac_11787-allow_numpy_arrays.patch] to `devel/sage`
--
Comment:
Added patch to use numpy arrays. I am not happy with having to use len()
but I don't know of a better way or non-ugly way to ''not'' traverse the
whole list of input data. Hopefully, the impact to the running time is not
too high for large input lists or tuples.
The alternative to checking `len(data) == 0` was something like the
following (let's say we are calling `list_plot(data)`):
{{{#!python
import collections
if not isinstance(data, collections.Iterable):
raise TypeError
if isinstance(data, dict) and not data:
return Graphics()
try:
a = data[0]
except IndexError: # this means we have an iterable with no items
return Graphics()
}}}
If you would like me to patch up with this ugly kludge of a code instead
of the simple `len(data) == 0`, then let me know - I will put up a new
patch. :)
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/11787#comment:4>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en.