When there are very many MP trees, it's possible to get the following error during inference:
AttributeError: 'int' object has no attribute 'log'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/wdumm/Downloads/gctree/gctree/branching_processes.py", line 1124, in mle
self.parameters = _mle_helper(self.ll, **kwargs)
File "/Users/wdumm/Downloads/gctree/gctree/branching_processes.py", line 1631, in _mle_helper
grad_check = sco.check_grad(lambda x: f(x)[0], lambda x: f(x)[1], x_0)
File "/Users/wdumm/Downloads/gctreetestenv/lib/python3.9/site-packages/scipy/optimize/_optimize.py", line 1178, in check_grad
analytical_grad = grad(x0, *args)
File "/Users/wdumm/Downloads/gctree/gctree/branching_processes.py", line 1631, in <lambda>
grad_check = sco.check_grad(lambda x: f(x)[0], lambda x: f(x)[1], x_0)
File "/Users/wdumm/Downloads/gctree/gctree/branching_processes.py", line 1629, in f
return tuple(-y for y in ll(*x, **kwargs))
File "/usr/local/Cellar/python@3.9/3.9.18_2/Frameworks/Python.framework/Versions/3.9/lib/python3.9/contextlib.py", line 79, in inner
return func(*args, **kwds)
File "/Users/wdumm/Downloads/gctree/gctree/branching_processes.py", line 1104, in ll
return (-np.log(count_ls.sum()) + scs.logsumexp(ls, b=count_ls)), np.array(
TypeError: loop of ufunc does not support argument 0 of type int which has no callable log method
This is because numpy.log doesn't work on integer arguments greater than 2**64. Luckily in this case we're always just calling log on an integer (not arrays) so the fix is simply to use math.log.
When there are very many MP trees, it's possible to get the following error during inference:
This is because
numpy.log
doesn't work on integer arguments greater than 2**64. Luckily in this case we're always just calling log on an integer (not arrays) so the fix is simply to usemath.log
.