Skip to content

Axes computation for constant function causes division by zero #4384

@rbeezer

Description

@rbeezer
mannequin

For a function which is constant, but not obviously so, it would appear that some computation for laying out the axis creates a step size of 0 (tick marks on the vertical axis?).

sage: h=plot(sin(x)^2+cos(x)^2, -6, 6)
sage: show(h)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/rob/.sage/sage_notebook/worksheets/admin/48/code/6.py", line 8, in <module>
    show(h)
  File "/opt/sage-3.1.4/local/lib/python2.5/site-packages/SQLAlchemy-0.4.6-py2.5.egg/", line 1, in <module>
    
  File "/opt/sage-3.1.4/local/lib/python2.5/site-packages/sage/misc/functional.py", line 882, in show
    return x.show(*args, **kwds)
  File "https://user-images.githubusercontent.com/124320864/216875280-eff9d44e-cdac-4be1-887f-d57a0e6c3deb.png.py", line 1350, in show
    hgridlinesstyle=hgridlinesstyle)
  File "https://user-images.githubusercontent.com/124320864/216875280-eff9d44e-cdac-4be1-887f-d57a0e6c3deb.png.py", line 1547, in save
    xmin, xmax, ymin, ymax = sage_axes.add_xy_axes(subplot, xmin, xmax, ymin, ymax)
  File "https://user-images.githubusercontent.com/124320864/216875280-eff9d44e-cdac-4be1-887f-d57a0e6c3deb.png/axes.py", line 325, in add_xy_axes
    x_axis_ypos, ystep, ytslminor, ytslmajor = self._find_axes(ymin, ymax)
  File "https://user-images.githubusercontent.com/124320864/216875280-eff9d44e-cdac-4be1-887f-d57a0e6c3deb.png/axes.py", line 239, in _find_axes
    tslmajor, oppaxis, step = self._tasteless_ticks(minval, maxval, 10)
  File "https://user-images.githubusercontent.com/124320864/216875280-eff9d44e-cdac-4be1-887f-d57a0e6c3deb.png/axes.py", line 217, in _tasteless_ticks
    tslmajor = sage.misc.misc.srange(minval, minval+(num_pieces+1)*step, step)
  File "/opt/sage-3.1.4/local/lib/python2.5/site-packages/sage/misc/misc.py", line 710, in srange
    count = int(math.ceil((float((end-start)/step))))
ZeroDivisionError: float division

CC: @sagetrac-anakha @jasongrout @sagetrac-mvngu

Component: graphics

Keywords: plot contant ZeroDivisionError

Issue created by migration from https://trac.sagemath.org/ticket/4384

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions