Skip to content

Commit

Permalink
Addressing PR feedback from isce-framework#10
Browse files Browse the repository at this point in the history
  • Loading branch information
piyushrpt committed May 20, 2024
1 parent c6f0d96 commit e5dbca5
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/spurt/mcf/_ortools.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,24 +147,24 @@ def compute_residues_from_gradients(
self,
graddata: ArrayLike,
) -> ArrayLike:
"""Compute phase residues for one set of real input gradients."""

if graddata.size != self.nedges:
errmsg = (
f"Size mismatch for residue computation."
f" Received {graddata.shape} with {self.nedges} edges"
)
raise ValueError(errmsg)

cyc0 = np.abs(self.dual_edges[:, 0])
cyc1 = np.abs(self.dual_edges[:, 1])
cyc0 = self.dual_edges[:, 0]
cyc1 = self.dual_edges[:, 1]
cyc0_dir = self.dual_edge_dir[:, 0]
cyc1_dir = self.dual_edge_dir[:, 1]
grad_sum = np.zeros(self.ncycles + 1, dtype=np.float32)
# add.at to handle repeated indices
np.add.at(grad_sum, cyc0, cyc0_dir * graddata)
np.add.at(grad_sum, cyc1, cyc1_dir * graddata)

residues = np.rint(grad_sum / (2 * np.pi))
residues = np.rint(grad_sum / (2 * np.pi)).astype(int)
# Set supply of groud_node
residues[0] = -np.sum(residues[1:])

Expand Down

0 comments on commit e5dbca5

Please sign in to comment.