Opened 13 years ago

Closed 13 years ago

# unfriendly error message when plotting square roots of a function that is negative.

Reported by: Owned by: jason was major sage-2.10.2 graphics

### Description

This came up on IRC. The error (something about floats being unsubscriptable) does not indicate that the problem is that you are trying to plot the square root of a function that is negative in the plot interval. We should probably have a more friendly error message.

```sage: plot((1-x^2)^(0.5),(x,1,10))
---------------------------------------------------------------------------
<type 'exceptions.TypeError'>             Traceback (most recent call last)

3334             del kwds['show']
3335         if hasattr(funcs, 'plot'):
-> 3336             G = funcs.plot(*args, **kwds)
3337         # if we are using the generic plotting method
3338         else:

667         else:
668             f = self.function(param)
--> 669         return plot(f, *args, **kwds)
670
671     def __lt__(self, right):

3334             del kwds['show']
3335         if hasattr(funcs, 'plot'):
-> 3336             G = funcs.plot(*args, **kwds)
3337         # if we are using the generic plotting method
3338         else:

667         else:
668             f = self.function(param)
--> 669         return plot(f, *args, **kwds)
670
671     def __lt__(self, right):

3343             # if there is one extra arg, then it had better be a tuple
3344             elif n == 1:
-> 3345                 G = self._call(funcs, *args, **kwds)
3346             elif n == 2:
3347             # if ther eare two extra args, then pull them out and pass them as a tuple

3419         del options['plot_division']
3420         while i < len(data) - 1:
-> 3421             if abs(data[i+1][1] - data[i][1]) > max_bend:
3422                 x = (data[i+1][0] + data[i][0])/2
3423                 try:

<type 'exceptions.TypeError'>: 'float' object is unsubscriptable
```

### comment:1 Changed 13 years ago by jason

Or maybe we could even just put up a blank plot, but somehow print out a warning too that you are trying to plot imaginary numbers.

### comment:2 Changed 13 years ago by was

• Resolution set to duplicate
• Status changed from new to closed

This is a dupe of #2038.

Note: See TracTickets for help on using tickets.