batchglm icon indicating copy to clipboard operation
batchglm copied to clipboard

print(test.model) throws RecursionError

Open ilibarra opened this issue 4 years ago • 2 comments

When printing the type of test.model, an error is thrown.

print(test.model)
---------------------------------------------------------------------------
RecursionError                            Traceback (most recent call last)
<ipython-input-28-359bfcc26acd> in <module>
----> 1 print(test.model)
~/miniconda3/envs/batchglm_gpu/lib/python3.8/site-packages/batchglm/models/base/model.py in __repr__(self)
     43 
     44     def __repr__(self):
---> 45         return self.__str__()
... last 1 frames repeated, from the frame below ...
~/miniconda3/envs/batchglm_gpu/lib/python3.8/site-packages/batchglm/models/base/model.py in __repr__(self)
     43 
     44     def __repr__(self):
---> 45         return self.__str__()
RecursionError: maximum recursion depth exceeded while calling a Python object

The type of test.model can be checked when by using type

type(test.model)
batchglm.train.numpy.glm_nb.model.ModelIwlsNb

The correction seems to be fixing that self.str() recursion while calling __str__()

ilibarra avatar Jan 18 '21 17:01 ilibarra

Thanks! We can open a PR for this!

davidsebfischer avatar Jan 21 '21 12:01 davidsebfischer

Has been fixed here #130 but this is a breaking change since the entire API is reworked. I will leave this open until the next release and inform once we're done merging.

picciama avatar Mar 04 '22 12:03 picciama