Skip to content

Specify a minimum version for numpy in setup.py. #2796

Closed

Description

@bcarrier2010

In dask's setup.py there is no minimum version specified for numpy.

13    'dataframe': ['numpy', 'pandas >= 0.19.0', 'toolz >= 0.7.3',
14                  'partd >= 0.3.8', 'cloudpickle >= 0.2.1'],

This allows a users to get into the situation where a previously installed and potentially outdated version of numpy is in the environment. This causes an issue when importing dask if the numpy version is less than 1.10.0 because np.cbrt was introduced in numpy version 1.10.0,

In [1]: import dask.dataframe as dd
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-1-e012ff17e82a> in <module>()
----> 1 import dask.dataframe as dd

/home/test/.virtualenvs/dask/lib/python3.4/site-packages/dask/dataframe/__init__.py in <module>()
      1 from __future__ import print_function, division, absolute_import
      2 
----> 3 from .core import (DataFrame, Series, Index, _Frame, map_partitions,
      4                    repartition, to_delayed, to_datetime, to_timedelta)
      5 from .groupby import Aggregation

/home/test/.virtualenvs/dask/lib/python3.4/site-packages/dask/dataframe/core.py in <module>()
     17     Cache = dict
     18 
---> 19 from .. import array as da
     20 from .. import core
     21 from ..utils import partial_by_order

/home/test/.virtualenvs/dask/lib/python3.4/site-packages/dask/array/__init__.py in <module>()
     13                        apply_along_axis, apply_over_axes, result_type)
     14 from .reshape import reshape
---> 15 from .ufunc import (add, subtract, multiply, divide, logaddexp, logaddexp2,
     16         true_divide, floor_divide, negative, power, remainder, mod, conj, exp,
     17         exp2, log, log2, log10, log1p, expm1, sqrt, square, cbrt, reciprocal,

/home/test/.virtualenvs/dask/lib/python3.4/site-packages/dask/array/ufunc.py in <module>()
    136 sqrt = ufunc(np.sqrt)
    137 square = ufunc(np.square)
--> 138 cbrt = ufunc(np.cbrt)
    139 reciprocal = ufunc(np.reciprocal)
    140 

AttributeError: 'module' object has no attribute 'cbrt'

There was an existing issue #2596 where another user had the same problem which was closed.

Python environment:

Python version: 3.4.3

Libraries:
cloudpickle (0.4.0)
dask (0.15.4)
locket (0.2.0)
numpy (1.9.1)
pandas (0.20.3)
partd (0.3.8)
pip (9.0.1)
python-dateutil (2.6.1)
pytz (2017.2)
setuptools (36.6.0)
six (1.11.0)
toolz (0.8.2)
wheel (0.30.0)

Copy and paste example:

import dask.dataframe as dd
print('test is complete')

Is there a reason as to why the setup.py could not be modified to contain numpy>=1.10.0?

13    'dataframe': ['numpy>=1.10.0', 'pandas >= 0.19.0', 'toolz >= 0.7.3',
14                  'partd >= 0.3.8', 'cloudpickle >= 0.2.1'],

Activity

  1. mrocklin commented on Oct 19, 2017

    @mrocklin
    Member

    Seems reasonable to me. It looks like we also don't mention a minimum version in the conda-forge recipe: https://github.com/conda-forge/dask-feedstock/blob/master/recipe/meta.yaml

    The next question is probably "what is the minimum version?"

    This issue might interest @jakirkham

  2. jakirkham commented on Oct 19, 2017

    @jakirkham
    Member

    Agreed. I guess the oldest one we test in CI, which IIRC is NumPy 1.10. Though I do remember seeing compatibility code for earlier versions. Maybe it's time to revisit what compatibility code is still needed and what can be dropped.

  3. djkirkham commented on Nov 8, 2017

    @djkirkham

    There appear to be errors with the masking functionality with numpy <1.12:

    >>> import numpy as np
    >>> import dask.array as da
    >>> a = np.ma.arange(12).reshape(3,4)
    >>> d = da.from_array(a, 1, asarray=False)
    >>> print d.mean(axis=1).compute()
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File ".../lib/python2.7/site-packages/dask/base.py", line 99, in compute
        (result,) = compute(self, traverse=False, **kwargs)
      File ".../lib/python2.7/site-packages/dask/base.py", line 206, in compute
        results = get(dsk, keys, **kwargs)
      File ".../lib/python2.7/site-packages/dask/threaded.py", line 75, in get
        pack_exception=pack_exception, **kwargs)
      File ".../lib/python2.7/site-packages/dask/local.py", line 521, in get_async
        raise_exception(exc, tb)
      File ".../lib/python2.7/site-packages/dask/local.py", line 290, in execute_task
        result = _execute_task(task, data)
      File ".../lib/python2.7/site-packages/dask/local.py", line 271, in _execute_task
        return func(*args2)
      File ".../lib/python2.7/site-packages/toolz/functoolz.py", line 466, in __call__
        ret = self.first(*args, **kwargs)
      File ".../lib/python2.7/site-packages/dask/array/core.py", line 517, in _concatenate2
        return concatenate(arrays, axis=axes[0])
    IndexError: axis 1 out of bounds [0, 1)
    
  4. jakirkham commented on Nov 20, 2017

    @jakirkham
    Member

    Considering the masked array functionality is relatively new and may have some rough areas, would not suggest setting the NumPy minimum version based on it. Instead would suggest that bugs related to masked array support be raised in fresh issues where they can be addressed more appropriately.

  5. jakirkham commented on Mar 13, 2018

    @jakirkham
    Member

    Have added PR ( #3283 ) to set the minimum version of NumPy supported to be 1.10.4 as that is the oldest version we run CI against. Also have seen evidence that some things we include (e.g. wrapping cbrt) don't work on NumPy 1.9. We should probably follow this PR with a bit of spring cleaning as there is back compat code for versions of NumPy earlier than 1.10.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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