File tree Expand file tree Collapse file tree 2 files changed +37
-0
lines changed
Filter options
Expand file tree Collapse file tree 2 files changed +37
-0
lines changed
Original file line number Diff line number Diff line change
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.
Original file line number Diff line number Diff line change
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')
You can’t perform that action at this time.
0 commit comments