Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Adding 'api_changes' and 'whats_new' docs for PR #4172 #4191

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 2 commits into from
Mar 8, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions doc/api/api_changes/2015-03-03-LEO.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Added set_params function to all Locator types
````````````````````````````````````````````````

This was a bug fix targeted at making the api for Locators more consistent.

In the old behavior, only locators of type MaxNLocator have set_params()
defined, causing its use on any other Locator to throw an AttributeError *(
aside: set_params(args) is a function that sets the parameters of a Locator
instance to be as specified within args)*. The fix involves moving set_params()
to the Locator class such that all subtypes will have this function defined.

Since each of the Locator subtype have their own modifiable parameters, a
universal set_params() in Locator isn't ideal. Instead, a default no-operation
function that raises a warning is implemented in Locator. Subtypes extending
Locator will then override with their own implementations. Subtypes that do
not have a need for set_params() will fall back onto their parent's
implementation, which raises a warning as intended.

In the new behavior, all Locator instances will not throw an AttributeError
when set_param() is called. For Locators that do not implement set_params(),
the default implementation in Locator is used.
16 changes: 16 additions & 0 deletions doc/users/whats_new/2015-03-03_locator-set_params.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
API Consistency fix within Locators set_params() function
---------------------------------------------------------

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.

To use, simply call set_params() on a Locator instance with desired arguments:
::

loc = matplotlib.ticker.LogLocator()
# Set given attributes for loc.
loc.set_params(numticks=8, numdecs=8, subs=[2.0], base=8)
# The below will error, as there is no such parameter for LogLocator
# named foo
# loc.set_params(foo='bar')