[BUG] Graph matching errors when similarity matrix has unequal dimensions
dokato opened this issue · comments
dokato commented
Expected Behavior
Graspologic handles similarity matrices with dimensions of different sizes for matrices A and B.
Actual Behavior
~/projects/graspologic/graspologic/match/solver.py in __init__(self, A, B, AB, BA, S, partial_match, init, init_perturbation, verbose, shuffle_input, padding, maximize, max_iter, tol, transport, transport_regularizer, transport_tol, transport_max_iter)
191 S = csr_array((self.n, self.n))
192
--> 193 _compare_dimensions(A, [S], "row", "row", "A", "S")
194 _compare_dimensions(B, [S], "row", "column", "B", "S")
195
~/projects/graspologic/graspologic/match/solver.py in _compare_dimensions(A, B, dimension_A, dimension_B, name1, name2)
686 f"`{name2}` number of {dimension_B}s."
687 )
--> 688 raise ValueError(msg)
689
690
ValueError: Input matrix/matrices `A` number of rows must match `S` number of rows.
Example Code
from graspologic.simulations import er_np
from graspologic.match import graph_match
import numpy as np
adj_l = er_np(49, 0.2)
adj_r = er_np(51, 0.3)
sim = np.zeros((49,51))
graph_match(adj_l, adj_r, S = sim)
Your Environment
- Python version: 3.9.7
- graspologic version:1.0.0
Additional Details
It's due to the fact that padding of A and B happens before checking dimensions of A and B vs. S.