Skip to content

Commit

Permalink
Merge pull request #49 from zincware/update_CI
Browse files Browse the repository at this point in the history
Update CI
  • Loading branch information
SamTov authored Aug 7, 2024
2 parents 4a043d5 + 27fa053 commit 8bcf3b8
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 23 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/pytest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ jobs:
fail-fast: false
matrix:
python-version:
- "3.11"
- "3.10"
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
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
8 changes: 4 additions & 4 deletions CI/integration_tests/test_simple_spheres.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
open3d
numpy
open3d==0.17.0
numpy==1.26.4
pytest
rich
opencv-python
Expand Down
2 changes: 1 addition & 1 deletion znvis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions znvis/mesh/arrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -43,6 +42,7 @@ class Arrow(Mesh):
resolution : int
Resolution of the mesh.
"""

scale: float = 1.0
resolution: int = 10

Expand Down Expand Up @@ -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()
Expand Down
6 changes: 3 additions & 3 deletions znvis/particle/vector_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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)
Expand Down
5 changes: 2 additions & 3 deletions znvis/visualizer/visualizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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(
Expand Down Expand Up @@ -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.

Expand Down

0 comments on commit 8bcf3b8

Please sign in to comment.