Skip to content

Commit

Permalink
Fix broadcast operators from #429 using deprecated syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
mratsim committed Apr 19, 2020
1 parent db3f637 commit bde1880
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions src/tensor/operators_comparison.nim
Original file line number Diff line number Diff line change
Expand Up @@ -98,38 +98,38 @@ template gen_broadcasted_scalar_comparison(op: untyped): untyped {.dirty.} =
result = map_inline(t):
op(x, value)

proc `.==`*[T](t: Tensor[T], value : T): Tensor[bool] {.noInit.} =
proc `==.`*[T](t: Tensor[T], value : T): Tensor[bool] {.noInit.} =
## Tensor element-wise equality with scalar
## Returns:
## - A tensor of boolean
gen_broadcasted_scalar_comparison(`==`)


proc `.!=`*[T](t: Tensor[T], value : T): Tensor[bool] {.noInit.} =
proc `!=.`*[T](t: Tensor[T], value : T): Tensor[bool] {.noInit.} =
## Tensor element-wise inequality with scalar
## Returns:
## - A tensor of boolean
gen_broadcasted_scalar_comparison(`!=`)

proc `.<=`*[T](t: Tensor[T], value : T): Tensor[bool] {.noInit.} =
proc `<=.`*[T](t: Tensor[T], value : T): Tensor[bool] {.noInit.} =
## Tensor element-wise lesser or equal with scalar
## Returns:
## - A tensor of boolean
gen_broadcasted_scalar_comparison(`<=`)

proc `.<`*[T](t: Tensor[T], value : T): Tensor[bool] {.noInit.} =
proc `<.`*[T](t: Tensor[T], value : T): Tensor[bool] {.noInit.} =
## Tensor element-wise lesser than a scalar
## Returns:
## - A tensor of boolean
gen_broadcasted_scalar_comparison(`<`)

proc `.>=`*[T](t: Tensor[T], value : T): Tensor[bool] {.noInit.} =
proc `>=.`*[T](t: Tensor[T], value : T): Tensor[bool] {.noInit.} =
## Tensor element-wise greater or equal than a scalar
## Returns:
## - A tensor of boolean
gen_broadcasted_scalar_comparison(`>=`)

proc `.>`*[T](t: Tensor[T], value : T): Tensor[bool] {.noInit.} =
proc `>.`*[T](t: Tensor[T], value : T): Tensor[bool] {.noInit.} =
## Tensor element-wise greater than a scalar
## Returns:
## - A tensor of boolean
Expand Down
4 changes: 2 additions & 2 deletions tests/tensor/test_selectors.nim
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ suite "Selectors":
[2, 2]].toTensor

let rowsum = x.sum(axis = 1)
let cond = rowsum .<= 2
let cond = rowsum <=. 2
let r = x.masked_axis_select(cond.squeeze(), axis = 0)

let expected = [[0, 1],
Expand Down Expand Up @@ -179,7 +179,7 @@ suite "Selectors":
[ 1, 2, 0],
[ 1, -1, 1]].toTensor

let cond = squeeze(a.sum(axis = 0) .> 1)
let cond = squeeze(a.sum(axis = 0) >. 1)
a.masked_axis_fill(cond, axis = 1, -10)

let expected = [[-1, -2, -10],
Expand Down

0 comments on commit bde1880

Please sign in to comment.