Better pysawsim.sawsim.SAWSIM detection via distutils.spawn.find_executable().
authorW. Trevor King <wking@drexel.edu>
Tue, 2 Nov 2010 19:45:00 +0000 (15:45 -0400)
committerW. Trevor King <wking@drexel.edu>
Tue, 2 Nov 2010 20:08:04 +0000 (16:08 -0400)
pysawsim/parameter_error.py
pysawsim/parameter_scan.py
pysawsim/sawsim.py
pysawsim/sawsim_histogram.py

index ee915b2dcfdf5113a644a30f1084e2501806dd76..b75b31043a4392700c1d114c545cb65b28d09afa 100644 (file)
@@ -80,8 +80,7 @@ def main(argv=None):
     >>> f = tempfile.NamedTemporaryFile()
     >>> f.write(EXAMPLE_HISTOGRAM_FILE_CONTENTS)
     >>> f.flush()
     >>> f = tempfile.NamedTemporaryFile()
     >>> f.write(EXAMPLE_HISTOGRAM_FILE_CONTENTS)
     >>> f.flush()
-    >>> main(['-s', 'bin/sawsim',
-    ...       '-r', '[1e-6,1e-4,3]', '--log',
+    >>> main(['-r', '[1e-6,1e-4,3]', '--log',
     ...       '-N', '4', '-t', '0.8',
     ...       f.name])
     ... # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE, +REPORT_UDIFF
     ...       '-N', '4', '-t', '0.8',
     ...       f.name])
     ... # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE, +REPORT_UDIFF
index ff34a44661a34a99b4ba1366a631a3b3c5926990..3d6e99bbed6c42977dde1c7ea369fe5accdfd356 100644 (file)
@@ -157,7 +157,7 @@ class HistogramMatcher (object):
     ...     '-s "unfolded,wlc,{0.39e-9,28e-9}" '
     ...     '-k "folded,unfolded,bell,{%g,%g}" -q folded')
     >>> m = ThreadManager()
     ...     '-s "unfolded,wlc,{0.39e-9,28e-9}" '
     ...     '-k "folded,unfolded,bell,{%g,%g}" -q folded')
     >>> m = ThreadManager()
-    >>> sr = SawsimRunner(sawsim='bin/sawsim', manager=m)
+    >>> sr = SawsimRunner(manager=m)
     >>> hm = HistogramMatcher(histogram_stream, param_format_string, sr, N=3)
     >>> hm.plot([[1e-5,1e-3,3],[0.1e-9,1e-9,3]], logx=True, logy=False)
     >>> m.teardown()
     >>> hm = HistogramMatcher(histogram_stream, param_format_string, sr, N=3)
     >>> hm.plot([[1e-5,1e-3,3],[0.1e-9,1e-9,3]], logx=True, logy=False)
     >>> m.teardown()
@@ -343,8 +343,7 @@ def main(argv=None):
     >>> f = tempfile.NamedTemporaryFile()
     >>> f.write(EXAMPLE_HISTOGRAM_FILE_CONTENTS)
     >>> f.flush()
     >>> f = tempfile.NamedTemporaryFile()
     >>> f.write(EXAMPLE_HISTOGRAM_FILE_CONTENTS)
     >>> f.flush()
-    >>> main(['-s', 'bin/sawsim',
-    ...       '-r', '[1e-5,1e-3,3],[0.1e-9,1e-9,3]',
+    >>> main(['-r', '[1e-5,1e-3,3],[0.1e-9,1e-9,3]',
     ...       '-N', '2',
     ...       f.name])
     >>> f.close()
     ...       '-N', '2',
     ...       f.name])
     >>> f.close()
index 4f34da89c540ee4b44d824ce7cb8a8603d0c64a3..0f85869dd634111a0ce0f64d65a9700895f6d8f1 100644 (file)
@@ -27,6 +27,7 @@ try:
     from collections import namedtuple
 except ImportError:  # work around Python < 2.6
     from ._collections import namedtuple
     from collections import namedtuple
 except ImportError:  # work around Python < 2.6
     from ._collections import namedtuple
+from distutils.spawn import find_executable
 import hashlib
 from optparse import Option
 import os
 import hashlib
 from optparse import Option
 import os
@@ -43,7 +44,10 @@ _multiprocess_can_split_ = True
 """Allow nosetests to split tests between processes.
 """
 
 """Allow nosetests to split tests between processes.
 """
 
-SAWSIM = 'sawsim'  # os.path.expand(os.path.join('~', 'bin', 'sawsim'))
+SAWSIM = find_executable('sawsim')
+if SAWSIM == None:
+    SAWSIM = os.path.join('bin', 'sawsim')
+
 CACHE_DIR = os.path.expanduser(os.path.join('~', '.sawsim-cache'))
 DEFAULT_PARAM_STRING = (
     '-s cantilever,hooke,0.05 -N1 '
 CACHE_DIR = os.path.expanduser(os.path.join('~', '.sawsim-cache'))
 DEFAULT_PARAM_STRING = (
     '-s cantilever,hooke,0.05 -N1 '
@@ -62,7 +66,7 @@ Event = namedtuple(
 class SawsimRunner (object):
     """
     >>> m = get_manager()()
 class SawsimRunner (object):
     """
     >>> m = get_manager()()
-    >>> sr = SawsimRunner(sawsim='bin/sawsim', manager=m)
+    >>> sr = SawsimRunner(manager=m)
     >>> for run in sr(param_string=DEFAULT_PARAM_STRING, N=2):
     ...     print 'New run'
     ...     for i,event in enumerate(run):
     >>> for run in sr(param_string=DEFAULT_PARAM_STRING, N=2):
     ...     print 'New run'
     ...     for i,event in enumerate(run):
@@ -272,11 +276,11 @@ def main(argv=None):
     Options:
       -h, --help            show this help message and exit
       -s PATH, --sawsim=PATH
     Options:
       -h, --help            show this help message and exit
       -s PATH, --sawsim=PATH
-                            Set sawsim binary (sawsim).
+                            Set sawsim binary (...sawsim).
       ...
     >>> print e
     0
       ...
     >>> print e
     0
-    >>> main(['--sawsim', 'bin/sawsim', '-N', '2'])
+    >>> main(['-N', '2'])
     ... # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE
     #Force (N)  Initial state  Final state
     ...         folded         unfolded
     ... # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE
     #Force (N)  Initial state  Final state
     ...         folded         unfolded
index 969ad4655a63a3ec5e4f06e4168ce11b5f59a199..14b94ede18227195f61fa294a835d1d116f1b288 100644 (file)
@@ -50,7 +50,7 @@ def sawsim_histogram(sawsim_runner, param_string, N=400, bin_edges=None):
 
 def main(argv=None):
     """
 
 def main(argv=None):
     """
-    >>> main(['--sawsim', 'bin/sawsim', '-N', '2'])
+    >>> main(['-N', '2'])
     ... # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE
     #Force (N)  Unfolding events
     ...
     ... # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE
     #Force (N)  Unfolding events
     ...