Skip to content

REF: misplaced formatting tests #55740

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 7 commits into from
Oct 28, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def test_info_categorical_column_smoke_test():
"float_frame",
"datetime_frame",
"duplicate_columns_frame",
"float_string_frame",
],
)
def test_info_smoke_test(fixture_func_name, request):
Expand All @@ -80,6 +81,19 @@ def test_info_smoke_test(fixture_func_name, request):
result = buf.getvalue().splitlines()
assert len(result) > 10

buf = StringIO()
frame.info(buf=buf, verbose=False)


def test_info_smoke_test2(float_frame):
# pretty useless test, used to be mixed into the repr tests
buf = StringIO()
float_frame.reindex(columns=["A"]).info(verbose=False, buf=buf)
float_frame.reindex(columns=["A", "B"]).info(verbose=False, buf=buf)

# no columns or index
DataFrame().info(buf=buf)


@pytest.mark.parametrize(
"num_columns, max_info_columns, verbose",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import pandas.io.formats.format as fmt


class TestDataFrameReprInfoEtc:
class TestDataFrameRepr:
def test_repr_bytes_61_lines(self):
# GH#12857
lets = list("ACDEFGHIJKLMNOP")
Expand Down Expand Up @@ -141,11 +141,8 @@ def test_repr_empty(self):
repr(frame)

def test_repr_mixed(self, float_string_frame):
buf = StringIO()

# mixed
repr(float_string_frame)
float_string_frame.info(verbose=False, buf=buf)

@pytest.mark.slow
def test_repr_mixed_big(self):
Expand All @@ -162,26 +159,11 @@ def test_repr_mixed_big(self):

repr(biggie)

def test_repr(self, float_frame):
buf = StringIO()

# small one
repr(float_frame)
float_frame.info(verbose=False, buf=buf)

# even smaller
float_frame.reindex(columns=["A"]).info(verbose=False, buf=buf)
float_frame.reindex(columns=["A", "B"]).info(verbose=False, buf=buf)

# exhausting cases in DataFrame.info

def test_repr(self):
# columns but no index
no_index = DataFrame(columns=[0, 1, 3])
repr(no_index)

# no columns or index
DataFrame().info(buf=buf)

df = DataFrame(["a\n\r\tb"], columns=["a\n\r\td"], index=["a\n\r\tf"])
assert "\t" not in repr(df)
assert "\r" not in repr(df)
Expand All @@ -204,7 +186,7 @@ def test_repr_big(self):
biggie = DataFrame(np.zeros((200, 4)), columns=range(4), index=range(200))
repr(biggie)

def test_repr_unsortable(self, float_frame):
def test_repr_unsortable(self):
# columns are not sortable

unsortable = DataFrame(
Expand All @@ -218,6 +200,9 @@ def test_repr_unsortable(self, float_frame):
)
repr(unsortable)

def test_repr_float_frame_options(self, float_frame):
repr(float_frame)

fmt.set_option("display.precision", 3)
repr(float_frame)

Expand Down Expand Up @@ -257,7 +242,7 @@ def test_str_to_bytes_raises(self):
with pytest.raises(TypeError, match=msg):
bytes(df)

def test_very_wide_info_repr(self):
def test_very_wide_repr(self):
df = DataFrame(
np.random.default_rng(2).standard_normal((10, 20)),
columns=np.array(["a" * 10] * 20, dtype=object),
Expand Down
10 changes: 10 additions & 0 deletions pandas/tests/indexes/multi/test_formats.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,3 +229,13 @@ def test_tuple_width(self, wide_multi_index):
('abc', 10, '2000-01-01 00:33:19', '2000-01-01 00:33:19', ...)],
names=['a', 'b', 'dti_1', 'dti_2', 'dti_3'], length=2000)"""
assert result == expected

def test_multiindex_long_element(self):
# Non-regression test towards GH#52960
data = MultiIndex.from_tuples([("c" * 62,)])

expected = (
"MultiIndex([('cccccccccccccccccccccccccccccccccccccccc"
"cccccccccccccccccccccc',)],\n )"
)
assert str(data) == expected
14 changes: 14 additions & 0 deletions pandas/tests/io/formats/test_eng_formatting.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,20 @@


class TestEngFormatter:
def test_eng_float_formatter2(self, float_frame):
df = float_frame
df.loc[5] = 0

fmt.set_eng_float_format()
repr(df)

fmt.set_eng_float_format(use_eng_prefix=True)
repr(df)

fmt.set_eng_float_format(accuracy=0)
repr(df)
tm.reset_display_options()

def test_eng_float_formatter(self):
df = DataFrame({"A": [1.41, 141.0, 14100, 1410000.0]})

Expand Down
Loading