Skip to content

Tests fail when no SciPy installed #5565

Closed
@feefladder

Description

@feefladder

What happened:
Tests failed, also reported in #5564 and relatd to #5559
What you expected to happen:

Minimal Complete Verifiable Example:

cd xarray
pip install -e .
pip install h5netcdf pytest-xdist netcdf4
py.test -n 4
======================================================= FAILURES =======================================================
_______________________________________ TestH5NetCDFFileObject.test_open_fileobj _______________________________________
[gw3] linux -- Python 3.9.5 /home/joeperdefloep/miniconda3/envs/xr-dev/bin/python3.9

self = <xarray.tests.test_backends.TestH5NetCDFFileObject object at 0x7f051a6b59a0>

    def test_open_fileobj(self):
        # open in-memory datasets instead of local file paths
        expected = create_test_data().drop_vars("dim3")
        expected.attrs["foo"] = "bar"
        with create_tmp_file() as tmp_file:
            expected.to_netcdf(tmp_file, engine="h5netcdf")

            with open(tmp_file, "rb") as f:
                with open_dataset(f, engine="h5netcdf") as actual:
                    assert_identical(expected, actual)

                f.seek(0)
                with open_dataset(f) as actual:
                    assert_identical(expected, actual)

                f.seek(0)
                with BytesIO(f.read()) as bio:
                    with open_dataset(bio, engine="h5netcdf") as actual:
                        assert_identical(expected, actual)

                f.seek(0)
                with pytest.raises(TypeError, match="not a valid NetCDF 3"):
>                   open_dataset(f, engine="scipy")

/mnt/e/Git/xarray/xarray/tests/test_backends.py:2887:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/mnt/e/Git/xarray/xarray/backends/api.py:483: in open_dataset
    backend = plugins.get_backend(engine)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

engine = 'scipy'

    def get_backend(engine):
        """Select open_dataset method based on current engine."""
        if isinstance(engine, str):
            engines = list_engines()
            if engine not in engines:
>               raise ValueError(
                    f"unrecognized engine {engine} must be one of: {list(engines)}"
                )
E               ValueError: unrecognized engine scipy must be one of: ['netcdf4', 'h5netcdf', 'store']

/mnt/e/Git/xarray/xarray/backends/plugins.py:156: ValueError
______________________________________________________ test_3641 _______________________________________________________
[gw0] linux -- Python 3.9.5 /home/joeperdefloep/miniconda3/envs/xr-dev/bin/python3.9

    @requires_cftime
    def test_3641():
        times = xr.cftime_range("0001", periods=3, freq="500Y")
        da = xr.DataArray(range(3), dims=["time"], coords=[times])
>       da.interp(time=["0002-05-01"])

/mnt/e/Git/xarray/xarray/tests/test_interp.py:733:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/mnt/e/Git/xarray/xarray/core/dataarray.py:1687: in interp
    ds = self._to_temp_dataset().interp(
/mnt/e/Git/xarray/xarray/core/dataset.py:3146: in interp
    variables[name] = missing.interp(var, var_indexers, method, **kwargs)
/mnt/e/Git/xarray/xarray/core/missing.py:633: in interp
    interped = interp_func(
/mnt/e/Git/xarray/xarray/core/missing.py:752: in interp_func
    return _interpnd(var, x, new_x, func, kwargs)
/mnt/e/Git/xarray/xarray/core/missing.py:770: in _interpnd
    return _interp1d(var, x, new_x, func, kwargs)
/mnt/e/Git/xarray/xarray/core/missing.py:758: in _interp1d
    rslt = func(x, var, assume_sorted=True, **kwargs)(np.ravel(new_x))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <[AttributeError("'ScipyInterpolator' object has no attribute 'method'") raised in repr()] ScipyInterpolator object at 0x7f1aa547fc40>
xi = <xarray.IndexVariable 'time' (time: 2)>
array([0.00000e+00, 1.57788e+19]), yi = array([0, 1]), method = 'linear'
fill_value = None, assume_sorted = True, copy = False, bounds_error = False, order = None, kwargs = {}

    def __init__(
        self,
        xi,
        yi,
        method=None,
        fill_value=None,
        assume_sorted=True,
        copy=False,
        bounds_error=False,
        order=None,
        **kwargs,
    ):
>       from scipy.interpolate import interp1d
E       ModuleNotFoundError: No module named 'scipy'

/mnt/e/Git/xarray/xarray/core/missing.py:129: ModuleNotFoundError
=================================================== warnings summary ===================================================
xarray/tests/test_dataarray.py::TestReduce1D::test_min[x3-5-2-1]
xarray/tests/test_dataarray.py::TestReduce1D::test_max[x3-5-2-1]
xarray/tests/test_dataarray.py::TestReduce2D::test_min[x2-minindex2-maxindex2-nanindex2]
xarray/tests/test_dataarray.py::TestReduce2D::test_max[x2-minindex2-maxindex2-nanindex2]
  /home/joeperdefloep/miniconda3/envs/xr-dev/lib/python3.9/site-packages/numpy/core/fromnumeric.py:86: RuntimeWarning: invalid value encountered in reduce
    return ufunc.reduce(obj, axis, dtype, out, **passkwargs)

-- Docs: https://docs.pytest.org/en/stable/warnings.html
=============================================== short test summary info ================================================
FAILED xarray/tests/test_backends.py::TestH5NetCDFFileObject::test_open_fileobj - ValueError: unrecognized engine sci...
FAILED xarray/tests/test_interp.py::test_3641 - ModuleNotFoundError: No module named 'scipy'
============= 2 failed, 8243 passed, 3776 skipped, 29 xfailed, 26 xpassed, 4 warnings in 229.01s (0:03:49) =============

Anything else we need to know?:

Environment:

Output of xr.show_versions()

INSTALLED VERSIONS

commit: a874739
python: 3.9.5 | packaged by conda-forge | (default, Jun 19 2021, 00:32:32)
[GCC 9.3.0]
python-bits: 64
OS: Linux
OS-release: 4.19.128-microsoft-standard
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: C.UTF-8
LOCALE: ('en_US', 'UTF-8')
libhdf5: 1.12.0
libnetcdf: 4.7.4

xarray: 0.18.2.dev69+gc472f8a4
pandas: 1.2.5
numpy: 1.21.0
scipy: None
netCDF4: 1.5.7
pydap: None
h5netcdf: 0.11.0
h5py: 3.3.0
Nio: None
zarr: None
cftime: 1.5.0
nc_time_axis: None
PseudoNetCDF: None
rasterio: None
cfgrib: None
iris: None
bottleneck: None
dask: None
distributed: None
matplotlib: None
cartopy: None
seaborn: None
numbagg: None
pint: None
setuptools: 49.6.0.post20210108
pip: 21.1.3
conda: None
pytest: 6.2.4
IPython: None
sphinx: None

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions