-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
ENH: Make print_thing respect display.precision for Real numbers #60613
base: main
Are you sure you want to change the base?
ENH: Make print_thing respect display.precision for Real numbers #60613
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR!
escape_chars = list(escape_chars.keys()) | ||
else: | ||
escape_chars = escape_chars or () | ||
|
||
result = str(thing) | ||
# Real instance kontrolü ve precision uygulaması | ||
if isinstance(thing, Real) and not isinstance(thing, int): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you use is_float
from padnas.core.dtypes.inference
escape_chars = list(escape_chars.keys()) | ||
else: | ||
escape_chars = escape_chars or () | ||
|
||
result = str(thing) | ||
# Real instance kontrolü ve precision uygulaması |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment repeats the code verbatim and can be removed. Also, can you make any comments in English.
import pytest | ||
|
||
from pandas._config.config import option_context # option_context |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you remove the comment
@@ -155,6 +158,13 @@ def test_east_asian_len(self): | |||
assert adj.len("パンダpanda") == 11 | |||
assert adj.len("パンダpanda") == 10 | |||
|
|||
def test_pprint_thing_real_precision(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you move to TestPPrintThing above
@@ -155,6 +158,13 @@ def test_east_asian_len(self): | |||
assert adj.len("パンダpanda") == 11 | |||
assert adj.len("パンダpanda") == 10 | |||
|
|||
def test_pprint_thing_real_precision(self): | |||
with option_context('display.precision', 3): | |||
assert pprint_thing(3.14159265359) == "3.142" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use printing.pprint_thing
instead, as the other tests here do
closes ENH: How about let pprint_thing print Real instance according to display.precision #60503
Tests added and passed:
All code checks passed
Added type annotations for clarity in modified functions
Added an entry in the latest doc/source/whatsnew/vX.X.X.rst file:
- Enhanced print_thing to respect display.precision setting for Real numbers
This PR modifies the print_thing function to respect display.precision settings when formatting Real numbers. For example: