Skip to content

Commit

Permalink
Merge pull request #19 from tovrstra/cipy37
Browse files Browse the repository at this point in the history
Enable CI with Python 3.7
  • Loading branch information
tovrstra committed Sep 12, 2019
2 parents 79e853c + ab40687 commit ea680bb
Show file tree
Hide file tree
Showing 49 changed files with 1,033 additions and 962 deletions.
25 changes: 9 additions & 16 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
env:
matrix:
- MYCONDAPY=2.7
# - MYCONDAPY=3.7
- MYCONDAPY=3.6
- MYCONDAPY=3.7
global:
# ANACONDA_TOKEN
- secure: "JCX7xPCgInrZVvt78cZeU+M4dx0CWC7MmVawSR4GqoAxrscG5yEkTjbG0uL6jVc1OxV2wiEzzY\
rtYYUnRY4W0UCs2hHSew99REUKm4UE52mKI+pcN0KDEVdub2pcNamfL1t00mjfOG6fzOZ02dN+ugDSmJJXLGOzYRB\
mAZNgWC4="
- secure: "C9W6W6tPzXEhMWpkrRSf3lx6f3JJ5j5jZCsGymUQqrF9SU7RLgTvINc57M72s+I9enaL8wvldELzut0pamzMxuicFeFsSZzPlBuPdJcAy1QdxDYI3HWM8g/TmLTq9PV9sBgmbJ7rO7hGYdAXcTcrfFQk3SBARUWF5IGA95k+Kto="
# GITHUB_TOKEN
- secure: "JjZdWGS8ZxYw5GBChepbu4jEJpT5Hemgj4DITkmridUdyjRB+hpxxR3z08pDz3SXkmuEsXyLsx\
7RJAg2a+IpCnK8sG4wrOyb3Jf0tXhE1vKa1t80CVXDd0somQe6Mna+7X5SrOsP5pLs1IsaP/j6pnrDCPB2wUP3g/j\
/iAQ1SP8="
- secure: "Skwu+NVG5NuZdp6G8N4y4dPS4nGmifg2NSgp/Vz2vUO0R34IrdY/lBT0aWoDMVxxYnG6h8U0S4mr3NKgVvcbugXD/omDDLJlg07PmpByrZI42gSpRcnQ6CVq8teEwCFT923ZaM5T+jujTHHQ3fzP219J/Jy+WxyImUjDVTxIzBQ="
# PYPI_PASSWD
- secure: "CVw8wOQNRR7E7McAsy52Rq3f1eAvn4ukfWhW6Nn5H7GwQzha+qykm1MOnj3U1qsg7qvPvg0k2L\
wVYkPU6nImdqHqQt8R8ekiNQNP9z97pGlJDC8T3hc/5VpvaRQA3E2wI5jzvHhNLafum/ss5h1+CsOs2AkdKgwRzM6\
HlxbmLCE="
- secure: "K3A2uBMjw2akoLaVeKMkW7kpxsui5yz9GClUjWgP2L/hbt9S4S81fwE+8htw2gDmM1ehFDhWgbHYU1HomB3k6KHhaBxmtyZ842dewqZRgtdwKQUyVleK0FaB+I1MpJyVggABfAbwSuqCDaL2QxDVnDmwdJ45yed4DPemyuCMkEw="
- PYPKG=tamkin
- GITHUB_REPO_NAME=molmod/tamkin

Expand Down Expand Up @@ -48,21 +43,19 @@ install:
fi;
fi
- bash miniconda.sh -b -p $HOME/miniconda
- export PATH="$HOME/miniconda/bin:$PATH"
- source ~/miniconda/bin/activate
- hash -r

# Configure conda and get a few essentials
- conda config --set always_yes yes --set changeps1 no
- conda update -q conda
- conda update conda
# Get the right python version for building. This only does something for 3.5.
# Install extra package needed to make things work. Most things can be listed as
# dependencies on metal.yaml and setup.py, unless setup.py already imports them.
# Install conda tools for packaging and uploading
- conda install python=${MYCONDAPY} sphinx conda-build anaconda-client numpy
- conda install python=${MYCONDAPY} sphinx conda-build anaconda-client numpy codecov coverage nose graphviz conda-verify
# Add the molmod channel to get access to the molmod dependency
- conda config --add channels molmod
# Install more recent stuff with pip
- pip install codecov coverage
# Show conda info for debugging
- conda info -a

Expand All @@ -78,7 +71,7 @@ script:

# Build the conda package
- git fetch origin --tags
- conda build -q tools/conda.recipe
- conda build tools/conda.recipe

# Build source package, should work too and needed for deployment.
- python setup.py sdist
Expand Down
2 changes: 1 addition & 1 deletion doc/getscriptdoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@
import imp
import codecs

script = imp.load_source('tamkin-driver', '../scripts/tamkin-driver')
script = imp.load_source('tamkin-driver', '../tamkin/driver.py')
with codecs.open('reference/tamkin-driver.rst', 'w', 'utf-8') as f:
f.write(script.__doc__)
21 changes: 12 additions & 9 deletions doc/tutorial/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,30 +53,31 @@ distribution to install these dependencies.

The following software must be installed for TAMkin:

* Python >=2.7,<3.0: http://www.python.org/doc/
* Python >=2.7,>=3.6: http://www.python.org/doc/
* Numpy >=1.0: http://numpy.scipy.org/
* Scipy >=0.17.1: http://www.scipy.org/
* MatPlotLib >=1.1: http://matplotlib.org/
* MolMod >=1.3.1: https://github.com/molmod/molmod/
* Nosetests >=0.11: http://nose.readthedocs.io/en/latest/

Most Linux distributions can install most required software with a single command. Except
for Python, missing dependencies will get automatically installed by pip. (See below.)
Most Linux distributions can install most required software with a single
command. Except for Python, missing dependencies will get automatically
installed by pip. (See below.)

* **Ubuntu**

sudo apt-get install python python-numpy python-scipy python-matplotlib
sudo apt-get install python python-numpy python-scipy python-matplotlib python-nose

* **Debian 5** or newer. You first have to become root because the sudo program is not
configured by default::

su -
apt-get install python python-numpy python-scipy python-matplotlib
apt-get install python python-numpy python-scipy python-matplotlib python-nose
exit

* **Fedora 17 to 22**
* **Fedora 23 and up**

sudo yum install python numpy scipy python-matplotlib
sudo dnf install python numpy scipy python-matplotlib python-nose


Installation
Expand All @@ -88,20 +89,22 @@ TAMkin can be installed with pip (system wide or in a virtual environment):
pip install numpy
pip install tamkin
pip install nose # only needed to run unit tests
Alternatively, you can install TAMkin in your home directory:

.. code:: bash
pip install numpy --user
pip install tamkin --user
pip install nose --user # only needed to run unit tests
Lastly, you can also install MolMod with conda. (See
Lastly, you can also install TAMkin with conda. (See
https://www.continuum.io/downloads)

.. code:: bash
conda install -c molmod tamkin
conda install -c molmod tamkin nose
Testing your installation
Expand Down
9 changes: 4 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,18 +92,17 @@
url='http://molmod.ugent.be/code/',
package_dir = {'tamkin': 'tamkin'},
packages = ['tamkin', 'tamkin.io', 'tamkin.test'],
scripts=["scripts/tamkin-driver"],
entry_points={
'console_scripts': ['tamkin-driver = tamkin.driver:main']
},
include_package_data=True,
install_requires=['numpy>=1.0', 'nose>=0.11', 'matplotlib>1.1',
'molmod>=1.3.2', 'scipy>=0.17.1'],
install_requires=['numpy>=1.0', 'matplotlib>1.1', 'molmod>=1.3.2', 'scipy>=0.17.1'],
classifiers=[
'Environment :: Console',
'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)',
'Operating System :: POSIX :: Linux',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Topic :: Scientific/Engineering :: Physics',
Expand Down
18 changes: 8 additions & 10 deletions tamkin/chemmod.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"""Convenient interfaces to define thermodynamic and kinetic models"""


from __future__ import print_function
from __future__ import print_function, division

import numpy as np, csv

Expand Down Expand Up @@ -223,10 +223,9 @@ def write_table(self, temp, filename):
quantities.
| ``filename`` -- The name of the CSV file.
"""
f = open(filename, "w")
c = csv.writer(f)
self.dump_table(temp, c)
f.close()
with open(filename, "w") as f:
c = csv.writer(f)
self.dump_table(temp, c)


def dump_table(self, temp, c):
Expand Down Expand Up @@ -276,9 +275,8 @@ def write_to_file(self, filename):
One argument:
| ``filename`` -- The file to write the output.
"""
f = open(filename, "w")
self.dump(f)
f.close()
with open(filename, "w") as f:
self.dump(f)

def dump(self, f):
"""Write all info about the model to a file."""
Expand Down Expand Up @@ -435,8 +433,8 @@ def __init__(self, tm, km):
BaseKineticModel.__init__(self)
self.tm = tm
self.km = km
self._add_pfs(tm.pfs_all.iteritems())
self._add_pfs(km.pfs_all.iteritems())
self._add_pfs(tm.pfs_all.items())
self._add_pfs(km.pfs_all.items())
self._set_unit(per_second=True)

def rate_constant(self, temp, do_log=False):
Expand Down
16 changes: 9 additions & 7 deletions tamkin/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
output with a standardized interface.
"""

from __future__ import print_function, division

from tamkin.geom import transrot_basis

from molmod import Molecule as BaseMolecule, MolecularGraph, ReadOnly, \
Expand Down Expand Up @@ -68,13 +70,13 @@ def check_hessian(self, hessian):

energy = ReadOnlyAttribute(float, none=False)
gradient = ReadOnlyAttribute(np.ndarray, none=False,
check=check_gradient, npdim=2, npshape=(None, 3), npdtype=float)
check=check_gradient, npdim=2, npshape=(None, 3), npdtype=np.floating)
hessian = ReadOnlyAttribute(np.ndarray, none=False,
check=check_hessian, npdim=2, npdtype=float)
check=check_hessian, npdim=2, npdtype=np.floating)
multiplicity = ReadOnlyAttribute(int)
symmetry_number = ReadOnlyAttribute(int)
periodic = ReadOnlyAttribute(bool)
fixed = ReadOnlyAttribute(np.ndarray, npdim=1, npdtype=int)
fixed = ReadOnlyAttribute(np.ndarray, npdim=1, npdtype=np.signedinteger)

def __init__(self, numbers, coordinates, masses, energy, gradient, hessian, multiplicity=None, symmetry_number=None, periodic=False, title=None, graph=None, symbols=None, unit_cell=None, fixed=None):
"""
Expand Down Expand Up @@ -287,7 +289,7 @@ def read_from_file(cls, filename):
mandatory_fields = set([
"numbers", "coordinates", "masses", "energy", "gradient", "hessian"
])
if not set(data.iterkeys()).issuperset(mandatory_fields):
if not set(data).issuperset(mandatory_fields):
raise IOError("The Checkpoint file does not contain the mandatory fields.")
# take the mandatory fields
constructor_args = {}
Expand Down Expand Up @@ -454,11 +456,11 @@ def check_top_indexes(self, top_indexes):
"rotating")

dihedral = ReadOnlyAttribute(np.ndarray, none=False, npdim=1,
npshape=(4,), npdtype=int)
npshape=(4,), npdtype=np.signedinteger)
top_indexes = ReadOnlyAttribute(np.ndarray, none=False,
check=check_top_indexes, npdim=1, npdtype=int)
check=check_top_indexes, npdim=1, npdtype=np.signedinteger)
potential = ReadOnlyAttribute(np.ndarray, npdim=2, npshape=(2, None),
npdtype=float)
npdtype=np.floating)

def __init__(self, dihedral, molecule=None, top_indexes=None, potential=None):
"""
Expand Down
17 changes: 11 additions & 6 deletions scripts/tamkin-driver → tamkin/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>
#
#--
#!/usr/bin/env python
# --
u'''\
The TAMkin driver script
Expand Down Expand Up @@ -270,12 +269,18 @@
'''


from __future__ import print_function
import sys, os, numpy as np
from __future__ import print_function, division

import sys
import os
from glob import glob
from tamkin import *

import numpy as np
from molmod.periodic import periodic

from tamkin import *


# A few variables for debugging purposes only
gradient_threshold = 1e-2
v_threshold = 0.01
Expand Down Expand Up @@ -520,7 +525,7 @@ def get_pf(dn, temps):

def get_chemical_formula(numbers):
tmp = dict((number, (numbers == number).sum()) for number in np.unique(numbers))
return ' '.join(['%s_%i' % (periodic[number].symbol, count) for number, count in tmp.iteritems()])
return ' '.join(['%s_%i' % (periodic[number].symbol, count) for number, count in tmp.items()])


def check_mass_balance(pfs1, pfs2, name1, name2):
Expand Down
13 changes: 6 additions & 7 deletions tamkin/examples/004_alkanes/bin/analyse_static.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,12 @@


# Write the frequencies to a csv file
f = open(os.path.join(args[0], "freqs.csv"), "w")
print('"Frequency","Wavenumber","Vibrational temperature"', file=f)
print('"Atomic units","1/cm","K"', file=f)
for i in range(len(pf.vibrational.freqs)):
freq = pf.vibrational.freqs[i]
print('%e,%f,%f' % (freq, freq/lightspeed*centimeter, 2*numpy.pi*freq/boltzmann), file=f)
f.close()
with open(os.path.join(args[0], "freqs.csv"), "w") as f:
print('"Frequency","Wavenumber","Vibrational temperature"', file=f)
print('"Atomic units","1/cm","K"', file=f)
for i in range(len(pf.vibrational.freqs)):
freq = pf.vibrational.freqs[i]
print('%e,%f,%f' % (freq, freq/lightspeed*centimeter, 2*numpy.pi*freq/boltzmann), file=f)


# B) Generate a thermo analysis report
Expand Down
2 changes: 1 addition & 1 deletion tamkin/examples/004_alkanes/bin/xyz2psf.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
}

def get_atom_type(index, graph):
for atom_type, atom_filter in atom_filters.iteritems():
for atom_type, atom_filter in atom_filters.items():
if atom_filter(index, graph):
return atom_type
raise ValueError("Unrecognized atom (index %i)." % index)
Expand Down
55 changes: 27 additions & 28 deletions tamkin/examples/010_adk/output/get_overlap_7-7.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,35 +47,35 @@


def get_freqs_and_overlap_7_7(filename):
f = open(filename)
print("-"*20)
print("Reading file...", filename)
with open(filename) as f:
print("-"*20)
print("Reading file...", filename)

# read 7th freq on first line (first element is 0, so is 8th freq)
for line in f:
words = line.split(";")
#freq1 = float(words[7]) # !!!!!!!!!!!!!
freq1 = float(words[-1])
break

# get 7th freq in first column (we already skipped first line)
# and overlap 7th-7th
count = 0
for line in f:
count +=1
if count==7:
# read 7th freq on first line (first element is 0, so is 8th freq)
for line in f:
words = line.split(";")
freq2 = float(words[0])
#overlap = float(words[7]) # !!!!!!!!!
overlap = float(words[-1])
#freq1 = float(words[7]) # !!!!!!!!!!!!!
freq1 = float(words[-1])
break

f.close()
print("freq1: ", freq1)
print("freq2: ", freq2)
print("overlap: ", overlap)
# get 7th freq in first column (we already skipped first line)
# and overlap 7th-7th
count = 0
for line in f:
count +=1
if count==7:
words = line.split(";")
freq2 = float(words[0])
#overlap = float(words[7]) # !!!!!!!!!
overlap = float(words[-1])
break

f.close()
print("freq1: ", freq1)
print("freq2: ", freq2)
print("overlap: ", overlap)

return freq1, freq2, overlap
return freq1, freq2, overlap


import sys, glob
Expand All @@ -99,8 +99,7 @@ def get_freqs_and_overlap_7_7(filename):
conv = 7.25163277859109E-07 # conversion factor such that frequencies are printed in 1/cm

filename_out = "delta.overlaps.7-7.csv"
f = open(filename_out,"w+")
for i in range(len(freqs1)):
print(filenames[i]+";"+str(freqs1[i]/conv)+";"+str(freqs2[i]/conv)+";"+str(overlaps[i]), file=f)
f.close()
with open(filename_out, "w+") as f:
for i in range(len(freqs1)):
print(filenames[i]+";"+str(freqs1[i]/conv)+";"+str(freqs2[i]/conv)+";"+str(overlaps[i]), file=f)
print("file written:", filename_out)
Loading

0 comments on commit ea680bb

Please sign in to comment.