Loading .gitignore 0 → 100644 +1 −0 Original line number Diff line number Diff line __pycache__ pizza/__init__.py 0 → 100644 +0 −0 Empty file added. src/log.py→pizza/log.py +4 −7 Original line number Diff line number Diff line Loading @@ -126,7 +126,7 @@ class log: m = [] for key in keys: if self.ptr.has_key(key): if key in self.ptr: m.append(self.ptr[key]) else: count = 0 Loading Loading @@ -154,7 +154,7 @@ class log: if len(keys): m = [] for key in keys: if self.ptr.has_key(key): if key in self.ptr: m.append(self.ptr[key]) else: count = 0 Loading @@ -169,12 +169,9 @@ class log: else: m = list(range(self.nvec)) f = open(filename,"w") with open(filename,"w") as f: for i in range(self.nlen): for x in m: print(self.data[i][x], end='', file=f) print(file=f) f.close() print(' '.join(map(str, [self.data[i][x] for x in m])), file=f) # -------------------------------------------------------------------- Loading setup.py 0 → 100644 +15 −0 Original line number Diff line number Diff line #!/usr/bin/env python from distutils.core import setup setup(name='Pizza.py', version='1.0', description='Pizza.py is a loosely integrated collection of tools written in Python, many of which provide pre- ' 'and post-processing capability for the LAMMPS molecular dynamics package. There are tools to create ' 'input files, convert between file formats, process log and dump files, create plots, and visualize ' 'and animate simulation snapshots.', author='Steve Plimpton', author_email='sjplimp@sandia.gov', url='http://pizza.sandia.gov/', packages=['pizza'], ) No newline at end of file tests/test_log.py 0 → 100644 +43 −0 Original line number Diff line number Diff line import unittest import csv import os from pizza.log import log class TestLog(unittest.TestCase): EXAMPLE_FILE = "../examples/files/log.obstacle" def test_read_log(self): lg = log(TestLog.EXAMPLE_FILE) self.assertEqual(lg.nvec, 7) self.assertEqual(lg.nlen, 26) self.assertListEqual(lg.names, ["Step", "Temperature", "E_pair", "E_bond", "E_total", "Pressure", "Volume"]) def test_log_get(self): lg = log(TestLog.EXAMPLE_FILE) time, temp, press = lg.get("Step", "Temp", "Press") self.assertEqual(len(time), 26) self.assertEqual(len(temp), 26) self.assertEqual(len(press), 26) def test_write_all(self): tmp_file = "/tmp/tmp.log" lg = log(TestLog.EXAMPLE_FILE) lg.write(tmp_file) self.assertTrue(os.path.exists(tmp_file)) with open(tmp_file, 'rt') as csvfile: lines = list(csv.reader(csvfile, delimiter=' ')) self.assertEqual(len(lines), 26) self.assertEqual(len(lines[0]), 7) def test_write_columns(self): tmp_file = "/tmp/tmp.log.two" lg = log(TestLog.EXAMPLE_FILE) lg.write(tmp_file, "Step", "E_pair") self.assertTrue(os.path.exists(tmp_file)) with open(tmp_file, 'rt') as csvfile: lines = list(csv.reader(csvfile, delimiter=' ')) self.assertEqual(len(lines), 26) self.assertEqual(len(lines[0]), 2) Loading
src/log.py→pizza/log.py +4 −7 Original line number Diff line number Diff line Loading @@ -126,7 +126,7 @@ class log: m = [] for key in keys: if self.ptr.has_key(key): if key in self.ptr: m.append(self.ptr[key]) else: count = 0 Loading Loading @@ -154,7 +154,7 @@ class log: if len(keys): m = [] for key in keys: if self.ptr.has_key(key): if key in self.ptr: m.append(self.ptr[key]) else: count = 0 Loading @@ -169,12 +169,9 @@ class log: else: m = list(range(self.nvec)) f = open(filename,"w") with open(filename,"w") as f: for i in range(self.nlen): for x in m: print(self.data[i][x], end='', file=f) print(file=f) f.close() print(' '.join(map(str, [self.data[i][x] for x in m])), file=f) # -------------------------------------------------------------------- Loading
setup.py 0 → 100644 +15 −0 Original line number Diff line number Diff line #!/usr/bin/env python from distutils.core import setup setup(name='Pizza.py', version='1.0', description='Pizza.py is a loosely integrated collection of tools written in Python, many of which provide pre- ' 'and post-processing capability for the LAMMPS molecular dynamics package. There are tools to create ' 'input files, convert between file formats, process log and dump files, create plots, and visualize ' 'and animate simulation snapshots.', author='Steve Plimpton', author_email='sjplimp@sandia.gov', url='http://pizza.sandia.gov/', packages=['pizza'], ) No newline at end of file
tests/test_log.py 0 → 100644 +43 −0 Original line number Diff line number Diff line import unittest import csv import os from pizza.log import log class TestLog(unittest.TestCase): EXAMPLE_FILE = "../examples/files/log.obstacle" def test_read_log(self): lg = log(TestLog.EXAMPLE_FILE) self.assertEqual(lg.nvec, 7) self.assertEqual(lg.nlen, 26) self.assertListEqual(lg.names, ["Step", "Temperature", "E_pair", "E_bond", "E_total", "Pressure", "Volume"]) def test_log_get(self): lg = log(TestLog.EXAMPLE_FILE) time, temp, press = lg.get("Step", "Temp", "Press") self.assertEqual(len(time), 26) self.assertEqual(len(temp), 26) self.assertEqual(len(press), 26) def test_write_all(self): tmp_file = "/tmp/tmp.log" lg = log(TestLog.EXAMPLE_FILE) lg.write(tmp_file) self.assertTrue(os.path.exists(tmp_file)) with open(tmp_file, 'rt') as csvfile: lines = list(csv.reader(csvfile, delimiter=' ')) self.assertEqual(len(lines), 26) self.assertEqual(len(lines[0]), 7) def test_write_columns(self): tmp_file = "/tmp/tmp.log.two" lg = log(TestLog.EXAMPLE_FILE) lg.write(tmp_file, "Step", "E_pair") self.assertTrue(os.path.exists(tmp_file)) with open(tmp_file, 'rt') as csvfile: lines = list(csv.reader(csvfile, delimiter=' ')) self.assertEqual(len(lines), 26) self.assertEqual(len(lines[0]), 2)