Commit Graph
100 Commits
Author SHA1 Message Date
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
wirawan 26db0806ae * Make Struct available publicly in wpylib.params namespace (with the
'struct' name).
2011-03-10 19:22:37 +00:00
wirawan 3ac8e37b35 * Using the __dict__ attribute to store user-defined values.
Dict-like behavior is exemplified by this class although it is *not*
  derived from a dict.
2011-03-10 19:21:33 +00:00
wirawan 6d043f6721 * Simple clarification on example. 2011-03-10 19:20:35 +00:00
wirawan d8984cf032 * Introducing "Struct", the base class for all structured datatypes.
This is the original implementation as found in Ca+4H2_Hstorage_iter.py .
2011-03-10 17:17:48 +00:00
wirawan dbd36e0f1f * Added division of errorbar by a scalar. 2010-12-01 17:11:46 +00:00
wirawan 7dbef49f6c * Minor documentation edit. 2010-11-11 18:00:01 +00:00
wirawan 8363eb03bc * Adding more extensive documentation.
* Making minor changes to the expected method name (parse_text_file_ =>
  parse_file_).
2010-11-11 17:59:36 +00:00
wirawan 0bd6f56422 * Moving pyqmc.results.result_base module to wpylib.db.result_base for more
general uses.
2010-11-11 17:48:01 +00:00
wirawan bceef1e601 * Adding more methods for fitting: fmin (simplex minimization).
I still have hard time making fitting routine work for me.
  But at least this one works for simple SHO fitting.
2010-11-05 02:28:20 +00:00
wirawan 592d6bd7c9 * Correcting recursive updates. 2010-10-29 15:58:51 +00:00
wirawan c0f67e9992 * Ignore compiled modules. 2010-10-25 14:43:17 +00:00
wirawan 3fbc20ddb0 * Correction on notes. 2010-10-25 14:42:50 +00:00
wirawan 2303ad8d0b * pipe_in (subprocess version): added "flush" method. 2010-10-25 14:41:39 +00:00
wirawan 428b481b87 * Added initial support for errorbar object, which includes
compression-to-string (ad hoc implementation is written in C++ with the
  help of my cp.inc library, unfortunately).
2010-10-19 20:19:25 +00:00
wirawan 9eb177bc27 * Adding wpylib.math.stats submodule which contains commonly used statistical
analysis tools.
2010-10-07 15:57:29 +00:00
wirawan 02776c1e6a * Moving pyqmc.stats.avg to wpylib.math.stats.avg . 2010-10-07 15:56:55 +00:00
wirawan 46e5caa7a2 * Convenience regular expression module. 2010-10-06 16:37:42 +00:00
wirawan 96d1f9afd7 * Upgrade to allow reading complex-valued data directly.
Please see the documentation of text_input.read_items for more detail.
2010-09-30 17:23:34 +00:00
wirawan 71474e2973 * Standard python ignore. 2010-09-30 16:17:00 +00:00
wirawan 6641410d89 * Moving the fancy "Parameters" parameter lookup class to its own module.
From now on, use it as wpylib.params.flat class.
2010-09-30 16:16:38 +00:00
wirawan 4c9b5ce9f7 * Update documentations. 2010-09-27 19:54:29 +00:00
wirawan cae9cabdea * Simple text input reader. Imported from pyqmc.utils.text_input . 2010-09-27 19:54:05 +00:00
wirawan 5f367c8fc8 * My own update scripts. 2010-09-27 19:53:22 +00:00
wirawan 090d9f7b00 * Moving pyqmc.utils.file_utils to wpylib project. 2010-09-27 19:47:19 +00:00
wirawan 631a152b8e * Moving pyqmc.utils.timer to wpylib. 2010-09-27 19:41:15 +00:00
wirawan 5392a71943 * Correcting minor mistake. 2010-09-27 19:40:40 +00:00
wirawan f1b8746147 * Updating Parameters class: now based on dict.
* Can add two Parameters together, which means joining the two or more dicts,
  much like what function dict_join does.
2010-09-10 21:24:56 +00:00
wirawan 379e83fdec * Added epsilon() function to find out the granuality of a given floating
point type.
2010-09-10 21:23:59 +00:00
wirawan fcba27ae24 * Added list_join, much like dict_join, except for list.
* Added ranges "magic" object to define piecewise ranges.
2010-08-12 19:35:55 +00:00
wirawan ffd21689be * Parameters class: a way to look for parameters in definite search order
across functions, so that these parameters do not have to be passed in
  kitchen-sink manner.
  WARNING: STILL UNDER TESTING.
2010-05-28 18:47:56 +00:00
wirawan 3701e5655a * added str_grep and str_igrep. 2010-05-28 18:46:53 +00:00
wirawan 1c6547d3c0 * Added default debug level. 2010-05-28 18:46:16 +00:00
wirawan a6582aa8f2 * pipe_in() for "piping in" input to an external command.
* system() like os.system() except with error checking.
* getenv() to get look for a value from a list of environment variables--
  they are searched sequentially in definite order.
2010-05-28 18:45:51 +00:00
wirawan 75d4c2240c * Function ztol: for zeroing out array elements below certain tolerance. 2010-05-28 18:43:59 +00:00
wirawan adbe499db8 * Fitting seemed to work, but still not perfectly. Do not use in production
yet.
2010-05-28 18:43:39 +00:00
wirawan c87ba9dbfa * Minor updates. 2010-05-28 18:43:14 +00:00
wirawan 40ac890d6f * Net-related helper objects.
* Python-based SFTP client.
2010-05-28 18:42:29 +00:00
wirawan ed52cd4af0 * Added slice_str for easy printout of a slice object in python typical slice
syntax (e.g. 0:10: or 0:10:3 or :10:3, etc).
2010-02-24 14:28:13 +00:00
wirawan 733c518735 * Added: density refitter onto a different FFT grid and/or supercell size
(expansion to a larger supercell).
2010-02-24 14:27:23 +00:00
wirawan 8c37b36673 * Template for dirty scripts/experiments. 2010-02-24 14:26:29 +00:00
wirawan ba3fcb6b6f * Added: dict_join to join several dicts, with keys from latter dicts taking
higher precedence.
2010-02-19 18:42:15 +00:00
wirawan 582c7f25aa * Generic generator module. 2010-02-19 18:41:28 +00:00
wirawan 9e7eeca3a2 * import_commands now will *NOT* override built-in python names (like dir,
id). Otherwise, this will result in disaster.
2010-02-19 18:40:19 +00:00
wirawan 69592e9a8f * Added writing facility. Still largely untested. 2010-02-19 18:39:17 +00:00
wirawan 15baf746f9 * Ignore all compiled python modules. 2010-02-11 02:29:51 +00:00
wirawan 21e85704aa * Initial version of Fortran binary file reader.
Later a writing facility can be added as well.
* Note that this module is intended only for reading/writing
  Fortran-generated files.
  It is not recommended for any other purpose because of its terrible feature:
  no metadata, no description whatsoever.
2010-02-08 21:49:54 +00:00
wirawan f246d382bf * Fix to make this work with independent pysqlite2 package.
* Allow rows to be returned as sqlite3.Row objects instead of simple tuple.
2010-02-08 20:00:14 +00:00
wirawan 37b556ded8 * Added dict_slice, a slicing tool returning a subset of a given dict
(or other dict-like object).
2010-02-08 19:58:44 +00:00
wirawan 599401a543 * Include *all* coreutils as the repertoire of the shell_tool commands.
* Added sorted_glob to return sorted list of globbed files. Needed for
  this script to run on older python 2.3-based systems.
2010-02-08 19:57:35 +00:00
wirawan dfc7a780f9 * Renaming file_db to file_table class.
* Allow record update in somewhat pythonic way (instead of using SQL).
2010-02-08 01:46:12 +00:00
wirawan 669e48b8d3 * Added "db" module group to deal with database management tasks.
* First module: file_db to store filename, fingerprint (md5sum) and basic
  stats (mtime, size). Additional fields can be specified as well.
* Will use sqlite as the backend for now.
* API is rather generic so the underlying database engine can be replaced.
2010-02-06 23:21:09 +00:00
wirawan 9de91dcc59 * Don't save python compiled modules. 2010-01-22 18:50:39 +00:00