Skip to content

COMPAT: numpy master changes, floordiv & getitem(nan) #12406

Closed
@jreback

Description

@jreback

https://travis-ci.org/pydata/pandas/jobs/110280302

These indicate an indexing change with nan that now returns TypeError rather than IndexError, ok makes sense

======================================================================
ERROR: test_range_slice_day (pandas.tseries.tests.test_period.TestPeriodIndex)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/jreback/miniconda/envs/numpy_dev/pandas/pandas/tseries/tests/test_period.py", line 2589, in test_range_slice_day
    idx[v:]
  File "/Users/jreback/miniconda/envs/numpy_dev/pandas/pandas/tseries/base.py", line 175, in __getitem__
    result = getitem(key)
TypeError: slice indices must be integers or None or have an __index__ method

======================================================================
ERROR: test_range_slice_seconds (pandas.tseries.tests.test_period.TestPeriodIndex)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/jreback/miniconda/envs/numpy_dev/pandas/pandas/tseries/tests/test_period.py", line 2643, in test_range_slice_seconds
    idx[v:]
  File "/Users/jreback/miniconda/envs/numpy_dev/pandas/pandas/tseries/base.py", line 175, in __getitem__
    result = getitem(key)
TypeError: slice indices must be integers or None or have an __index__ method

So our comparison in this test changed. So we need to make this change for 0.18.0 as well here, where these should be NaN and not inf.

So numpy now returns:
In [1]: np.__version__
Out[1]: '1.12.0.dev0+7d4d26a'

In [3]: np.array([3])//np.array([0],dtype='float64')
Out[3]: array([ nan])

In [2]: np.float64(3)//np.float64(0)
Out[2]: nan

In [3]: np.__version__
Out[3]: '1.10.4'

In [4]: np.float64(3)//np.float64(0)
Out[4]: inf

In [7]: np.array([3])//np.array([0],dtype='float64')
Out[7]: array([ inf])
======================================================================
FAIL: test_sparse_series_ops (pandas.sparse.tests.test_sparse.TestSparseDataFrame)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/jreback/miniconda/envs/numpy_dev/pandas/pandas/sparse/tests/test_sparse.py", line 1151, in test_sparse_series_ops
    self._check_frame_ops(self.frame)
  File "/Users/jreback/miniconda/envs/numpy_dev/pandas/pandas/sparse/tests/test_sparse.py", line 1221, in _check_frame_ops
    _compare_to_dense(frame, s, frame.to_dense(), s.to_dense(), f)
  File "/Users/jreback/miniconda/envs/numpy_dev/pandas/pandas/sparse/tests/test_sparse.py", line 1194, in _compare_to_dense
    exact_indices=False)
  File "/Users/jreback/miniconda/envs/numpy_dev/pandas/pandas/sparse/tests/test_sparse.py", line 95, in assert_sp_frame_equal
    assert_series_equal(series.to_dense(), right[col].to_dense())
  File "/Users/jreback/miniconda/envs/numpy_dev/pandas/pandas/util/testing.py", line 999, in assert_series_equal
    check_less_precise, obj='{0}'.format(obj))
  File "testing.pyx", line 58, in pandas._testing.assert_almost_equal (pandas/src/testing.c:3254)
  File "testing.pyx", line 147, in pandas._testing.assert_almost_equal (pandas/src/testing.c:2395)
  File "/Users/jreback/miniconda/envs/numpy_dev/pandas/pandas/util/testing.py", line 867, in raise_assert_detail
    raise AssertionError(msg)
AssertionError: Series are different

Series values are different (10.0 %)
[left]:  [nan, nan, nan, inf, 4.0, 2.0, 2.0, 1.0, 1.0, 1.0]
[right]: [nan, nan, nan, nan, 4.0, 2.0, 2.0, 1.0, 1.0, 1.0]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Compatpandas objects compatability with Numpy or Python functions

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions