From bd0511a1631e34df9be7ba95b151118f7d617433 Mon Sep 17 00:00:00 2001 From: dmitrishastin Date: Sun, 29 Oct 2023 03:06:47 +0000 Subject: [PATCH] sorting out wrong shapes and unit test error --- cpp/open3d/t/geometry/RaycastingScene.cpp | 5 +++-- python/test/t/geometry/test_raycasting_scene.py | 2 +- util/check_style.py | 10 +++++----- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/cpp/open3d/t/geometry/RaycastingScene.cpp b/cpp/open3d/t/geometry/RaycastingScene.cpp index b06d6211752..4774beeafa4 100644 --- a/cpp/open3d/t/geometry/RaycastingScene.cpp +++ b/cpp/open3d/t/geometry/RaycastingScene.cpp @@ -868,13 +868,14 @@ RaycastingScene::ListIntersections(const core::Tensor& rays, // generate results structure std::unordered_map 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(); 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); diff --git a/python/test/t/geometry/test_raycasting_scene.py b/python/test/t/geometry/test_raycasting_scene.py index d89fdc404b3..9b930a877da 100644 --- a/python/test/t/geometry/test_raycasting_scene.py +++ b/python/test/t/geometry/test_raycasting_scene.py @@ -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) diff --git a/util/check_style.py b/util/check_style.py index 97b7c1ba58c..437446092f5 100644 --- a/util/check_style.py +++ b/util/check_style.py @@ -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 = [ @@ -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)) @@ -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) @@ -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 @@ -444,4 +444,4 @@ def main(): if __name__ == "__main__": - main() + main() \ No newline at end of file