Skip to content

Commit 28fd9e9

Browse files
committed
Passed another unit check
1 parent 95e7730 commit 28fd9e9

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

pandas/core/indexes/base.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -488,9 +488,10 @@ def __new__(
488488
name = maybe_extract_name(name, data, cls)
489489

490490
if dtype is not None:
491-
if dtype == "str":
491+
if dtype == "str" and not isinstance(dtype, StringDtype):
492492
dtype = StringDtype(storage="python")
493-
dtype = pandas_dtype(dtype)
493+
else:
494+
dtype = pandas_dtype(dtype)
494495

495496
data_dtype = getattr(data, "dtype", None)
496497

@@ -569,7 +570,6 @@ def __new__(
569570

570571
try:
571572
arr = sanitize_array(data, None, dtype=dtype, copy=copy)
572-
# print(f"sanitize_array received dtype: {dtype}")
573573
except ValueError as err:
574574
if "index must be specified when data is not list-like" in str(err):
575575
raise cls._raise_scalar_data_error(data) from err

pandas/tests/indexes/categorical/test_formats.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,12 @@ def test_string_categorical_index_repr(self):
9696

9797
# multiple lines
9898
idx = CategoricalIndex(["あ", "いい", "ううう"] * 10)
99-
expected = """CategoricalIndex(['あ', 'いい', 'ううう', 'あ', 'いい', 'ううう', 'あ', 'いい',
99+
expected ="""CategoricalIndex(['あ', 'いい', 'ううう', 'あ', 'いい', 'ううう', 'あ', 'いい',
100100
'ううう', 'あ', 'いい', 'ううう', 'あ', 'いい', 'ううう',
101101
'あ', 'いい', 'ううう', 'あ', 'いい', 'ううう', 'あ', 'いい',
102102
'ううう', 'あ', 'いい', 'ううう', 'あ', 'いい', 'ううう'],
103103
categories=['あ', 'いい', 'ううう'],
104-
ordered=False, dtype='category')"""""
104+
ordered=False, dtype='category')"""
105105

106106
assert repr(idx) == expected
107107

@@ -121,6 +121,6 @@ def test_string_categorical_index_repr(self):
121121
'お', 'か', 'き', 'く', 'け', 'こ',
122122
'さ', 'し', 'す', 'せ', 'そ'],
123123
categories=['あ', 'い', 'う', 'え', ..., 'し', 'す', 'せ', 'そ'],
124-
ordered=False, dtype='category')"""""
124+
ordered=False, dtype='category')"""
125125

126126
assert repr(idx) == expected

0 commit comments

Comments
 (0)