Skip to content

Commit

Permalink
0.1.1 fix roundoff bug in time, update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Kendrick.Shaw authored and Kendrick.Shaw committed Jul 21, 2009
1 parent 96284bd commit 9acfc64
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 12 deletions.
4 changes: 2 additions & 2 deletions axographio.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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)"""
Expand Down
44 changes: 35 additions & 9 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

setup(
name = "axographio",
version = "0.1.0",
version = "0.1.1b1",
setup_requires = ['setuptools_cython', 'numpy'],
ext_modules = [
Extension('axographio', [
Expand Down Expand Up @@ -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
------------
Expand All @@ -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
Expand All @@ -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
Expand All @@ -115,25 +125,41 @@
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)
>>> column2 = np.cos(2*np.pi * 60 * times)
>>> 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
=====================
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
===============
Expand Down
19 changes: 18 additions & 1 deletion test_axographio.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,29 @@ 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 ([email protected])
"""
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()
fix_module_doctest(axographio)
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

#
Expand Down Expand Up @@ -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())

0 comments on commit 9acfc64

Please sign in to comment.