Added test/tutorial.py. Works until you get to note_filter_playlist
authorW. Trevor King <wking@drexel.edu>
Sun, 15 Aug 2010 14:41:18 +0000 (10:41 -0400)
committerW. Trevor King <wking@drexel.edu>
Sun, 15 Aug 2010 14:41:18 +0000 (10:41 -0400)
doc/tutorial.txt
test/tutorial.py [new file with mode: 0644]

index b3cfa65d2c9428e5cfcbbc54d58dd0f3b1f88559..714c59716e60fc5c8d238e0c72bd78766525af81 100644 (file)
@@ -223,11 +223,10 @@ to :file:`hooke.log`.
 Usually curves you annotated are useful later.  You can create a
 playlist for only annotated curves with
 
 Usually curves you annotated are useful later.  You can create a
 playlist for only annotated curves with
 
-    hooke> note_filter_playlist --name c:\curves\nice.hkp
+    hooke> note_filter_playlist --output_playlist nice_list
 
 
-will create sub-playlist :file:`c:\curves\nice.hkp`.  Make sure that
-the target directory (here :file:`c:\curves\`) already exists before
-doing that.
+will create sub-playlist `nice_list`.  Remember to save the new list
+if you like it.
 
 If you change your mind about a note, you can remove it by setting a
 blank note string with ``set_note ''``.
 
 If you change your mind about a note, you can remove it by setting a
 blank note string with ``set_note ''``.
@@ -239,9 +238,13 @@ You can export Hooke curves as images and as text columns. To export
 as images or text, use the ``export_block`` command.  Supported
 formats are PNG (Portable Network Graphic, raster) and EPS
 (Encapsulated Postscript, vector).  The export format is determined by
 as images or text, use the ``export_block`` command.  Supported
 formats are PNG (Portable Network Graphic, raster) and EPS
 (Encapsulated Postscript, vector).  The export format is determined by
-the filename extension, so ``export_block foo.png``, ``export_block
-foo.eps``, and ``export_block foo.txt`` will save PNG, EPS, and
-TAB-delimited text files respectively.
+the filename extension, so ``export_block --output foo.png``,
+``export_block --output foo.eps``, and ``export_block --output
+foo.txt`` will save PNG, EPS, and TAB-delimited text files
+respectively.
+
+.. todo:: Currently no PNG or EPS output, use the GUI and the plot
+  panel's toolbar for non-text exports.
 
 .. todo:: Multiple cycles in exported data?  Solution: blank lines for
   "breaks", add option to extract specific sections using Python's
 
 .. todo:: Multiple cycles in exported data?  Solution: blank lines for
   "breaks", add option to extract specific sections using Python's
@@ -269,6 +272,8 @@ you click a point, a blue dot should appear.  When you click the
 second point, the distances will appear in the output panel.  If you
 want to know the coordinates of a single point, left click on it.
 
 second point, the distances will appear in the output panel.  If you
 want to know the coordinates of a single point, left click on it.
 
+.. todo:: Add description of ``delta``'s command line interface.
+
 Hooke automatically adjusts the position of the clicked point to the
 nearest point in the graph, so you will be always measuring distances
 and forces between points in the graph.
 Hooke automatically adjusts the position of the clicked point to the
 nearest point in the graph, so you will be always measuring distances
 and forces between points in the graph.
@@ -276,6 +281,8 @@ and forces between points in the graph.
 Worm like chain and freely jointed chain fitting
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 Worm like chain and freely jointed chain fitting
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
+.. todo:: Update WLC fitting tutorial section.
+
 You can measure by hand the parameters relative to a force peak using
 a worm-like chain fitting with the ``fit`` command.  The command by
 default automatically finds the contact point, asks for two points
 You can measure by hand the parameters relative to a force peak using
 a worm-like chain fitting with the ``fit`` command.  The command by
 default automatically finds the contact point, asks for two points
@@ -290,6 +297,7 @@ line for details.
 
 Multiple curve fitting and measuring
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 Multiple curve fitting and measuring
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+.. todo:: Update multiple curve fitting tutorial section.
 
 You can cycle through all your current playlist obtaining WLC fit, FJC
 fit, rupture force and slope (loading rate) information from each
 
 You can cycle through all your current playlist obtaining WLC fit, FJC
 fit, rupture force and slope (loading rate) information from each
@@ -302,6 +310,8 @@ current curve before fitting all the files in your playlist, use
 Fast curve reviewing and saving
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 Fast curve reviewing and saving
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
+.. todo:: Update curve review tutorial section.
+
 When automatic routines are not good enough to filter your data, use
 ``review`` command to cycle through your playlist presenting ten
 curves in the same graph.  You can then enter the numbers of the
 When automatic routines are not good enough to filter your data, use
 ``review`` command to cycle through your playlist presenting ten
 curves in the same graph.  You can then enter the numbers of the
@@ -314,5 +324,6 @@ Configuring Hooke
 You can set environment variables to influence the behaviour of
 Hooke. The command to use is ``set_config``.  Use ``get_config`` to
 read a particular option and ``print_config`` to display the entire
 You can set environment variables to influence the behaviour of
 Hooke. The command to use is ``set_config``.  Use ``get_config`` to
 read a particular option and ``print_config`` to display the entire
-configuration file.  Any changes to the configuration will be saved
-when you exit Hooke, see :doc:`config` for details.
+configuration file.  To save changes, either run ``save_config`` or
+start Hooke with the ``--save-config`` option.  See :doc:`config` for
+details.
diff --git a/test/tutorial.py b/test/tutorial.py
new file mode 100644 (file)
index 0000000..58d2b10
--- /dev/null
@@ -0,0 +1,262 @@
+# 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/>.
+
+"""
+Test the commands listed in :file:`doc/tutorial.txt`.
+
+>>> import os
+>>> import os.path
+>>> from hooke.hooke import Hooke, HookeRunner
+>>> h = Hooke()
+>>> r = HookeRunner()
+
+*Help*
+
+>>> h = r.run_lines(h, ['help'])  # doctest: +ELLIPSIS
+<BLANKLINE>
+Documented commands (type help <topic>):
+========================================
+...
+>>> h = r.run_lines(h, ['help load_playlist'])
+Command: load_playlist
+<BLANKLINE>
+Arguments:
+<BLANKLINE>
+help BOOL (bool) Print a help message.
+output_playlist STRING (string) Name of the new playlist (defaults to
+    an auto-generated name).
+input FILE (file) File name for the input playlist.
+drivers DRIVER (driver) Drivers for loading curves.
+<BLANKLINE>
+Load a playlist.
+<BLANKLINE>
+----
+Usage: load_playlist [options] input
+
+*Creating a playlist*
+
+>>> h = r.run_lines(h, ['cd --path .'])
+Success
+<BLANKLINE>
+>>> h = r.run_lines(h, ['pwd'])  # doctest: +ELLIPSIS
+/.../hooke
+Success
+<BLANKLINE>
+>>> h = r.run_lines(h, ['ls'])  # doctest: +ELLIPSIS +REPORT_UDIFF
+.hg
+...
+AUTHORS
+...
+README
+...
+hooke
+...
+Success
+<BLANKLINE>
+>>> h = r.run_lines(h, ['new_playlist --output_playlist mylist'])
+Success
+<BLANKLINE>
+>>> h = r.run_lines(h, ['jump_to_playlist -- -1'])
+Success
+<BLANKLINE>
+>>> h = r.run_lines(h, ['get_playlist'])
+<FilePlaylist mylist>
+Success
+<BLANKLINE>
+>>> h = r.run_lines(h, ['glob_curves_to_playlist test/data/vclamp_picoforce/*']
+...     )  # doctest: +ELLIPSIS
+<Curve 0x06130001>
+<Curve 0x07200000>
+<Curve 20071120a_i27_t33.100>
+<Curve 20071120a_i27_t33.101>
+...
+<Curve 20071120a_i27_t33.199>
+Success
+<BLANKLINE>
+>>> playlist_already_exists = os.path.exists('mylist.hkp')
+>>> playlist_already_exists
+False
+>>> h = r.run_lines(h, ['save_playlist --output mylist'])
+Success
+<BLANKLINE>
+>>> os.path.isfile('mylist.hkp')
+True
+>>> h = r.run_lines(h, ['load_playlist --output_playlist other_list mylist'])
+<FilePlaylist other_list>
+Success
+<BLANKLINE>
+>>> if playlist_already_exists == False:
+...     os.remove('mylist.hkp')
+
+*Navigating the playlist*
+
+>>> h = r.run_lines(h, ['get_curve'])
+<Curve 0x06130001>
+Success
+<BLANKLINE>
+>>> h = r.run_lines(h, ['next_curve'])
+Success
+<BLANKLINE>
+>>> h = r.run_lines(h, ['get_curve'])
+<Curve 0x07200000>
+Success
+<BLANKLINE>
+>>> h = r.run_lines(h, ['previous_curve'])
+Success
+<BLANKLINE>
+>>> h = r.run_lines(h, ['get_curve'])
+<Curve 0x06130001>
+Success
+<BLANKLINE>
+>>> h = r.run_lines(h, ['curve_index'])
+0
+Success
+<BLANKLINE>
+>>> h = r.run_lines(h, ['previous_curve'])
+Success
+<BLANKLINE>
+>>> h = r.run_lines(h, ['get_curve'])
+<Curve 20071120a_i27_t33.199>
+Success
+<BLANKLINE>
+>>> h = r.run_lines(h, ['curve_index'])
+101
+Success
+<BLANKLINE>
+>>> h = r.run_lines(h, ['next_curve'])
+Success
+<BLANKLINE>
+>>> h = r.run_lines(h, ['get_curve'])
+<Curve 0x06130001>
+Success
+<BLANKLINE>
+>>> h = r.run_lines(h, ['curve_index'])
+0
+Success
+<BLANKLINE>
+>>> h = r.run_lines(h, ['jump_to_curve 14'])
+Success
+<BLANKLINE>
+>>> h = r.run_lines(h, ['get_curve'])
+<Curve 20071120a_i27_t33.112>
+Success
+<BLANKLINE>
+>>> h = r.run_lines(h, ['curve_index'])
+14
+Success
+<BLANKLINE>
+
+>>> h = r.run_lines(h, ['get_playlist'])
+<FilePlaylist mylist>
+Success
+<BLANKLINE>
+>>> h = r.run_lines(h, ['next_playlist'])
+Success
+<BLANKLINE>
+>>> h = r.run_lines(h, ['get_playlist'])
+<FilePlaylist other_list>
+Success
+<BLANKLINE>
+>>> h = r.run_lines(h, ['previous_playlist'])
+Success
+<BLANKLINE>
+>>> h = r.run_lines(h, ['get_playlist'])
+<FilePlaylist mylist>
+Success
+<BLANKLINE>
+>>> h = r.run_lines(h, ['playlist_index'])
+0
+Success
+<BLANKLINE>
+>>> h = r.run_lines(h, ['previous_playlist'])
+Success
+<BLANKLINE>
+>>> h = r.run_lines(h, ['get_playlist'])
+<FilePlaylist other_list>
+Success
+<BLANKLINE>
+>>> h = r.run_lines(h, ['playlist_index'])
+1
+Success
+<BLANKLINE>
+>>> h = r.run_lines(h, ['next_playlist'])
+Success
+<BLANKLINE>
+>>> h = r.run_lines(h, ['get_playlist'])
+<FilePlaylist mylist>
+Success
+<BLANKLINE>
+>>> h = r.run_lines(h, ['playlist_index'])
+0
+Success
+<BLANKLINE>
+>>> h = r.run_lines(h, ['jump_to_playlist 1'])
+Success
+<BLANKLINE>
+>>> h = r.run_lines(h, ['get_playlist'])
+<FilePlaylist other_list>
+Success
+<BLANKLINE>
+>>> h = r.run_lines(h, ['playlist_index'])
+1
+Success
+<BLANKLINE>
+
+*Taking notes*
+
+>>> h = r.run_lines(h, ['''set_note "Hi there.\\nI'm a note"'''])
+Success
+<BLANKLINE>
+>>> h = r.run_lines(h, ['note_filter_playlist --output_playlist filtered'])
+>>> h = r.run_lines(h, ['get_playlist'])
+>>> h = r.run_lines(h, ['jump_to_playlist -- -1'])
+>>> h = r.run_lines(h, ['get_playlist'])
+>>> h = r.run_lines(h, ['get_curve'])
+>>> h = r.run_lines(h, ['curve_index'])
+>>> h = r.run_lines(h, ['jump_to_curve -- -1'])
+>>> h = r.run_lines(h, ['get_curve'])
+>>> h = r.run_lines(h, ['curve_index'])
+>>> h = r.run_lines(h, ['get_note'])
+>>> h = r.run_lines(h, ['set_note ""'])
+>>> h = r.run_lines(h, ['get_note'])
+
+*Exporting curves*
+
+>>> os.path.exists('mycurve.dat')
+>>> h = r.run_lines(h, ['export_bock --output mycurve.dat'])
+>>> os.path.isfile('mycurve.dat')
+
+*Measuring distances and forces*
+
+>>> h = r.run_lines(h, ['delta 300 500'])
+
+*Worm like chain and freely jointed chain fitting*
+
+*Multiple curve fitting and measuring*
+
+*Fast curve reviewing and saving*
+
+*Configuring Hooke*
+
+>>> h = r.run_lines(h, ['set_config conditions temperature 300.0'])
+>>> h = r.run_lines(h, ['get_config conditions temperature'])
+>>> h = r.run_lines(h, ['set_config conditions temperature 295.3'])
+>>> h = r.run_lines(h, ['get_config conditions temperature'])
+>>> h = r.run_lines(h, ['print_config'])
+>>> h = r.run_lines(h, ['save_config'])
+"""