Skip to content

Commit

Permalink
[DAPHNE-#789] Conditional operator in DaphneLib, follow-up.
Browse files Browse the repository at this point in the history
- Added test case files I forgot in the previous commit.
  • Loading branch information
pdamme committed Jul 18, 2024
1 parent 6789f18 commit 4e96943
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
13 changes: 13 additions & 0 deletions test/api/python/matrix_ifelse_1.daphne
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
M = (seq(1, 8) % 3) == 1;

X = seq(1, 8);
Y = seq(1, 8) * 10;

# mat ? sca : sca
print(M ? 3.141 : 2.718);
# mat ? mat : sca
print(M ? X : 0);
# mat ? sca : mat
print(M ? 0 : Y);
# mat ? mat : mat
print(M ? X : Y);
17 changes: 17 additions & 0 deletions test/api/python/matrix_ifelse_1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from daphne.context.daphne_context import DaphneContext

dc = DaphneContext()

M = (dc.seq(1, 8) % 3) == 1

X = dc.seq(1, 8)
Y = dc.seq(1, 8) * 10

# mat ? sca : sca
M.ifElse(3.141, 2.718).print().compute()
# mat ? mat : sca
M.ifElse(X, 0).print().compute()
# mat ? sca : mat
M.ifElse(0, Y).print().compute()
# mat ? mat : mat
M.ifElse(X, Y).print().compute()

0 comments on commit 4e96943

Please sign in to comment.