test/data/vclamp_jpk/README: Document sample versions
[hooke.git] / hooke / curve.py
index 030efcbab3601b6a0608dc908d0bbe1b6b2b6dec..53670151685a92bbc16a373e5b396854ae0e7fc3 100644 (file)
@@ -1,20 +1,19 @@
-# Copyright (C) 2010 W. Trevor King <wking@drexel.edu>
+# Copyright (C) 2010-2012 W. Trevor King <wking@tremily.us>
 #
 # 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 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.
+# 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/>.
+# You should have received a copy of the GNU Lesser General Public License
+# along with Hooke.  If not, see <http://www.gnu.org/licenses/>.
 
 """The `curve` module provides :class:`Curve` and :class:`Data` for
 storing force curves.
@@ -92,10 +91,14 @@ class Data (numpy.ndarray):
     The data-type is also YAMLable (see :mod:`hooke.util.yaml`).
 
     >>> import yaml
-    >>> print yaml.dump(d)
+    >>> s = yaml.dump(d)
+    >>> print(s)
     !hooke.curve.DataInfo
     columns: [distance (m), force (N)]
     <BLANKLINE>
+    >>> z = yaml.load(s)
+    >>> z
+    Data([], shape=(0, 0), dtype=float32)
     """
     def __new__(subtype, shape, dtype=numpy.float, buffer=None, offset=0,
                 strides=None, order=None, info=None):
@@ -185,7 +188,7 @@ class Curve (object):
     [<CommandMessage curve info {curve: <Curve path>}>]
     >>> z.command_stack[-1].arguments['curve'] == z
     True
-    >>> print yaml.dump(c)  # doctest: +REPORT_UDIFF
+    >>> print(yaml.dump(c))  # doctest: +REPORT_UDIFF
     &id001 !!python/object:hooke.curve.Curve
     command_stack: !!python/object/new:hooke.command_stack.CommandStack
       listitems:
@@ -211,7 +214,7 @@ class Curve (object):
 
     YAML still works, though.
 
-    >>> print yaml.dump(c.command_stack)  # doctest: +REPORT_UDIFF
+    >>> print(yaml.dump(c.command_stack))  # doctest: +REPORT_UDIFF
     &id001 !!python/object/new:hooke.command_stack.CommandStack
     listitems:
     - !!python/object:hooke.engine.CommandMessage
@@ -237,6 +240,8 @@ class Curve (object):
         return self.__str__()
 
     def set_path(self, path):
+        if path != None:
+            path = os.path.expanduser(path)
         self.path = path
         if self.name == None and path != None:
             self.name = os.path.basename(path)