Created
July 10, 2015 01:36
-
-
Save aokj4ck/6971cfc889856ed94835 to your computer and use it in GitHub Desktop.
Python: Decimal array with Numpy test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy | |
import decimal | |
items = [decimal.Decimal(x) for x in range(0, 20)] | |
array = numpy.array(items, dtype=decimal.Decimal) | |
array.mean() | |
# OS X, python 2.7.6: | |
# Traceback (most recent call last): | |
# File "<stdin>", line 1, in <module> | |
# File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/core/_methods.py", line 67, in _mean | |
# ret = ret.dtype.type(ret / rcount) | |
# AttributeError: 'Decimal' object has no attribute 'dtype' | |
# | |
# ------------ | |
# | |
# Cent OS, python 2.6.6: | |
# Traceback (most recent call last): | |
# File "<stdin>", line 1, in <module> | |
# TypeError: Unsupported operand type(s) for /: 'Decimal' and 'float' | |
array.mean(dtype=decimal.Decimal) | |
# OS X, Python 2.7.6: | |
# Traceback (most recent call last): | |
# File "<stdin>", line 1, in <module> | |
# File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/core/_methods.py", line 67, in _mean | |
# ret = ret.dtype.type(ret / rcount) | |
# AttributeError: 'Decimal' object has no attribute 'dtype' | |
# | |
# ------------ | |
# | |
# Cent OS error with python 2.6.6: | |
# Traceback (most recent call last): | |
# File "<stdin>", line 1, in <module> | |
# TypeError: Unsupported operand type(s) for /: 'Decimal' and 'float' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment