Skip to content

Removed unnecessary dict calls #38319

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 1 commit into from
Dec 7, 2020
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
18 changes: 9 additions & 9 deletions pandas/tests/io/parser/test_quoting.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
@pytest.mark.parametrize(
"kwargs,msg",
[
(dict(quotechar="foo"), '"quotechar" must be a(n)? 1-character string'),
({"quotechar": "foo"}, '"quotechar" must be a(n)? 1-character string'),
(
dict(quotechar=None, quoting=csv.QUOTE_MINIMAL),
{"quotechar": None, "quoting": csv.QUOTE_MINIMAL},
"quotechar must be set if quoting enabled",
),
(dict(quotechar=2), '"quotechar" must be string, not int'),
({"quotechar": 2}, '"quotechar" must be string, not int'),
],
)
def test_bad_quote_char(all_parsers, kwargs, msg):
Expand Down Expand Up @@ -72,7 +72,7 @@ def test_quote_char_various(all_parsers, quote_char):
@pytest.mark.parametrize("quoting", [csv.QUOTE_MINIMAL, csv.QUOTE_NONE])
@pytest.mark.parametrize("quote_char", ["", None])
def test_null_quote_char(all_parsers, quoting, quote_char):
kwargs = dict(quotechar=quote_char, quoting=quoting)
kwargs = {"quotechar": quote_char, "quoting": quoting}
data = "a,b,c\n1,2,3"
parser = all_parsers

Expand All @@ -91,17 +91,17 @@ def test_null_quote_char(all_parsers, quoting, quote_char):
@pytest.mark.parametrize(
"kwargs,exp_data",
[
(dict(), [[1, 2, "foo"]]), # Test default.
({}, [[1, 2, "foo"]]), # Test default.
# QUOTE_MINIMAL only applies to CSV writing, so no effect on reading.
(dict(quotechar='"', quoting=csv.QUOTE_MINIMAL), [[1, 2, "foo"]]),
({"quotechar": '"', "quoting": csv.QUOTE_MINIMAL}, [[1, 2, "foo"]]),
# QUOTE_MINIMAL only applies to CSV writing, so no effect on reading.
(dict(quotechar='"', quoting=csv.QUOTE_ALL), [[1, 2, "foo"]]),
({"quotechar": '"', "quoting": csv.QUOTE_ALL}, [[1, 2, "foo"]]),
# QUOTE_NONE tells the reader to do no special handling
# of quote characters and leave them alone.
(dict(quotechar='"', quoting=csv.QUOTE_NONE), [[1, 2, '"foo"']]),
({"quotechar": '"', "quoting": csv.QUOTE_NONE}, [[1, 2, '"foo"']]),
# QUOTE_NONNUMERIC tells the reader to cast
# all non-quoted fields to float
(dict(quotechar='"', quoting=csv.QUOTE_NONNUMERIC), [[1.0, 2.0, "foo"]]),
({"quotechar": '"', "quoting": csv.QUOTE_NONNUMERIC}, [[1.0, 2.0, "foo"]]),
],
)
def test_quoting_various(all_parsers, kwargs, exp_data):
Expand Down
18 changes: 9 additions & 9 deletions pandas/tests/io/parser/test_usecols.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,14 +477,14 @@ def test_incomplete_first_row(all_parsers, usecols):
(
"19,29,39\n" * 2 + "10,20,30,40",
[0, 1, 2],
dict(header=None),
{"header": None},
DataFrame([[19, 29, 39], [19, 29, 39], [10, 20, 30]]),
),
# see gh-9549
(
("A,B,C\n1,2,3\n3,4,5\n1,2,4,5,1,6\n1,2,3,,,1,\n1,2,3\n5,6,7"),
["A", "B", "C"],
dict(),
{},
DataFrame(
{
"A": [1, 3, 1, 1, 1, 5],
Expand All @@ -507,39 +507,39 @@ def test_uneven_length_cols(all_parsers, data, usecols, kwargs, expected):
[
(
["a", "b", "c", "d"],
dict(),
{},
DataFrame({"a": [1, 5], "b": [2, 6], "c": [3, 7], "d": [4, 8]}),
None,
),
(
["a", "b", "c", "f"],
dict(),
{},
None,
_msg_validate_usecols_names.format(r"\['f'\]"),
),
(["a", "b", "f"], dict(), None, _msg_validate_usecols_names.format(r"\['f'\]")),
(["a", "b", "f"], {}, None, _msg_validate_usecols_names.format(r"\['f'\]")),
(
["a", "b", "f", "g"],
dict(),
{},
None,
_msg_validate_usecols_names.format(r"\[('f', 'g'|'g', 'f')\]"),
),
# see gh-14671
(
None,
dict(header=0, names=["A", "B", "C", "D"]),
{"header": 0, "names": ["A", "B", "C", "D"]},
DataFrame({"A": [1, 5], "B": [2, 6], "C": [3, 7], "D": [4, 8]}),
None,
),
(
["A", "B", "C", "f"],
dict(header=0, names=["A", "B", "C", "D"]),
{"header": 0, "names": ["A", "B", "C", "D"]},
None,
_msg_validate_usecols_names.format(r"\['f'\]"),
),
(
["A", "B", "f"],
dict(names=["A", "B", "C", "D"]),
{"names": ["A", "B", "C", "D"]},
None,
_msg_validate_usecols_names.format(r"\['f'\]"),
),
Expand Down