pytorch-ts
pytorch-ts copied to clipboard
ImportError of 'maybe_len'
Hello,
I installed pytorchts by using command pip install pytorchts.
It occurs an ImportError when import maybe_len from gluonts.itertools
from gluonts.itertools import maybe_len
Could you tell me how to solve this problem?
https://ts.gluon.ai/_modules/gluonts/support/util.html#maybe_len
def maybe_len(obj) -> Optional[int]:
try:
return len(obj)
except (NotImplementedError, AttributeError):
return None
try this in pytorch-ts/pts/model/estimator.py:
# from gluonts.itertools import maybe_len
from gluonts.support.util import maybe_len
So recently gluonts refactored this method in their master branch and so in preparation for this change, I also merged in a fix in pytorch-ts' master branch. If you are using the release version then you should not have an issue... else you might want to use the master branch of gluonts and pytorch-ts.
hope that helps!