-
Notifications
You must be signed in to change notification settings - Fork 41
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
Allow importing specific field from vtk #1394
Conversation
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.
Thanks @dbochkov-flexcompute just a couple minor comments.
tests/test_data/test_datasets.py
Outdated
@@ -352,6 +374,14 @@ def test_tetrahedral_dataset(tmp_path, ds_name): | |||
assert np.all(tet_grid._vtk_offsets == np.array([0, 4, 8])) | |||
assert tet_grid.name == ds_name | |||
|
|||
# since vtk is attempted to be imported during a dependent function call | |||
# let's call one of those so that vtk dict is properly populated | |||
try: |
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.
what is the reason behind using a try / except
here? (when would vtk not be imported in the test?) maybe it could make sense to make this a pytest.mark.parameterized()
where we run the function once with vtk and once without? maybe I'm just a bit confused about what this block of code is doing here.
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.
Revised this a bit. So, currently it works the following way:
- This test is designed to work for both when
vtk
is present and when it is not. - Which branch to check is determined by parameter
no_vtk
. - I tried using
pytest.mark.parameterized()
to conveniently test both cases, but I couldn't make it work. it seems to be tricky to properly unload already loaded module. So, instead I just re-run the same tests in a separate pytest call here with a monkeypatch to skip loadingvtk
andno_vtk=True
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.
I see, I think the new implementation is fine.
btw I ran into something similar with wanting to test adjoint
with and without jax installed, here's what I came up with in the end.
(I guess I also didn't use parameterize, maybe for similar reasons)
A small PR that came out of working on the charge example flexcompute/tidy3d-notebooks#25 and it does two things:
.vtu
files with specific names if such files contain multiple fields (e.g. "Electrons", "Holes", etc)PerturbationMedium
withCustomChargePerturbation
/CustomHeatPerturbation