diff --git a/Packages/vcs/vcs/VCS_validation_functions.py b/Packages/vcs/vcs/VCS_validation_functions.py index 2968d7832f..271fb17938 100644 --- a/Packages/vcs/vcs/VCS_validation_functions.py +++ b/Packages/vcs/vcs/VCS_validation_functions.py @@ -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]) @@ -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): diff --git a/Packages/vcs/vcs/projection.py b/Packages/vcs/vcs/projection.py index 6b19c5e62f..cabf461eb5 100644 --- a/Packages/vcs/vcs/projection.py +++ b/Packages/vcs/vcs/projection.py @@ -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') @@ -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 ########################################################################## # # diff --git a/testing/vcs/CMakeLists.txt b/testing/vcs/CMakeLists.txt index a3b3b155e0..828e88f725 100644 --- a/testing/vcs/CMakeLists.txt +++ b/testing/vcs/CMakeLists.txt @@ -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 diff --git a/testing/vcs/test_vcs_extends.py b/testing/vcs/test_vcs_extends.py new file mode 100644 index 0000000000..4106cecd64 --- /dev/null +++ b/testing/vcs/test_vcs_extends.py @@ -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 + + +