[cig-commits] [commit] master: py: Use correct exceptions instead of generic raise. (398a2b0)

cig_noreply at geodynamics.org cig_noreply at geodynamics.org
Sat Jan 17 08:39:48 PST 2015


Repository : https://github.com/geodynamics/specfem1d

On branch  : master
Link       : https://github.com/geodynamics/specfem1d/compare/58c6e68e5fc4e335b2fa135ce471179cc1f417fc...d71011cecc0efd4599edda577831565bbebd41ac

>---------------------------------------------------------------

commit 398a2b00d4702e6d42110fb122aa25a59788b4c2
Author: Elliott Sales de Andrade <esalesde at physics.utoronto.ca>
Date:   Fri Jan 16 18:11:02 2015 -0500

    py: Use correct exceptions instead of generic raise.


>---------------------------------------------------------------

398a2b00d4702e6d42110fb122aa25a59788b4c2
 Python_version/config.py |  3 +--
 Python_version/grid.py   | 11 +++++------
 2 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/Python_version/config.py b/Python_version/config.py
index 8f7a893..95d70f7 100644
--- a/Python_version/config.py
+++ b/Python_version/config.py
@@ -171,8 +171,7 @@ class Source(object):
             self.decayRate = param.decayRate
             self.alpha = self.decayRate / self.hdur
         else:
-            print "Unknown source's type"
-            raise
+            raise ValueError('Unknown source type: %s' % (self.typeOfSource, ))
 
     def __getitem__(self, t):
         """What happens when we do source[t]"""
diff --git a/Python_version/grid.py b/Python_version/grid.py
index b2692f8..656dc6b 100644
--- a/Python_version/grid.py
+++ b/Python_version/grid.py
@@ -39,17 +39,16 @@ class OneDimensionalGrid(object):
             self.z[-1] = self.ticks[-1]
 
         elif param.gridType == 'gradient':
-            print "typeOfGrid == 'gradient' Has not been implemented yet"
-            raise
+            msg = "typeOfGrid == 'gradient' has not been implemented yet"
+            raise NotImplementedError(msg)
         elif param.gridType == 'miscellaneous':
-            print "typeOfGrid == 'miscellaneous' Has not been implemented yet"
-            raise
+            msg = "typeOfGrid == 'miscellaneous' has not been implemented yet"
+            raise NotImplementedError(msg)
         elif param.gridType == 'file':
             self.z, self.rho, self.mu = np.loadtxt(param.gridFile, unpack=True)
             self.ticks = np.loadtxt(param.ticksFile)
         else:
-            print "Unknown grid's type"
-            raise
+            raise ValueError('Unknown grid type: %s' % (param.gridType, ))
         # Jacobians at the GLL (and GLJ for the first element in axisym)
         # points (arrays nSpec*(N+1) elements)
         self.dXdKsi = gll.jacobian(self.ticks, param)



More information about the CIG-COMMITS mailing list