Skip to content

Commit

Permalink
Issue246 (#267)
Browse files Browse the repository at this point in the history
* recreate cdms2 with libpng from conda-forge

* force libpng=1.6.34 in circleci yml

* fix #246 clone axis units issue

* add test
  • Loading branch information
dnadeau4 authored and doutriaux1 committed Aug 20, 2018
1 parent 9bbf339 commit e4ea279
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Lib/axis.py
Original file line number Diff line number Diff line change
Expand Up @@ -1708,13 +1708,13 @@ def clone(self, copyData=1):
else:
mycopy = createAxis(self[:])
mycopy.id = self.id
mycopy.__dict__.update(self.__dict__.copy())
mycopy._obj_ = None # Erase Cdfile object if exist
try:
mycopy.setBounds(b, isGeneric=isGeneric[0])
except CDMSError:
b = mycopy.genGenericBounds()
mycopy.setBounds(b, isGeneric=False)
for k, v in list(self.attributes.items()):
setattr(mycopy, k, v)
return mycopy

def listall(self, all=None):
Expand Down
28 changes: 28 additions & 0 deletions tests/test_cdms_axis_clone.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from __future__ import print_function
import unittest
import os
from subprocess import Popen, PIPE
import shlex
import MV2, cdms2


class TestAxis(unittest.TestCase):

def testCloneUnits(self):

tmp = MV2.ones(3, id='tmp')
ax = tmp.getAxis(0)
ax.standard_name = "time"
ax.id = 'time'
ax.units = "seconds since 1900-01-01T00:00:00Z"
ax.long_name = "time in seconds (UT)"
ax.time_origin = "01-JAN-1900 00:00:00"
ax.designateTime()

f = cdms2.open('tmp.nc', 'w')
f.write(tmp)
f.close()

f = cdms2.open('tmp.nc')
assert f['time'].clone().units == f['time'].units
f.close()

0 comments on commit e4ea279

Please sign in to comment.