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

make Graphics.plot refuses argument #19539

Closed
videlec opened this issue Nov 6, 2015 · 18 comments
Closed

make Graphics.plot refuses argument #19539

videlec opened this issue Nov 6, 2015 · 18 comments

Comments

@videlec
Copy link
Contributor

videlec commented Nov 6, 2015

Currently Graphics.plot ignore all input arguments which make the following very confusing

sage: S = circle((0,0), 1)
sage: T = S.plot(aspect_ratio=2)
sage: T.aspect_ratio()
1.0

We simply disallow arguments in order to have

sage: S.plot(aspect_ratio=1)
Traceback (most recent call last):
...
TypeError: plot() got an unexpected keyword argument 'aspect_ratio'

CC: @sagetrac-mhs @kcrisman

Component: graphics

Author: Vincent Delecroix

Branch/Commit: a322663

Reviewer: Nathann Cohen

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

@videlec videlec added this to the sage-6.10 milestone Nov 6, 2015
@videlec
Copy link
Contributor Author

videlec commented Nov 6, 2015

Branch: u/vdelecroix/19539

@videlec
Copy link
Contributor Author

videlec commented Nov 6, 2015

New commits:

e374128Trac 19539: remove args and kwds in Graphics.plot

@videlec
Copy link
Contributor Author

videlec commented Nov 6, 2015

Commit: e374128

@nathanncohen
Copy link
Mannequin

nathanncohen mannequin commented Nov 6, 2015

comment:2

Just adding a comment to say that I admire your courage.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Nov 6, 2015

Changed commit from e374128 to 03dbb2e

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Nov 6, 2015

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

03dbb2eTrac 19539: fix doctests

@videlec
Copy link
Contributor Author

videlec commented Nov 6, 2015

comment:4

Replying to @nathanncohen:

Just adding a comment to say that I admire your courage.

What about a courageous review?

@nathanncohen
Copy link
Mannequin

nathanncohen mannequin commented Nov 7, 2015

comment:5

What about a courageous review?

Let's try:

-    if hasattr(funcs, 'plot'):
+    if isinstance(funcs, Graphics):
+        G = funcs
+    elif hasattr(funcs, 'plot'):

Why would you ignore (without warning) the contents of *args and **kwds when 'funcs' is a Graphics object? It seems as bad as what you try to fix in this branch.

Nathann

@videlec
Copy link
Contributor Author

videlec commented Nov 7, 2015

comment:6

More or less. Graphics is precisely the class that implemented

def plot(self, *args, **kwds):
    return self

And nobody inherits from it.

I did it because some code is calling plot(x)... you are right that it would be better to fix it instead.

What do you think that the following should do

sage: C = circle((0,0), 1)
sage: plot(C, aspect_ratio=2)

It used to return C unchanged and it still does. What my code is modifying is

sage: C.plot(aspect_ratio=2)
... -> error

@nathanncohen
Copy link
Mannequin

nathanncohen mannequin commented Nov 7, 2015

comment:7

Hello,

What do you think that the following should do

sage: C = circle((0,0), 1)
sage: plot(C, aspect_ratio=2)

It used to return C unchanged and it still does. What my code is modifying is

If it ignores the 'aspect_ratio=2' argument then it should raise an exception instead, exactly as you do it in this branch for C.plot(whatever=3)?

Nathann

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Nov 7, 2015

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

41dcc53Trac 19539: revert the change to the function plot
82f3805Trac 19539: fix ode_solver.plot_solutions

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Nov 7, 2015

Changed commit from 03dbb2e to 82f3805

@videlec
Copy link
Contributor Author

videlec commented Nov 7, 2015

comment:9

done!

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Nov 7, 2015

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

a322663Trac 19539: fix more doctests

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Nov 7, 2015

Changed commit from 82f3805 to a322663

@nathanncohen
Copy link
Mannequin

nathanncohen mannequin commented Nov 7, 2015

comment:11

Looks good. Thank you for this branch,

Nathann

@nathanncohen
Copy link
Mannequin

nathanncohen mannequin commented Nov 7, 2015

Reviewer: Nathann Cohen

@vbraun
Copy link
Member

vbraun commented Nov 8, 2015

Changed branch from u/vdelecroix/19539 to a322663

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

2 participants