Skip to content

Commit

Permalink
Merge pull request #2017 from sampsonbryce/master
Browse files Browse the repository at this point in the history
Fixed extends not working if you have a premade list for custom.
  • Loading branch information
doutriaux1 authored Jun 22, 2016
2 parents d5537f6 + 85b48f8 commit a06818f
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 14 deletions.
21 changes: 11 additions & 10 deletions Packages/vcs/vcs/VCS_validation_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2007,7 +2007,7 @@ def add_level_ext_2(self, ext_value):
if isinstance(self.levels[0], list): # remove from tuple of lists
if self.levels[-1][1] > 9.e19:
self.levels.pop(-1)
if isinstance(self.levels, tuple): # remove from list
if isinstance(self.levels, (tuple, list)): # remove from list
ret_tup = []
for i in range(len(self.levels) - 1):
ret_tup.insert(i + 1, self.levels[i])
Expand All @@ -2021,15 +2021,16 @@ def add_level_ext_2(self, ext_value):
return self.levels

# We may need to add extnsion
if isinstance(self.levels, tuple):
self.levels = list(self.levels)
if isinstance(self.levels[-1], list): # add to tuple of lists
if self.levels[-1][1] < 9.e19:
self.levels.append([self.levels[-1][1], 1e20])
else:
if self.levels[-1] < 9.e19:
self.levels.append(1.e20)
return self.levels
if isinstance(self.levels, (list, tuple)):
if isinstance(self.levels, tuple):
self.levels = list(self.levels)
if isinstance(self.levels[-1], list): # add to tuple of lists
if self.levels[-1][1] < 9.e19:
self.levels.append([self.levels[-1][1], 1e20])
else:
if self.levels[-1] < 9.e19:
self.levels.append(1.e20)
return self.levels


def _getext_1(self):
Expand Down
9 changes: 7 additions & 2 deletions Packages/vcs/vcs/projection.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,12 @@ def list(self):
print 'name =', self.name
print 'type =', self.type
# print 'parameters =',self.parameters

for att in self.attributes:
print att, '=', getattr(self, att)

@property
def attributes(self):
p = []
if self._type in [3, 4]:
p.append('smajor')
Expand Down Expand Up @@ -455,8 +461,7 @@ def list(self):
p.append('centerlatitude')
p.append('falseeasting')
p.append('falsenorthing')
for att in p:
print att, '=', getattr(self, att)
return p

##########################################################################
# #
Expand Down
6 changes: 4 additions & 2 deletions testing/vcs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ foreach(lat_0 45 90)
${lat_0}
)
endforeach()


cdat_add_test(test_vcs_extends
"${PYTHON_EXECUTABLE}"
${cdat_SOURCE_DIR}/testing/vcs/test_vcs_extends.py
)
cdat_add_test(test_vcs_create_get
"${PYTHON_EXECUTABLE}"
${cdat_SOURCE_DIR}/testing/vcs/test_vcs_create_get.py
Expand Down
29 changes: 29 additions & 0 deletions testing/vcs/test_vcs_extends.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import vcs
import numpy

box = vcs.createboxfill()

box.ext_1 = True
assert numpy.allclose(box.levels, [1e20] * 2)

box.ext_2 = True
assert numpy.allclose(box.levels, [1e20] * 2)

box.levels = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
assert box.ext_1 == False
assert box.ext_1 == False

box.ext_1 = True
assert box.levels[0] < -9e19

box.ext_2 = True
assert box.levels[-1] > 9e19

box.ext_1 = False
assert box.levels[0] > -9e19

box.ext_2 = False
assert box.levels[-1] < 9e19



0 comments on commit a06818f

Please sign in to comment.