Skip to content

Commit 2d72820

Browse files
committed
Add tentative fix for #357
1 parent 7dd0fb4 commit 2d72820

File tree

2 files changed

+12
-15
lines changed

2 files changed

+12
-15
lines changed

pineappl/src/grid.rs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -944,17 +944,8 @@ impl Grid {
944944
.multi_slice_mut((s![.., .., index], s![.., .., other_index]));
945945

946946
for (lhs, rhs) in a.iter_mut().zip(b.iter_mut()) {
947-
if !rhs.is_empty() {
948-
if lhs.is_empty() {
949-
// we can't merge into an EmptySubgridV1
950-
*lhs = mem::replace(rhs, EmptySubgridV1.into());
951-
// transpose `lhs`
952-
todo!();
953-
} else {
954-
lhs.merge(rhs, Some((a_subgrid, b_subgrid)));
955-
*rhs = EmptySubgridV1.into();
956-
}
957-
}
947+
lhs.merge(rhs, Some((a_subgrid, b_subgrid)));
948+
*rhs = EmptySubgridV1.into();
958949
}
959950
}
960951
}

pineappl/src/subgrid.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -418,15 +418,21 @@ impl SubgridEnum {
418418
if other.is_empty() {
419419
return;
420420
}
421+
421422
if let Self::EmptySubgridV1(_) = self {
422-
if transpose.is_none() {
423+
if transpose.is_some() {
424+
// change the type of `self` to the type of `other`
423425
*self = other.clone();
426+
// TODO: emptying `self` could be done more efficiently, we're probably storing a
427+
// lot of zeros here
428+
self.scale(0.0);
424429
} else {
425-
todo!();
430+
*self = other.clone();
431+
return;
426432
}
427-
} else {
428-
self.merge_impl(other, transpose);
429433
}
434+
435+
self.merge_impl(other, transpose);
430436
}
431437
}
432438

0 commit comments

Comments
 (0)