Commit Graph

58 Commits

Author SHA1 Message Date
Mark Dickinson 539bff4234 Update decimal test data to the most recent set from Mike Cowlishaw. 2009-10-08 16:28:39 +00:00
Mark Dickinson 5cfa8044ff Issue #6857: Fix Decimal formatting to be consistent with existing float
formatting:  both are now right-aligned by default.
2009-09-08 20:20:19 +00:00
Mark Dickinson 968f1690d3 #Issue 6795: Fix infinite recursion in long(Decimal('nan')); change int(Decimal('nan')) to raise ValueError instead of either returning NaN or raising InvalidContext. 2009-09-07 18:04:58 +00:00
Mark Dickinson 491ea55f28 Issue #6850: Fix bug in Decimal._parse_format_specifier for formats
with no type specifier.
2009-09-07 16:17:41 +00:00
Mark Dickinson 4326ad8f72 Issue #6595: Allow Decimal constructor to accept non-European decimal
digits, as recommended by the specification.  (Backport of r74279 from
py3k.)
2009-08-02 10:59:36 +00:00
Benjamin Peterson 5c8da86f3a convert usage of fail* to assert* 2009-06-30 22:57:08 +00:00
Benjamin Peterson bec087f29d fix incorrect auto-translation of TestSkipped -> unittest.SkipTest 2009-03-26 21:10:30 +00:00
Benjamin Peterson 888a39b54c remove test_support.TestSkipped and just use unittest.SkipTest 2009-03-26 20:48:25 +00:00
Mark Dickinson b14514a153 Fix bug in _insert_thousands_sep: too much zero padding could be
added for 'n' formats with non-repeating thousands-separator.
2009-03-18 08:22:51 +00:00
Mark Dickinson 277859d591 Issue #2110: Add support for thousands separator and 'n' format specifier
to Decimal __format__ method.
2009-03-17 23:03:46 +00:00
Mark Dickinson b065e52bc2 Fix bug in Decimal __format__ method that swapped left and right
alignment.
2009-03-17 18:01:03 +00:00
Raymond Hettinger 2c8585b0af Register decimals as numbers.Number 2009-02-03 03:37:03 +00:00
Mark Dickinson da62f81d1d Remove an unnecessary check from test_decimal. 2009-01-10 19:14:55 +00:00
Raymond Hettinger f4d8597a59 Issue 4796: Add from_float methods to the decimal module. 2009-01-03 19:02:23 +00:00
Mark Dickinson 70c3289085 Replace occurrences of '\d' with '[0-9]' in Decimal regex, to make sure
that the behaviour of Decimal doesn't change if/when re.UNICODE becomes
assumed in Python 3.0.

Also add a check that alternative Unicode digits (e.g. u'\N{FULLWIDTH
DIGIT ONE}') are *not* accepted in a numeric string.
2008-07-02 09:37:01 +00:00
Facundo Batista ee340e501d Fixed some test structures. Thanks Mark Dickinson. 2008-05-02 17:39:00 +00:00
Benjamin Peterson 95287fa951 Remove some from __future__ import with_statements 2008-04-30 21:25:55 +00:00
Mark Dickinson 8e85ffa4b2 Issue #2482: Make sure that the coefficient of a Decimal
instance is always stored as a str instance, even
when that Decimal has been created from a unicode string.
2008-03-25 18:47:59 +00:00
Mark Dickinson 3b24ccbe7e Issue #2478: Decimal(sqrt(0)) failed when the decimal context
was not explicitly supplied.
2008-03-25 14:33:23 +00:00
Facundo Batista 6415667fe2 Small fix that complicated the test actually when that
test failed.
2008-03-22 02:45:37 +00:00
Mark Dickinson 1ddf1d8482 Add __format__ method to Decimal, to support PEP 3101 2008-02-29 02:16:37 +00:00
Raymond Hettinger abe3237187 Fix decimal repr which should have used single quotes like other reprs. 2008-02-14 02:41:22 +00:00
Mark Dickinson 2fc9263df5 Issue 1979: Make Decimal comparisons (other than !=, ==) involving NaN
raise InvalidOperation (and return False if InvalidOperation is trapped).
2008-02-06 22:10:50 +00:00
Jeffrey Yasskin ca2b69f765 Move __builtins__.trunc() to math.trunc() per
http://mail.python.org/pipermail/python-dev/2008-January/076626.html and issue
1965.
2008-02-01 06:22:46 +00:00
Raymond Hettinger 5a05364049 Add support for trunc(). 2008-01-24 19:05:29 +00:00
Mark Dickinson 59bc20bb27 Issue 1780: Allow leading and trailing whitespace in Decimal constructor,
when constructing from a string. Disallow trailing newlines in
Context.create_decimal.
2008-01-12 01:56:00 +00:00
Facundo Batista 52b25795c0 Issue #1757: The hash of a Decimal instance is no longer affected
by the current context.  Thanks Mark Dickinson.
2008-01-08 12:25:20 +00:00
Facundo Batista 72bc54faed Major change in the internal structure of the Decimal
number: now it does not store the mantissa as a tuple
of numbers, but as a string.

This avoids a lot of conversions, and achieves a
speedup of 40%. The API remains intact.

Thanks Mark Dickinson.
2007-11-23 17:59:00 +00:00
Facundo Batista 9b5e23148b The constructor from tuple was way too permissive: it allowed bad
coefficient numbers, floats in the sign, and other details that
generated directly the wrong number in the best case, or triggered
misfunctionality in the alorithms.

Test cases added for these issues. Thanks Mark Dickinson.
2007-10-19 19:25:57 +00:00
Facundo Batista 1a191df14d Made the various is_* operations return booleans. This was discussed
with Cawlishaw by mail, and he basically confirmed that to these is_*
operations, there's no need to return Decimal(0) and Decimal(1) if
the language supports the False and True booleans.

Also added a few tests for the these functions in extra.decTest, since
they are mostly untested (apart from the doctests).

Thanks Mark Dickinson
2007-10-02 17:01:24 +00:00
Facundo Batista 8c20244069 Issue #1772851. Optimization of __hash__ to behave better for big big
numbers.
2007-09-19 17:53:25 +00:00
Thomas Wouters b3e6e8c895 Fix obvious typo in threaded test. 2007-09-19 17:27:29 +00:00
Facundo Batista 6c398da0e7 The methods always return Decimal classes, even if they're
executed through a subclass (thanks Mark Dickinson).
Added a bit of testing for this.
2007-09-17 17:30:13 +00:00
Facundo Batista 353750c405 Merged the decimal-branch (revisions 54886 to 58140). Decimal is now
fully updated to the latests Decimal Specification (v1.66) and the
latests test cases (v2.56).

Thanks to Mark Dickinson for all his help during this process.
2007-09-13 18:13:15 +00:00
Nick Coghlan ced1218dd1 Make decimal.ContextManager a private implementation detail of decimal.localcontext() 2006-09-02 03:54:17 +00:00
Nick Coghlan 8b6999b4c5 Fix the wrongheaded implementation of context management in the decimal module and add unit tests. (python-dev discussion is ongoing regarding what we do about Python 2.5) 2006-08-31 12:00:43 +00:00
Neal Norwitz ce4a9c9019 Fix tests so they pass in -R mode 2006-04-09 08:36:46 +00:00
Tim Peters 46cc702b72 test_main(): Restore the decimal context that was in
effect at the time test_decimal was imported.  Else
running test_decimal had the bad side effect of
permanently changing the decimal context in effect.
That caused text_tokenize to fail if it ran after
test_decimal.
2006-03-31 04:11:16 +00:00
Anthony Baxter 4ef3a23a35 whitespace normalisation 2006-03-30 12:59:11 +00:00
Georg Brandl 96c3f7f56b Make test_decimal work with -Qnew. 2006-03-28 08:06:35 +00:00
Raymond Hettinger 267b868f23 * Fix decimal's handling of foreign types. Now returns NotImplemented
instead of raising a TypeError.  Allows other types to successfully
  implement __radd__() style methods.
* Remove future division import from test suite.
* Remove test suite's shadowing of __builtin__.dir().
2005-03-27 10:47:39 +00:00
Raymond Hettinger bea3f6f5c7 Bug #1163325: "special" decimals aren't hashable 2005-03-15 04:59:17 +00:00
Raymond Hettinger 7e71fa5cfa Bug #1083645
* The decimal module wouldn't load on builds without threads.
2004-12-18 19:07:19 +00:00
Raymond Hettinger 605ed02483 SF bug #1071588 coercing decimal to int doesn't work between -1 and 1 2004-11-24 07:28:48 +00:00
Raymond Hettinger ed20ad8473 Change the strategy for coping with time intensive tests from
"all or none" to "all or some".

This provides much greater test coverage without eating much time.
It also makes it more likely that routine regression testing will
unearth bugs.
2004-09-04 20:09:13 +00:00
Raymond Hettinger f04d8a8898 There are no longer any special case test skips. 2004-08-17 16:34:51 +00:00
Raymond Hettinger f63ba43733 * Dynamically build a list of files to be tested (necessary because
version 2.39 of dectest.zip adds some new test files and because
  some existing test files were getting skipped).
* Remove two docstrings which cluttered unittest's output.
* Simplify a for-loop with a list comprehension.
2004-08-17 05:42:09 +00:00
Raymond Hettinger 955d2b2168 Add a test for Context.copy(). 2004-08-08 20:17:45 +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