Skip to content

region_plot raises weird IndexError when y_min > y_max #35032

@seblabbe

Description

@seblabbe

Is there an existing issue for this?

  • I have searched the existing issues for a bug report that matches the one I want to file, without success.

Did you read the documentation and troubleshoot guide?

  • I have read the documentation and troubleshoot guide

Environment

- **OS**: Ubuntu 20.04
- **Sage Version**: SageMath version 9.8.beta1, Release Date: 2022-09-29

Steps To Reproduce

sage: region_plot(x+y>0, (x,-20,20), (y,20,-20))

Expected Behavior

A ValueError saying that y_min and y_max should satisfy y_min < y_max.

Actual Behavior

IndexError                                
Traceback (most recent call last)
Input In [168], in <cell line: 1>()
----> 1 region_plot(x+y>Integer(0), (x,-Integer(20),Integer(20)), (y, Integer(20),-Integer(20)))

File ~/GitBox/sage/src/sage/misc/decorators.py:491, in options.__call__.<locals>.wrapper(*args, **kwds)
    489     options['__original_opts'] = kwds
    490 options.update(kwds)
--> 491 return func(*args, **options)

File ~/GitBox/sage/src/sage/plot/contour_plot.py:1727, in region_plot(f, xrange, yrange, plot_points, incol, outcol, bordercol, borderstyle, borderwidth, alpha, **options)
   1723 g._set_extra_kwds(Graphics._extract_kwds_for_show(options,
   1724                                                   ignore=['xmin', 'xmax']))
   1726 if neqs == 0:
-> 1727     g.add_primitive(ContourPlot(xy_data_array, xrange, yrange,
   1728                                 dict(contours=[-1e-20, 0, 1e-20],
   1729                                      cmap=cmap,
   1730                                      fill=True, **options)))
   1731 else:
   1732     mask = numpy.asarray([[elt > 0 for elt in rows]
   1733                           for rows in xy_data_array],
   1734                          dtype=bool)

File ~/GitBox/sage/src/sage/plot/contour_plot.py:82, in ContourPlot.__init__(self, xy_data_array, xrange, yrange, options)
     80 self.xy_data_array = xy_data_array
     81 self.xy_array_row = len(xy_data_array)
---> 82 self.xy_array_col = len(xy_data_array[0])
     83 GraphicPrimitive.__init__(self, options)

IndexError: index 0 is out of bounds for axis 0 with size 0

Additional Information

The current error does not help the user to find the real problem.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions