Skip to content

Commit

Permalink
Simplify @planar numout, numin checks
Browse files Browse the repository at this point in the history
  • Loading branch information
lkdvos committed Nov 28, 2023
1 parent 0b8ee10 commit 06a8d3f
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/planar/preprocessors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,13 @@ function _extract_tensormap_objects(ex)
if (obj in existingtensors)
nl = length(leftind)
nr = length(rightind)
nlsym = gensym()
nrsym = gensym()
objstr = string(obj)
errorstr1 = "incorrect number of input-output indices: ($nl, $nr) instead of "
errorstr2 = " for $objstr."
tensor_inds = :((numout($newobj)), (numin($newobj)))
errorstr = Expr(:string,
"Incorrect number of input-output indices for $obj: ($nl, $nr) instead of (",
tensor_inds, ").")
checksize = quote
$nlsym, $nrsym = numout($newobj), numin($newobj)
(numout($newobj) == $nl && $numin($newobj) == $nr) ||
throw(IndexError($errorstr1 * string(($nlsym, $nrsym)) * $errorstr2))
(numout($newobj) == $nl && numin($newobj) == $nr) ||
throw(IndexError($errorstr))
end
push!(pre2.args, checksize)
end
Expand Down

0 comments on commit 06a8d3f

Please sign in to comment.