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

add default legend_color to eliminate KeyError when plotting arrow2d or disk #36460

Merged
merged 2 commits into from
Oct 21, 2023

Conversation

DaveWitteMorris
Copy link
Member

Fixes #36153.

The line g._legend_colors = [options['legend_color']] appears in the code for seven graphics objects. Five of them (circle, ellipse, line2d, point2d, and polygon2d) set None as the default value for legend_color. The other two (arrow2d and disk) do not set a default, so a KeyError is raised if a legend_label is supplied, but no legend_color is specified. This bug was pointed out in #36153.

This PR adds None as the default value of legend_color in arrow2d and disk.

It also adds the corresponding doctest to all seven of these graphics objects, except line2d, which already has the example line([(0,0),(1,1)], legend_label='line').

The PR also corrects a typo in the docstring of the cone graphic object.

📝 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.

@DaveWitteMorris DaveWitteMorris changed the title add default legend_color to eliminate KeyError when plotting line2d or disk add default legend_color to eliminate KeyError when plotting arrow2d or disk Oct 13, 2023

Verify that :trac:`36153` is fixed::

sage: A = arrow2d((-1,-1), (2,3), legend_label="test")
"""
Copy link
Collaborator

Choose a reason for hiding this comment

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

:trac: --> :issue:

@kwankyu
Copy link
Collaborator

kwankyu commented Oct 14, 2023

Otherwise lgtm.

@DaveWitteMorris
Copy link
Member Author

Thanks, I didn't know that. I made the correction, so I think the PR is ready for review again.

Copy link
Collaborator

@kwankyu kwankyu left a comment

Choose a reason for hiding this comment

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

Thanks.

@DaveWitteMorris
Copy link
Member Author

Thanks!

vbraun pushed a commit to vbraun/sage that referenced this pull request Oct 15, 2023
… plotting arrow2d or disk

Fixes sagemath#36153.

The line `g._legend_colors = [options['legend_color']]` appears in the
code for seven graphics objects. Five of them (`circle`, `ellipse`,
`line2d`, `point2d`, and  `polygon2d`) set `None` as the default value
for `legend_color`. The other two (`arrow2d` and `disk`) do not set a
default, so a `KeyError` is raised if a `legend_label` is supplied, but
no `legend_color` is specified. This bug was pointed out in sagemath#36153.

This PR adds `None` as the default value of `legend_color` in `arrow2d`
and `disk`.

It also adds the corresponding doctest to all seven of these graphics
objects, except `line2d`, which already has the example
`line([(0,0),(1,1)], legend_label='line')`.

The PR also corrects a typo in the docstring of the `cone` graphic
object.

### 📝 Checklist

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

URL: sagemath#36460
Reported by: DaveWitteMorris
Reviewer(s): Kwankyu Lee
vbraun pushed a commit to vbraun/sage that referenced this pull request Oct 17, 2023
… plotting arrow2d or disk

    
Fixes sagemath#36153.

The line `g._legend_colors = [options['legend_color']]` appears in the
code for seven graphics objects. Five of them (`circle`, `ellipse`,
`line2d`, `point2d`, and  `polygon2d`) set `None` as the default value
for `legend_color`. The other two (`arrow2d` and `disk`) do not set a
default, so a `KeyError` is raised if a `legend_label` is supplied, but
no `legend_color` is specified. This bug was pointed out in sagemath#36153.

This PR adds `None` as the default value of `legend_color` in `arrow2d`
and `disk`.

It also adds the corresponding doctest to all seven of these graphics
objects, except `line2d`, which already has the example
`line([(0,0),(1,1)], legend_label='line')`.

The PR also corrects a typo in the docstring of the `cone` graphic
object.

### 📝 Checklist

- [x] The title is concise, informative, and self-explanatory.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [x] I have created tests covering the changes.
    
URL: sagemath#36460
Reported by: DaveWitteMorris
Reviewer(s): Kwankyu Lee
@vbraun vbraun merged commit 47b5eb9 into sagemath:develop Oct 21, 2023
19 of 27 checks passed
@mkoeppe mkoeppe added this to the sage-10.2 milestone Oct 21, 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.

When plotting, legend_color should default to black
4 participants