-
Notifications
You must be signed in to change notification settings - Fork 299
Include bbox() functions for YTCoveringGrids and YTIntersectionContainer3D #5328
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
base: main
Are you sure you want to change the base?
Changes from 4 commits
dd2ed42
2ce4162
1c9b114
c3e2afa
186ebb6
e7abbf5
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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -3,7 +3,7 @@ | |||||
| import numpy as np | ||||||
| from numpy.testing import assert_equal | ||||||
|
|
||||||
| from yt.testing import assert_allclose_units, fake_amr_ds | ||||||
| from yt.testing import assert_allclose_units, fake_amr_ds, fake_octree_ds | ||||||
|
|
||||||
|
|
||||||
| def test_object_bbox(): | ||||||
|
|
@@ -55,3 +55,29 @@ def test_object_bbox(): | |||||
| assert_allclose_units(re3, re0) | ||||||
| assert_equal(le4, regb.left_edge) | ||||||
| assert_equal(re4, regb.right_edge) | ||||||
|
|
||||||
| def test_covering_grid_bbox(): | ||||||
| ds = fake_octree_ds(num_zones=32) | ||||||
|
|
||||||
| cg = ds.covering_grid(level=0, left_edge=[0.3, 0.3, 0.3], dims=[8, 8, 8]) | ||||||
|
|
||||||
| # Make a covering grid with a data source | ||||||
| sp = ds.sphere( | ||||||
| [0.5, 0.5, 0.5], | ||||||
| 0.15, | ||||||
| ) | ||||||
| cgds = ds.covering_grid( | ||||||
| level=0, left_edge=[0.3, 0.3, 0.3], dims=[8, 8, 8], data_source = sp, | ||||||
| ) | ||||||
|
|
||||||
| # The bounding boxes of the two covering grids should be the same | ||||||
| cg_bbox = cg.get_bbox() | ||||||
| cgds_bbox = cgds.get_bbox() | ||||||
| assert_equal(cg_bbox, cgds_bbox) | ||||||
|
|
||||||
| # The bounding box of the cg's data source should be the left edge of sp and right edge of cgds | ||||||
| cgds_ds_bbox = cgds._data_source.get_bbox() | ||||||
| le_sp, re_sp = sp.get_bbox() | ||||||
|
|
||||||
| assert_equal(le_sp, cgds_ds_bbox[0]) | ||||||
| assert_equal(cgds_ds_bbox[1], cgds_ds_bbox[1]) | ||||||
|
||||||
| assert_equal(cgds_ds_bbox[1], cgds_ds_bbox[1]) | |
| assert_equal(re_sp, cgds_ds_bbox[1]) |
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.
Yes its a typo but it should actually be comparing cgds_bbox[1] to cgds_ds_bbox[1] (the right edge of the covering grid to the right edge of the covering grid's datasource)
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 find the comment quite cryptic. Do you mean that the covering grid's datasource (
sp) should have the same bbox assp?Uh oh!
There was an error while loading. Please reload this page.
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.
So they way I've set up this test is I've made a covering grid in the lower left of the box, and placed a sphere in the center. Parts of the sphere is in the bounding box but some of it is not.
The covering grid which includes the sphere should have a data source which is the intersection of these two objects, and whose bounding box should be the lower left of the sphere, and the upper right of the covering grid.