8000 Added api_changes and whats_new docs on bug fix for issue #3658, PR #… · wypd/matplotlib@7fae906 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7fae906

Browse files
committed
Added api_changes and whats_new docs on bug fix for issue matplotlib#3658, PR matplotlib#4172
1 parent 6387fca commit 7fae906

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
Added set_params function to all Locator types
2+
````````````````````````````````````````````````
3+
4+
This was a bug fix targeted at making the api for Locators more consistent.
5+
6+
In the old behavior, only locators of type MaxNLocator have set_params()
7+
available, causing its use on any other Locator to throw an AttributeError *(
8+
aside: set_params(args) is a function that sets the parameters of a Locator
9+
instance to be as specified within args)*. Since MaxNLocator itself is a
10+
subtype of Locator, the fix will involve the moving of set_params()to the
11+
Locator class.
12+
13+
Since each of the Locator subtype have their own modifiable parameters, a
14+
universal set_params() in Locator isn't ideal. Instead, a default no-operation
15+
function that raises a warning is implemented in Locator. Subtypes extending
16+
Locator will then override with their own implementations. Subtypes that do
17+
not have a need for set_params() will fall back onto their parent's
18+
implementation, which raises a warning as intended.
19+
20+
In the new behavior, all Locator instances will not throw an AttributeError
21+
when set_param() is called. For Locators that do not implement set_params(),
22+
the default implementation in Locator is used.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
API Consistency fix within Locators set_params() function
2+
---------------------------------------------------------
3+
4+
set_params() function, which sets parameters within a Locator type instance, is now available to all Locator types. The implementation also prevents unsafe usage by strictly defining the parameters that a user can set.
5+
6+
To use, simply initialize a Locator type, and call set_params() with desired arguments: ::
7+
8+
loc = matplotlib.ticker.LogLocator()
9+
# Set given attributes for loc.
10+
loc.set_params(numticks=8, numdecs=8, subs=[2.0], base=8)
11+
# The below will error, as there is no such parameter for LogLocator
12+
# named foo
13+
# loc.set_params(foo='bar')

0 commit comments

Comments
 (0)
0