Skip to content

UnitsDataArray ufuncs suddenly not working in TravisCI #112

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jmilloy opened this issue Oct 4, 2018 · 3 comments
Closed

UnitsDataArray ufuncs suddenly not working in TravisCI #112

jmilloy opened this issue Oct 4, 2018 · 3 comments
Assignees
Labels
bug Something isn't working testing

Comments

@jmilloy
Copy link
Collaborator

jmilloy commented Oct 4, 2018

Description
The CI tests are no longer passing because of the UnitsDataArray ufuncs test. This includes the master branch. This suggests that something in our CI build process has changed.

Steps to Reproduce

See a recent TravisCI build on any branch, including this rebuild of master.

Expected Behavior

np.std(a1) should work, so that the tests should pass.

Observed Behavior

The test_units::TestUnitDataArray::test_ufuncs test is failing:

TypeError: nanstd() got an unexpected keyword argument 'ddof'

Additional Notes

This seems to be the case on any branch for any version of Python.

Full excerpt from a build log:

________________________ TestUnitDataArray.[secure]_ufuncs _________________________
self = <[secure]_units.TestUnitDataArray object at 0x7efdd4717b38>
    def [secure]_ufuncs(self):
        a1 = UnitsDataArray(np.ones((4,3)), dims=['lat', 'lon'],
                               attrs={'units': ureg.meter})
        a2 = UnitsDataArray(np.ones((4,3)), dims=['lat', 'lon'],
                               attrs={'units': ureg.kelvin})
    
        np.sqrt(a1)
        np.mean(a1)
        np.min(a1)
        np.max(a1)
        a1 ** 2
    
        # These don't have units!
        np.dot(a2.T, a1)
>       np.std(a1)
podpac/core/[secure]/[secure]_units.py:334: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../../../virtualenv/python3.5.6/lib/python3.5/site-packages/numpy/core/fromnumeric.py:3035: in std
    return std(axis=axis, dtype=dtype, out=out, ddof=ddof, **kwargs)
../../../virtualenv/python3.5.6/lib/python3.5/site-packages/xarray/core/common.py:23: in wrapped_func
    skipna=skipna, allow_lazy=True, **kwargs)
../../../virtualenv/python3.5.6/lib/python3.5/site-packages/xarray/core/dataarray.py:1591: in reduce
    var = self.variable.reduce(func, dim, axis, keep_attrs, **kwargs)
../../../virtualenv/python3.5.6/lib/python3.5/site-packages/xarray/core/variable.py:1342: in reduce
    axis=axis, **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
values = array([[1., 1., 1.],
       [1., 1., 1.],
       [1., 1., 1.],
       [1., 1., 1.]])
axis = None, skipna = None, kwargs = {'ddof': 0, 'dtype': None}
func = <function nanstd at 0x7efdf4f4ba60>, nanname = 'nanstd'
    def f(values, axis=None, skipna=None, **kwargs):
        if kwargs.pop('out', None) is not None:
            raise TypeError('`out` is not valid for {}'.format(name))
    
        values = asarray(values)
    
        if coerce_strings and values.dtype.kind in 'SU':
            values = values.astype(object)
    
        func = None
        if skipna or (skipna is None and values.dtype.kind in 'cfO'):
            nanname = 'nan' + name
            func = getattr(nanops, nanname)
        else:
            func = _dask_or_eager_func(name)
    
        try:
>           return func(values, axis=axis, **kwargs)
E           TypeError: nanstd() got an unexpected keyword argument 'ddof'
../../../virtualenv/python3.5.6/lib/python3.5/site-packages/xarray/core/duck_array_ops.py:236: TypeError
If applicable, a clear and concise description of what actually happens (e.g. a traceback or output from executing the sample code).
@jmilloy jmilloy added bug Something isn't working testing labels Oct 4, 2018
@jmilloy
Copy link
Collaborator Author

jmilloy commented Oct 4, 2018

I took a peek at this but I couldn't figure anything out quickly. I can't reproduce here on my machine. Possibly this is a numpy or xarray version issue?

@mpu-creare I assigned you because you wrote the UnitsDataArray ufuncs code.
@mlshapiro I also assigned you because I think you might have more familiarity with the TravisCI jobs.

@mpu-creare
Copy link
Contributor

Looks like it's an error straight in the xarray layer:

import xarray as xr
a = xr.DataArray(np.ones((4,3)), dims=['lat', 'lon'])
np.std(a)
Traceback (most recent call last):
  Debug Probe, prompt 114, line 1
  File "c:\Anaconda27\envs\podpac\Lib\site-packages\numpy\core\fromnumeric.py", line 3072, in std
    return std(axis=axis, dtype=dtype, out=out, ddof=ddof, **kwargs)
  File "c:\Anaconda27\envs\podpac\Lib\site-packages\xarray\core\common.py", line 23, in wrapped_func
    skipna=skipna, allow_lazy=True, **kwargs)
  File "c:\Anaconda27\envs\podpac\Lib\site-packages\xarray\core\dataarray.py", line 1591, in reduce
    var = self.variable.reduce(func, dim, axis, keep_attrs, **kwargs)
  File "c:\Anaconda27\envs\podpac\Lib\site-packages\xarray\core\variable.py", line 1342, in reduce
    axis=axis, **kwargs)
  File "c:\Anaconda27\envs\podpac\Lib\site-packages\xarray\core\duck_array_ops.py", line 249, in f
    return func(values, axis=axis, **kwargs)
builtins.TypeError: nanstd() got an unexpected keyword argument 'ddof'

Let's skip it for now.

@mpu-creare
Copy link
Contributor

Finally fixed in f24d084

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working testing
Projects
None yet
Development

No branches or pull requests

3 participants