-
Notifications
You must be signed in to change notification settings - Fork 231
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
compiler: Nested indexification #1789
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,7 @@ | |
" import gempy as gp\n", | ||
"except ModuleNotFoundError:\n", | ||
" # Need to install these\n", | ||
" ! pip install aiohttp==3.7.1\n", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. how does that help? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any chance you checked whether now, we can have working version without installing specific gempy and specific pyvista? @EdCaunt ? |
||
" ! pip install pyvista==0.29\n", | ||
" ! pip install pyqt5\n", | ||
" # Install gempy\n", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -317,6 +317,34 @@ def test_nested_lowering(self): | |
assert np.all(u0.data[:2, :2] == 1) and np.all(u0.data[1:3, 1:3] == 1) | ||
assert np.all(u0.data[2:3, 3] == 2) and np.all(u0.data[3, 2:3] == 2) | ||
|
||
def test_nested_lowering_indexify(self): | ||
""" | ||
Tests that nested function are lowered if only used as index. | ||
""" | ||
grid = Grid(shape=(4, 4), dtype=np.int32) | ||
x, y = grid.dimensions | ||
|
||
u0 = Function(name="u0", grid=grid) | ||
u1 = Function(name="u1", grid=grid) | ||
u2 = Function(name="u2", grid=grid) | ||
|
||
u0.data[:, :] = 2 | ||
u1.data[:, :] = 1 | ||
u2.data[:, :] = 1 | ||
|
||
# Function as index only | ||
eq0 = Eq(u0._subs(x, u1), 2*u0) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why not There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh it does the same just quicker through our |
||
# Function as part of expression as index only | ||
eq1 = Eq(u0._subs(x, u1._subs(y, u2) + 1), 4*u0) | ||
|
||
op0 = Operator(eq0) | ||
op0.apply() | ||
op1 = Operator(eq1) | ||
op1.apply() | ||
assert np.all(np.all(u0.data[i, :] == 2) for i in [0, 3]) | ||
assert np.all(u0.data[1, :] == 4) | ||
assert np.all(u0.data[2, :] == 8) | ||
|
||
|
||
class TestArithmetic(object): | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uh? 😮
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nested lower_expr takes care of it through the indexed part of it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
awesome!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doesn't it apply to
subs
as well?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No subs is needed because of sudomain dimension map in
lower_expr
, becausef.indexe
don't have a subdomain