-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Added left/right indexing on DaphneLib matrices through Python's square bracket operators. - Implemented via Python's __setitem__()/__getitem__() functions. - Keys can be int, slice, or DaphneLib Matrix (the latter only for right indexing). - OperationNode has a list of consumer nodes now. - Was necessary as we need to rewire the inputs of the consumers of a node on which we do left indexing. - This is because, as Python's __setitem__() cannot return a value, we need to copy the current node and change the current node to a left indexing operation using the new copy as an input. All other consumers of the original node must use the new copy, too. - Added script-level test cases for left/right indexing in DaphneLib. - Added a new utility function for script-level test cases that compares the output of a DaphneLib script to a given string. - Updated the DaphneLib documentation. - Closes #657.
- Loading branch information
1 parent
7beda09
commit ae21092
Showing
10 changed files
with
307 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
m1 = reshape(seq(1, 100), 10, 10); | ||
|
||
row_ids = seq(0, 2, 1) * 3 + 1; | ||
col_ids = seq(0, 1, 1) * 2; | ||
|
||
# Only row | ||
print(m1[0, :]); | ||
print(m1[0:5, :]); | ||
print(m1[0:, :]); | ||
print(m1[:5, :]); | ||
print(m1[row_ids, :]); | ||
|
||
# Only col | ||
print(m1[:, 0]); | ||
print(m1[:, 0:5]); | ||
print(m1[:, 0:]); | ||
print(m1[:, :5]); | ||
print(m1[:, col_ids]); | ||
|
||
# Row and col | ||
print(m1[0:5, 0]); | ||
print(m1[0, 0:5]); | ||
print(m1[0, 0]); | ||
print(m1[0:5, 0:5]); | ||
print(m1[0:, 0]); | ||
print(m1[0, 0:]); | ||
print(m1[0:, 0:]); | ||
print(m1[:5, 0]); | ||
print(m1[0, :5]); | ||
print(m1[:5, :5]); | ||
print(m1[row_ids, col_ids]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/usr/bin/python | ||
|
||
from daphne.context.daphne_context import DaphneContext | ||
|
||
|
||
daphne_context = DaphneContext() | ||
|
||
m1 = daphne_context.seq(1, 100).reshape(10, 10) | ||
|
||
row_ids = daphne_context.seq(0, 2, 1) * 3 + 1 | ||
col_ids = daphne_context.seq(0, 1, 1) * 2 | ||
|
||
# Only row | ||
m1[0, :].print().compute() | ||
m1[0:5, :].print().compute() | ||
m1[0:, :].print().compute() | ||
m1[:5, :].print().compute() | ||
m1[row_ids, :].print().compute() | ||
|
||
# Only col | ||
m1[:, 0].print().compute() | ||
m1[:, 0:5].print().compute() | ||
m1[:, 0:].print().compute() | ||
m1[:, :5].print().compute() | ||
m1[:, col_ids].print().compute() | ||
|
||
# Row and col | ||
m1[0:5, 0].print().compute() | ||
m1[0, 0:5].print().compute() | ||
m1[0, 0].print().compute() | ||
m1[0:5, 0:5].print().compute() | ||
m1[0:, 0].print().compute() | ||
m1[0, 0:].print().compute() | ||
m1[0:, 0:].print().compute() | ||
m1[:5, 0].print().compute() | ||
m1[0, :5].print().compute() | ||
m1[:5, :5].print().compute() | ||
m1[row_ids, col_ids].print().compute() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
m1 = fill(123, 10, 10); | ||
|
||
m1[0, 0] = fill(1001, 1, 1); | ||
print(m1); | ||
|
||
m1[0:5, 0] = fill(1002, 5, 1); | ||
print(m1); | ||
|
||
m1[:5, 0] = fill(1003, 5, 1); | ||
print(m1); | ||
|
||
m1[0:, 0] = fill(1004, 10, 1); | ||
print(m1); | ||
|
||
m1[:, 0] = fill(1005, 10, 1); | ||
print(m1); | ||
|
||
m1[0, :] = fill(1006, 1, 10); | ||
print(m1); | ||
|
||
m1[0, 0:] = fill(1007, 1, 10); | ||
print(m1); | ||
|
||
m1[0, :5] = fill(1008, 1, 5); | ||
print(m1); | ||
|
||
m1[0, 0:5] = fill(1009, 1, 5); | ||
print(m1); | ||
|
||
m1[:, 0:5] = fill(1010, 10, 5); | ||
print(m1); | ||
|
||
m1[0:5, :] = fill(1011, 5, 10); | ||
print(m1); |
Oops, something went wrong.