Skip to content

portrait plot does not work with python 3 env #368

@lee1043

Description

@lee1043

Python code: pp.py.txt

Input JSON: monsoon-wang_CMIP5_historical-regrid2_regrid2_2018-07-19-10-58-22.json.txt

Error message:

/Users/lee1043/anaconda2/envs/pmp_nightly_20180830/lib/python3.6/site-packages/numpy/ma/core.py:3169: FutureWarning: Using a non-tuple sequence for multidimensional indexing is deprecated; use `arr[tuple(seq)]` instead of `arr[seq]`. In the future this will be interpreted as an array index, `arr[np.array(seq)]`, which will result either in an error or a different result.
  dout = self.data[indx]
(44, 7) (44, 7)
/Users/lee1043/anaconda2/envs/pmp_nightly_20180830/lib/python3.6/site-packages/genutil/statistics.py:1712: VisibleDeprecationWarning: `rank` is deprecated; use the `ndim` attribute or function instead. To find the rank of a matrix see `numpy.linalg.matrix_rank`.
  if numpy.rank(ii) > 0:
/Users/lee1043/anaconda2/envs/pmp_nightly_20180830/lib/python3.6/site-packages/numpy/ma/core.py:3201: FutureWarning: Using a non-tuple sequence for multidimensional indexing is deprecated; use `arr[tuple(seq)]` instead of `arr[seq]`. In the future this will be interpreted as an array index, `arr[np.array(seq)]`, which will result either in an error or a different result.
  mout = _mask[indx]
Traceback (most recent call last):
  File "pp.py", line 95, in <module>
    P.plot(rms_norm,x=x,bg=0)
  File "/Users/lee1043/anaconda2/envs/pmp_nightly_20180830/lib/python3.6/site-packages/pcmdi_metrics/graphics/portraits.py", line 849, in plot
    self.set_colormap()
  File "/Users/lee1043/anaconda2/envs/pmp_nightly_20180830/lib/python3.6/site-packages/pcmdi_metrics/graphics/portraits.py", line 1942, in set_colormap
    cols = MV2.reshape(cols, (len(cols) / 3, 3))
  File "/Users/lee1043/anaconda2/envs/pmp_nightly_20180830/lib/python3.6/site-packages/cdms2/MV2.py", line 992, in reshape
    maresult = numpy.ma.reshape(ta, newshape)
  File "/Users/lee1043/anaconda2/envs/pmp_nightly_20180830/lib/python3.6/site-packages/numpy/ma/core.py", line 7002, in reshape
    return a.reshape(new_shape, order=order)
  File "/Users/lee1043/anaconda2/envs/pmp_nightly_20180830/lib/python3.6/site-packages/numpy/ma/core.py", line 4577, in reshape
    result = self._data.reshape(*s, **kwargs).view(type(self))
TypeError: 'float' object cannot be interpreted as an integer

The final Type Error is coming from cols = MV2.reshape(cols, (len(cols) / 3, 3)) part in the above message, where Python 2 returns integer while Python 3 returns float.

For example in Python 2:

>>> 3/2
1

But in Python 3:

>>> 3/2
1.5

And given float number cannot be used for the reshape of MV2.

@doutriaux1 any chance to fix this? @gleckler1 you may experience same error when you update your pmp to most recent.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions