Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Composite Source Arrows cause problems with invert #114

Open
zenna opened this issue Jan 28, 2018 · 0 comments
Open

Composite Source Arrows cause problems with invert #114

zenna opened this issue Jan 28, 2018 · 0 comments
Labels

Comments

@zenna
Copy link
Owner

zenna commented Jan 28, 2018

if a composite arrow is a source arrow, it will cause invert to fail.
This is because the logic of invert is wrong, it turns the outport into an inport and then throws an error when it cant fix the links.
Could add a special case for this but is there a more general solution?

"Broadcasted Source"
function bsource(x)
  c = CompArrow(:bsource)
  ssarr = add_sub_arr!(c, source(x))
  bsarr = add_sub_arr!(c, Arrows.BroadcastArrow())
  (ssarr, 1)  (bsarr, 1)
  link_to_parent!((bsarr, 1))
  c

bsource!(arr::Arrow, x) = (Arrows.add_sub_arr!(arr, bsource(x)), 1)

function ifelseconst()
  carr = CompArrow(:ifelseconst, [:a, :b, :c], [:z])
  a, b, c, z = (carr)
  d = ifelse(c > bsource!(carr, 3),
             a + b,
             a * b)
  d  z
  @assert is_valid(carr)
  carr
end

invert(ifelseconst())

Note, bsource! has been updated to avoid this error

@zenna zenna added the bug label Jan 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant