Repository: dask/dask
Pull request #10943 (2024-02-20 14:38:55)

Fix flaky test_describe_empty


Patch:
diff --git a/.github/workflows/additional.yml b/.github/workflows/additional.yml
index e2d4438f4..d8bd3f11d 100644
--- a/.github/workflows/additional.yml
+++ b/.github/workflows/additional.yml
@@ -22,8 +22,7 @@ jobs:
           miniforge-version: latest
           use-mamba: true
           channel-priority: strict
-          python-version: "3.11"
-          environment-file: continuous_integration/environment-3.11.yaml
+          environment-file: continuous_integration/environment-3.12.yaml
           activate-environment: test-environment
           auto-activate-base: false
 
diff --git a/.github/workflows/upstream.yml b/.github/workflows/upstream.yml
index 100096817..21cffde94 100644
--- a/.github/workflows/upstream.yml
+++ b/.github/workflows/upstream.yml
@@ -56,7 +56,7 @@ jobs:
           miniforge-version: latest
           use-mamba: true
           channel-priority: strict
-          environment-file: continuous_integration/environment-3.11.yaml
+          environment-file: continuous_integration/environment-3.12.yaml
           activate-environment: test-environment
           auto-activate-base: false
 
diff --git a/continuous_integration/environment-3.10.yaml b/continuous_integration/environment-3.10.yaml
index 82f301b36..77e73a66d 100644
--- a/continuous_integration/environment-3.10.yaml
+++ b/continuous_integration/environment-3.10.yaml
@@ -68,8 +68,8 @@ dependencies:
   - sparse
   - cachey
   - python-graphviz
-  - python-xxhash
   - python-cityhash
+  - python-xxhash
   - mmh3
   - jinja2
   - pip
diff --git a/continuous_integration/environment-3.11.yaml b/continuous_integration/environment-3.11.yaml
index f15c8ea38..16a8f9c3a 100644
--- a/continuous_integration/environment-3.11.yaml
+++ b/continuous_integration/environment-3.11.yaml
@@ -26,6 +26,7 @@ dependencies:
   - mimesis
   - numpy
   - pandas
+  - numba
   - flask
   - fastparquet
   - h5py
@@ -41,7 +42,7 @@ dependencies:
   - pyarrow>=13
   - coverage
   - jsonschema
-  # # other -- IO
+  # other -- IO
   - boto3
   - botocore
   - bokeh
@@ -59,7 +60,6 @@ dependencies:
   - ipywidgets<8.0.5
   - ipykernel<6.22.0
   - lz4
-  - numba
   - psutil
   - requests
   - scikit-image
diff --git a/continuous_integration/environment-3.12.yaml b/continuous_integration/environment-3.12.yaml
index c2a528358..fac2a8f5f 100644
--- a/continuous_integration/environment-3.12.yaml
+++ b/continuous_integration/environment-3.12.yaml
@@ -26,6 +26,7 @@ dependencies:
   - mimesis
   - numpy
   - pandas
+  - numba
   - flask
   - fastparquet
   - h5py
@@ -41,7 +42,7 @@ dependencies:
   - pyarrow>=13
   - coverage
   - jsonschema
-  # # other -- IO
+  # other -- IO
   - boto3
   - botocore
   - bokeh
@@ -59,7 +60,6 @@ dependencies:
   - ipywidgets<8.0.5
   - ipykernel<6.22.0
   - lz4
-  # - numba no support for 3.12
   - psutil
   - requests
   - scikit-image
@@ -69,8 +69,7 @@ dependencies:
   - sparse
   - cachey
   - python-graphviz
-  # Not available on macOS for Python 3.12 yet
-  # - python-cityhash
+  - python-cityhash
   - python-xxhash
   - mmh3
   - jinja2
diff --git a/continuous_integration/environment-3.9.yaml b/continuous_integration/environment-3.9.yaml
index 4a0b9043a..d383afb09 100644
--- a/continuous_integration/environment-3.9.yaml
+++ b/continuous_integration/environment-3.9.yaml
@@ -68,8 +68,8 @@ dependencies:
   - sparse
   - cachey
   - python-graphviz
-  - python-xxhash
   - python-cityhash
+  - python-xxhash
   - mmh3
   - jinja2
   - pip
diff --git a/docs/source/develop.rst b/docs/source/develop.rst
index a680895ff..bf48d4d41 100644
--- a/docs/source/develop.rst
+++ b/docs/source/develop.rst
@@ -108,7 +108,7 @@ pip or conda_
 
 ``conda``::
 
-  conda env create -n dask-dev -f continuous_integration/environment-3.11.yaml
+  conda env create -n dask-dev -f continuous_integration/environment-3.12.yaml
   conda activate dask-dev
   python -m pip install --no-deps -e .
 
@@ -133,7 +133,7 @@ language support, testing, documentation, and style.
 Python Versions
 ~~~~~~~~~~~~~~~
 
-Dask supports Python versions 3.9, 3.10 and 3.11.
+Dask supports Python versions 3.9 to 3.12.
 Name changes are handled by the :file:`dask/compatibility.py` file.
 
 .. _develop-test:


Test patch:
diff --git a/dask/dataframe/tests/test_dataframe.py b/dask/dataframe/tests/test_dataframe.py
index a6f622a4c..917064d93 100644
--- a/dask/dataframe/tests/test_dataframe.py
+++ b/dask/dataframe/tests/test_dataframe.py
@@ -604,6 +604,10 @@ def test_describe_without_datetime_is_numeric():
             ddf.e.describe()
 
 
+# Note: this warning is not always raised on Windows
+@pytest.mark.filterwarnings(
+    "ignore:invalid value encountered in (true_)?divide:RuntimeWarning"
+)
 def test_describe_empty():
     df_none = pd.DataFrame({"A": [None, None]})
     ddf_none = dd.from_pandas(df_none, 2)
@@ -611,15 +615,8 @@ def test_describe_empty():
     ddf_len0 = dd.from_pandas(df_len0, 2)
     ddf_nocols = dd.from_pandas(pd.DataFrame({}), 2)
 
-    # Pandas have different dtypes for resulting describe dataframe if there are only
-    # None-values, pre-compute dask df to bypass _meta check
-    assert_eq(
-        df_none.describe(), ddf_none.describe(percentiles_method="dask").compute()
-    )
-
-    with pytest.warns(RuntimeWarning):
-        ddf_len0.describe(percentiles_method="dask").compute()
-
+    assert_eq(df_none.describe(), ddf_none.describe(percentiles_method="dask"))
+    assert_eq(df_len0.describe(), ddf_len0.describe(percentiles_method="dask"))
     with pytest.raises(ValueError):
         ddf_nocols.describe(percentiles_method="dask").compute()
 
diff --git a/dask/tests/test_docs.py b/dask/tests/test_docs.py
index 4869dca24..21b5db6ec 100644
--- a/dask/tests/test_docs.py
+++ b/dask/tests/test_docs.py
@@ -5,20 +5,21 @@ from pathlib import Path
 import pytest
 
 
-def test_development_guidelines_matches_ci():
+@pytest.mark.parametrize(
+    "filename",
+    [
+        "docs/source/develop.rst",
+        ".github/workflows/additional.yml",
+        ".github/workflows/upstream.yml",
+    ],
+)
+def test_development_guidelines_matches_ci(filename):
     """When the environment.yaml changes in CI, make sure to change it in the docs as well"""
     root_dir = Path(__file__).parent.parent.parent
 
     if not (root_dir / ".github" / "workflows").exists():
         pytest.skip("Test can only be run on an editable install")
 
-    development_doc_file = root_dir / "docs" / "source" / "develop.rst"
-    additional_ci_file = root_dir / ".github" / "workflows" / "additional.yml"
-    upstream_ci_file = root_dir / ".github" / "workflows" / "upstream.yml"
-    latest_env = "environment-3.11.yaml"
-
-    for filename in [development_doc_file, additional_ci_file, upstream_ci_file]:
-        with open(filename, encoding="utf8") as f:
-            assert any(
-                latest_env in line for line in f
-            ), f"{latest_env} not found in {filename}"
+    latest_env = "environment-3.12.yaml"
+    with open(root_dir / filename, encoding="utf8") as f:
+        assert latest_env in f.read()