Skip to content

Fix/low rank conversion pointcloud#672

Open
clijo wants to merge 1 commit intoott-jax:mainfrom
clijo:fix/low-rank-conversion-pointcloud
Open

Fix/low rank conversion pointcloud#672
clijo wants to merge 1 commit intoott-jax:mainfrom
clijo:fix/low-rank-conversion-pointcloud

Conversation

@clijo
Copy link
Copy Markdown
Contributor

@clijo clijo commented Feb 2, 2026

This PR fixes the issue #669 .

root cause

Root cause seems to be that PointCloud._check_LRC_dim was False in this case, and so PointCloud.to_LRCGeometry() returned the unmodified point cloud; which meant that the geom.to_LRCGeometry(rank=0, scale=scale, **kwargs) call in grid.py was not returning a low_rank.LRCGeometry object, and so the line c_1, c_2 = geom.cost_1, geom.cost_2 causes the crash because AttributeError: 'PointCloud' object has no attribute 'cost_1'.

fix

As the inline comments above geom.to_LRCGeometry(rank=0, scale=scale, **kwargs) call in grid.py explain, rank=0 is supposed to force low rank conversion. But, PointCloud.to_LRCGeometry() was ignoring that kwarg. I added a Boolean flag called force = (kwargs.get("rank") == 0) to coerce a low rank conversion.

The repro code from the issue now runs:

import jax.numpy as jnp
from ott.geometry.grid import Grid
from ott.problems.linear.linear_problem import LinearProblem
from ott.solvers.linear.sinkhorn import Sinkhorn
grid = Grid(grid_size=(2,))
prob = LinearProblem(grid, a=jnp.array([1,0]), b=jnp.array([0,1]))
out = Sinkhorn()(prob)
print(out.primal_cost)
1.0

@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 3, 2026

Codecov Report

❌ Patch coverage is 66.66667% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 87.35%. Comparing base (7ecebc9) to head (c1d60bb).

Files with missing lines Patch % Lines
src/ott/geometry/pointcloud.py 66.66% 0 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #672   +/-   ##
=======================================
  Coverage   87.35%   87.35%           
=======================================
  Files          82       82           
  Lines        8476     8477    +1     
  Branches      581      581           
=======================================
+ Hits         7404     7405    +1     
  Misses        922      922           
  Partials      150      150           
Files with missing lines Coverage Δ
src/ott/geometry/pointcloud.py 94.09% <66.66%> (+0.02%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@clijo clijo force-pushed the fix/low-rank-conversion-pointcloud branch from 6a0f4dd to 2ac46aa Compare February 6, 2026 01:10
@clijo clijo marked this pull request as ready for review February 6, 2026 04:34
@clijo clijo force-pushed the fix/low-rank-conversion-pointcloud branch from 93599f1 to c1d60bb Compare February 28, 2026 12:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant