insilichem / ommprotocol

A command line application to launch molecular dynamics simulations with OpenMM
http://ommprotocol.readthedocs.io
GNU Lesser General Public License v3.0
39 stars 8 forks source link

unsupported operand type(s) for /: 'datetime.timedelta' and 'int' #5

Closed danielSoler93 closed 7 years ago

danielSoler93 commented 7 years ago

When printing out on screen:

Traceback (most recent call last): File "/home/daniel/anaconda3/envs/py27/bin/ommprotocol", line 9, in load_entry_point('ommprotocol', 'console_scripts', 'ommprotocol')() File "/home/daniel/repos/ommprotocol/ommprotocol/init.py", line 19, in run_protocol protocol(handler, cfg) File "/home/daniel/repos/ommprotocol/ommprotocol/md.py", line 91, in protocol pos, vel, box = stage.run() File "/home/daniel/repos/ommprotocol/ommprotocol/md.py", line 314, in run self.simulate() File "/home/daniel/repos/ommprotocol/ommprotocol/md.py", line 344, in simulate self.simulation.step(steps) File "/home/daniel/anaconda3/envs/py27/lib/python2.7/site-packages/simtk/openmm/app/simulation.py", line 132, in step self._simulate(endStep=self.currentStep+steps) File "/home/daniel/anaconda3/envs/py27/lib/python2.7/site-packages/simtk/openmm/app/simulation.py", line 219, in _simulate reporter.report(self, state) File "/home/daniel/repos/ommprotocol/ommprotocol/io.py", line 584, in report delta = (self.total_steps-steps)*time/steps TypeError: unsupported operand type(s) for /: 'datetime.timedelta' and 'int'

Version --> ommprotocol v0.1.3+0.g24fde72.dirty

jaimergp commented 7 years ago

I can't reproduce this bug with Python 2.7 nor Python 3.5. Can you provide more details on that, please? Which Python version are you using? Anyway, try with latest master (git pull should do).

danielSoler93 commented 7 years ago

Same issue with latests master.

FAILED :( Traceback (most recent call last): File "/home/daniel/anaconda3/envs/py27/bin/ommprotocol", line 9, in load_entry_point('ommprotocol==0.1.3+8.g68e67c1', 'console_scripts', 'ommprotocol')() File "build/bdist.linux-x86_64/egg/ommprotocol/init.py", line 19, in run_protocol File "build/bdist.linux-x86_64/egg/ommprotocol/md.py", line 92, in protocol File "build/bdist.linux-x86_64/egg/ommprotocol/md.py", line 315, in run File "build/bdist.linux-x86_64/egg/ommprotocol/md.py", line 345, in simulate File "/home/daniel/anaconda3/envs/py27/lib/python2.7/site-packages/simtk/openmm/app/simulation.py", line 132, in step self._simulate(endStep=self.currentStep+steps) File "/home/daniel/anaconda3/envs/py27/lib/python2.7/site-packages/simtk/openmm/app/simulation.py", line 219, in _simulate reporter.report(self, state) File "build/bdist.linux-x86_64/egg/ommprotocol/io.py", line 630, in report

TypeError: unsupported operand type(s) for /: 'datetime.timedelta' and 'int'

ommprotocol v0.1.3+8.g68e67c1 Python 2.7.12 conda env: my_conda_env.txt

Let me know if you need anything else.

jaimergp commented 7 years ago

Nah, nothing else. Python 2.x does not support float or int division for timedeltas. I'll fix this (possible workaround here) and report back.

jaimergp commented 7 years ago

Can you please create a .py file and run the attached code? It should print 245 to stdout.

#!/usr/bin/env python

from __future__ import print_function
from datetime import datetime
from time import sleep

t0 = datetime.now()
sleep(5)
total = 1500
steps = 30
time = datetime.now() - t0
delta = (total - steps)*time/steps
print(delta.seconds)
danielSoler93 commented 7 years ago

Runned on the same env as before with python and pychimera commands and everything works fine

jaimergp commented 7 years ago

So...? Does that mean it is magically fixed?

danielSoler93 commented 7 years ago

It is working on python pychimera and IDLE of chimera but when executing file and importing from eggs is not working...