Skip to content

Commit 6e95f87

Browse files
committed
Mask cleanup.
1 parent dc954d2 commit 6e95f87

File tree

4 files changed

+3
-12
lines changed

4 files changed

+3
-12
lines changed

cfpq_matrix/block/block_matrix.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ def optimize_similarly(self, other: Matrix) -> "OptimizedMatrix":
2525

2626
def to_mask(self):
2727
if self.block_matrix_space.is_single_cell(self.shape):
28-
print ("@@@@@@@")
29-
print (self.shape)
3028
return self.base.to_mask()
3129
else:
3230
return None

cfpq_matrix/format_optimized_matrix.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ def base(self) -> OptimizedMatrix:
3131
return self._base
3232

3333
def to_mask(self) -> Matrix:
34-
print ("#####")
35-
#print (self.matrices[0].to_mask())
3634
return list(self.matrices.values())[0].to_mask()
3735

3836
def _force_init_format(self, desired_format: str) -> OptimizedMatrix:

cfpq_matrix/lazy_add_optimized_matrix.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def nvals(self) -> int:
2424
return sum(m.nvals for m in self.matrices)
2525

2626
def to_mask(self) -> Matrix:
27-
return self.matrices[0].to_mask()
27+
return (max(self.matrices, key = lambda m: m.nvals)).to_mask()
2828

2929
def _map_and_fold(
3030
self,

cfpq_matrix/matrix_to_optimized_adapter.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,21 +39,16 @@ def to_unoptimized(self) -> Matrix:
3939
def mxm(self, other: Matrix, op: Semiring, mask: Matrix, swap_operands: bool = False) -> Matrix:
4040
if swap_operands:
4141
if not mask is None:
42-
#print("It would be nice to apply mask in swap operands")
4342
print("Mask applied, swap operands.")
4443
result = Matrix(self.dtype,nrows=other.shape[0],ncols=self.shape[1])
45-
#mask_t = Matrix(mask.dtype, ncols=mask.ncols, nrows=mask.nrows)
46-
#mask_t << mask.T
47-
#result(~mask) << other.mxm(self.base, op)
48-
result(~mask) << other.mxm(self.base, op).new(self.dtype)
44+
result(~mask.S) << other.mxm(self.base, op).new(self.dtype)
4945
return result
50-
#return other.mxm(self.base, op).new(self.dtype)
5146
else: return other.mxm(self.base, op).new(self.dtype)
5247
else:
5348
if not mask is None:
5449
print("Mask applied.")
5550
result = Matrix(self.dtype,nrows=self.shape[0],ncols=other.shape[1])
56-
result(~mask) << self.base.mxm(other, op).new(self.dtype)
51+
result(~mask.S) << self.base.mxm(other, op).new(self.dtype)
5752
return result
5853
else: return self.base.mxm(other, op).new(self.dtype)
5954

0 commit comments

Comments
 (0)