Skip to content

Commit

Permalink
Bug fix to 0.2.x branch. Fix to the plot functions. Previously all x-…
Browse files Browse the repository at this point in the history
…axis values were being set to the `lowx` value given to the function.
  • Loading branch information
mjdrushton committed May 19, 2018
1 parent a90ff51 commit bee0847
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 19 deletions.
5 changes: 5 additions & 0 deletions CHANGES.md
@@ -1,5 +1,10 @@
#Change Log

##0.2.1 (2018-05-19)
### Bug-Fixes

* Fix to the plot functions. Previously all x-axis values were being set to the `lowx` value given to the function.

##0.2.0 (2018-05-01)
### New Features

Expand Down
2 changes: 1 addition & 1 deletion atsim/potentials/__init__.py
Expand Up @@ -82,7 +82,7 @@ def plotToFile(fileobj,lowx, highx, func, steps=10000):
:param highx: X-axis upper value
:param func: Function to be plotted
:param steps: Number of data points to be plotted"""
step = int((highx - lowx) // steps)
step = (highx - lowx) / float(steps)

for i in range(steps):
v = lowx + float(i)*step
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Expand Up @@ -48,7 +48,7 @@

# General information about the project.
project = u'atsim.potentials'
copyright = u'2014, M.J.D. Rushton'
copyright = u'2018, M.J.D. Rushton'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand Down
1 change: 0 additions & 1 deletion docs/potentials/zbl_spline.py
Expand Up @@ -4,7 +4,6 @@
import atsim.potentials

def main():

bks_buck = potentialforms.buck(18003.7572, 1.0/4.87318, 133.5381)
bks_coul = potentialforms.coul(2.4, -1.2)

Expand Down
4 changes: 2 additions & 2 deletions setup.py
Expand Up @@ -6,9 +6,9 @@
namespace_packages = ["atsim"],
test_suite = "tests",
setup_requires = ["setuptools"],
install_requires = [],
install_requires = ["future"],

version = '0.2.0',
version = '0.2.1',

# Meta-data for PyPI
description = "atsim.potentials provides tools for working with pair and embedded atom method potential models including tabulation routines for DL_POLY and LAMMPS",
Expand Down
7 changes: 3 additions & 4 deletions tests/_rundlpoly.py
@@ -1,5 +1,5 @@
from future import standard_library
standard_library.install_aliases()
# from future import standard_library
# standard_library.install_aliases()
from builtins import next
import unittest

Expand All @@ -11,11 +11,10 @@

def runDLPoly():
import subprocess
subprocess.getoutput('DLPOLY.Z')
subprocess.check_output('DLPOLY.Z', shell = True)

def extractDLPOLYEnergy():
with open('STATIS') as infile:
# import pdb;pdb.set_trace()
next(infile)
next(infile)
next(infile)
Expand Down
6 changes: 3 additions & 3 deletions tests/_runlammps.py
@@ -1,5 +1,5 @@
from future import standard_library
standard_library.install_aliases()
# from future import standard_library
# standard_library.install_aliases()
import unittest

import distutils
Expand All @@ -18,5 +18,5 @@ def extractLAMMPSEnergy():

def runLAMMPS():
import subprocess
output = subprocess.getoutput("lammps -in calc_energy.lmpin -log out.lmpout -echo none")
output = subprocess.check_output("lammps -in calc_energy.lmpin -log out.lmpout -echo none", shell = True)

23 changes: 16 additions & 7 deletions tests/test_documentation_examples.py
Expand Up @@ -7,6 +7,7 @@

import os
import unittest
import pytest
import imp
import shutil

Expand All @@ -29,7 +30,6 @@ def _getLAMMPSResourceDirectory():
def _getDLPolyResourceDirectory():
return os.path.join(os.path.dirname(__file__), 'dl_poly_resources')


def _loadModule(scriptname):
name = os.path.basename(scriptname)
name = os.path.splitext(name)[0]
Expand Down Expand Up @@ -145,8 +145,6 @@ def testLAMMPSExample(self):
finally:
os.chdir(oldpwd)



#eam_tabulate_example1.py
class eam_tabulate_example1TestCase(TempfileTestCase):
"""Test docs/potentials/eam_tabulate_example1.py"""
Expand Down Expand Up @@ -177,7 +175,6 @@ def testExample(self):
finally:
os.chdir(oldpwd)


class eam_tabulate_example2TestCase(TempfileTestCase):
"""Test docs/potentials/eam_tabulate_example2a.py and docs/potentials/eam_tabulate_example2b.py"""
test_nameA = os.path.join(_getDocsDirectory(), "eam_tabulate_example2a.py")
Expand Down Expand Up @@ -437,8 +434,6 @@ def testCrossCheckLAMMPS_DLPOLY(self):
finally:
os.chdir(oldpwd)



#eam_tabulate_example3a.py
class eam_tabulate_example3TestCase(TempfileTestCase):
"""Test docs/potentials/eam_tabulate_example3a.py and eam_tabulate_example3b.py"""
Expand Down Expand Up @@ -514,7 +509,6 @@ def testCrossCheckLAMMPS_DLPOLY(self):
except ImportError:
NUMPY_AVAILABLE = False


#zbl_spline.py
class zbl_splineTestCase(TempfileTestCase):
"""Test docs/potentials/zbl_spline.py"""
Expand All @@ -528,6 +522,21 @@ def testExample(self):
os.chdir(self.tempdir)
try:
exampleModule.main()

output_path = os.path.join(self.tempdir, "bks_buck.dat")
assert os.path.exists(output_path)

with open(output_path) as infile:
line = next(infile)
tokens = line.split()
r = float(tokens[0])
assert pytest.approx(0.1) == r

line = next(infile)
tokens = line.split()
r = float(tokens[0])
assert pytest.approx(0.1 + (10.0-0.1)/5000.0) == r

finally:
os.chdir(oldpwd)

0 comments on commit bee0847

Please sign in to comment.