Skip to content

Commit

Permalink
Merge pull request #60 from twiecki/fix_pandas_object_dtype
Browse files Browse the repository at this point in the history
Only cast pandas Series or DataFrame to numpy if dtype is not 'O'.
  • Loading branch information
Chris Fonnesbeck committed Oct 13, 2015
2 parents 7641d70 + e107350 commit 77874e4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
6 changes: 3 additions & 3 deletions pymc/PyMCObjects.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ def gen_lazy_function(self):
parameter] = lazy_logp_partial_gradients

def get_logp(self):

if self.verbose > 1:
print_('\t' + self.__name__ + ': log-probability accessed.')
logp = self._logp.get()
Expand Down Expand Up @@ -736,9 +736,9 @@ def __init__(self,

# Initialize value, either from value provided or from random function.
try:
# Convert Pandas DataFrames and Series to numpy arrays
value = getattr(value, 'values', value)
if dtype.kind != 'O' and value is not None:
# Convert Pandas DataFrames and Series to numpy arrays
value = getattr(value, 'values', value)
self._value = np.array(value, dtype=dtype)
self._value.flags['W'] = False
else:
Expand Down
4 changes: 1 addition & 3 deletions pymc/distributions.py
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@ def bernoulli_like(x, p):
- :math:`Var(x)= p(1-p)`
"""

return flib.bernoulli(x, p)

bernoulli_grad_like = {'p': flib.bern_grad_p}
Expand Down Expand Up @@ -2976,8 +2976,6 @@ def valuewrapper(f, arguments=None):
"""
def wrapper(**kwds):
value = kwds.pop('value')
# Handle Pandas DataFrames
value = getattr(value, 'values', value)
return f(value, **kwds)

if arguments is None:
Expand Down

0 comments on commit 77874e4

Please sign in to comment.