runtime warning from numpy about invalid value in cast

Open
#293 12 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
numpy, python
Domain
data

Research direction

Start by reproducing the warning with the attached zero.cdl.txt example and the shown cf-python and NumPy versions. Trace the n.dim('T').dump() path that emits the masked-array cast warning; done means the example runs without the RuntimeWarning while preserving the displayed time coordinate output.

Written by the indexing model from the issue text.

Description

bug

There's an example field in the attached zero.cdl.txt. The following produces the warning "/usr/share/anaconda3/lib/python3.8/site-packages/numpy/ma/core.py:467: RuntimeWarning: invalid value encountered in cast".


>>> cf.__version__
'3.14.1'
>>> numpy.__version__
'1.24.2'
n=cf.read('zero.nc')[0]
>>> n.dim('T').dump()
/usr/share/anaconda3/lib/python3.8/site-packages/numpy/ma/core.py:467: RuntimeWarning: invalid value encountered in cast
  fill_value = np.array(fill_value, copy=False, dtype=ndtype)
Dimension coordinate: time
    axis = 'T'
    calendar = '360_day'
    standard_name = 'time'
    units = 'days since 2007-1-1'
    Data(294) = [2007-01-01 00:00:00, ..., 2300-01-01 00:00:00] 360_day
Dominant language
Python
Stars
32
Forks
14
Avg merge
3d 20h
Merged PRs (30d)
1

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from NCAS-CMS/cfdm

All issues in NCAS-CMS/cfdm

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.