Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test should pass
  • Loading branch information
rflamary committed Oct 30, 2024
commit 108f9c89e60309ee30e9493776748cbaaddc6793
7 changes: 6 additions & 1 deletion ot/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -1890,7 +1890,12 @@ def _to_numpy(self, a):
return a.cpu().detach().numpy()

def _from_numpy(self, a, type_as=None):
if isinstance(a, float) or isinstance(a, int):
if (
isinstance(a, float)
or isinstance(a, int)
or isinstance(a, np.float32)
or isinstance(a, np.float64)
):
a = np.array(a)
if type_as is None:
return torch.from_numpy(a)
Expand Down
4 changes: 2 additions & 2 deletions test/gromov/test_lowrank.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ def test__flat_product_operator():
X = np.reshape(1.0 * np.arange(2 * n), (n, d))
A1, A2 = ot.lowrank.compute_lr_sqeuclidean_matrix(X, X, rescale_cost=False)

A1_ = ot.gromov._flat_product_operator(A1)
A2_ = ot.gromov._flat_product_operator(A2)
A1_ = ot.gromov._lowrank._flat_product_operator(A1)
A2_ = ot.gromov._lowrank._flat_product_operator(A2)
cost = ot.dist(X, X)

# test value
Expand Down