Skip to content

TST: Check float format in object column (#35603) #41668

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 9 commits into from
May 27, 2021

Conversation

mdhsieh
Copy link
Contributor

@mdhsieh mdhsieh commented May 25, 2021

This test checks if a Series cast to object still shows data in float format.

Ran pytest pandas/tests/series/test_constructors.py
Output:

================================================= test session starts =================================================
platform win32 -- Python 3.8.10, pytest-6.2.4, py-1.10.0, pluggy-0.13.1
rootdir: C:\Users\mdhsi\pandas-michael, configfile: pyproject.toml
plugins: hypothesis-6.12.0, asyncio-0.14.0, cov-2.11.1, forked-1.3.0, instafail-0.4.1, xdist-2.2.1
collected 301 items

pandas\tests\series\test_constructors.py .......................................................................................................................................................................................................x.....................................................................................................

--------------------------- generated xml file: C:\Users\mdhsi\pandas-michael\test-data.xml ---------------------------
================================================ slowest 30 durations =================================================
0.25s call     pandas/tests/series/test_constructors.py::TestSeriesConstructors::test_empty_constructor[<lambda>-True0]
0.13s call     pandas/tests/series/test_constructors.py::TestSeriesConstructorIndexCoercion::test_series_constructor_datetimelike_index_coercion
0.09s call     pandas/tests/series/test_constructors.py::TestSeriesConstructors::test_constructor_data_aware_dtype_naive['dateutil/US/Pacific'-True]
0.04s call     pandas/tests/series/test_constructors.py::TestSeriesConstructors::test_constructor_dtype_datetime64_10
0.02s call     pandas/tests/series/test_constructors.py::TestSeriesConstructors::test_constructor_empty[OrderedDict]
0.02s call     pandas/tests/series/test_constructors.py::TestSeriesConstructors::test_constructor_empty[dict]
0.02s call     pandas/tests/series/test_constructors.py::TestSeriesConstructors::test_constructor_cant_cast_datetimelike[PeriodIndex]
0.02s call     pandas/tests/series/test_constructors.py::TestSeriesConstructors::test_constructor_cant_cast_datetimelike[DatetimeIndex]
0.02s call     pandas/tests/series/test_constructors.py::TestSeriesConstructors::test_constructor_cant_cast_datetimelike[TimedeltaIndex]
0.02s setup    pandas/tests/series/test_constructors.py::TestSeriesConstructors::test_constructor_datetimelike_scalar_to_string_dtype[string]
0.02s call     pandas/tests/series/test_constructors.py::TestSeriesConstructors::test_constructor_pass_none
0.02s call     pandas/tests/series/test_constructors.py::TestSeriesConstructors::test_constructor_categorical_with_coercion
0.02s call     pandas/tests/series/test_constructors.py::TestSeriesConstructors::test_constructor_dtype_timedelta64
0.01s call     pandas/tests/series/test_constructors.py::TestSeriesConstructors::test_constructor_data_aware_dtype_naive[pytz.FixedOffset(300)-False]
0.01s call     pandas/tests/series/test_constructors.py::TestSeriesConstructors::test_constructor_data_aware_dtype_naive['Asia/Tokyo'-True]
0.01s call     pandas/tests/series/test_constructors.py::TestSeriesConstructors::test_constructor_data_aware_dtype_naive[pytz.FixedOffset(300)-True]
0.01s call     pandas/tests/series/test_constructors.py::TestSeriesConstructors::test_constructor_data_aware_dtype_naive[tzlocal()-False]
0.01s call     pandas/tests/series/test_constructors.py::TestSeriesConstructors::test_constructor_data_aware_dtype_naive['dateutil/Asia/Singapore'-False]
0.01s call     pandas/tests/series/test_constructors.py::TestSeriesConstructors::test_constructor_data_aware_dtype_naive[datetime.timezone(datetime.timedelta(seconds=3600))-False]
0.01s call     pandas/tests/series/test_constructors.py::TestSeriesConstructors::test_constructor_data_aware_dtype_naive[tzutc()-False]
0.01s call     pandas/tests/series/test_constructors.py::TestSeriesConstructors::test_constructor_data_aware_dtype_naive['+01:15'-True]
0.01s call     pandas/tests/series/test_constructors.py::TestSeriesConstructors::test_constructor
0.01s call     pandas/tests/series/test_constructors.py::TestSeriesConstructors::test_constructor_data_aware_dtype_naive['UTC'-False]
0.01s call     pandas/tests/series/test_constructors.py::TestSeriesConstructors::test_constructor_data_aware_dtype_naive['UTC-02:15'-True]
0.01s call     pandas/tests/series/test_constructors.py::TestSeriesConstructors::test_constructor_data_aware_dtype_naive[tzlocal()-True]
0.01s call     pandas/tests/series/test_constructors.py::TestSeriesConstructors::test_constructor_data_aware_dtype_naive[pytz.FixedOffset(-300)-True]
0.01s call     pandas/tests/series/test_constructors.py::TestSeriesConstructors::test_constructor_data_aware_dtype_naive['dateutil/Asia/Singapore'-True]
0.01s call     pandas/tests/series/test_constructors.py::TestSeriesConstructors::test_constructor_data_aware_dtype_naive['UTC'-True]
0.01s call     pandas/tests/series/test_constructors.py::TestSeriesConstructors::test_constructor_data_aware_dtype_naive['-02:15'-False]
0.01s call     pandas/tests/series/test_constructors.py::TestSeriesConstructors::test_constructor_data_aware_dtype_naive[pytz.FixedOffset(-300)-False]
=========================================== 300 passed, 1 xfailed in 2.22s ============================================

@pep8speaks
Copy link

pep8speaks commented May 25, 2021

Hello @mdhsieh! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2021-05-27 17:30:45 UTC

@mzeitlin11
Copy link
Member

Thanks for the pr @mdhsieh! If you look at the linked issue, we actually want to be testing output formatting, not construction. The test should essentially make sure that printing the series from the issue gives the expected result (hardcoded as a string).

@mzeitlin11 mzeitlin11 added Output-Formatting __repr__ of pandas objects, to_string Testing pandas testing functions or related to the test suite labels May 26, 2021
@mdhsieh
Copy link
Contributor Author

mdhsieh commented May 26, 2021

Oh ok, I'll change it. Should the test be moved to tests/series/test_repr folder then?

mdhsieh added 2 commits May 26, 2021 10:28
Needs to be rewritten to check formatting not construction.
Checks if series representation matches expected String.
@mzeitlin11
Copy link
Member

Oh ok, I'll change it. Should the test be moved to tests/series/test_repr folder then?

Either there or pandas/tests/io/formats/test_format.py, not 100% sure so whichever looks like it has more similar tests to the one you write. (will be easy to change location once test is written, so don't worry too much about it :)

@jreback jreback added this to the 1.3 milestone May 27, 2021
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.

pls merge master and fix the linting issues.

@@ -240,6 +240,15 @@ def test_series_repr_nat(self):
)
assert result == expected

def test_float_repr_in_frame(self):
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 remove _in_frame (as this a series).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, sure.

mdhsieh added 4 commits May 27, 2021 10:03
It is a Series not a DataFrame.
Failed pre-commit check since want 2 newlines before defining class,
but only had 1.
@jreback jreback merged commit 1a20d13 into pandas-dev:master May 27, 2021
@jreback
Copy link
Contributor

jreback commented May 27, 2021

thanks @mdhsieh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Output-Formatting __repr__ of pandas objects, to_string Testing pandas testing functions or related to the test suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: Incorrect float format in object column
4 participants