From 9acfc64ce1d811cae6bae26a3554f1f44708e9da Mon Sep 17 00:00:00 2001 From: "Kendrick.Shaw" Date: Tue, 21 Jul 2009 21:45:50 +0000 Subject: [PATCH] 0.1.1 fix roundoff bug in time, update docs --- axographio.pyx | 4 ++-- setup.py | 44 +++++++++++++++++++++++++++++++++++--------- test_axographio.py | 19 ++++++++++++++++++- 3 files changed, 55 insertions(+), 12 deletions(-) diff --git a/axographio.pyx b/axographio.pyx index c08c92e..712c1e9 100644 --- a/axographio.pyx +++ b/axographio.pyx @@ -279,8 +279,8 @@ class linearsequence: def __array__(self, dtype=np.float64): """Implements numpy.asarray(s)""" - return np.arange(self.start, self.start + self.step * self.numpoints, - self.step, dtype=dtype) + return np.linspace(self.start, self.start + self.step * self.numpoints, + self.numpoints, endpoint=False) def __iter__(self): """Implements iter(s)""" diff --git a/setup.py b/setup.py index ddb51de..1c5ba89 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ setup( name = "axographio", - version = "0.1.0", + version = "0.1.1b1", setup_requires = ['setuptools_cython', 'numpy'], ext_modules = [ Extension('axographio', [ @@ -67,12 +67,20 @@ ---------------------------- * A working Python installation -* The NumPy package * The setuptools package +* The NumPy package +* The Cython package Note that NumPy takes a bit of work to build, so it may be easiest to install -it from a repository (if you're using Linux) or install a Python distribution -containing it, such as the Enthought Python Distribution. +it from your linux distribution's repository, or use as pre-built package +such as the Scipy Superpack (http://macinscience.org/?page_id=6) for the mac. +Depending on your OS, you may be able to get away with simply typing: + +:: + + sudo easy_install numpy + sudo easy_install Cython + Installation ------------ @@ -81,7 +89,7 @@ install axographio using easy_install by typing the following command in a terminal window: - easy_install axographio + easy_install axographio Usage @@ -104,6 +112,8 @@ >>> plt.ylabel(f.names[1]) >>> plt.show() +(The plt.show() may not be optional depending on your OS.) + Of course, you probably have grander plans than just plotting the data. The column data supports the standard sequence interfaces (i.e. indexing, iteration, etc.) and can be converted to a scipy or numpy array using the @@ -115,10 +125,11 @@ Writing files is also relatively easy. You simply create a new file_contents object (or use one you loaded earlier), and then call write. For example, the -following code creates a file called "my60Hz.axgd" with two channels with 60 Hz -sine waves +following code creates a file in the current directory called "my60Hz.axgx" +with two channels with 60 Hz sine waves ->>> import axographio import numpy as np +>>> import axographio +>>> import numpy as np >>> >>> times = np.arange(0,10,0.0001) >>> column1 = np.sin(2*np.pi * 60 * times) @@ -126,7 +137,8 @@ >>> f = axographio.file_contents( ... ['time (s)', 'my recording (V)', 'your recording (V)'], ... [times, column1, column2]) ->>> f.write("my60Hz.axgd") +>>> f.write("my60Hz.axgx") + Questions and Support ===================== @@ -134,6 +146,20 @@ Please post any questions, problems, comments, or suggestions on the axographio group on google groups (http://groups.google.com/group/axographio) + +News +==== + +0.1.1 +----- + Fixed a rounding error that could create one extra data point in the times + column. + +0.1.0 +----- + First release + + Acknowledgments =============== diff --git a/test_axographio.py b/test_axographio.py index 382c798..a5e9d04 100644 --- a/test_axographio.py +++ b/test_axographio.py @@ -147,6 +147,21 @@ def testreadwrite(self): +class TestRegressions(unittest.TestCase): + """Tests for bugs that were found in previous releases""" + + # bugs fixed in 0.1.1 + def test_linearsequencelength(self): + """ Off-by-one error in len(np.asarray(a_linearsequence)) + Found by: Dr. Hillel Chiel (hjc@case.edu) + """ + seq = axographio.linearsequence(1000, 0., 0.036) + seqAsArray = np.asarray(seq) + self.assertEqual(len(seq), 1000) + self.assertEqual(len(seqAsArray), 1000) + + + def test_all(): """Returns a test suite with all of the tests for axographio""" suite = unittest.TestSuite() @@ -154,6 +169,7 @@ def test_all(): suite.addTest(doctest.DocTestSuite(axographio)) suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestSampleFiles)) suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestReadWrite)) + suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestRegressions)) return suite # @@ -192,5 +208,6 @@ def fix_module_doctest(module): and _from_module(module, value)): module.__test__[name] = value.__doc__ + if __name__ == '__main__': - unittest.main() + unittest.TextTestRunner(verbosity=2).run(test_all())