Commit Graph
100 Commits
Author SHA1 Message Date
Wirawan Purwanto 42babbe767 * Add "global variable" statement. 2013-10-23 13:03:49 -04:00
Wirawan Purwanto 869aa91109 * fit_func(): Allow non-(numpy.ndarray) args for x, y, dy.
* Documentation update.
2013-10-17 13:49:50 -04:00
Wirawan Purwanto fb6631f756 * Use is_iterable to detect iterable specs argument. 2013-10-17 13:49:17 -04:00
Wirawan Purwanto 9a5d2dfa9f * text_tools: Added str_fmt_heading() function for formatting table heading
a la printf.
2013-10-17 13:48:07 -04:00
Wirawan Purwanto 579be3e18a * errorbar: Added "lazy" string evaluation to speed up errorbar algebra. 2013-10-02 15:32:46 -04:00
Wirawan Purwanto ed1242dc66 * Added "lazy string printout" which will speed up errorbar algebra--i.e.
we only need to evaluate the string representation when
  the string printout isrequired.
2013-10-02 14:30:55 -04:00
Wirawan Purwanto c8aad2e2f8 * Added facility for smoothed approximating spline instead of "exact"
interpolation.
2013-09-17 18:00:08 -04:00
Wirawan Purwanto 06fa307e84 * spline_2d: Use public scipy API functions. 2013-09-17 17:18:29 -04:00
Wirawan Purwanto 564d1f4364 * wpylib.math.fitting.fit_func: Added support for weight (or y uncertainty).
* For `leastsq' fit method, also introduced 'xerr' output (in outfmt=0)
  as the error estimate of the fitted parameters.
2013-08-19 15:43:49 -04:00
Wirawan Purwanto 37b0939671 * Documentation clarification. 2013-08-19 15:43:19 -04:00
Wirawan Purwanto 1421cf3bc5 * wpylib.math.fitting.fit_func: Allow Guess argument to override
machine-generated guess.
* Add 'funcalls' data key to the leastsq complete output to conform to the
  fmin-style output.
2013-08-19 10:50:54 -04:00
Wirawan Purwanto 2907b2ca77 * Set lcg48 default seed_index for user's reference 2013-08-19 10:11:09 -04:00
Wirawan Purwanto 42fdcc5253 * Added new module wpylib.math.random and its submodule (rng_lcg48).
The LCG48 generator is primarily for testing algorithms involving random
  numbers.
2013-08-14 15:29:26 -04:00
Wirawan Purwanto e485cabbe8 * wpylib.math.fitting.fit_func: Added optional Funct_hook argument to
be called (for debugging purposes) every time "the" Funct function
  is called.
2013-08-13 01:05:38 -04:00
Wirawan Purwanto cdad14e034 * Added BFGS minimization. 2013-08-09 16:51:38 -04:00
Wirawan Purwanto f49d166a77 * wpylib.iofmt.fortbin: Added fortran_types class to manage and analyze
Fortran datatypes.

  First edition contains tool to estimate the size of datatypes,
  and size of file records (or sequence of records).
2013-06-26 16:24:19 -05:00
Wirawan Purwanto 2e21e2857a * Added function relpath() to compute relative path from one to another
path.
2013-06-25 17:01:26 -04:00
Wirawan Purwanto fc0d97db1e * Parameters._flatten_(): Added workaround to avoid evaluating the
dict values while flattening the list.
  This is critical for avoiding evaluation of the 'active' members.
2013-04-25 16:54:36 -04:00
Wirawan Purwanto 2daca4af6e * tee_output: Allow None to be given in the `files' argument, which stands
for a null file.
2013-04-19 16:46:09 -04:00
Wirawan Purwanto 80961ed2bd * Added test7 and test8 for param_flat module.
- test7 tests active parameters which can work OK if the search dicts are
    flatten.
  - test8 tests the _flatten_() method.
2013-04-17 17:26:48 -04:00
Wirawan Purwanto b326937d80 * Parameters: Now correctly implements _flatten_() method and flag.
- The _flatten_() method should recursively flatten the parameter
    search space into a single dict.
  - The _flatten_ flag will flatten the input dicts and keyword-based
    parameter (in the __init__() method only) in the expected order of
    priority (where the first found keyword is the most overriding one)
    into a single search dict.
2013-04-16 14:06:26 -04:00
Wirawan Purwanto 8d32c2c067 * Parameters: if _flatten_ is enabled, must flatten in reverse order to
give the firstly mentioned dict the priority.
2013-04-16 11:55:18 -04:00
Wirawan Purwanto 254aaca622 * Added tester for active Parameters value. 2013-04-11 14:38:04 -04:00
Wirawan Purwanto 0f58bc0f03 * params_flat.py: Added ActiveReadValue magic class to enable `active',
or executable, parameter, which will be executed upon `reading' such a
  value.
2013-04-11 14:36:52 -04:00
Wirawan Purwanto fe9fa59e76 * params_flat.py: Documentation and note updates. 2013-04-11 14:06:14 -04:00
Wirawan Purwanto f7c9ad7d34 * Added functions time_diff() and shift_time() for UNIX time manipulation. 2013-03-05 23:44:31 -05:00
Wirawan Purwanto 8f513ff5b4 * Added tests for Parameters._all_keys(). 2013-03-04 13:59:26 -05:00
Wirawan Purwanto 6709679af9 * Parameters: Added _all_keys_() and _flatten_() methods.
Warning: These are expensive, and not for general use.
2013-03-04 13:58:32 -05:00
Wirawan Purwanto 5a84a98b84 * Added tests for _append_() and _prepend_() methods. 2013-03-04 13:42:22 -05:00
Wirawan Purwanto f04531a601 * Parameters: Added _append_() and _prepend_() methods. 2013-03-04 13:37:48 -05:00
Wirawan Purwanto 099f3e7e06 * Module wpylib.db.indexing_float: utility for floating-point (FP)-based
indexing, allowing tolerances to account for imprecise nature of FP
  numbers.

  Initial implementation, rather complicated.
  A simple rounding-based implementation can be put in later.

  Includes initial test.
2013-03-03 09:15:43 -05:00
Wirawan Purwanto 4fb16c56b2 * Documentation update. 2013-02-28 14:01:18 -05:00
Wirawan Purwanto 9de8407dd9 * Added Test_3(). 2012-10-15 17:25:06 -04:00
Wirawan Purwanto a0eb82ed2b * Mute debug printing. 2012-10-15 16:59:35 -04:00
Wirawan Purwanto 5b213b0ee7 * Little syntax optimization. 2012-10-15 16:45:37 -04:00
Wirawan Purwanto 414643ecde * Added testcase wpylib.math.fitting.linear.Test_2() against numpy.polyfit(). 2012-10-15 16:35:12 -04:00
Wirawan Purwanto cb8124f699 * Provide uncertainty of both a and b fit parameters. 2012-10-15 16:12:37 -04:00
Wirawan Purwanto 87763d6e57 * wpylib.math.fitting.linear: for linear fit methods.
First method: linregr2d_SZ() from Shiwei's email in 2006.
2012-10-15 16:02:41 -04:00
Wirawan Purwanto 908a4e0682 * Rebase fit_result on result_base. 2012-10-15 16:01:46 -04:00
Wirawan Purwanto 348c204699 * Change wpylib.math.fitting module from a file into a subdirectory. 2012-10-15 15:16:02 -04:00
Wirawan Purwanto 332d9ae240 * wpylib.math: added choose() function. 2012-08-24 16:32:33 -04:00
Wirawan Purwanto b58ea30ba8 * Added a facility to catch exception while capturing stdout, and deliver
the output printed so far (to stderr), plus re-raising the exception.
2012-08-24 16:31:48 -04:00
Wirawan Purwanto f677dc1a81 * Added wpylib.py.stdout_capture as a hack tool to capture sys.stdout
output of a given function call (and its child subroutines).
2012-08-10 10:13:18 -04:00
Wirawan Purwanto 17d242213d * Added some useful functions from my pw2g_bench_MnO.py scriptlet collection:
- wpylib.math.roundup()
  - wpylib.shell_tools.dirname2()

* file_exists_nonempty() is moved to wpylib.shell_tools.
2012-07-25 09:40:37 -04:00
Wirawan Purwanto 96cec22fca * wpylib.file.file_utils: added file_exists_nonempty() function. 2012-07-24 17:11:36 -04:00
Wirawan Purwanto 7ebb4004dc * str_igrep(): use enumerate function. 2012-06-13 19:36:35 -04:00
Wirawan Purwanto d70bcf2149 * In text_output methods, do the required action iff self.out is not None. 2012-06-13 19:35:06 -04:00
Wirawan Purwanto 81316af285 * Added os.path-like methods: isdir, isfile, islink.
The last one is not reliable, but is added for uniformity for the time
  being.
2012-06-03 20:35:40 -04:00
Wirawan Purwanto dcb7fa304c * Added sftp_client.put() method.
* Added sftp_status_callback class.
2012-05-26 08:37:01 -04:00
Wirawan Purwanto 6433e5da3c * Added prefix and suffix options for matrix_str and vector_str. 2012-05-23 00:25:42 -04:00
Wirawan Purwanto 140b3b699c * Added wpylib.interactive_tools.printstr class to facilitate logging of
print-ed output in interactive python sessions.
2012-05-17 12:29:30 -04:00
Wirawan Purwanto 5c72506135 * New module: wpylib.file.tee
* Added class tee_output for splitting text output to multiple destinations.
2012-05-14 15:48:43 -04:00
Wirawan Purwanto ad841e0b90 * text_input.read_items(): added option end_line_match' and last_line_match'
(mutually exclusive options) to allow the dataset reading to end upon
  encountering certain text pattern (or a more complicated match, if we
  specify a function for the option value).
  These options can be used to work with the `maxcount' option; the shortest
  of the two (maxcount records read first, or end/last_line_match finds a
  match) will end the reading of the dataset.
2012-04-17 11:03:29 -04:00
Wirawan Purwanto 501552a65a * Added zip_gen() to simulate the effect of built-in zip() function, but
implemented as a generator rather than yielding the list right away.
  This is used mainly in loops, where we don't want to generate all the
  elements due to memory concerns.
2012-04-17 11:00:30 -04:00
Wirawan Purwanto 606214eb66 * Changing all isinstance(STUFF, str)' to isinstance(STUFF, basestring)'
for future-proofing this code.
2012-04-13 17:10:32 -04:00
Wirawan Purwanto 6656d3d5e3 * In module text_input: Added head() and tail() to emulate the basic
behavior of UNIX commands with the same name.
  Output lines are already split into a list of strings.
2012-03-19 16:53:23 -04:00
Wirawan Purwanto 41079fd92c * sugar: Added is_iterable(). 2012-03-19 11:57:19 -04:00
Wirawan Purwanto 14303979f1 * Recorded down some notes/caveat for init_interactive(). 2012-02-16 13:53:58 -05:00
Wirawan Purwanto 4194344891 * init_interactive() returns True if interactive session is detected; False
otherwise.
2012-02-16 13:45:46 -05:00
Wirawan Purwanto 1674bfd256 * Added workaround so at least interactive python detection works
(although not perfectly) in python <= 2.5.
2012-02-16 13:32:55 -05:00
Wirawan Purwanto f8a101fbe9 * Added comment_char option for text_input object creation.
* Memory leak bugfix: Use instance method weakref.
2012-02-15 23:02:11 -05:00
Wirawan Purwanto 5666280a45 * Alias "|" operator to "+" operator. 2012-02-09 15:02:38 -05:00
Wirawan Purwanto 3698671bed * Added: fortran_bin_file.peek_next_rec_len() to fetch the next record length
while not advancing the read pointer to that record yet.
2012-01-30 16:04:17 -05:00
Wirawan Purwanto 050e2414ef * Added faster LDdec1 for 1-based indexing.
Tested through N=1000.
2012-01-26 10:46:55 -05:00
Wirawan Purwanto d04ea8cbea * Completing jskip formula for LD that is analogous to the jskip formula for
UD matrix format.
2012-01-25 17:07:50 -05:00
Wirawan Purwanto 93a89d2606 * Created array indexer for "upper diagonal" indexing mode.
Apparently I was able to create the non-iterative version of UDdec (1-based
  indices).
2012-01-24 17:32:39 -05:00
Wirawan Purwanto 961a802326 * Keep a copy of my symmetric array indexer worksheet in GIT.
Original signature:
    -rw-r--r-- 1 wirawan0 wirawan0 1380 2010-04-27 15:55 symmetrix-array-index.py
    b873ece4610483b3cd5290c6ddbc7426  symmetrix-array-index.py
2012-01-24 17:28:10 -05:00
wirawan 7017fdc6af * Committing all dirty work to CVS. We are migrating to GIT.
Beware: changes in this commit may or may not work properly.
2011-10-06 19:15:05 +00:00
wirawan 8ebf1e422e * Add important warning. Maybe in the future we need to use operator "|"
and append the search paths to _list_?
2011-09-19 20:06:45 +00:00
wirawan 81e2ada60c * Allow comment character to be changed from "#" using the
instance.comment_char attribute.
2011-09-16 21:21:23 +00:00
wirawan 3f38cbfb34 * Allow printing of numpy.matrix objects. 2011-09-13 21:50:16 +00:00
wirawan 6fb10829e0 * Added Parameters._get_() method. 2011-09-12 21:58:43 +00:00
wirawan aad559d86b * Class Parameters: important change of behavior for more safety to avoid
potential confusion.

* Detail of the important changes:

  1) by default now the function's local variables are not included in the
     lookup chain. Use _localvars_ flag if you insist on doing that; but
     be aware of the caveat (see Parameters' documentation).

  2) the default _kwparam_ and _userparam_ names are now passed on to the
     child Parameters object instead of the override values given through
     the _create_ function argument.
     Rationale: To begin with, the default names defined during the creation
     of the parent Parameters object should be used by *all* the relevant
     functions.
     Overrides should be regarded as exceptional rather than common cases.

  3) Value overrides (_kwparam_, _userparam_, etc.) in _create_ must now
     be specified in keyword=value manner rather than as positional argument.
     Rationale: Those overrides must be made conspicuous.
     The keyword=value approach also makes the code more resilient to minor
     API changes.
     All unnamed parameters are supposed to be low-priority defaults.
2011-09-09 18:58:48 +00:00
wirawan 4aff740f55 * Parameters value lookup: use try..except EAFP rather LBYL approach.
* Add simple checks for _p, _opts_ default arguments in case they are not
  indexable/dict-like objects. This is needed to avoid bizzare error messages
  later then the Parameters object is in use.
2011-09-07 15:05:54 +00:00
wirawan 1181a7e516 * Add descriptive error message. 2011-09-07 15:04:15 +00:00
wirawan ceeafa811a * Added str_snippet() from MnO ipython script. 2011-09-07 15:03:54 +00:00
wirawan c675077620 * Introducing self.lineno counter for line numbers (including the blanks
and comment lines).
2011-09-05 19:09:21 +00:00
wirawan 3f3c49df94 * Added file mode for file creation (default: "w"). 2011-09-02 15:07:47 +00:00
wirawan cde48ef8de * wpylib.datetime: Date/time related module. 2011-09-01 15:34:03 +00:00
wirawan 3b522de2d6 * Added text_input.close() method. 2011-08-31 20:28:30 +00:00
wirawan 7d37c0b6ba * Internal upgrade to factor out reusable parts (for future upgrades). 2011-08-31 20:27:31 +00:00
wirawan cf46af2bc2 * Simple function rename: make_unbound_method -> make_unbound_instance_method. 2011-08-31 18:26:18 +00:00
wirawan 77a15740cb * New module wpylib.debugging: Debugging tools. 2011-08-31 18:25:07 +00:00
wirawan 16c24736e4 * ipython-interactive-script.PY: skeleton for my ipython interactive script. 2011-08-19 17:23:10 +00:00
wirawan 1e3d236b1c * Completing initial version of interactive tool support: added interactive
mode detection (plain python, `python -i', and ipython supported),
  and my canned initialization for interactive python environment
  (like MYSELF, ARGV).
2011-07-18 15:48:52 +00:00
wirawan 47f6bced79 * wpylib.math.linalg: Added initial module for linear-algebra convenience
functions, objects, and submodules.
2011-07-14 19:00:59 +00:00
wirawan 94c1651586 * wpylib.py.im_weakref: weakref for instance method.
Copied from Linux Screen Reader project.
2011-06-08 15:50:07 +00:00
wirawan 424a9238bb * hacks.py: Added make_unbound_method to allow general function to participate
as hacked class methods.
2011-06-08 15:49:04 +00:00
wirawan ceb8f35ec3 * Creating wpylib.py module to contain all python-level hacks.
Submodules are available for specialized and more complicated hacks.
2011-06-08 15:29:14 +00:00
wirawan ad73b5af7f * Added set_next_proc() method to set which procedure should be called when
"next()" method dispatcher is called.

  This approach should get rid of the problem with circular reference which
  causes the text_input instance not be erasable because of strong reference
  to `self' in `self.next.im_self'.
2011-06-03 21:34:32 +00:00
wirawan 1bbaae135f * Added python-level advanced hack module which should hide all my dirty
tricks here.
2011-06-03 21:31:59 +00:00
wirawan 90c4f1b50b * Added vector_str and matrix_str generic function to print a matrix/vector
in space-seprated string format.
  The output is mainly for human consumption, not for machine re-reading
  (although it is possible to do so, in general).
2011-06-03 18:24:00 +00:00
wirawan 9e1c6f5868 * Commenting out the verbose printout. I think the module is robust now. 2011-05-12 14:51:02 +00:00
wirawan 90f1603499 * Added text_output as a converse facility to print out text stream to
a file.
  Useful for a shortened output statements in the code, and also for
  reroutable output (to stdout? to file? to both?) and flexible output
  kind.
2011-05-11 20:28:51 +00:00
wirawan 0531e4e511 * Add documentation for file_table. Add note for future hash: SHA1,256,... 2011-04-26 15:28:37 +00:00
wirawan f42f2d82fa * __imul__ and __idiv__ should return the lvalue object itself. 2011-04-05 19:20:55 +00:00
wirawan f1dee72d09 * Reset fitting debug level to 0. 2011-04-05 19:20:01 +00:00
wirawan f64a3cfd8e * Using external login node on jaguar. 2011-03-10 20:18:27 +00:00
wirawan 6181d5588d * The sign of the scalar prefactor should not enter the uncertainty
(err) field!
2011-03-10 20:17:55 +00:00
wirawan 2a30c20a79 * Added dict_islice to support slicing while ignoring non-existing keys
in the source dict.
2011-03-10 20:16:58 +00:00