Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
4 changes: 2 additions & 2 deletions pandas/tests/arrays/categorical/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ def test_rename_categories(self):
def test_rename_categories_wrong_length_raises(self, new_categories):
cat = Categorical(["a", "b", "c", "a"])
msg = (
"new categories need to have the same number of items as the"
" old categories!"
"new categories need to have the same number of items as the "
"old categories!"
)
with pytest.raises(ValueError, match=msg):
cat.rename_categories(new_categories)
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/arrays/categorical/test_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ def test_categories_assigments(self):
def test_categories_assigments_wrong_length_raises(self, new_categories):
cat = Categorical(["a", "b", "c", "a"])
msg = (
"new categories need to have the same number of items"
" as the old categories!"
"new categories need to have the same number of items "
"as the old categories!"
)
with pytest.raises(ValueError, match=msg):
cat.categories = new_categories
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/arrays/categorical/test_operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ def test_comparison_with_unknown_scalars(self):
cat = Categorical([1, 2, 3], ordered=True)

msg = (
"Cannot compare a Categorical for op __{}__ with a scalar,"
" which is not a category"
"Cannot compare a Categorical for op __{}__ with a scalar, "
"which is not a category"
)
with pytest.raises(TypeError, match=msg.format("lt")):
cat < 4
Expand Down
6 changes: 3 additions & 3 deletions pandas/tests/arrays/test_integer.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ def test_repr_array_long():
data = integer_array([1, 2, None] * 1000)
expected = (
"<IntegerArray>\n"
"[ 1, 2, NA, 1, 2, NA, 1, 2, NA, 1,\n"
" ...\n"
" NA, 1, 2, NA, 1, 2, NA, 1, 2, NA]\n"
"[ 1, 2, NA, 1, 2, NA, 1, 2, NA, 1,\n "
"...\n "
Copy link
Member

Choose a reason for hiding this comment

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

It feels like in this case the previous option is more natural. Since every line represents the content of a line if this was the content of a file.

So, for example, if we have a file:

XX
 X

It probably makes more sense to have:

data = (
    "XX\n"
    " X\n"
)

Than

data = (
    "XX\n "
    "X\n"
)

What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm I do get you're point.

so if I can check if the line is ending with a \n, it's OK for the next line to begin with a space? right?

correct me if I misunderstood

Copy link
Member

Choose a reason for hiding this comment

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

Yes, I think the rule could be that if one line finishes with \n, we don't really care what's in the next, it should always be ok.

But if you think it makes sense, you can revert these few lines for now, so we can merge this. And then we can see in more detail in the other PR (but I think it should just be that condition).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But if you think it makes sense, you can revert these few lines for now, so we can merge this. And then we can see in more detail in the other PR (but I think it should just be that condition).

Sure!

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, I think the rule could be that if one line finishes with \n, we don't really care what's in the next, it should always be ok.

Logic for this test case is now implemented at a4ec49e

"NA, 1, 2, NA, 1, 2, NA, 1, 2, NA]\n"
"Length: 3000, dtype: Int64"
)
result = repr(data)
Expand Down
14 changes: 7 additions & 7 deletions pandas/tests/arrays/test_period.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,13 +270,13 @@ def test_repr_large():
expected = (
"<PeriodArray>\n"
"['2000-01-01', '2001-01-01', '2000-01-01', '2001-01-01', "
"'2000-01-01',\n"
" '2001-01-01', '2000-01-01', '2001-01-01', '2000-01-01', "
"'2001-01-01',\n"
" ...\n"
" '2000-01-01', '2001-01-01', '2000-01-01', '2001-01-01', "
"'2000-01-01',\n"
" '2001-01-01', '2000-01-01', '2001-01-01', '2000-01-01', "
"'2000-01-01',\n "
"'2001-01-01', '2000-01-01', '2001-01-01', '2000-01-01', "
"'2001-01-01',\n "
"...\n "
"'2000-01-01', '2001-01-01', '2000-01-01', '2001-01-01', "
"'2000-01-01',\n "
"'2001-01-01', '2000-01-01', '2001-01-01', '2000-01-01', "
"'2001-01-01']\n"
"Length: 1000, dtype: period[D]"
)
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/frame/methods/test_quantile.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ def test_quantile_axis_parameter(self):
with pytest.raises(ValueError, match=msg):
df.quantile(0.1, axis=-1)
msg = (
"No axis named column for object type"
" <class 'pandas.core.frame.DataFrame'>"
"No axis named column for object type "
"<class 'pandas.core.frame.DataFrame'>"
)
with pytest.raises(ValueError, match=msg):
df.quantile(0.1, axis="column")
Expand Down
8 changes: 4 additions & 4 deletions pandas/tests/io/formats/test_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -2659,14 +2659,14 @@ def test_format_explicit(self):
assert exp == res
res = repr(test_sers["asc"])
exp = (
"0 a\n1 ab\n ... \n4 abcde\n5"
" abcdef\ndtype: object"
"0 a\n1 ab\n ... \n4 abcde\n5 "
"abcdef\ndtype: object"
)
assert exp == res
res = repr(test_sers["desc"])
exp = (
"5 abcdef\n4 abcde\n ... \n1 ab\n0"
" a\ndtype: object"
"5 abcdef\n4 abcde\n ... \n1 ab\n0 "
"a\ndtype: object"
)
assert exp == res

Expand Down
12 changes: 4 additions & 8 deletions pandas/tests/io/formats/test_style.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,20 +530,17 @@ def test_bar_align_left_0points(self):
(1, 0): [
"width: 10em",
" height: 80%",
"background: linear-gradient(90deg,#d65f5f 50.0%,"
" transparent 50.0%)",
"background: linear-gradient(90deg,#d65f5f 50.0%, transparent 50.0%)",
],
(1, 1): [
"width: 10em",
" height: 80%",
"background: linear-gradient(90deg,#d65f5f 50.0%,"
" transparent 50.0%)",
"background: linear-gradient(90deg,#d65f5f 50.0%, transparent 50.0%)",
],
(1, 2): [
"width: 10em",
" height: 80%",
"background: linear-gradient(90deg,#d65f5f 50.0%,"
" transparent 50.0%)",
"background: linear-gradient(90deg,#d65f5f 50.0%, transparent 50.0%)",
],
(2, 0): [
"width: 10em",
Expand Down Expand Up @@ -572,8 +569,7 @@ def test_bar_align_left_0points(self):
(0, 1): [
"width: 10em",
" height: 80%",
"background: linear-gradient(90deg,#d65f5f 50.0%,"
" transparent 50.0%)",
"background: linear-gradient(90deg,#d65f5f 50.0%, transparent 50.0%)",
],
(0, 2): [
"width: 10em",
Expand Down
14 changes: 7 additions & 7 deletions pandas/tests/io/formats/test_to_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
import pandas.io.formats.format as fmt

lorem_ipsum = (
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod"
" tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim"
" veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex"
" ea commodo consequat. Duis aute irure dolor in reprehenderit in"
" voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur"
" sint occaecat cupidatat non proident, sunt in culpa qui officia"
" deserunt mollit anim id est laborum."
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod "
"tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim "
"veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex "
"ea commodo consequat. Duis aute irure dolor in reprehenderit in "
"voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur "
"sint occaecat cupidatat non proident, sunt in culpa qui officia "
"deserunt mollit anim id est laborum."
)


Expand Down
8 changes: 4 additions & 4 deletions pandas/tests/io/test_stata.py
Original file line number Diff line number Diff line change
Expand Up @@ -1296,8 +1296,8 @@ def test_write_variable_label_errors(self):
}

msg = (
"Variable labels must contain only characters that can be"
" encoded in Latin-1"
"Variable labels must contain only characters that can be "
"encoded in Latin-1"
)
with pytest.raises(ValueError, match=msg):
with tm.ensure_clean() as path:
Expand Down Expand Up @@ -1467,8 +1467,8 @@ def test_out_of_range_float(self):

original.loc[2, "ColumnTooBig"] = np.inf
msg = (
"Column ColumnTooBig has a maximum value of infinity which"
" is outside the range supported by Stata"
"Column ColumnTooBig has a maximum value of infinity which "
"is outside the range supported by Stata"
)
with pytest.raises(ValueError, match=msg):
with tm.ensure_clean() as path:
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/series/indexing/test_boolean.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,8 @@ def test_where_error():
with pytest.raises(ValueError, match=msg):
s[[True, False]] = [0, 2, 3]
msg = (
"NumPy boolean array indexing assignment cannot assign 0 input"
" values to the 1 output values where the mask is true"
"NumPy boolean array indexing assignment cannot assign 0 input "
"values to the 1 output values where the mask is true"
)
with pytest.raises(ValueError, match=msg):
s[[True, False]] = []
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/series/indexing/test_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,8 @@ def test_getitem_dataframe():
s = pd.Series(10, index=rng)
df = pd.DataFrame(rng, index=rng)
msg = (
"Indexing a Series with DataFrame is not supported,"
" use the appropriate DataFrame column"
"Indexing a Series with DataFrame is not supported, "
"use the appropriate DataFrame column"
)
with pytest.raises(TypeError, match=msg):
s[df > 5]
Expand Down
3 changes: 1 addition & 2 deletions pandas/tests/series/methods/test_rank.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,7 @@ def test_rank_signature(self):
s = Series([0, 1])
s.rank(method="average")
msg = (
"No axis named average for object type"
" <class 'pandas.core.series.Series'>"
"No axis named average for object type <class 'pandas.core.series.Series'>"
)
with pytest.raises(ValueError, match=msg):
s.rank("average")
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/series/methods/test_sort_values.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ def test_sort_values(self, datetime_series):
s = df.iloc[:, 0]

msg = (
"This Series is a view of some other array, to sort in-place"
" you must create a copy"
"This Series is a view of some other array, to sort in-place "
"you must create a copy"
)
with pytest.raises(ValueError, match=msg):
s.sort_values(inplace=True)
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/series/test_alter_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ def test_setindex(self, string_series):

# wrong length
msg = (
"Length mismatch: Expected axis has 30 elements, new"
" values have 29 elements"
"Length mismatch: Expected axis has 30 elements, "
"new values have 29 elements"
)
with pytest.raises(ValueError, match=msg):
string_series.index = np.arange(len(string_series) - 1)
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/series/test_missing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1180,8 +1180,8 @@ def test_interpolate_index_values(self):
def test_interpolate_non_ts(self):
s = Series([1, 3, np.nan, np.nan, np.nan, 11])
msg = (
"time-weighted interpolation only works on Series or DataFrames"
" with a DatetimeIndex"
"time-weighted interpolation only works on Series or DataFrames "
"with a DatetimeIndex"
)
with pytest.raises(ValueError, match=msg):
s.interpolate(method="time")
Expand Down
5 changes: 1 addition & 4 deletions pandas/tests/series/test_timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,10 +501,7 @@ def test_between_time_raises(self):
def test_between_time_types(self):
# GH11818
rng = date_range("1/1/2000", "1/5/2000", freq="5min")
msg = (
r"Cannot convert arg \[datetime\.datetime\(2010, 1, 2, 1, 0\)\]"
" to a time"
)
msg = r"Cannot convert arg \[datetime\.datetime\(2010, 1, 2, 1, 0\)\] to a time"
with pytest.raises(ValueError, match=msg):
rng.indexer_between_time(datetime(2010, 1, 2, 1), datetime(2010, 1, 2, 5))

Expand Down