Ticket #4465 (assigned defect)

Opened 2 months ago

Last modified 2 months ago

zero-length errors give division error instead of just drawing a point.

Reported by: jason Assigned to: jason (accepted)
Priority: major Milestone: sage-3.4
Component: graphics Keywords:
Cc:

Description

This is an error to a custom patch that we have to the matplotlib code so that we can have arrows that are shortened by a certain number of points.

This week, I was drawing plot vector field using two ways : (1) plot_vector_field and (2) by simply suming up plenty of arrows as I wished. Since their was a fixed point somewhere, I came up with the problem of drawing a zero length arrow. Using sage 3.1.4, I get a zero division error. Where is this division from? The example below show that it is not from the slope as it can draw a vertical arrow.

sage: arrow((1, 1), (2, 1))
sage: arrow((1, 1), (1, 2))
sage: arrow((1, 1), (1, 1))
---------------------------------------------------------------------------
ZeroDivisionError                         Traceback (most recent call last) :
...
/home/slabbe/sage/local/lib/python2.5/site-packages/matplotlib/arrow_line.pyc in draw(self, renderer)
    100         pixel_vector = (orig_t.transform_point(points[1]) - orig_t.transform_point(points[0]))
    101         pixel_length=math.sqrt(sum(pixel_vector**2))
--> 102         clip_fraction = renderer.points_to_pixels(self._arrowshorten)/pixel_length
    103         head_clip_fraction = renderer.points_to_pixels(self._arrowshorten+self._arrowheadlength*0.8)/pixel_length
    104

ZeroDivisionError: float division

In my problem, I would have been happy if arrow(x,x) would draw simply a point. I know I can define my own arrow but maybe sage's arrow could behave like myarrow ?

Change History

11/07/2008 07:04:10 PM changed by jason

  • owner changed from was to jason.
  • status changed from new to assigned.