From d8c2654b75d0974efcf675e350142c052305a3da Mon Sep 17 00:00:00 2001 From: Joris Van den Bossche Date: Sat, 27 Apr 2024 21:04:35 +0200 Subject: [PATCH 1/2] TST / string dtype: add env variable to enable future_string and add test build --- .github/workflows/unit-tests.yml | 5 +++++ pandas/core/config_init.py | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index f93950224eaae..5ff22a266732d 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -57,6 +57,10 @@ jobs: # Also install zh_CN (its encoding is gb2312) but do not activate it. # It will be temporarily activated during tests with locale.setlocale extra_loc: "zh_CN" + - name: "Future infer strings" + env_file: actions-311.yaml + pattern: "not slow and not network and not single_cpu" + pandas_future_infer_string: "1" - name: "Pypy" env_file: actions-pypy-39.yaml pattern: "not slow and not network and not single_cpu" @@ -75,6 +79,7 @@ jobs: LANG: ${{ matrix.lang || 'C.UTF-8' }} LC_ALL: ${{ matrix.lc_all || '' }} PANDAS_CI: ${{ matrix.pandas_ci || '1' }} + PANDAS_FUTURE_INFER_STRING: ${{ matrix.pandas_future_infer_string || '0' }} TEST_ARGS: ${{ matrix.test_args || '' }} PYTEST_WORKERS: ${{ matrix.pytest_workers || 'auto' }} PYTEST_TARGET: ${{ matrix.pytest_target || 'pandas' }} diff --git a/pandas/core/config_init.py b/pandas/core/config_init.py index 46c9139c3456c..766f74a4bc5d6 100644 --- a/pandas/core/config_init.py +++ b/pandas/core/config_init.py @@ -858,7 +858,7 @@ def register_converter_cb(key: str) -> None: with cf.config_prefix("future"): cf.register_option( "infer_string", - False, + True if os.environ.get("PANDAS_FUTURE_INFER_STRING", "0") == "1" else False, "Whether to infer sequence of str objects as pyarrow string " "dtype, which will be the default in pandas 3.0 " "(at which point this option will be deprecated).", From 57b24642b062214ec18d7195cac364ccd6562d9e Mon Sep 17 00:00:00 2001 From: Joris Van den Bossche Date: Fri, 26 Jul 2024 09:46:52 +0200 Subject: [PATCH 2/2] suppress pytest failures when future_string is enabled --- ci/run_tests.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ci/run_tests.sh b/ci/run_tests.sh index d2c2f58427a23..c6071100fc86f 100755 --- a/ci/run_tests.sh +++ b/ci/run_tests.sh @@ -16,5 +16,11 @@ if [[ "$PATTERN" ]]; then PYTEST_CMD="$PYTEST_CMD -m \"$PATTERN\"" fi +# temporarily let pytest always succeed (many tests are not yet passing in the +# build enabling the future string dtype) +if [[ "$PANDAS_FUTURE_INFER_STRING" == "1" ]]; then + PYTEST_CMD="$PYTEST_CMD || true" +fi + echo $PYTEST_CMD sh -c "$PYTEST_CMD"