Add test/difference.py
authorW. Trevor King <wking@drexel.edu>
Wed, 11 Aug 2010 17:45:22 +0000 (13:45 -0400)
committerW. Trevor King <wking@drexel.edu>
Wed, 11 Aug 2010 17:45:22 +0000 (13:45 -0400)
test/difference.py [new file with mode: 0644]

diff --git a/test/difference.py b/test/difference.py
new file mode 100644 (file)
index 0000000..43ee58b
--- /dev/null
@@ -0,0 +1,45 @@
+# Copyright (C) 2010 W. Trevor King <wking@drexel.edu>
+#
+# This file is part of Hooke.
+#
+# Hooke is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# Hooke is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General
+# Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with Hooke.  If not, see
+# <http://www.gnu.org/licenses/>.
+
+"""
+>>> from hooke.hooke import Hooke, HookeRunner
+>>> h = Hooke()
+>>> r = HookeRunner()
+>>> h = r.run_lines(h, ['load_playlist test/data/test']) # doctest: +ELLIPSIS
+<FilePlaylist test.hkp>
+Success
+<BLANKLINE>
+>>> h = r.run_lines(h,
+...     ['difference --block_A retract --block_B approach --column_A "deflection (m)"']
+...     ) # doctest: +ELLIPSIS, +REPORT_UDIFF
+Success
+<BLANKLINE>
+>>> curve = h.playlists.current().current()
+>>> retract = curve.data[1]
+>>> retract.info['columns']
+['z piezo (m)', 'deflection (m)', 'difference of retract deflection and approach deflection (m)']
+>>> retract[:5,-1]
+Data([ -3.89891186e-09,  -4.19359706e-09,  -4.42027798e-09,
+        -4.78296746e-09,  -5.10032075e-09])
+>>> retract[-5:,-1]
+Data([  4.08025660e-10,   2.04012830e-10,   4.53361844e-10,
+         5.21366121e-10,   1.08806843e-09])
+
+Note the differences are not near zero because the z piezo position
+runs in opposite directions for the two blocks.
+"""