sandialabs / pyttb

Python Tensor Toolbox
https://pyttb.readthedocs.io
BSD 2-Clause "Simplified" License
21 stars 12 forks source link

sptensor: output of comparison operators should have `bool` values #285

Open dmdunla opened 10 months ago

dmdunla commented 10 months ago

Although #269 fixed the output for logical_* methods, the comparison operators in sptensor currently output float values and not bool values.

For consistency with other tensor classes and the logical_* methods, this should change to outputting bool values.

>>> import pyttb as ttb
>>> import numpy as np
>>> S = ttb.sptensor(shape=(2,2))
>>> S[1,1] = 1.0
>>> S > 0
sparse tensor of shape (2, 2) with 1 nonzeros
[1, 1] = 1.0
>>> S >= 0
sparse tensor of shape (2, 2) with 4 nonzeros
[1, 1] = 1.0
[0, 0] = 1.0
[0, 1] = 1.0
[1, 0] = 1.0