[New-bugs-announce] [issue41589] Strange behavior with sparse.dok_matrix decimal is cast to integer
browser.365
report at bugs.python.org
Wed Aug 19 13:18:37 EDT 2020
New submission from browser.365 <browser.home.365 at gmail.com>:
import numpy as np
from scipy import sparse
import decimal
D = decimal.Decimal
Al = sparse.dok_matrix((10, 10), dtype=np.dtype(D))
Al.astype(D)
Al[1,1] = D('0.1')
print(Al[1,1])
print(type(Al[1,1]))
Al[0,0] = D('0')
print(Al[0,0])
print(type(Al[0,0]))
z = decimal.Decimal('0')
print(z)
print(type(z))
print(' - ')
Running the above code gives:
0.1
<class 'decimal.Decimal'>
0
<class 'int'>
0
<class 'decimal.Decimal'>
-
All of the elements should be decimal.
----------
messages: 375660
nosy: browser.365
priority: normal
severity: normal
status: open
title: Strange behavior with sparse.dok_matrix decimal is cast to integer
type: behavior
versions: Python 3.7
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue41589>
_______________________________________
More information about the New-bugs-announce
mailing list