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

sage.plot: Add/update # needs #36038

Merged
merged 21 commits into from
Aug 13, 2023
Merged

Conversation

mkoeppe
Copy link
Contributor

@mkoeppe mkoeppe commented Aug 5, 2023

📝 Checklist

  • The title is concise, informative, and self-explanatory.
  • The description explains in detail what this PR is about.
  • I have linked a relevant issue or discussion.
  • I have created tests covering the changes.
  • I have updated the documentation accordingly.

⌛ Dependencies

@mkoeppe mkoeppe force-pushed the needs_for_sage_plot branch from 1eb4390 to 6ff7f14 Compare August 5, 2023 23:35
....: region=lambda x,y,z: x<=t or y>=t or z<=t)
sage: a = animate([frame(t)
....: for t in srange(.01,1.5,.2)])
sage: a[0] # long time
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

L90 looks bad after splitting. Please insert spaces after commas.

Copy link
Contributor Author

@mkoeppe mkoeppe Aug 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess I made these changes before deciding to use a file-level tag for sage.symbolic. Undone now in 0754253

Copy link
Contributor

@dcoudert dcoudert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some questions, and some required changes.

....: region=lambda x,y,z: x<=t or y>=t or z<=t)
sage: a = animate([frame(t)
....: for t in srange(.01,1.5,.2)])
sage: a[0] # long time
Graphics3d Object
sage: a.show() # long time # optional -- ImageMagick
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to be sure, are both forms accepted ? # optional -- ImageMagick and # optional - ImageMagick

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of these forms accepted; sage -fixdoctests normalizes to the # optional - imagemagick form.

sage: a = animate(v, xmin=0, ymin=0, axes=False)
sage: print(a)
Animation with 3 frames
sage: a.show() # optional -- ImageMagick
sage: a.show() # optional - imagemagick
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ImageMagick ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I am normalizing in this file to # optional -- ImageMagick because that seemed to be the preference of the author

Copy link
Collaborator

@kwankyu kwankyu Aug 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we use uncapitalized names for all optional doctest tags, except this one? If we allow an exception, then the result would just be an inconsistency. I mean that some will use # optional - imagemagick anyway.

Is the author strong about this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing it to the fixdoctests normal form is also fine with me.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have other exceptions. For instance we use both gurobi and Gurobi:

xyz:sage dcoudert$ git grep "# optional - [gG]urobi" src/sage/
src/sage/combinat/matrices/dancing_links.pyx:            sage: d.to_milp('gurobi')   # optional - gurobi sage_numerical_backends_gurobi
src/sage/combinat/matrices/dancing_links.pyx:            sage: s = d.one_solution_using_milp_solver('gurobi') # optional - gurobi sage_numerical_backends_gurobi
src/sage/combinat/matrices/dancing_links.pyx:            sage: s in solutions                                 # optional - gurobi sage_numerical_backends_gurobi
src/sage/features/mip_backends.py:            sage: Gurobi()._is_present()  # optional - gurobi
src/sage/knots/link.py:            sage: L.plot(solver='Gurobi')  # optional - Gurobi
src/sage/numerical/backends/cvxpy_backend.pyx:        sage: p = MixedIntegerLinearProgram(solver="CVXPY/Gurobi"); p.solve()          # optional - gurobi
src/sage/numerical/mip.pyx:            sage: p = MixedIntegerLinearProgram(solver="gurobi")   # optional - Gurobi
src/sage/numerical/mip.pyx:            sage: p.add_constraint(p[0] - p[2], min=1, max=4)      # optional - Gurobi
src/sage/numerical/mip.pyx:            sage: p.number_of_variables()                          # optional - Gurobi

When running git grep "# optional - [[:upper:]]" src/sage/, we see occurrences of: # optional - SAGE_ROOT, # optional - CPLEX, # optional - Gurobi, # optional - Nonexistent_LP_solver, # optional - CHomP, # optional - FES , # optional - RSat.

I don't think we want to force the use of the uncapitalized form for SAGE_ROOT. At least we should be consistent inside a file.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All right then. I won't insist.

sage: import numpy as np
sage: from sage.plot.complex_plot import add_lightness_smoothing_to_rgb
sage: add_lightness_smoothing_to_rgb(np.array([[[0, 0.25, 0.5]]]), np.array([[0.75]])) # abs tol 1e-4
sage: import numpy as np # needs numpy
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

block scope here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

sage: p = plot(y, -4.1, 1.1)
sage: xlines = lambda a,b: [z for z,m in y.roots()]
sage: p.show(gridlines=[xlines, [0]], frame=True, axes=False)
sage: y = x^5 + 4*x^4 - 10*x^3 - 40*x^2 + 9*x + 36 # needs sage.symbolic
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

block scope

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 63dcc78


- ``phirange`` - A 2-tuple of the form `(\phi_{\min},\phi_{\max})`, (default `(0,\pi)`) that specifies the angle in which the curve is to be revolved.
- ``phirange`` -- A 2-tuple of the form `(\phi_{\min},\phi_{\max})`, (default `(0,\pi)`) that specifies the angle in which the curve is to be revolved.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could do the alignment on 80 columns

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Too much for this ticket

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, it's already a giant one ;)

sage: G += G.translate(2.3, 0, -.5)
sage: G += G.translate(3.5, 2, -1)
sage: G.show(aspect_ratio=1, frame=False)
sage: G += sum(Cylinder(.2, 1).translate(cos(2*pi*n/9), sin(2*pi*n/9), 0) # needs sage.symbolic
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

block scope ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 73a5b51

....: G.save_image(filename, **kwds)

sage: B = MyAnimation([graphs.CompleteGraph(n) for n in range(7,11)], figsize=5)
sage: B = MyAnimation([graphs.CompleteGraph(n)
....: for n in range(7,11)], figsize=5)
sage: d = B.png()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if we should count leading spaces to check 80 characters limit. 80 characters without counting leading spaces look fine in the rendered doc.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I've joined these lines in b5c1e8a

@@ -419,7 +420,8 @@ def y(x): return x*sin(x**2)

sage: g1 = plot(sin(x), 0, 2*pi)
sage: g2 = plot(cos(x), 0, 2*pi, linestyle="--")
sage: (g1+g2).show(ticks=pi/6, tick_formatter=pi) # long time # show their sum, nicely formatted
sage: (g1 + g2).show(ticks=pi/6, # show their sum, nicely formatted # long time
....: tick_formatter=pi)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The bot reports this alignement error. 4 spaces missing before ....:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, fixed in e5b62ef

@github-actions
Copy link

github-actions bot commented Aug 7, 2023

Documentation preview for this PR (built with commit e18852a; changes) is ready! 🎉

Copy link
Contributor

@dcoudert dcoudert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Aug 10, 2023

Thanks!

vbraun pushed a commit to vbraun/sage that referenced this pull request Aug 11, 2023
sagemathgh-36038: `sage.plot`: Add/update `# needs`
    
<!-- ^^^^^
Please provide a concise, informative and self-explanatory title.
Don't put issue numbers in there, do this in the PR body below.
For example, instead of "Fixes sagemath#1234" use "Introduce new method to
calculate 1+1"
-->
<!-- Describe your changes here in detail -->

<!-- Why is this change required? What problem does it solve? -->
<!-- If this PR resolves an open issue, please link to it here. For
example "Fixes sagemath#12345". -->
- Part of: sagemath#29705
- Cherry-picked from: sagemath#35095
<!-- If your change requires a documentation PR, please link it
appropriately. -->

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->
<!-- If your change requires a documentation PR, please link it
appropriately -->
<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
<!-- Feel free to remove irrelevant items. -->

- [x] The title is concise, informative, and self-explanatory.
- [ ] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation accordingly.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on
- sagemath#12345: short description why this is a dependency
- sagemath#34567: ...
-->

<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
    
URL: sagemath#36038
Reported by: Matthias Köppe
Reviewer(s): David Coudert, Kwankyu Lee, Matthias Köppe
@vbraun vbraun merged commit 47b6151 into sagemath:develop Aug 13, 2023
@mkoeppe mkoeppe added this to the sage-10.1 milestone Aug 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants