markovmodel / PyEMMA

🚂 Python API for Emma's Markov Model Algorithms 🚂
http://pyemma.org
GNU Lesser General Public License v3.0
307 stars 118 forks source link

tqdm breaks jupyter notebook #1438

Closed Ginok1 closed 4 years ago

Ginok1 commented 4 years ago

When using jupyter notebook, VAMP and TICA are unable to build objects based on more than 2 trajectories. I assume this is because tqdm tries to show some kind of loading bar, that can't properly be shown in the notebook.

Here is my code and the corresponding error. Running the same code as a "code.py" via python3 in shell works perfectly fine.

btw: The documentation of VAMP is missing a description of the data parameter.

from pyemma.coordinates import vamp
import numpy as np

test_traj_list = []
for i in range(10):
    test_traj_list.append(np.random.rand(20,5))

vamp_object = vamp(data = test_traj_list)

AttributeError Traceback (most recent call last)

in ----> 1 vamp_object = vamp(data = test_traj_list) ~/miniconda3/lib/python3.7/site-packages/pyemma/coordinates/api.py in vamp(data, lag, dim, scaling, right, ncov_max, stride, skip, chunksize) 1421 res = VAMP(lag, dim=dim, scaling=scaling, right=right, skip=skip, ncov_max=ncov_max) 1422 if data is not None: -> 1423 res.estimate(data, stride=stride, chunksize=chunksize) 1424 else: 1425 res.chunksize = chunksize ~/miniconda3/lib/python3.7/site-packages/pyemma/coordinates/data/_base/transformer.py in estimate(self, X, **kwargs) 213 """ Basis class for pipelined Transformers, which perform also estimation. """ 214 def estimate(self, X, **kwargs): --> 215 super(StreamingEstimationTransformer, self).estimate(X, **kwargs) 216 # we perform the mapping to memory exactly here, because a StreamingEstimator on its own 217 # has not output to be mapped. Only the combination of Estimation/Transforming has this feature. ~/miniconda3/lib/python3.7/site-packages/pyemma/coordinates/data/_base/streaming_estimator.py in estimate(self, X, chunksize, **kwargs) 42 # run estimation 43 try: ---> 44 super(StreamingEstimator, self).estimate(X, **kwargs) 45 except NotConvergedWarning as ncw: 46 self.logger.info( ~/miniconda3/lib/python3.7/site-packages/pyemma/_base/estimator.py in estimate(self, X, **params) 405 if params: 406 self.set_params(**params) --> 407 self._model = self._estimate(X) 408 # ensure _estimate returned something 409 assert self._model is not None ~/miniconda3/lib/python3.7/site-packages/pyemma/coordinates/transform/vamp.py in _estimate(self, iterable, **kw) 609 " with dimension (%i, %i)" % (self._lag, indim, indim)) 610 --> 611 covar.estimate(iterable, **kw) 612 self.model.update_model_params(mean_0=covar.mean, 613 mean_t=covar.mean_tau, ~/miniconda3/lib/python3.7/site-packages/pyemma/coordinates/data/_base/streaming_estimator.py in estimate(self, X, chunksize, **kwargs) 42 # run estimation 43 try: ---> 44 super(StreamingEstimator, self).estimate(X, **kwargs) 45 except NotConvergedWarning as ncw: 46 self.logger.info( ~/miniconda3/lib/python3.7/site-packages/pyemma/_base/estimator.py in estimate(self, X, **params) 405 if params: 406 self.set_params(**params) --> 407 self._model = self._estimate(X) 408 # ensure _estimate returned something 409 assert self._model is not None ~/miniconda3/lib/python3.7/site-packages/pyemma/coordinates/estimation/covariance.py in _estimate(self, iterable, partial_fit) 208 #self.skipped=0 209 pg = ProgressReporter() --> 210 pg.register(it.n_chunks, 'calculate covariances', stage=0) 211 with it, pg.context(stage=0): 212 self._init_covar(partial_fit, it.n_chunks) ~/miniconda3/lib/python3.7/site-packages/pyemma/_base/progress/reporter/__init__.py in register(self, amount_of_work, description, stage, tqdm_args) 218 219 def register(self, amount_of_work, description='', stage=0, tqdm_args=None): --> 220 self._progress_register(amount_of_work=amount_of_work, description=description, stage=stage, tqdm_args=tqdm_args) 221 222 def update(self, increment, stage=0): ~/miniconda3/lib/python3.7/site-packages/pyemma/_base/progress/reporter/__init__.py in _progress_register(self, amount_of_work, description, stage, tqdm_args) 143 if _attached_to_ipy_notebook_with_widgets(): 144 from .notebook import my_tqdm_notebook --> 145 pg = my_tqdm_notebook(leave=False, **args) 146 else: 147 import tqdm ~/miniconda3/lib/python3.7/site-packages/tqdm/notebook.py in __init__(self, *args, **kwargs) 216 # Print initial bar state 217 if not self.disable: --> 218 self.display() 219 220 def __iter__(self, *args, **kwargs): ~/miniconda3/lib/python3.7/site-packages/tqdm/notebook.py in display(self, msg, pos, close, bar_style) 151 msg = self.__repr__() 152 --> 153 pbar, ptext = self.container.children 154 pbar.value = self.n 155 AttributeError: 'function' object has no attribute 'children'

conda_list.txt I am working on Debian 4.12.13-1~bpo9+1 (2017-09-28) x86_64 GNU/Linux

marscher commented 4 years ago

Thanks for your report. Please upgrade pyemma to 2.5.7, where this issue has been dealt with.

marscher commented 4 years ago

duplicate of #1433