Commit Graph

20 Commits

Author SHA1 Message Date
Raymond Hettinger 61992efc4b SF bug #1002530: test_decimal fails if repeated
* Protect the pre-defined contexts by using a deepcopy() instead of copy().
* Micro-optimization:  prefer x&1 over x%2
2004-08-06 23:42:16 +00:00
Raymond Hettinger ef66debd7e Use threading.local() instead of threading.currentThread(). 2004-07-14 21:04:27 +00:00
Raymond Hettinger 99148e7eaa Factor out two unnecessary global variables. 2004-07-14 19:56:56 +00:00
Raymond Hettinger b91af521fd * Hide a loop induction variable that was inadvertantly being picked up
by the locals() call in the context constructor.

* Remove unnecessary properties for int, exp, and sign which duplicated
  information returned by as_tuple().
2004-07-14 16:35:30 +00:00
Raymond Hettinger fed52963fc * Rename "Signals" to "_signals" making it non-public.
* Context.create_decimal can take a zero default just like Decimal().
* Fix typo in comment.
2004-07-14 15:41:57 +00:00
Raymond Hettinger bf4406971c Improve Context construction and representation:
* Rename "trap_enablers" to just "traps".
* Simplify names of "settraps" and "setflags" to just "traps" and "flags".
* Show "capitals" in the context representation
* Simplify the Context constructor to match its repr form so that only
  the set flags and traps need to be listed.
* Representation can now be run through eval().

Improve the error message when the Decimal constructor is given a float.

The test suite no longer needs a duplicate reset_flags method.
2004-07-10 14:14:37 +00:00
Raymond Hettinger d87ac8f24d * Update the test suite to reflect that ConversionSyntax was no longer
public.
* Removed the non-signal conditions from __all__.
* Removed the XXX comment which was resolved.
* Use ^ instead of operator.xor
* Remove the threading lock which is no longer necessary.
2004-07-09 10:52:54 +00:00
Raymond Hettinger 5aa478badf Module and tests:
* Map conditions to related signals.
* Make contexts unhashable.
* Eliminate used "default" attribute in exception definitions.
* Eliminate the _filterfunc in favor of a straight list.

Docs:
* Eliminate documented references to conditions that are not signals.
* Eliminate parenthetical notes such as "1/0 --> Inf" which are no
  longer true with the new defaults.
2004-07-09 10:02:53 +00:00
Raymond Hettinger bd7f76dd04 Tim gets his default traps. 2004-07-08 00:49:18 +00:00
Tim Peters 4e0e1b6a54 Whitespace normalization. 2004-07-07 20:54:48 +00:00
Raymond Hettinger 0aeac107ca * Add __eq__ and __ne__ so that things like list.index() work properly
for lists of mixed types.
* Test that sort works.
2004-07-05 22:53:03 +00:00
Raymond Hettinger ca3cc2fe21 * Update the todo list.
* Make ConversionSyntax signals get trapped by default.
2004-07-05 18:48:22 +00:00
Raymond Hettinger e0f1581bab * Fixup docstrings
* Make capitals default part of DefaultContext
2004-07-05 05:36:39 +00:00
Raymond Hettinger 0ea241e9e2 Changed the rounding constant values to match their variable names.
This serves to made the context representation more useful (the names in
match the names out).

Removed the link to ReXX.  That document did not shed add anything to
information already in the spec.

Further tighten the public API to improve usability:

* Emax and Emin are set through Context().  Their defaults are set in the
  DefaultContext, so there is no need to expose DEFAULT_MAX_EXPONENT
  and DEFAULT_MIN_EXPONENT.

* The string functions isnan() and isinfinity() were only used internal to
  the module and were not among the test cases.  External use cases are
  served by the Decimal constructor.  So, made these private.
2004-07-04 13:53:24 +00:00
Raymond Hettinger b1b605ef54 Fix clear_flags(). Make a readable (not evalable) Context repr. 2004-07-04 01:55:39 +00:00
Raymond Hettinger 9ec3e3b6eb Namespace cleanups:
* delete temporary globals immediately after use
* move a global into a class variable
* Rename BasicDefaultContext and ExtendedDefaultContext
  to BasicContext and ExtendedContext.
2004-07-03 13:48:56 +00:00
Raymond Hettinger 6ea4845822 * Make the tests independent of the default precision.
* Change the default precision to 28 (to match VB's decimal type).
2004-07-03 12:26:21 +00:00
Raymond Hettinger d9c0a7ae94 Work through several open todos:
* Added test for pickling contexts
* Renamed ExceptionList to Signals (to match wording in the spec)
* Simplified Context constructor by allowing flags=None to automatically
  generate a zeroed-out flags dictionary.
* inlined _convertString() which was used only once
* _rounding_decision is private, so excluded its contants from __all__.
* added an XXX comment with concerns about subclassing signals results in
  a deviation from the spec (maybe important, maybe not).
* Taught the test_suite to determine its own directory (modeled after code
  in regrtest.py).  Enables it to be run when the current directory is not
  the test directory.
* Added a clear_flags() method to the Context API to make it easier to do
  a common operation with flags.
* Fixed the trap_enablers defaults in BasicDefaultContext to match the spec.
2004-07-03 10:02:28 +00:00
Fred Drake 1f34eb17b5 fix small consistency nit 2004-07-01 14:28:36 +00:00
Raymond Hettinger 7c85fa4a52 Move Decimal from the sandbox into production. 2004-07-01 11:01:35 +00:00