Skip to content
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

BUG: Display precision doesn't affect complex float numbers #25514 #25745

Merged
merged 8 commits into from
Apr 12, 2019

Conversation

sakarpanta
Copy link
Contributor

@sakarpanta sakarpanta commented Mar 16, 2019

@codecov
Copy link

codecov bot commented Mar 16, 2019

Codecov Report

Merging #25745 into master will decrease coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #25745      +/-   ##
==========================================
- Coverage   91.25%   91.25%   -0.01%     
==========================================
  Files         172      172              
  Lines       52977    52979       +2     
==========================================
+ Hits        48343    48344       +1     
- Misses       4634     4635       +1
Flag Coverage Δ
#multiple 89.82% <100%> (ø) ⬆️
#single 41.74% <50%> (ø) ⬆️
Impacted Files Coverage Δ
pandas/core/frame.py 96.79% <ø> (ø) ⬆️
pandas/io/formats/format.py 98% <100%> (ø) ⬆️
pandas/util/testing.py 88.98% <0%> (-0.1%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 65c0441...0e1f3b6. Read the comment docs.

@codecov
Copy link

codecov bot commented Mar 16, 2019

Codecov Report

Merging #25745 into master will decrease coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #25745      +/-   ##
==========================================
- Coverage    91.9%   91.89%   -0.02%     
==========================================
  Files         175      175              
  Lines       52485    52501      +16     
==========================================
+ Hits        48235    48244       +9     
- Misses       4250     4257       +7
Flag Coverage Δ
#multiple 90.44% <100%> (-0.01%) ⬇️
#single 40.73% <27.27%> (-0.16%) ⬇️
Impacted Files Coverage Δ
pandas/core/frame.py 96.79% <ø> (-0.12%) ⬇️
pandas/io/formats/format.py 97.91% <100%> (+0.01%) ⬆️
pandas/io/gbq.py 75% <0%> (-12.5%) ⬇️
pandas/core/sparse/frame.py 95.5% <0%> (-0.2%) ⬇️
pandas/compat/__init__.py 77.5% <0%> (-0.15%) ⬇️
pandas/plotting/_core.py 83.77% <0%> (-0.09%) ⬇️
pandas/core/computation/expr.py 96.7% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e02ec8f...3fd69e9. Read the comment docs.

@gfyoung gfyoung added Output-Formatting __repr__ of pandas objects, to_string Numeric Operations Arithmetic, Comparison, and Logical operations labels Mar 16, 2019
Copy link
Member

@WillAyd WillAyd left a comment

Choose a reason for hiding this comment

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

Can you add a whatsnew for v0.25?

@simonjayhawkins
Copy link
Member

does this also change the notebook display? if so can we have a test for to_html() with notebook =True and False.

@@ -1417,6 +1417,18 @@ def test_to_string_float_index(self):
'5.0 4')
assert result == expected

def test_to_string_complex_float_formatting(self):
fmt.set_option('display.precision', 5)
Copy link
Member

Choose a reason for hiding this comment

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

do we need to use the context manger here?

Copy link
Contributor

Choose a reason for hiding this comment

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

yep

Copy link
Contributor

Choose a reason for hiding this comment

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

can you use the context manager here

@jreback
Copy link
Contributor

jreback commented Apr 5, 2019

can you merge master and see if you can update

@sakarpanta
Copy link
Contributor Author

can you merge master and see if you can update

Done.

2 1 1.0 (1+0j) 1 True
3 1 1.0 (1+0j) 1 True
4 1 1.0 (1+0j) 1 True
int64 float64 complex128 object bool
Copy link
Contributor

Choose a reason for hiding this comment

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

is there an extra space here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. Good catch! Thanks.

@@ -1094,7 +1097,10 @@ def format_values_with(float_format):
for val in values.ravel()[imask]])

if self.fixed_width:
return _trim_zeros(values, na_rep)
if is_complex:
Copy link
Contributor

Choose a reason for hiding this comment

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

you can do the type check right here instead of above

Copy link
Contributor Author

@sakarpanta sakarpanta Apr 11, 2019

Choose a reason for hiding this comment

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

The problem with that is at that point the values object has been reassigned as values = np.array(values, dtype='object') and is no longer a complex type but an array with the complex numbers (or floats) as strings.

@@ -1417,6 +1417,18 @@ def test_to_string_float_index(self):
'5.0 4')
assert result == expected

def test_to_string_complex_float_formatting(self):
fmt.set_option('display.precision', 5)
Copy link
Contributor

Choose a reason for hiding this comment

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

can you use the context manager here

(0.2739442392974528 + 0.23515228785438969j),
(0.26974928742135185 + 0.3250604054898979j)]})
result = df.to_string()
expected = (' x\n0 0.44678+0.07152j\n'
Copy link
Contributor

Choose a reason for hiding this comment

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

do these have an extra space?

Copy link
Contributor Author

@sakarpanta sakarpanta Apr 11, 2019

Choose a reason for hiding this comment

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

No, this is how it would display normally.

Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

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

minor change. ping on green.

@@ -1370,6 +1370,18 @@ def test_to_string_float_index(self):
'5.0 4')
assert result == expected

def test_to_string_complex_float_formatting(self):
with pd.option_context('display.precision', 5):
Copy link
Contributor

Choose a reason for hiding this comment

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

can you add the gh issue number as a comment

@jreback jreback added this to the 0.25.0 milestone Apr 12, 2019
@jreback jreback merged commit 90a85e0 into pandas-dev:master Apr 12, 2019
@jreback
Copy link
Contributor

jreback commented Apr 12, 2019

thanks @sakarpanta

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Numeric Operations Arithmetic, Comparison, and Logical operations Output-Formatting __repr__ of pandas objects, to_string
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Display precision doesn't affect complex float numbers
5 participants