Commit d3209a92 authored by Paulo Medeiros's avatar Paulo Medeiros
Browse files

Fix a few warnings

parent 9c7271f1
......@@ -164,7 +164,7 @@ def _to_dense(data, n, dtype):
"""
dense = np.zeros(shape=(n, n), dtype=dtype)
for idata in prange(len(data)):
for idata in prange(len(data)): # pylint: disable=not-an-iterable
i, j = _data_index_to_matrix_index(n, idata, check_bounds=False)
data_value = data[idata]
dense[i, j] = data_value
......@@ -195,7 +195,7 @@ def _to_compact(dense, dtype):
n = dense.shape[0]
n_indep = (n ** 2 - n) // 2
compact = np.zeros(n_indep, dtype=dtype)
for idata in prange(len(compact)):
for idata in prange(len(compact)): # pylint: disable=not-an-iterable
i, j = _data_index_to_matrix_index(n, idata, check_bounds=False)
compact[idata] = dense[i, j]
return compact
......@@ -617,7 +617,7 @@ class HollowSymmetricMatrix(np.lib.mixins.NDArrayOperatorsMixin):
"""Return (i, j) such that self.data[data_i] == self[i, j]."""
return _data_index_to_matrix_index(self.order, data_i)
def __array__(self, dtype=None, copy=False, order=None):
def __array__(self, *args, **kwargs):
# See <https://numpy.org/devdocs/user/basics.dispatch.html>
# TODO: Remove the ".astype(np.float64)" when possible.
# HDBSCAN requires that the result of np.array(self) to have
......@@ -702,9 +702,9 @@ class HollowSymmetricMatrix(np.lib.mixins.NDArrayOperatorsMixin):
def __setitem__(self, ij_tuple, value):
try:
boolean_indexing = ij_tuple.dtype == np.bool
boolean_indexing = ij_tuple.dtype == bool
except AttributeError:
boolean_indexing = np.array(ij_tuple).dtype == np.bool
boolean_indexing = np.array(ij_tuple).dtype == bool
if boolean_indexing:
if isinstance(ij_tuple, type(self)):
......
......@@ -28,9 +28,7 @@ def gen_random_hsm(n):
def gen_random_bool_mask_triu(n):
"""Return a random numpy.triu matrix with dtype numpy.bool."""
return np.triu(np.random.randint(n, size=n * n).reshape(n, n)).astype(
np.bool
)
return np.triu(np.random.randint(n, size=n * n).reshape(n, n)).astype(bool)
def gen_random_bool_mask_tril(n):
......@@ -119,7 +117,7 @@ class TestsSetitem:
# A single diagonal element as (int, int)
lambda n: tuple(np.repeat(np.random.randint(n), 2)),
# All diag elements as boolean array
lambda n: np.eye(n).astype(np.bool),
lambda n: np.eye(n).astype(bool),
],
)
def test_setitem_enforces_hollow(self, random_hsm, gen_indices):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment