Skip to content

ENH: EngFormatter new kwarg 'sep' #6542

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
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
5a550f2
ENH: Add the space_sep option to EngFormatter, and docstring updates
afvincent Jun 6, 2016
722f5d6
FIX: force format_eng(-0.0) to be consistent with format_eng(0)
afvincent Jun 6, 2016
3c221ff
Fix docstrings and comments (remove leading spaces)
afvincent Jun 7, 2016
122cfa2
Simplify and move cleaning strip op. from 'format_eng' to '__call__'
afvincent Jun 7, 2016
07f022d
DOC: update the api example engineering_formatter.py
afvincent Jun 19, 2016
e371e5a
More extensive testing of EngFormatter (including 'space_sep' param)
afvincent Feb 11, 2017
3049a2d
space_sep=bool <- sep=string, and adapt tests
afvincent Feb 12, 2017
e0a2ec8
remove unnecessary trailing 'u' characters in strings
afvincent Feb 12, 2017
1621a2d
fix EngFormatter docstring: escape Unicode character codes
afvincent Feb 12, 2017
c82dcff
'fix' docstring: unindent and reorder bullet list + mention regular t…
afvincent Feb 12, 2017
f09a1b4
Update the example
afvincent Feb 12, 2017
dc9409b
fix test docstring PEP8 errors in test_ticker.py
afvincent Feb 12, 2017
0195beb
Add a 'whats_new' entry
afvincent Feb 12, 2017
3ec1dbd
docstring overhaul: fix bullet list and merge duplicated infos betwee…
afvincent Feb 13, 2017
cd2ac88
use named entities instead of raw unicode codes
afvincent Aug 17, 2017
7f1422c
stop mixing C-style and format-based formatting
afvincent Aug 17, 2017
aba7a7f
Small example tweaking to avoid label cluttering
afvincent Aug 17, 2017
b75f20d
fix an issue with {:g} and str format
afvincent Aug 17, 2017
41a69da
get rid of decimal.Decimal + fix rounding special cases like 999.9...
afvincent Aug 19, 2017
556ec20
Fix the related rounding discrepancies in test_ticker
afvincent Aug 19, 2017
a9af431
(try) fix(ing) an exception about raising an int to a negative power
afvincent Aug 19, 2017
0bde03a
fix some anntzer's comments
afvincent Aug 20, 2017
c98ba91
more complete handling of corner-case roundings + add proper tests
afvincent Aug 20, 2017
60b95ab
Fix some additional remarks made by anntzer
afvincent Aug 21, 2017
ac42b94
Deprecate passing a string as *num* argument
afvincent Aug 24, 2017
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
Prev Previous commit
Deprecate passing a string as *num* argument
  • Loading branch information
afvincent committed Aug 25, 2017
commit ac42b94e990e878a2b831cf3e4382cf6cb40a1b5
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Deprecation in EngFormatter
```````````````````````````

Passing a string as *num* argument when calling an instance of
`matplotlib.ticker.EngFormatter` is deprecated and will be removed in 2.3.
6 changes: 6 additions & 0 deletions lib/matplotlib/ticker.py
Original file line number Diff line number Diff line change
Expand Up @@ -1262,6 +1262,12 @@ def format_eng(self, num):
`num` may be a numeric value or a string that can be converted
to a numeric value with ``float(num)``.
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we actually have a use case for supporting this? Could this behavior be deprecated? (this is not strictly needed for the PR)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

String were accepted before so I let it here. But other formatter classes do not seems to support such a feature, so if one thinks it is not worth supporting it anymore, it could be deprecated indeed.

Copy link
Contributor Author

@afvincent afvincent Aug 24, 2017

Choose a reason for hiding this comment

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

Note to myself: add a deprecation warning for 2.1 (=> removing in 2.3?). (Have a look at #8040 to remember how to do it...)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Deprecated in f207c89

"""
if isinstance(num, six.string_types):
warnings.warn(
"Passing a string as *num* argument is deprecated since"
"Matplotlib 2.1, and is expected to be removed in 2.3.",
mplDeprecation)

dnum = float(num)
sign = 1
fmt = "g" if self.places is None else ".{:d}f".format(self.places)
Expand Down