Skip to content

Commit

Permalink
fix: computed columns with negative domain (#298)
Browse files Browse the repository at this point in the history
  • Loading branch information
DavePearce committed Nov 11, 2024
1 parent 01c65e5 commit f75f865
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/column.rs
Original file line number Diff line number Diff line change
Expand Up @@ -663,11 +663,11 @@ impl ValueBacking {
ValueBacking::Expression { e, .. } => e.eval(
i,
|handle, j, _| {
cs.get(handle, j, false)
cs.get(handle, j, wrap)
.or_else(|| cs.column(handle).unwrap().padding_value.as_ref().cloned())
},
&mut None,
&EvalSettings { wrap: false },
&EvalSettings { wrap },
),
ValueBacking::Function { f, .. } => f(i, cs),
}
Expand All @@ -677,8 +677,9 @@ impl ValueBacking {
match self {
ValueBacking::Vector { v, spilling } => {
if i < 0 {
if wrap {
v.get((v.len() as isize + i) as usize)
let new_i = v.len() as isize + i;
if wrap && new_i >= 0 {
v.get(new_i as usize)
} else {
None
}
Expand All @@ -690,11 +691,11 @@ impl ValueBacking {
ValueBacking::Expression { e, .. } => e.eval(
i,
|handle, j, _| {
cs.get(handle, j, false)
cs.get(handle, j, wrap)
.or_else(|| cs.column(handle).unwrap().padding_value.as_ref().cloned())
},
&mut None,
&EvalSettings { wrap: false },
&EvalSettings { wrap },
),
ValueBacking::Function { f, .. } => f(i, cs),
}
Expand Down

0 comments on commit f75f865

Please sign in to comment.