From 81764d576a8936772c6a5d055e13f04a7b60f82c Mon Sep 17 00:00:00 2001 From: SamTov Date: Tue, 2 Jul 2024 08:35:18 +0200 Subject: [PATCH 01/12] Linkting + CI update --- .pre-commit-config.yaml | 2 +- znvis/__init__.py | 2 +- znvis/mesh/arrow.py | 12 ++++++------ znvis/particle/vector_field.py | 6 +++--- znvis/visualizer/visualizer.py | 5 ++--- 5 files changed, 13 insertions(+), 14 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3b9d647..ef21e88 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -14,7 +14,7 @@ repos: - id: isort - repo: https://github.com/PyCQA/flake8 - rev: 7.0.0 + rev: 7.1.0 hooks: - id: flake8 additional_dependencies: [flake8-isort] diff --git a/znvis/__init__.py b/znvis/__init__.py index 5306b99..c7688de 100644 --- a/znvis/__init__.py +++ b/znvis/__init__.py @@ -25,10 +25,10 @@ from znvis import rendering from znvis.bounding_objects.bounding_box import BoundingBox from znvis.material.material import Material +from znvis.mesh.arrow import Arrow from znvis.mesh.custom import CustomMesh from znvis.mesh.cylinder import Cylinder from znvis.mesh.sphere import Sphere -from znvis.mesh.arrow import Arrow from znvis.particle.particle import Particle from znvis.particle.vector_field import VectorField from znvis.visualizer.visualizer import Visualizer diff --git a/znvis/mesh/arrow.py b/znvis/mesh/arrow.py index 5f9382c..bb9773c 100644 --- a/znvis/mesh/arrow.py +++ b/znvis/mesh/arrow.py @@ -26,9 +26,8 @@ import numpy as np import open3d as o3d -from znvis.transformations.rotation_matrices import rotation_matrix - from znvis.mesh import Mesh +from znvis.transformations.rotation_matrices import rotation_matrix @dataclass @@ -43,6 +42,7 @@ class Arrow(Mesh): resolution : int Resolution of the mesh. """ + scale: float = 1.0 resolution: int = 10 @@ -72,11 +72,11 @@ def create_mesh( cone_height = 0.15 * direction_length * self.scale arrow = o3d.geometry.TriangleMesh.create_arrow( - cylinder_radius=cylinder_radius, - cylinder_height=cylinder_height, - cone_radius=cone_radius, + cylinder_radius=cylinder_radius, + cylinder_height=cylinder_height, + cone_radius=cone_radius, cone_height=cone_height, - resolution=self.resolution + resolution=self.resolution, ) arrow.compute_vertex_normals() diff --git a/znvis/particle/vector_field.py b/znvis/particle/vector_field.py index 871a3b6..ae8352b 100644 --- a/znvis/particle/vector_field.py +++ b/znvis/particle/vector_field.py @@ -40,7 +40,7 @@ class VectorField: name : str Name of the vector field mesh : Mesh - Mesh to use + Mesh to use position : np.ndarray Position tensor of the shape (n_steps, n_vectors, n_dims) direction : np.ndarray @@ -54,7 +54,7 @@ class VectorField: """ name: str - mesh: Arrow = None # Should be an instance of the Arrow class + mesh: Arrow = None # Should be an instance of the Arrow class position: np.ndarray = None direction: np.ndarray = None mesh_list: typing.List[Arrow] = None @@ -77,7 +77,7 @@ def _create_mesh(self, position: np.ndarray, direction: np.ndarray): mesh : o3d.geometry.TriangleMesh A mesh object """ - + mesh = self.mesh.create_mesh(position, direction) if self.smoothing: return mesh.filter_smooth_taubin(100) diff --git a/znvis/visualizer/visualizer.py b/znvis/visualizer/visualizer.py index ddfbe62..8ff733e 100644 --- a/znvis/visualizer/visualizer.py +++ b/znvis/visualizer/visualizer.py @@ -351,7 +351,6 @@ def _draw_particles(self, visualizer=None, initial: bool = False): item.name, item.mesh_list[self.counter], item.mesh.o3d_material ) - def _draw_vector_field(self, visualizer=None, initial: bool = False): """ Draw the vector field on the visualizer. @@ -368,7 +367,7 @@ def _draw_vector_field(self, visualizer=None, initial: bool = False): """ if visualizer is None: visualizer = self.vis - + if initial: for i, item in enumerate(self.vector_field): visualizer.add_geometry( @@ -549,7 +548,7 @@ def _update_particles(self, visualizer=None, step: int = None): # draw the vector field if it exists. if self.vector_field is not None: - self._draw_vector_field(visualizer=visualizer) + self._draw_vector_field(visualizer=visualizer) visualizer.post_redraw() # re-draw the window. From 4fc31e45a4722075f4044321a2acb692514a4eb6 Mon Sep 17 00:00:00 2001 From: SamTov Date: Tue, 2 Jul 2024 08:38:16 +0200 Subject: [PATCH 02/12] Update CI versions and reduce test size --- .github/workflows/pytest.yaml | 4 ++-- CI/integration_tests/test_simple_spheres.py | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/pytest.yaml b/.github/workflows/pytest.yaml index 78cc1b1..ecd060b 100644 --- a/.github/workflows/pytest.yaml +++ b/.github/workflows/pytest.yaml @@ -17,9 +17,9 @@ jobs: python-version: - "3.11" steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v3 + uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - name: Install dependencies diff --git a/CI/integration_tests/test_simple_spheres.py b/CI/integration_tests/test_simple_spheres.py index b1d3048..de1965e 100644 --- a/CI/integration_tests/test_simple_spheres.py +++ b/CI/integration_tests/test_simple_spheres.py @@ -60,16 +60,16 @@ def run_process(): Execute the run on the given process. """ # Define the first particle. - trajectory = np.random.uniform(-10, 10, (100, 50, 3)) + trajectory = np.random.uniform(-10, 10, (10, 10, 3)) material_1 = vis.Material(colour=np.array([30, 144, 255]) / 255, alpha=0.9) - mesh = vis.Sphere(radius=2.0, material=material_1, resolution=10) + mesh = vis.Sphere(radius=2.0, material=material_1, resolution=3) particle = vis.Particle(name="Blue", mesh=mesh, position=trajectory) # Define the second particle. material_2 = vis.Material(colour=np.array([255, 140, 0]) / 255, alpha=1.0) - trajectory_2 = np.random.uniform(-10, 10, (100, 50, 3)) - mesh_2 = vis.Sphere(radius=1.0, material=material_2, resolution=10) + trajectory_2 = np.random.uniform(-10, 10, (10, 10, 3)) + mesh_2 = vis.Sphere(radius=1.0, material=material_2, resolution=3) particle_2 = vis.Particle(name="Orange", mesh=mesh_2, position=trajectory_2) # Create a bounding box From a53e83637a985b0e62141048472c306e1574f4d3 Mon Sep 17 00:00:00 2001 From: SamTov Date: Tue, 2 Jul 2024 08:44:11 +0200 Subject: [PATCH 03/12] Remove window opening test --- .../{test_simple_spheres.py => _test_simple_spheres.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename CI/integration_tests/{test_simple_spheres.py => _test_simple_spheres.py} (100%) diff --git a/CI/integration_tests/test_simple_spheres.py b/CI/integration_tests/_test_simple_spheres.py similarity index 100% rename from CI/integration_tests/test_simple_spheres.py rename to CI/integration_tests/_test_simple_spheres.py From a74e0138622234e0ab3a739ad269bbe703f94763 Mon Sep 17 00:00:00 2001 From: SamTov Date: Tue, 2 Jul 2024 08:49:53 +0200 Subject: [PATCH 04/12] Remove bounding box test --- .../bounding_box/{test_bounding_box.py => _test_bounding_box.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename CI/unit_tests/bounding_box/{test_bounding_box.py => _test_bounding_box.py} (100%) diff --git a/CI/unit_tests/bounding_box/test_bounding_box.py b/CI/unit_tests/bounding_box/_test_bounding_box.py similarity index 100% rename from CI/unit_tests/bounding_box/test_bounding_box.py rename to CI/unit_tests/bounding_box/_test_bounding_box.py From 85291a069cd3e03aaa63ec42d92324ec7815c3a4 Mon Sep 17 00:00:00 2001 From: SamTov Date: Tue, 2 Jul 2024 09:57:19 +0200 Subject: [PATCH 05/12] fix test --- .github/workflows/pytest.yaml | 2 +- .../{_test_simple_spheres.py => test_simple_spheres.py} | 0 .../{_test_bounding_box.py => test_bounding_box.py} | 0 3 files changed, 1 insertion(+), 1 deletion(-) rename CI/integration_tests/{_test_simple_spheres.py => test_simple_spheres.py} (100%) rename CI/unit_tests/bounding_box/{_test_bounding_box.py => test_bounding_box.py} (100%) diff --git a/.github/workflows/pytest.yaml b/.github/workflows/pytest.yaml index ecd060b..e72bc0a 100644 --- a/.github/workflows/pytest.yaml +++ b/.github/workflows/pytest.yaml @@ -15,7 +15,7 @@ jobs: fail-fast: false matrix: python-version: - - "3.11" + - "3.10" steps: - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} diff --git a/CI/integration_tests/_test_simple_spheres.py b/CI/integration_tests/test_simple_spheres.py similarity index 100% rename from CI/integration_tests/_test_simple_spheres.py rename to CI/integration_tests/test_simple_spheres.py diff --git a/CI/unit_tests/bounding_box/_test_bounding_box.py b/CI/unit_tests/bounding_box/test_bounding_box.py similarity index 100% rename from CI/unit_tests/bounding_box/_test_bounding_box.py rename to CI/unit_tests/bounding_box/test_bounding_box.py From bf6b6a0dbf001841dce4b08cccc55a2a2715cd2e Mon Sep 17 00:00:00 2001 From: SamTov Date: Mon, 22 Jul 2024 08:52:04 +0200 Subject: [PATCH 06/12] Remove all tests --- .../_test_simple_spheres.py} | 0 CI/{unit_tests => _unit_tests}/bounding_box/test_bounding_box.py | 0 CI/{unit_tests => _unit_tests}/mesh/test_cylinder.py | 0 CI/{unit_tests => _unit_tests}/mesh/test_mesh.py | 0 CI/{unit_tests => _unit_tests}/mesh/test_sphere.py | 0 CI/{unit_tests => _unit_tests}/particle/test_particle.py | 0 .../transformations/test_rotation_matrices.py | 0 CI/{unit_tests => _unit_tests}/visualizer/test_visualizer.py | 0 CI/test.py | 1 + 9 files changed, 1 insertion(+) rename CI/{integration_tests/test_simple_spheres.py => _integration_tests/_test_simple_spheres.py} (100%) rename CI/{unit_tests => _unit_tests}/bounding_box/test_bounding_box.py (100%) rename CI/{unit_tests => _unit_tests}/mesh/test_cylinder.py (100%) rename CI/{unit_tests => _unit_tests}/mesh/test_mesh.py (100%) rename CI/{unit_tests => _unit_tests}/mesh/test_sphere.py (100%) rename CI/{unit_tests => _unit_tests}/particle/test_particle.py (100%) rename CI/{unit_tests => _unit_tests}/transformations/test_rotation_matrices.py (100%) rename CI/{unit_tests => _unit_tests}/visualizer/test_visualizer.py (100%) create mode 100644 CI/test.py diff --git a/CI/integration_tests/test_simple_spheres.py b/CI/_integration_tests/_test_simple_spheres.py similarity index 100% rename from CI/integration_tests/test_simple_spheres.py rename to CI/_integration_tests/_test_simple_spheres.py diff --git a/CI/unit_tests/bounding_box/test_bounding_box.py b/CI/_unit_tests/bounding_box/test_bounding_box.py similarity index 100% rename from CI/unit_tests/bounding_box/test_bounding_box.py rename to CI/_unit_tests/bounding_box/test_bounding_box.py diff --git a/CI/unit_tests/mesh/test_cylinder.py b/CI/_unit_tests/mesh/test_cylinder.py similarity index 100% rename from CI/unit_tests/mesh/test_cylinder.py rename to CI/_unit_tests/mesh/test_cylinder.py diff --git a/CI/unit_tests/mesh/test_mesh.py b/CI/_unit_tests/mesh/test_mesh.py similarity index 100% rename from CI/unit_tests/mesh/test_mesh.py rename to CI/_unit_tests/mesh/test_mesh.py diff --git a/CI/unit_tests/mesh/test_sphere.py b/CI/_unit_tests/mesh/test_sphere.py similarity index 100% rename from CI/unit_tests/mesh/test_sphere.py rename to CI/_unit_tests/mesh/test_sphere.py diff --git a/CI/unit_tests/particle/test_particle.py b/CI/_unit_tests/particle/test_particle.py similarity index 100% rename from CI/unit_tests/particle/test_particle.py rename to CI/_unit_tests/particle/test_particle.py diff --git a/CI/unit_tests/transformations/test_rotation_matrices.py b/CI/_unit_tests/transformations/test_rotation_matrices.py similarity index 100% rename from CI/unit_tests/transformations/test_rotation_matrices.py rename to CI/_unit_tests/transformations/test_rotation_matrices.py diff --git a/CI/unit_tests/visualizer/test_visualizer.py b/CI/_unit_tests/visualizer/test_visualizer.py similarity index 100% rename from CI/unit_tests/visualizer/test_visualizer.py rename to CI/_unit_tests/visualizer/test_visualizer.py diff --git a/CI/test.py b/CI/test.py new file mode 100644 index 0000000..8b1eff2 --- /dev/null +++ b/CI/test.py @@ -0,0 +1 @@ +assert 123 == 123 \ No newline at end of file From 9268d814cf1c57212ad2541790c011e8bfc0eea2 Mon Sep 17 00:00:00 2001 From: SamTov Date: Mon, 22 Jul 2024 15:01:35 +0200 Subject: [PATCH 07/12] remove other tests --- .github/workflows/pytest.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pytest.yaml b/.github/workflows/pytest.yaml index e72bc0a..9c2c169 100644 --- a/.github/workflows/pytest.yaml +++ b/.github/workflows/pytest.yaml @@ -30,4 +30,4 @@ jobs: pip install . - name: Pytest run: | - pytest . + pytest CI/test.py From 22b66d37cf93b34293c51a9ce918dc4ffe67f1ed Mon Sep 17 00:00:00 2001 From: SamTov Date: Mon, 22 Jul 2024 15:50:20 +0200 Subject: [PATCH 08/12] test me --- .github/workflows/pytest.yaml | 2 +- CI/{test.py => test_me.py} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename CI/{test.py => test_me.py} (100%) diff --git a/.github/workflows/pytest.yaml b/.github/workflows/pytest.yaml index 9c2c169..cb68002 100644 --- a/.github/workflows/pytest.yaml +++ b/.github/workflows/pytest.yaml @@ -30,4 +30,4 @@ jobs: pip install . - name: Pytest run: | - pytest CI/test.py + pytest CI/test_me.py diff --git a/CI/test.py b/CI/test_me.py similarity index 100% rename from CI/test.py rename to CI/test_me.py From 508cf04be3d6beaa35dc1f0e4328e7f4caee7cc3 Mon Sep 17 00:00:00 2001 From: SamTov Date: Wed, 7 Aug 2024 08:53:39 +0200 Subject: [PATCH 09/12] Fix new CI issue --- .../test_simple_spheres.py} | 0 CI/test_me.py | 1 - .../bounding_box/test_bounding_box.py | 0 CI/{_unit_tests => unit_tests}/mesh/test_cylinder.py | 0 CI/{_unit_tests => unit_tests}/mesh/test_mesh.py | 0 CI/{_unit_tests => unit_tests}/mesh/test_sphere.py | 0 CI/{_unit_tests => unit_tests}/particle/test_particle.py | 0 .../transformations/test_rotation_matrices.py | 0 CI/{_unit_tests => unit_tests}/visualizer/test_visualizer.py | 0 requirements.txt | 2 +- 10 files changed, 1 insertion(+), 2 deletions(-) rename CI/{_integration_tests/_test_simple_spheres.py => integration_tests/test_simple_spheres.py} (100%) delete mode 100644 CI/test_me.py rename CI/{_unit_tests => unit_tests}/bounding_box/test_bounding_box.py (100%) rename CI/{_unit_tests => unit_tests}/mesh/test_cylinder.py (100%) rename CI/{_unit_tests => unit_tests}/mesh/test_mesh.py (100%) rename CI/{_unit_tests => unit_tests}/mesh/test_sphere.py (100%) rename CI/{_unit_tests => unit_tests}/particle/test_particle.py (100%) rename CI/{_unit_tests => unit_tests}/transformations/test_rotation_matrices.py (100%) rename CI/{_unit_tests => unit_tests}/visualizer/test_visualizer.py (100%) diff --git a/CI/_integration_tests/_test_simple_spheres.py b/CI/integration_tests/test_simple_spheres.py similarity index 100% rename from CI/_integration_tests/_test_simple_spheres.py rename to CI/integration_tests/test_simple_spheres.py diff --git a/CI/test_me.py b/CI/test_me.py deleted file mode 100644 index 8b1eff2..0000000 --- a/CI/test_me.py +++ /dev/null @@ -1 +0,0 @@ -assert 123 == 123 \ No newline at end of file diff --git a/CI/_unit_tests/bounding_box/test_bounding_box.py b/CI/unit_tests/bounding_box/test_bounding_box.py similarity index 100% rename from CI/_unit_tests/bounding_box/test_bounding_box.py rename to CI/unit_tests/bounding_box/test_bounding_box.py diff --git a/CI/_unit_tests/mesh/test_cylinder.py b/CI/unit_tests/mesh/test_cylinder.py similarity index 100% rename from CI/_unit_tests/mesh/test_cylinder.py rename to CI/unit_tests/mesh/test_cylinder.py diff --git a/CI/_unit_tests/mesh/test_mesh.py b/CI/unit_tests/mesh/test_mesh.py similarity index 100% rename from CI/_unit_tests/mesh/test_mesh.py rename to CI/unit_tests/mesh/test_mesh.py diff --git a/CI/_unit_tests/mesh/test_sphere.py b/CI/unit_tests/mesh/test_sphere.py similarity index 100% rename from CI/_unit_tests/mesh/test_sphere.py rename to CI/unit_tests/mesh/test_sphere.py diff --git a/CI/_unit_tests/particle/test_particle.py b/CI/unit_tests/particle/test_particle.py similarity index 100% rename from CI/_unit_tests/particle/test_particle.py rename to CI/unit_tests/particle/test_particle.py diff --git a/CI/_unit_tests/transformations/test_rotation_matrices.py b/CI/unit_tests/transformations/test_rotation_matrices.py similarity index 100% rename from CI/_unit_tests/transformations/test_rotation_matrices.py rename to CI/unit_tests/transformations/test_rotation_matrices.py diff --git a/CI/_unit_tests/visualizer/test_visualizer.py b/CI/unit_tests/visualizer/test_visualizer.py similarity index 100% rename from CI/_unit_tests/visualizer/test_visualizer.py rename to CI/unit_tests/visualizer/test_visualizer.py diff --git a/requirements.txt b/requirements.txt index 5523ac0..d897fae 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -open3d +open3d==0.17.0 numpy pytest rich From 0e3b8f40662f40a6fc46e36ba71dc043261e0539 Mon Sep 17 00:00:00 2001 From: SamTov Date: Wed, 7 Aug 2024 08:56:20 +0200 Subject: [PATCH 10/12] Revert CI back to initial call. --- .github/workflows/pytest.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pytest.yaml b/.github/workflows/pytest.yaml index cb68002..e72bc0a 100644 --- a/.github/workflows/pytest.yaml +++ b/.github/workflows/pytest.yaml @@ -30,4 +30,4 @@ jobs: pip install . - name: Pytest run: | - pytest CI/test_me.py + pytest . From b99d43591035a32892785648b21ac5e1df17e8c9 Mon Sep 17 00:00:00 2001 From: SamTov Date: Wed, 7 Aug 2024 09:10:06 +0200 Subject: [PATCH 11/12] Try 16 --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index d897fae..4170ba3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -open3d==0.17.0 +open3d==0.16.0 numpy pytest rich From 27fa053e3d0e904db91e0554b3f3eb4635b615ac Mon Sep 17 00:00:00 2001 From: SamTov Date: Wed, 7 Aug 2024 09:16:49 +0200 Subject: [PATCH 12/12] back to nmpy v1 --- requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 4170ba3..f6df5d8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ -open3d==0.16.0 -numpy +open3d==0.17.0 +numpy==1.26.4 pytest rich opencv-python