Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test #37

Closed
wants to merge 16 commits into from
Closed

test #37

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions devutils/makesdist
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ sys.path.insert(0, BASEDIR)
from setup import versiondata
timestamp = versiondata.getint('DEFAULT', 'timestamp')

print 'Run "setup.py sdist --formats=tar"',
print('Run "setup.py sdist --formats=tar"',)
cmd_sdist = [sys.executable] + 'setup.py sdist --formats=tar'.split()
ec = subprocess.call(cmd_sdist, cwd=BASEDIR, stdout=open(os.devnull, 'w'))
if ec: sys.exit(ec)
print "[done]"
print("[done]")

tarname = max(glob.glob(BASEDIR + '/dist/*.tar'), key=os.path.getmtime)

Expand All @@ -36,8 +36,8 @@ def fixtarinfo(tinfo):
return tinfo


print 'Filter %s --> %s.gz' % (2 * (os.path.basename(tarname),)),
print('Filter %s --> %s.gz' % (2 * (os.path.basename(tarname),)),)
for ti in tfin:
tfout.addfile(fixtarinfo(ti), tfin.extractfile(ti))
os.remove(tarname)
print "[done]"
print("[done]")
52 changes: 27 additions & 25 deletions devutils/prep.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

__basedir__ = os.getcwdu()

from numpy.compat import unicode

# Example imports


Expand All @@ -18,20 +20,21 @@ def __init__(self):

def test(self, call, *args, **kwds):
m = sys.modules[call.__module__]
testname = m.__name__+'.'+call.__name__
testname = m.__name__ + "." + call.__name__
path = os.path.dirname(m.__file__)
os.chdir(path)
try:
call(*args, **kwds)
self.messages.append("%s: success" %testname)
except Exception, e:
self.messages.append("%s: error, details below.\n%s" %(testname, e))
self.messages.append("%s: success" % testname)
except Exception as e:
self.messages.append("%s: error, details below.\n%s" % (testname, e))
finally:
os.chdir(__basedir__)

def report(self):
print '==== Results of Tests ===='
print '\n'.join(self.messages)
print("==== Results of Tests ====")
print("\n".join(self.messages))


def scrubeol(directory, filerestr):
"""Use unix-style endlines for files in directory matched by regex string.
Expand All @@ -50,11 +53,11 @@ def scrubeol(directory, filerestr):
text = unicode(original.read())
original.close()

updated = io.open(f, 'w', newline='\n')
updated = io.open(f, "w", newline="\n")
updated.write(text)
updated.close()

print "Updated %s to unix-style endlines." %f
print("Updated %s to unix-style endlines." % f)


def rm(directory, filerestr):
Expand All @@ -72,30 +75,31 @@ def rm(directory, filerestr):
for f in files:
os.remove(f)

print "Deleted %s." %f

print("Deleted %s." % f)


if __name__ == "__main__":

# Temporarily add examples to path
lib_path = os.path.abspath(os.path.join('..','doc','examples'))
lib_path = os.path.abspath(os.path.join("..", "doc", "examples"))
sys.path.append(lib_path)

# Delete existing files that don't necessarily have a fixed name.
rm("../doc/examples/output", r"known_dG.*\.pwa")
rm("../doc/examples/output", r"unknown_dG.*\.pwa")

### Testing examples
# Testing examples
examples = Test()
test_names = ["extract_single_peak",
"parameter_summary",
"fit_initial",
"query_results",
"multimodel_known_dG1",
"multimodel_known_dG2",
"multimodel_unknown_dG1",
"multimodel_unknown_dG2"]
test_names = [
"extract_single_peak",
"parameter_summary",
"fit_initial",
"query_results",
"multimodel_known_dG1",
"multimodel_known_dG2",
"multimodel_unknown_dG1",
"multimodel_unknown_dG2",
]

test_modules = []
for test in test_names:
Expand All @@ -106,10 +110,8 @@ def rm(directory, filerestr):

examples.report()

### Convert output of example files to Unix-style endlines for sdist.
if os.linesep != '\n':
print "==== Scrubbing Endlines ===="
# Convert output of example files to Unix-style endlines for sdist.
if os.linesep != "\n":
print("==== Scrubbing Endlines ====")
# All *.srmise and *.pwa files in examples directory.
scrubeol("../doc/examples/output", r".*(\.srmise|\.pwa)")


26 changes: 2 additions & 24 deletions diffpy/srmise/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
##############################################################################
#
# SrMise by Luke Granlund
# (c) 2014 trustees of the Michigan State University.
# (c) 2014 trustees of the Michigan State University
# (c) 2024 trustees of Columia University in the City of New York
# All rights reserved.
#
# File coded by: Luke Granlund
Expand All @@ -13,28 +14,5 @@

"""Tools for peak extraction from PDF."""

__all__ = [
"basefunction",
"srmiseerrors",
"srmiselog",
"dataclusters",
"modelcluster",
"modelparts",
"pdfdataset",
"pdfpeakextraction",
"peakextraction",
"peakstability",
"multimodelselection",
]

from basefunction import BaseFunction
from dataclusters import DataClusters
from modelcluster import ModelCluster, ModelCovariance
from modelparts import ModelPart, ModelParts
from multimodelselection import MultimodelSelection
from pdfdataset import PDFDataSet
from pdfpeakextraction import PDFPeakExtraction
from peakextraction import PeakExtraction
from peakstability import PeakStability

from diffpy.srmise.version import __version__
3 changes: 2 additions & 1 deletion diffpy/srmise/applications/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
##############################################################################
#
# SrMise by Luke Granlund
# (c) 2014 trustees of the Michigan State University.
# (c) 2014 trustees of the Michigan State University
# (c) 2024 trustees of Columia University in the City of New York
# All rights reserved.
#
# File coded by: Luke Granlund
Expand Down
Loading
Loading