Skip to content

Commit

Permalink
sorting out wrong shapes and unit test error
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitrishastin committed Oct 29, 2023
1 parent 5e4c097 commit bd0511a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
5 changes: 3 additions & 2 deletions cpp/open3d/t/geometry/RaycastingScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -868,13 +868,14 @@ RaycastingScene::ListIntersections(const core::Tensor& rays,

// generate results structure
std::unordered_map<std::string, core::Tensor> result;
result["ray_splits"] = core::Tensor({cumsum.size() + 1}, core::UInt32);
shape[0] = shape[0] + 1;
result["ray_splits"] = core::Tensor(shape, core::UInt32);
uint32_t* ptr = result["ray_splits"].GetDataPtr<uint32_t>();
ptr[0] = 0;
for (int i = 1; i < cumsum.size() + 1; ++i) {
ptr[i] = cumsum[i - 1];
}
shape = {intersections_vector.sum()};
shape[0] = intersections_vector.sum();
result["ray_ids"] = core::Tensor(shape, core::UInt32);
result["geometry_ids"] = core::Tensor(shape, core::UInt32);
result["primitive_ids"] = core::Tensor(shape, core::UInt32);
Expand Down
2 changes: 1 addition & 1 deletion python/test/t/geometry/test_raycasting_scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def test_list_intersections():
ans = scene.list_intersections(rays)

np.testing.assert_allclose(ans['t_hit'].numpy(),
np.array([[1.0], [2.0], [0.5]]),
np.array([1.0, 2.0, 0.5]),
rtol=1e-6,
atol=1e-6)

Expand Down
10 changes: 5 additions & 5 deletions util/check_style.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def _check_style(file_path, clang_format_bin):
"""
Returns (true, true) if (style, header) is valid.
"""
with open(file_path, 'r') as f:
with open(file_path, 'r', encoding='utf-8') as f:
is_valid_header = f.read().startswith(CppFormatter.standard_header)

cmd = [
Expand Down Expand Up @@ -156,7 +156,7 @@ def _check_style(file_path, style_config):
Returns (true, true) if (style, header) is valid.
"""

with open(file_path, 'r') as f:
with open(file_path, 'r', encoding='utf-8') as f:
content = f.read()
is_valid_header = (len(content) == 0 or content.startswith(
PythonFormatter.standard_header))
Expand Down Expand Up @@ -218,7 +218,7 @@ def _check_or_apply_style(file_path, style_config, apply):
are merged into one.
"""
# Ref: https://gist.github.com/oskopek/496c0d96c79fb6a13692657b39d7c709
with open(file_path, "r") as f:
with open(file_path, "r", encoding='utf-8') as f:
notebook = nbformat.read(f, as_version=nbformat.NO_CONVERT)
nbformat.validate(notebook)

Expand All @@ -241,7 +241,7 @@ def _check_or_apply_style(file_path, style_config, apply):
changed = True

if apply:
with open(file_path, "w") as f:
with open(file_path, "w", encoding='utf-8') as f:
nbformat.write(notebook, f, version=nbformat.NO_CONVERT)

return not changed
Expand Down Expand Up @@ -444,4 +444,4 @@ def main():


if __name__ == "__main__":
main()
main()

0 comments on commit bd0511a

Please sign in to comment.