Skip to content

Conversation

zaz
Copy link
Contributor

@zaz zaz commented Jun 6, 2022

instead of from sympy.plotting.plot import plot_contour

Improve: issue #12034

  • plotting
    • Enable sympy.plotting.plot_contour

instead of `from sympy.plotting.plot import plot_contour`
@sympy-bot
Copy link

sympy-bot commented Jun 6, 2022

Hi, I am the SymPy bot (v167). I'm here to help you write a release notes entry. Please read the guide on how to write release notes.

Your release notes are in good order.

Here is what the release notes will look like:

  • plotting
    • Enable sympy.plotting.plot_contour (#23591 by @zaz)

This will be added to https://github.com/sympy/sympy/wiki/Release-Notes-for-1.11.

Click here to see the pull request description that was parsed.
instead of `from sympy.plotting.plot import plot_contour`

Improve: issue #12034

<!-- BEGIN RELEASE NOTES -->
* plotting
  * Enable `sympy.plotting.plot_contour`
<!-- END RELEASE NOTES -->

Update

The release notes on the wiki have been updated.

@zaz zaz mentioned this pull request Jun 6, 2022
@oscarbenjamin
Copy link
Collaborator

I guess it should probably be imported at top-level like from sympy import plot_contour.

@Davide-sd what do you think?

@zaz
Copy link
Contributor Author

zaz commented Jun 6, 2022

Why at the top level and not with the other plot functions under sympy.plotting.?

Is there something special about plot_contour vs plot3d?

What is the rationale behind putting some plot commands in the top level while others are under plotting? Is this just an inconvenience that has developed out of the need for backwards-compatibility?

It seems most sensible to have:

sympy.plot.plot()
          .3d()
          .contour()
          .
          .
          .

The way plotting commands are currently structured is just all around odd for me.

@github-actions
Copy link

github-actions bot commented Jun 6, 2022

Benchmark results from GitHub Actions

Lower numbers are good, higher numbers are bad. A ratio less than 1
means a speed up and greater than 1 means a slowdown. Green lines
beginning with + are slowdowns (the PR is slower then master or
master is slower than the previous release). Red lines beginning
with - are speedups.

Significantly changed benchmark results (PR vs master)

Significantly changed benchmark results (master vs previous release)

       before           after         ratio
     [77f1d79c]       [ae598245]
     <sympy-1.10.1^0>                 
+      88.4±0.5ms        159±0.9ms     1.80  sum.TimeSum.time_doit

Full benchmark results can be found as artifacts in GitHub Actions
(click on checks at the top of the PR).

@Davide-sd
Copy link
Contributor

I think it should be available both at the top level, from sympy import plot_contour, as well as from sympy.plotting import plot_contour. The last one is justified from by the fact that I have seen a couple of questions at StackOverflow about people importing plot functions from sympy.plotting. As a matter of fact, reading the documentation it is implied to use from sympy.plotting import plot_function_name.

@zaz
Copy link
Contributor Author

zaz commented Jun 7, 2022

It would be nice to have consistency with this: Either expose all the plotting functions at the top level, or keep them all in plotting, IMO. Personally, I think that changing the name of plotting to plot and removing plot_ gives us the best of both worlds; the user can do:

from sympy import plot
plot.3d(...)
plot.parametric()

Which has the same level of succinctness, but more versatility than importing from the top-level. Better yet, it allows the user to just import sympy as sp and still have a succinct way to make various kinds of plots, obviating the need to import plot functions explicitly.

The current sympy.plot() could be either retained permanently or deprecated using __call__:

>>> import sympy as sp
>>> class CallableModule(sp.__class__):
...     def __call__(self, **args):
...         sp.plotting.plot(**args)
... 
>>> sp.plotting.__class__ = CallableModule
>>> sp.plot = sp.plotting
>>> sp.plot()
>>> sp.plot.parametric()

@asmeurer
Copy link
Member

asmeurer commented Jun 8, 2022

This looks good. We should discuss the other changes in a new issue as they are more controversial since they would break compatibility.

@asmeurer asmeurer merged commit a96dce8 into sympy:master Jun 8, 2022
@zaz
Copy link
Contributor Author

zaz commented Nov 6, 2022

Thank you. I created a new issue for that: #23599

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

Successfully merging this pull request may close these issues.

5 participants