Skip to content

Reinstate & deprecate ContourSet.antialiased #26399

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

Merged
merged 1 commit into from
Jul 27, 2023

Conversation

rcomer
Copy link
Member

@rcomer rcomer commented Jul 27, 2023

PR summary

Closes #26343

As agreed on last week's call, reinstate antialiased as a deprecated property. Use all to get from the _antialiseds array to single bool on the way out.

There did not seem to be an existing get_ method so I added one. I've currently typed its output as NDArray, as that is what it will be due to the way the set_ method works. Would it better to type it as Sequence, consistent with other Collections.get_... methods?

PR checklist

@rcomer rcomer added Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. topic: contour labels Jul 27, 2023
@rcomer rcomer added this to the v3.8.0 milestone Jul 27, 2023
@rcomer rcomer force-pushed the contourset-antialias branch 5 times, most recently from cb30499 to 0ec8821 Compare July 27, 2023 12:05
Copy link
Member

@jklymak jklymak left a comment

Choose a reason for hiding this comment

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

Not sure about the typing question. @ksunden ?

@ksunden
Copy link
Member

ksunden commented Jul 27, 2023

Array is good, we have the normalization in there to ensure that the private variable is always an array (provided it goes through the setter)

The general principle is to be forgiving on inputs and specific on outputs, where possible (subclassing relationships can put some generalization pressure on outputs, in some cases, but usually not too much)

def antialiased(self):
return all(self.get_antialiased())

@antialiased.setter
Copy link
Member

Choose a reason for hiding this comment

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

deprecation needs to be added to the getter and setter individually (otherwise users who use only the setter will not be warned)

Copy link
Member Author

@rcomer rcomer Jul 27, 2023

Choose a reason for hiding this comment

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

This works for both - I've updated the test to show that. I also tried adding the deprecation to both but with different warning messages: this gave me both messages whether I was setting or getting.

In [3]: cs.antialiased = False
<ipython-input-3-e2ba4606272c>:1: MatplotlibDeprecationWarning: The antialiased attribute was deprecated in Matplotlib 3.8 and will be removed two minor releases later. Use set_antialiased instead.
  cs.antialiased = False
<ipython-input-3-e2ba4606272c>:1: MatplotlibDeprecationWarning: The antialiased attribute was deprecated in Matplotlib 3.8 and will be removed two minor releases later. Use get_antialiased instead. Note that get_antialiased returns an array.
  cs.antialiased = False

@@ -113,6 +112,8 @@ class ContourSet(ContourLabeler, Collection):
@property
def alpha(self) -> float | None: ...
@property
def antialiased(self) -> bool: ...
Copy link
Member

Choose a reason for hiding this comment

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

setter should be added to the pyi as well

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@rcomer rcomer force-pushed the contourset-antialias branch from 0ec8821 to 035d3e3 Compare July 27, 2023 17:18
@QuLogic QuLogic merged commit c12be12 into matplotlib:main Jul 27, 2023
@rcomer rcomer deleted the contourset-antialias branch July 27, 2023 19:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. topic: contour
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: ContourSet.antialiased attribute not present
4 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy