# Buggy code
def getattr_value(self, val):
    if isinstance(val, string_types):
        val = getattr(self, val)

    if isinstance(val, tt.TensorVariable):
        return val.tag.test_value

    if isinstance(val, tt.sharedvar.TensorSharedVariable):
        return val.get_value()

    if isinstance(val, theano_constant):
        return val.value

    return val


# Traceback (TypeError)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-6-6131815c61f7> in <module>()
4     a = pm.Lognormal('a',mu=product_mu_shared, sd=product_sd)
5     b = pm.Normal('b',mu=0.0, sd=product_sd)
----> 6     d = pm.Normal('d', mu=product_mu_shared, sd=product_sd)
7
8

C:\ProgramData\Anaconda3\lib\site-packages\pymc3\distributions\distribution.py in __new__(cls, name, *args, **kwargs)
40             total_size = kwargs.pop('total_size', None)
41             dist = cls.dist(*args, **kwargs)
---> 42             return model.Var(name, dist, data, total_size)
43         else:
44             raise TypeError("Name needs to be a string but got: {}".format(name))

C:\ProgramData\Anaconda3\lib\site-packages\pymc3\model.py in Var(self, name, dist, data, total_size)
806                 with self:
807                     var = FreeRV(name=name, distribution=dist,
--> 808                                  total_size=total_size, model=self)
809                 self.free_RVs.append(var)
810             else:

C:\ProgramData\Anaconda3\lib\site-packages\pymc3\model.py in __init__(self, type, owner, index, name, distribution, total_size, model)
1205             self.distribution = distribution
1206             self.tag.test_value = np.ones(
-> 1207                 distribution.shape, distribution.dtype) * distribution.default()
1208             self.logp_elemwiset = distribution.logp(self)
1209             # The logp might need scaling in minibatches.

C:\ProgramData\Anaconda3\lib\site-packages\pymc3\distributions\distribution.py in default(self)
65
66     def default(self):
---> 67         return np.asarray(self.get_test_val(self.testval, self.defaults), self.dtype)
68
69     def get_test_val(self, val, defaults):

C:\ProgramData\Anaconda3\lib\site-packages\pymc3\distributions\distribution.py in get_test_val(self, val, defaults)
70         if val is None:
71             for v in defaults:
---> 72                 if hasattr(self, v) and np.all(np.isfinite(self.getattr_value(v))):
73                     return self.getattr_value(v)
74         else:

TypeError: ufunc 'isfinite' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''```

**Please provide any additional information below.**


## Versions and main components

* PyMC3 Version: 3.5
* Theano Version: 1.0.2
* Python Version: 3.6
* Operating system: Windows 10
* How did you install PyMC3: (conda/pip) conda-forge

# Fixed code
def getattr_value(self, val):
    if isinstance(val, string_types):
        val = getattr(self, val)

    if isinstance(val, tt.TensorVariable):
        return val.tag.test_value

    if isinstance(val, tt.sharedvar.SharedVariable):
        return val.get_value()

    if isinstance(val, theano_constant):
        return val.value

    return val