Skip to content

Commit 262eedd

Browse files
REF (string dtype): rename using_pyarrow_string_dtype to using_string_dtype
1 parent d6c9941 commit 262eedd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+117
-163
lines changed

pandas/_config/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@
3030
from pandas._config.display import detect_console_encoding
3131

3232

33-
def using_pyarrow_string_dtype() -> bool:
33+
def using_string_dtype() -> bool:
3434
_mode_options = _global_config["future"]
3535
return _mode_options["infer_string"]

pandas/_libs/lib.pyx

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ from cython cimport (
3737
floating,
3838
)
3939

40-
from pandas._config import using_pyarrow_string_dtype
40+
from pandas._config import using_string_dtype
4141

4242
from pandas._libs.missing import check_na_tuples_nonequal
4343

@@ -2699,7 +2699,7 @@ def maybe_convert_objects(ndarray[object] objects,
26992699
seen.object_ = True
27002700

27012701
elif seen.str_:
2702-
if using_pyarrow_string_dtype() and is_string_array(objects, skipna=True):
2702+
if using_string_dtype() and is_string_array(objects, skipna=True):
27032703
from pandas.core.arrays.string_ import StringDtype
27042704

27052705
dtype = StringDtype(storage="pyarrow_numpy")

pandas/core/construction.py

+3-7
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import numpy as np
1717
from numpy import ma
1818

19-
from pandas._config import using_pyarrow_string_dtype
19+
from pandas._config import using_string_dtype
2020

2121
from pandas._libs import lib
2222
from pandas._libs.tslibs import (
@@ -571,11 +571,7 @@ def sanitize_array(
571571
if not is_list_like(data):
572572
if index is None:
573573
raise ValueError("index must be specified when data is not list-like")
574-
if (
575-
isinstance(data, str)
576-
and using_pyarrow_string_dtype()
577-
and original_dtype is None
578-
):
574+
if isinstance(data, str) and using_string_dtype() and original_dtype is None:
579575
from pandas.core.arrays.string_ import StringDtype
580576

581577
dtype = StringDtype("pyarrow_numpy")
@@ -609,7 +605,7 @@ def sanitize_array(
609605
subarr = data
610606
if data.dtype == object and infer_object:
611607
subarr = maybe_infer_to_datetimelike(data)
612-
elif data.dtype.kind == "U" and using_pyarrow_string_dtype():
608+
elif data.dtype.kind == "U" and using_string_dtype():
613609
from pandas.core.arrays.string_ import StringDtype
614610

615611
dtype = StringDtype(storage="pyarrow_numpy")

pandas/core/dtypes/cast.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
import numpy as np
2020

21-
from pandas._config import using_pyarrow_string_dtype
21+
from pandas._config import using_string_dtype
2222

2323
from pandas._libs import (
2424
Interval,
@@ -798,7 +798,7 @@ def infer_dtype_from_scalar(val) -> tuple[DtypeObj, Any]:
798798
# coming out as np.str_!
799799

800800
dtype = _dtype_obj
801-
if using_pyarrow_string_dtype():
801+
if using_string_dtype():
802802
from pandas.core.arrays.string_ import StringDtype
803803

804804
dtype = StringDtype(storage="pyarrow_numpy")

pandas/core/internals/construction.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import numpy as np
1515
from numpy import ma
1616

17-
from pandas._config import using_pyarrow_string_dtype
17+
from pandas._config import using_string_dtype
1818

1919
from pandas._libs import lib
2020

@@ -301,7 +301,7 @@ def ndarray_to_mgr(
301301
bp = BlockPlacement(slice(len(columns)))
302302
nb = new_block_2d(values, placement=bp, refs=refs)
303303
block_values = [nb]
304-
elif dtype is None and values.dtype.kind == "U" and using_pyarrow_string_dtype():
304+
elif dtype is None and values.dtype.kind == "U" and using_string_dtype():
305305
dtype = StringDtype(storage="pyarrow_numpy")
306306

307307
obj_columns = list(values)

pandas/io/feather_format.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
)
99
import warnings
1010

11-
from pandas._config import using_pyarrow_string_dtype
11+
from pandas._config import using_string_dtype
1212

1313
from pandas._libs import lib
1414
from pandas.compat._optional import import_optional_dependency
@@ -131,7 +131,7 @@ def read_feather(
131131
with get_handle(
132132
path, "rb", storage_options=storage_options, is_text=False
133133
) as handles:
134-
if dtype_backend is lib.no_default and not using_pyarrow_string_dtype():
134+
if dtype_backend is lib.no_default and not using_string_dtype():
135135
with warnings.catch_warnings():
136136
warnings.filterwarnings(
137137
"ignore",
@@ -155,7 +155,7 @@ def read_feather(
155155
elif dtype_backend == "pyarrow":
156156
return pa_table.to_pandas(types_mapper=pd.ArrowDtype)
157157

158-
elif using_pyarrow_string_dtype():
158+
elif using_string_dtype():
159159
return pa_table.to_pandas(types_mapper=arrow_string_types_mapper())
160160
else:
161161
raise NotImplementedError

pandas/io/orc.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
Literal,
1010
)
1111

12-
from pandas._config import using_pyarrow_string_dtype
12+
from pandas._config import using_string_dtype
1313

1414
from pandas._libs import lib
1515
from pandas.compat._optional import import_optional_dependency
@@ -136,7 +136,7 @@ def read_orc(
136136
df = pa_table.to_pandas(types_mapper=mapping.get)
137137
return df
138138
else:
139-
if using_pyarrow_string_dtype():
139+
if using_string_dtype():
140140
types_mapper = arrow_string_types_mapper()
141141
else:
142142
types_mapper = None

pandas/io/parquet.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
filterwarnings,
1616
)
1717

18-
from pandas._config import using_pyarrow_string_dtype
18+
from pandas._config import using_string_dtype
1919

2020
from pandas._libs import lib
2121
from pandas.compat._optional import import_optional_dependency
@@ -257,7 +257,7 @@ def read(
257257
to_pandas_kwargs["types_mapper"] = mapping.get
258258
elif dtype_backend == "pyarrow":
259259
to_pandas_kwargs["types_mapper"] = pd.ArrowDtype # type: ignore[assignment]
260-
elif using_pyarrow_string_dtype():
260+
elif using_string_dtype():
261261
to_pandas_kwargs["types_mapper"] = arrow_string_types_mapper()
262262

263263
path_or_handle, handles, filesystem = _get_path_or_handle(

pandas/io/parsers/arrow_parser_wrapper.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from typing import TYPE_CHECKING
44
import warnings
55

6-
from pandas._config import using_pyarrow_string_dtype
6+
from pandas._config import using_string_dtype
77

88
from pandas._libs import lib
99
from pandas.compat._optional import import_optional_dependency
@@ -301,7 +301,7 @@ def read(self) -> DataFrame:
301301
dtype_mapping = _arrow_dtype_mapping()
302302
dtype_mapping[pa.null()] = pd.Int64Dtype()
303303
frame = table.to_pandas(types_mapper=dtype_mapping.get)
304-
elif using_pyarrow_string_dtype():
304+
elif using_string_dtype():
305305
frame = table.to_pandas(types_mapper=arrow_string_types_mapper())
306306

307307
else:

pandas/io/pytables.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
from pandas._config import (
3131
config,
3232
get_option,
33-
using_pyarrow_string_dtype,
33+
using_string_dtype,
3434
)
3535

3636
from pandas._libs import (
@@ -3294,7 +3294,7 @@ def read(
32943294
index = self.read_index("index", start=start, stop=stop)
32953295
values = self.read_array("values", start=start, stop=stop)
32963296
result = Series(values, index=index, name=self.name, copy=False)
3297-
if using_pyarrow_string_dtype() and is_string_array(values, skipna=True):
3297+
if using_string_dtype() and is_string_array(values, skipna=True):
32983298
result = result.astype("string[pyarrow_numpy]")
32993299
return result
33003300

@@ -3363,7 +3363,7 @@ def read(
33633363

33643364
columns = items[items.get_indexer(blk_items)]
33653365
df = DataFrame(values.T, columns=columns, index=axes[1], copy=False)
3366-
if using_pyarrow_string_dtype() and is_string_array(values, skipna=True):
3366+
if using_string_dtype() and is_string_array(values, skipna=True):
33673367
df = df.astype("string[pyarrow_numpy]")
33683368
dfs.append(df)
33693369

@@ -4735,9 +4735,9 @@ def read(
47354735
else:
47364736
# Categorical
47374737
df = DataFrame._from_arrays([values], columns=cols_, index=index_)
4738-
if not (using_pyarrow_string_dtype() and values.dtype.kind == "O"):
4738+
if not (using_string_dtype() and values.dtype.kind == "O"):
47394739
assert (df.dtypes == values.dtype).all(), (df.dtypes, values.dtype)
4740-
if using_pyarrow_string_dtype() and is_string_array(
4740+
if using_string_dtype() and is_string_array(
47414741
values, # type: ignore[arg-type]
47424742
skipna=True,
47434743
):

pandas/io/sql.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
import numpy as np
3333

34-
from pandas._config import using_pyarrow_string_dtype
34+
from pandas._config import using_string_dtype
3535

3636
from pandas._libs import lib
3737
from pandas.compat._optional import import_optional_dependency
@@ -2197,7 +2197,7 @@ def read_table(
21972197
from pandas.io._util import _arrow_dtype_mapping
21982198

21992199
mapping = _arrow_dtype_mapping().get
2200-
elif using_pyarrow_string_dtype():
2200+
elif using_string_dtype():
22012201
from pandas.io._util import arrow_string_types_mapper
22022202

22032203
arrow_string_types_mapper()

pandas/tests/arithmetic/test_object.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import numpy as np
99
import pytest
1010

11-
from pandas._config import using_pyarrow_string_dtype
11+
from pandas._config import using_string_dtype
1212

1313
import pandas.util._test_decorators as td
1414

@@ -303,7 +303,7 @@ def test_iadd_string(self):
303303
index += "_x"
304304
assert "a_x" in index
305305

306-
@pytest.mark.xfail(using_pyarrow_string_dtype(), reason="add doesn't work")
306+
@pytest.mark.xfail(using_string_dtype(), reason="add doesn't work")
307307
def test_add(self):
308308
index = pd.Index([str(i) for i in range(10)])
309309
expected = pd.Index(index.values * 2)

pandas/tests/arrays/categorical/test_constructors.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import numpy as np
77
import pytest
88

9-
from pandas._config import using_pyarrow_string_dtype
9+
from pandas._config import using_string_dtype
1010

1111
from pandas.core.dtypes.common import (
1212
is_float_dtype,
@@ -442,7 +442,7 @@ def test_constructor_str_unknown(self):
442442
with pytest.raises(ValueError, match="Unknown dtype"):
443443
Categorical([1, 2], dtype="foo")
444444

445-
@pytest.mark.xfail(using_pyarrow_string_dtype(), reason="Can't be NumPy strings")
445+
@pytest.mark.xfail(using_string_dtype(), reason="Can't be NumPy strings")
446446
def test_constructor_np_strs(self):
447447
# GH#31499 Hashtable.map_locations needs to work on np.str_ objects
448448
cat = Categorical(["1", "0", "1"], [np.str_("0"), np.str_("1")])

pandas/tests/arrays/categorical/test_repr.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import numpy as np
22
import pytest
33

4-
from pandas._config import using_pyarrow_string_dtype
4+
from pandas._config import using_string_dtype
55

66
from pandas import (
77
Categorical,
@@ -78,7 +78,7 @@ def test_print_none_width(self):
7878
assert exp == repr(a)
7979

8080
@pytest.mark.skipif(
81-
using_pyarrow_string_dtype(),
81+
using_string_dtype(),
8282
reason="Change once infer_string is set to True by default",
8383
)
8484
def test_unicode_print(self):

pandas/tests/base/test_misc.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import numpy as np
44
import pytest
55

6-
from pandas._config import using_pyarrow_string_dtype
6+
from pandas._config import using_string_dtype
77

88
from pandas.compat import PYPY
99

@@ -82,7 +82,7 @@ def test_ndarray_compat_properties(index_or_series_obj):
8282

8383

8484
@pytest.mark.skipif(
85-
PYPY or using_pyarrow_string_dtype(),
85+
PYPY or using_string_dtype(),
8686
reason="not relevant for PyPy doesn't work properly for arrow strings",
8787
)
8888
def test_memory_usage(index_or_series_memory_obj):

pandas/tests/base/test_unique.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import numpy as np
22
import pytest
33

4-
from pandas._config import using_pyarrow_string_dtype
4+
from pandas._config import using_string_dtype
55

66
import pandas as pd
77
import pandas._testing as tm
@@ -100,7 +100,7 @@ def test_nunique_null(null_obj, index_or_series_obj):
100100

101101

102102
@pytest.mark.single_cpu
103-
@pytest.mark.xfail(using_pyarrow_string_dtype(), reason="decoding fails")
103+
@pytest.mark.xfail(using_string_dtype(), reason="decoding fails")
104104
def test_unique_bad_unicode(index_or_series):
105105
# regression test for #34550
106106
uval = "\ud83d" # smiley emoji

pandas/tests/extension/base/ops.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import numpy as np
66
import pytest
77

8-
from pandas._config import using_pyarrow_string_dtype
8+
from pandas._config import using_string_dtype
99

1010
from pandas.core.dtypes.common import is_string_dtype
1111

@@ -37,7 +37,7 @@ def _get_expected_exception(
3737
else:
3838
result = self.frame_scalar_exc
3939

40-
if using_pyarrow_string_dtype() and result is not None:
40+
if using_string_dtype() and result is not None:
4141
import pyarrow as pa
4242

4343
result = ( # type: ignore[assignment]

pandas/tests/extension/test_categorical.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import numpy as np
2020
import pytest
2121

22-
from pandas._config import using_pyarrow_string_dtype
22+
from pandas._config import using_string_dtype
2323

2424
import pandas as pd
2525
from pandas import Categorical
@@ -99,7 +99,7 @@ def test_contains(self, data, data_missing):
9999
continue
100100
assert na_value_obj not in data
101101
# this section suffers from super method
102-
if not using_pyarrow_string_dtype():
102+
if not using_string_dtype():
103103
assert na_value_obj in data_missing
104104

105105
def test_empty(self, dtype):

pandas/tests/frame/constructors/test_from_dict.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import numpy as np
44
import pytest
55

6-
from pandas._config import using_pyarrow_string_dtype
6+
from pandas._config import using_string_dtype
77

88
from pandas import (
99
DataFrame,
@@ -44,9 +44,7 @@ def test_constructor_single_row(self):
4444
)
4545
tm.assert_frame_equal(result, expected)
4646

47-
@pytest.mark.skipif(
48-
using_pyarrow_string_dtype(), reason="columns inferring logic broken"
49-
)
47+
@pytest.mark.skipif(using_string_dtype(), reason="columns inferring logic broken")
5048
def test_constructor_list_of_series(self):
5149
data = [
5250
OrderedDict([["a", 1.5], ["b", 3.0], ["c", 4.0]]),

pandas/tests/frame/constructors/test_from_records.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import numpy as np
99
import pytest
1010

11-
from pandas._config import using_pyarrow_string_dtype
11+
from pandas._config import using_string_dtype
1212

1313
from pandas.compat import is_platform_little_endian
1414

@@ -58,7 +58,7 @@ def test_from_records_with_datetimes(self):
5858
tm.assert_frame_equal(result, expected)
5959

6060
@pytest.mark.skipif(
61-
using_pyarrow_string_dtype(), reason="dtype checking logic doesn't work"
61+
using_string_dtype(), reason="dtype checking logic doesn't work"
6262
)
6363
def test_from_records_sequencelike(self):
6464
df = DataFrame(

0 commit comments

Comments
 (0)