PropMap Bug fix with unmapped derivs.

This commit is contained in:
Rowan Cockett
2015-06-01 15:41:25 -07:00
parent d07bb6722b
commit 658d481dd6
2 changed files with 11 additions and 2 deletions
+4 -1
View File
@@ -68,7 +68,10 @@ class Property(object):
if mapping is None and prop.propertyLink is not None:
linkName, linkMapClass = prop.propertyLink
linkMap = linkMapClass(None) * getattr(self, '%sMap'%linkName)
linkedMap = getattr(self, '%sMap'%linkName)
if linkedMap is None:
return None
linkMap = linkMapClass(None) * linkedMap
m = getattr(self, '%s'%linkName)
return linkMap.deriv( m )
+7 -1
View File
@@ -10,7 +10,8 @@ class MyPropMap(Maps.PropMap):
class MyReciprocalPropMap(Maps.PropMap):
sigma = Maps.Property("Electrical Conductivity", defaultInvProp=True, propertyLink=('rho', Maps.ReciprocalMap))
rho = Maps.Property("Electrical Resistivity", propertyLink=('sigma', Maps.ReciprocalMap))
mu = Maps.Property("Mu", defaultVal=mu_0)
mu = Maps.Property("Mu", defaultVal=mu_0, propertyLink=('mui', Maps.ReciprocalMap))
mui = Maps.Property("Mu", defaultVal=1./mu_0, propertyLink=('mu', Maps.ReciprocalMap))
class TestPropMaps(unittest.TestCase):
@@ -102,6 +103,11 @@ class TestPropMaps(unittest.TestCase):
assert pm.sigmaDeriv is not None
assert pm.rhoDeriv is not None
assert pm.muMap is None
assert pm.muDeriv is None
assert pm.muiMap is None
assert pm.muiDeriv is None
PM = MyReciprocalPropMap([('rho', iMap)])
pm = PM(np.r_[1,2.,3])
# print pm.sigma