Skip to content

Commit

Permalink
Merge branch 'baagaard/fix-uniformdb-errormsg'
Browse files Browse the repository at this point in the history
* baagaard/fix-uniformdb-errormsg:
  Update version info.
  Include spatial database label in error messages.
  Added UniformDB label to error mesasge.
  • Loading branch information
baagaard-usgs committed Jun 19, 2017
2 parents 4eb9a85 + 1a47ffd commit 369e71c
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 21 deletions.
5 changes: 4 additions & 1 deletion CHANGES
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@

2017/06/19 (version 1.9.9)

BUGFIX: Improved Python interface to SimpleGridDB to make it
possible to write 1-D and 2-D files.

Improve validation error messages; some error messages were missing
spatial database label.

2017/03/24 (version 1.9.8)

Added temperature scale to Nondimensional.
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#

AC_PREREQ(2.59)
AC_INIT([spatialdata], [1.9.8], [baagaard@usgs.gov])
AC_INIT([spatialdata], [1.9.9], [baagaard@usgs.gov])
AC_CONFIG_HEADER([portinfo])
AC_CONFIG_AUX_DIR([./aux-config])
AC_CONFIG_MACRO_DIR([m4])
Expand Down
2 changes: 1 addition & 1 deletion spatialdata/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
##
## @brief Python top-level SpatialData module initialization

__version__ = "1.9.8"
__version__ = "1.9.9"

__all__ = ['geocoords',
'spatialdb',
Expand Down
6 changes: 2 additions & 4 deletions spatialdata/spatialdb/GravityField.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,11 @@ def _validateParameters(self, params):
Validate parameters.
"""
if (len(params.gravityDir) != 3):
raise ValueError, \
"Gravity direction must be a 3 component list or tuple."
raise ValueError("Gravity direction must be a 3 component list or tuple.")
try:
dirFloat = map(float, params.gravityDir)
except:
raise ValueError, \
"'gravityDir' must contain floating point values."
raise ValueError("Gravity direction must contain floating point values.")
return


Expand Down
2 changes: 1 addition & 1 deletion spatialdata/spatialdb/SimpleGridDB.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def _parseQueryString(self, label):
elif label.lower() == "linear":
value = ModuleSimpleGridDB.LINEAR
else:
raise ValueError("Unknown value for query type '%s'." % label)
raise ValueError("Unknown value for query type '%s' in spatial database %s." % (label, self.label))
return value


Expand Down
7 changes: 3 additions & 4 deletions spatialdata/spatialdb/SimpleIO.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,9 @@ def _validateData(self, data):
(numLocs, spaceDim) = data['points'].shape
cs = data['coordsys']
if spaceDim != cs.spaceDim():
raise ValueError, \
"Simple database space-dim (%d) does not agree with spatial "\
"dimension of coordinate system (%d)." % \
(spaceDim, cs.spaceDim())
raise ValueError("Simple database '%s' space-dim (%d) does not agree with spatial "\
"dimension of coordinate system (%d)." % \
(self.label, spaceDim, cs.spaceDim()))
return


Expand Down
16 changes: 7 additions & 9 deletions spatialdata/spatialdb/UniformDB.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,14 @@ def _validateParameters(self, params):
Validate parameters.
"""
if len(params.values) == 0:
raise ValueError("Values in UniformDB not specified.")
raise ValueError("Values in UniformDB '%s' not specified.", self.inventory.label)
if len(params.data) == 0:
raise ValueError("Data for UniformDB not specified.")
raise ValueError("Data for UniformDB '%s' not specified." % self.inventory.label)
if len(params.values) != len(params.data):
raise ValueError, \
"Incompatible settings for uniform spatial database '%s'.\n"\
"'values' and 'data' must be lists of the same size.\n"\
"'values' has size of %d but 'data' has size of %d." \
% (self.label, len(params.values), len(params.data))
raise ValueError("Incompatible settings for uniform spatial database '%s'.\n"\
"'values' and 'data' must be lists of the same size.\n"\
"'values' has size of %d but 'data' has size of %d." \
% (self.inventory.label, len(params.values), len(params.data)))
try:
for x in params.data:
if len(str(x).split("*")) > 1:
Expand All @@ -128,8 +127,7 @@ def _validateParameters(self, params):
else:
dataFloat = float(x)
except:
raise ValueError, \
"'data' list must contain dimensioned or nondimensional values."
raise ValueError("'data' list for UniformDB '%s' must contain dimensioned or nondimensional values." % self.inventory.label)
return


Expand Down

0 comments on commit 369e71c

Please sign in to comment.