8000 Merge pull request #4191 from leeonadoh/master · matplotlib/matplotlib@b755043 · GitHub
[go: up one dir, main page]

Skip to content

Commit b755043

Browse files
committed
Merge pull request #4191 from leeonadoh/master
DOC : Adding 'api_changes' and 'whats_new' docs for PR #4172
2 parents ac335d9 + 3308d45 commit b755043

File tree

2 files changed

+37
-0
lines changed

2 files changed

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

0 commit comments

Comments
 (0)
0