Skip to content
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

ValueError: cannot reshape array of size 1 into shape (7,) #58

Closed
ReimarBauer opened this issue Sep 2, 2018 · 5 comments
Closed

ValueError: cannot reshape array of size 1 into shape (7,) #58

ReimarBauer opened this issue Sep 2, 2018 · 5 comments

Comments

@ReimarBauer
Copy link
Contributor

Issue:


conda install -c conda-forge netcdf4 Solving environment: done

Package Plan

environment location: /home/user/miniconda3/envs/mssenv3

added / updated specs:
- netcdf4

The following packages will be downloaded:

package                    |            build
---------------------------|-----------------
ca-certificates-2018.8.24  |       ha4d7672_0         136 KB  conda-forge
netcdf4-1.4.1              |   py36h62672b6_0         2.0 MB  conda-forge
certifi-2018.8.24          |           py36_1         139 KB  conda-forge
openssl-1.0.2p             |       h470a237_0         3.5 MB  conda-forge
------------------------------------------------------------
                                       Total:         5.8 MB

The following packages will be UPDATED:

ca-certificates: 2018.03.07-0         --> 2018.8.24-ha4d7672_0 conda-forge
certifi:         2018.8.24-py36_1     --> 2018.8.24-py36_1     conda-forge
netcdf4:         1.4.0-py36ha06eab4_1 --> 1.4.1-py36h62672b6_0 conda-forge
openssl:         1.0.2p-h14c3975_0    --> 1.0.2p-h470a237_0    conda-forge



Details about conda and system ( conda info ):
     active environment : mssenv3
    active env location : /home/user/miniconda3/envs/mssenv3
            shell level : 1
       user config file : /home/user/.condarc
 populated config files : /home/user/.condarc
          conda version : 4.5.11
    conda-build version : not installed
         python version : 3.6.5.final.0
       base environment : /home/user/miniconda3  (writable)
           channel URLs : https://repo.anaconda.com/pkgs/main/linux-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/free/linux-64
                          https://repo.anaconda.com/pkgs/free/noarch
                          https://repo.anaconda.com/pkgs/r/linux-64
                          https://repo.anaconda.com/pkgs/r/noarch
                          https://repo.anaconda.com/pkgs/pro/linux-64
                          https://repo.anaconda.com/pkgs/pro/noarch
                          https://conda.anaconda.org/conda-forge/linux-64
                          https://conda.anaconda.org/conda-forge/noarch
          package cache : /home/user/miniconda3/pkgs
                          /home/user/.conda/pkgs
       envs directories : /home/user/miniconda3/envs
                          /home/user/.conda/envs
               platform : linux-64
             user-agent : conda/4.5.11 requests/2.18.4 CPython/3.6.5 Linux/4.4.0-134-generic ubuntu/16.04 glibc/2.23
                UID:GID : 1000:1000
             netrc file : None
           offline mode : False


I had run in the problem that 1.4.0 works but 1.4.1 of netcdf4 doesn't

https://bitbucket.org/wxmetvis/mss/issues/366/demodata-mswms-problem

currently a downgrade to 1.4.0 solves it for me.

@dopplershift
Copy link
Member

Have you made sure you're running the latest libnetcdf?

@ocefpaf
Copy link
Member

ocefpaf commented Sep 19, 2018

Can you provide a sscce to help us debug this?

Also, it does not look like an issue with packaging. Please take a look at the issue tracker upstream for similar problems and check the package changelog.

@ReimarBauer
Copy link
Contributor Author

ReimarBauer commented Sep 25, 2018

I do look also upstream, this example shows what happens

The problem seemingly occurs, when a masked array is supplied that uses only a single boolean (np.ma.nomask) instead of a full boolean array.

import numpy as np
import netCDF4 as nc

a = np.asarray([0, 6, 12])
print(nc.num2date(a, "hours since 2012-10-17T12:00:00.000Z"))  # <- fine
b = np.ma.masked_invalid(a)
print(type(b), b.shape, b.mask)
print(nc.num2date(b, "hours since 2012-10-17T12:00:00.000Z"))  # <- fine
b = np.ma.asarray(a)
print(type(b), b.shape, b.mask)
print(nc.num2date(b, "hours since 2012-10-17T12:00:00.000Z"))  # <- Exception
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "cftime/_cftime.pyx", line 290, in cftime._cftime.num2date
  File "cftime/_cftime.pyx", line 1211, in cftime._cftime.utime.num2date
  File "/home/user/miniconda3/envs/simmple/lib/python3.7/site-packages/numpy/core/fromnumeric.py", line 279, in reshape
    return _wrapfunc(a, 'reshape', newshape, order=order)
  File "/home/user/miniconda3/envs/simmple/lib/python3.7/site-packages/numpy/core/fromnumeric.py", line 51, in _wrapfunc
    return getattr(obj, method)(*args, **kwds)
ValueError: cannot reshape array of size 1 into shape (3,)

see also Unidata/netcdf4-python#847

@dopplershift
Copy link
Member

Can you do conda update -c conda-forge cftime ? I think you're running an out-of-date version of cftime.

@ReimarBauer
Copy link
Contributor Author

ReimarBauer commented Sep 28, 2018

@dopplershift
yeah, you are right. I guess we should have cftime >=1.0.1 in netCDF 1.4.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants