Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better error messages for bad arrow plots #10925

Open
kcrisman opened this issue Mar 13, 2011 · 12 comments
Open

Better error messages for bad arrow plots #10925

kcrisman opened this issue Mar 13, 2011 · 12 comments

Comments

@kcrisman
Copy link
Member

The error messages for bad arrow setups are somewhat amusing.

sage: version()
'Sage Version 4.6.2, Release Date: 2011-02-25'
sage: arrow([1,2,1],[2,1])
ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (2, 0))

ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (844, 0))

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)

/Applications/MathApps/sage/local/lib/python2.6/site-packages/sage/plot/arrow.pyc in arrow(tailpoint, headpoint, **kwds)
    342     except ValueError:
    343         from sage.plot.plot3d.shapes import arrow3d
--> 344         return arrow3d(tailpoint, headpoint, **kwds)
    345 
    346 @rename_keyword(color='rgbcolor')

/Applications/MathApps/sage/local/lib/python2.6/site-packages/sage/misc/decorators.pyc in wrapper(*args, **kwds)
    571                     kwds[new_name] = kwds[old_name]
    572                     del kwds[old_name]
--> 573             return func(*args, **kwds)
    574         
    575         return wrapper

/Applications/MathApps/sage/local/lib/python2.6/site-packages/sage/plot/plot3d/shapes.so in sage.plot.plot3d.shapes.arrow3d (sage/plot/plot3d/shapes.c:5870)()

/Applications/MathApps/sage/local/lib/python2.6/site-packages/sage/structure/element.so in sage.structure.element.ModuleElement.__sub__ (sage/structure/element.c:8080)()

/Applications/MathApps/sage/local/lib/python2.6/site-packages/sage/structure/coerce.so in sage.structure.coerce.CoercionModel_cache_maps.bin_op (sage/structure/coerce.c:6996)()

TypeError: unsupported operand parent(s) for '-': 'Vector space of dimension 2 over Real Double Field' and 'Vector space of dimension 3 over Real Double Field'

and

sage: arrow([1],[1])
ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (2, 0))

---------------------------------------------------------------------------
ArithmeticError                           Traceback (most recent call last)
/Applications/MathApps/sage/local/lib/python2.6/site-packages/sage/plot/arrow.pyc in arrow(tailpoint, headpoint, **kwds)
    342     except ValueError:
    343         from sage.plot.plot3d.shapes import arrow3d
--> 344         return arrow3d(tailpoint, headpoint, **kwds)
    345 
    346 @rename_keyword(color='rgbcolor')

/Applications/MathApps/sage/local/lib/python2.6/site-packages/sage/misc/decorators.pyc in wrapper(*args, **kwds)
    571                     kwds[new_name] = kwds[old_name]
    572                     del kwds[old_name]
--> 573             return func(*args, **kwds)
    574         
    575         return wrapper

/Applications/MathApps/sage/local/lib/python2.6/site-packages/sage/plot/plot3d/shapes.so in sage.plot.plot3d.shapes.arrow3d (sage/plot/plot3d/shapes.c:6038)()

/Applications/MathApps/sage/local/lib/python2.6/site-packages/sage/modules/free_module_element.so in sage.modules.free_module_element.FreeModuleElement.cross_product (sage/modules/free_module_element.c:10882)()

ArithmeticError: Cross product only defined for vectors of length three or seven, not (3 and 1)

I leave the traces in for those who want to fix this; tentatively saying beginner. Ideally, we should plot one-dimensional arrows as well (such as how we plot one-dimensional vectors), or should this remain impossible?

CC: @jasongrout @sagetrac-ryan

Component: graphics

Work Issues: doctest bad cases, does not apply

Author: Phillip Wilt

Branch/Commit: u/kkiviat/ticket/10925 @ 4bc5203

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

@kcrisman

This comment has been minimized.

@sagetrac-philwilt
Copy link
Mannequin

sagetrac-philwilt mannequin commented May 29, 2014

Branch: u/philwilt/ticket/10925

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented May 30, 2014

Commit: b271d85

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented May 30, 2014

Branch pushed to git repo; I updated commit sha1. New commits:

c34e581Added ability to plot 1-dimensional arrows (similar to plotting 1-dimensional vectors) into a 2-D plane.
b271d85Updated docs for arrow2d

@kcrisman
Copy link
Member Author

comment:5

This seems really complicated. Would it be easier to just do

try:
    if len(headpoint) !=  len(tail point):
        stuff
    elif
except TypeError # kind of error when you ask for len of something that doesn't have it
    make into lists like you do

I get what this code is doing but I'm afraid it's going to be hard to maintain. I don't know how much of an efficiency gain your solution might be, though, or maybe there are too many cases anyway no matter how you do it.

What do you think? By the way, it needs doctests of the "bad" cases (there should be examples of traceback doctesting in nearby code, I think, for sure elsewhere in the plot modules). Thanks for working on this, it's close!

@kcrisman
Copy link
Member Author

Work Issues: doctest bad cases

@sagetrac-kkiviat
Copy link
Mannequin

sagetrac-kkiviat mannequin commented Mar 4, 2017

Changed branch from u/philwilt/ticket/10925 to u/kkiviat/ticket/10925

@sagetrac-kkiviat
Copy link
Mannequin

sagetrac-kkiviat mannequin commented Mar 5, 2017

New commits:

1fdac98Merge branch 'master' into t/10925/ticket/10925
c1a39a3Reorganized doctests and added tests that raise exceptions
4bc5203Reorganized if-statements to be more concise

@sagetrac-kkiviat
Copy link
Mannequin

sagetrac-kkiviat mannequin commented Mar 5, 2017

Changed commit from b271d85 to 4bc5203

@saraedum
Copy link
Member

Author: Phillip Wilt

@saraedum
Copy link
Member

saraedum commented Jan 6, 2018

Changed work issues from doctest bad cases to doctest bad cases, does not apply

@DaveWitteMorris
Copy link
Member

comment:11

Removing the "beginner" tag from old tickets. Some could be returned to beginner-friendly status by adding a comment about what needs to be done. Some others might be easy for an experienced developer to finish.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants