Skip to content

subtraction of cf.TimeDuration fails #287

@dlrhodson

Description

@dlrhodson

Hi Both!

Having a bit of trouble with cf.TimeDuration() - looking at the code def __sub__ appears to be missing this section that appears in def __add__
Is that why it fails? (I should test this!)

Cheers!
Dan

t=cf.Data(array=0.0,units='days since 2018-12-01')
t
<CF Data(): 2018-12-01 00:00:00>

 t+cf.TimeDuration(30,'day')
<CF Data(): 2018-12-31 00:00:00 gregorian>

 t-cf.TimeDuration(30,'day')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for -: 'Data' and 'TimeDuration'

>> cf.environment(paths=False)
Platform: Linux-3.10.0-1160.42.2.el7.x86_64-x86_64-with-glibc2.10
HDF5 library: 1.10.6
netcdf library: 4.7.4
udunits2 library: /apps/jasmin/jaspy/miniconda_envs/jaspy3.8/m3-4.9.2/envs/jaspy3.8-m3-4.9.2-r20211105/lib/libudunits2.so.0
Python: 3.8.12
netCDF4: 1.5.6
cftime: 1.5.1
numpy: 1.21.3
psutil: 5.8.0
scipy: 1.7.1
matplotlib: 3.4.3
ESMF: 8.1.0
cfdm: 1.9.0.1
cfunits: 3.3.4
cfplot: 3.1.16
cf: 3.11.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions