Skip to content

Commit

Permalink
Merge pull request #964 from skoudoro/update-ubuntu
Browse files Browse the repository at this point in the history
RF: install wgpu and mesa driver for ubuntu CI's
  • Loading branch information
skoudoro authored Jan 25, 2025
2 parents c3d3c23 + 1a6ae14 commit 35f533a
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 58 deletions.
3 changes: 2 additions & 1 deletion ci/setup_headless.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ echo "DISPLAY=:99.0" >> $GITHUB_ENV
if [ "$RUNNER_OS" == "Linux" ]; then
echo "LIBGL_ALWAYS_SOFTWARE=1" >> $GITHUB_ENV
echo "LIBGL_ALWAYS_INDIRECT=0" >> $GITHUB_ENV
sudo apt-get install -y libgl1-mesa-glx xvfb;
sudo apt-get update -y -qq;
sudo apt-get install --no-install-recommends -y libegl1-mesa-dev libgl1-mesa-dri libxcb-xfixes0-dev mesa-vulkan-drivers;
Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
sleep 3
elif [ "$RUNNER_OS" == "Windows" ]; then
Expand Down
113 changes: 56 additions & 57 deletions fury/tests/test_actor.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from PIL import Image
import numpy as np
import numpy.testing as npt

Expand All @@ -13,17 +14,17 @@ def test_sphere():
sphere_actor = actor.sphere(centers=centers, colors=colors, radii=radii)
scene.add(sphere_actor)

# window.record(scene=scene, fname="sphere_test_1.png")
window.snapshot(scene=scene, fname="sphere_test_1.png")

# img = Image.open("sphere_test_1.png")
# img_array = np.array(img)
img = Image.open("sphere_test_1.png")
img_array = np.array(img)

# mean_r, mean_g, mean_b, _ = np.mean(
# img_array.reshape(-1, img_array.shape[2]), axis=0
# )
mean_r, mean_g, mean_b, _ = np.mean(
img_array.reshape(-1, img_array.shape[2]), axis=0
)

# assert mean_r > mean_b and mean_r > mean_g
# assert 0 <= mean_r <= 255 and 0 <= mean_g <= 255 and 0 <= mean_b <= 255
assert mean_r > mean_b and mean_r > mean_g
assert 0 <= mean_r <= 255 and 0 <= mean_g <= 255 and 0 <= mean_b <= 255

npt.assert_array_equal(sphere_actor.local.position, centers[0])

Expand All @@ -45,21 +46,20 @@ def test_sphere():
scene.remove(sphere_actor)
scene.add(sphere_actor_2)

# TODO: Record does not exist in the v2, test needs to be update
# window.record(scene=scene, fname="sphere_test_2.png")
window.snapshot(scene=scene, fname="sphere_test_2.png")

# img = Image.open("sphere_test_2.png")
# img_array = np.array(img)
img = Image.open("sphere_test_2.png")
img_array = np.array(img)

# mean_r, mean_g, mean_b, mean_a = np.mean(
# img_array.reshape(-1, img_array.shape[2]), axis=0
# )
mean_r, mean_g, mean_b, mean_a = np.mean(
img_array.reshape(-1, img_array.shape[2]), axis=0
)

# assert mean_r > mean_b and mean_r > mean_g
# assert 0 <= mean_r <= 255 and 0 <= mean_g <= 255 and 0 <= mean_b <= 255
# assert mean_a == 255.0
# assert mean_b == 0.0
# assert mean_g == 0.0
assert mean_r > mean_b and mean_r > mean_g
assert 0 <= mean_r <= 255 and 0 <= mean_g <= 255 and 0 <= mean_b <= 255
assert mean_a == 255.0
assert mean_b == 0.0
assert mean_g == 0.0

vertices = sphere_actor_2.geometry.positions.view
faces = sphere_actor_2.geometry.indices.view
Expand Down Expand Up @@ -112,50 +112,49 @@ def test_cylinder():

assert cylinder_actor.prim_count == 1

# window.snapshot(scene=scene, fname="cylinder_test_1.png")
window.snapshot(scene=scene, fname="cylinder_test_1.png")

# img = Image.open("cylinder_test_1.png")
# img_array = np.array(img)
img = Image.open("cylinder_test_1.png")
img_array = np.array(img)

# mean_r, mean_g, mean_b, mean_a = np.mean(
# img_array.reshape(-1, img_array.shape[2]), axis=0
# )
mean_r, mean_g, mean_b, mean_a = np.mean(
img_array.reshape(-1, img_array.shape[2]), axis=0
)

# assert mean_r > mean_b and mean_r > mean_g
# assert 0 < mean_r < 255 and 0 < mean_g < 255 and 0 <= mean_b < 255
assert mean_r > mean_b and mean_r > mean_g
assert 0 < mean_r < 255 and 0 < mean_g < 255 and 0 <= mean_b < 255

# middle_pixel = img_array[img_array.shape[0] // 2, img_array.shape[1] // 2]
# r, g, b, a = middle_pixel
# assert r > g and r > b
# assert g == b
# assert r > 0 and g > 0 and b > 0
middle_pixel = img_array[img_array.shape[0] // 2, img_array.shape[1] // 2]
r, g, b, a = middle_pixel
assert r > g and r > b
assert g == b
assert r > 0 and g > 0 and b > 0

scene.remove(cylinder_actor)

# cylinder_actor_2 = actor.cylinder(
# centers=centers, colors=colors, sectors=sectors, capped=capped,
# material="basic"
# )
# scene.add(cylinder_actor_2)
# window.snapshot(scene=scene, fname="cylinder_test_2.png")

# img = Image.open("cylinder_test_2.png")
# img_array = np.array(img)

# mean_r, mean_g, mean_b, mean_a = np.mean(
# img_array.reshape(-1, img_array.shape[2]), axis=0
# )

# assert mean_r > mean_b and mean_r > mean_g
# assert 0 < mean_r < 255
# assert mean_g == 0 and mean_b == 0

# middle_pixel = img_array[img_array.shape[0] // 2, img_array.shape[1] // 2]
# r, g, b, a = middle_pixel
# assert r > g and r > b
# assert g == 0 and b == 0
# assert r == 255
# scene.remove(cylinder_actor_2)
cylinder_actor_2 = actor.cylinder(
centers=centers, colors=colors, sectors=sectors, capped=capped, material="basic"
)
scene.add(cylinder_actor_2)
window.snapshot(scene=scene, fname="cylinder_test_2.png")

img = Image.open("cylinder_test_2.png")
img_array = np.array(img)

mean_r, mean_g, mean_b, mean_a = np.mean(
img_array.reshape(-1, img_array.shape[2]), axis=0
)

assert mean_r > mean_b and mean_r > mean_g
assert 0 < mean_r < 255
assert mean_g == 0 and mean_b == 0

middle_pixel = img_array[img_array.shape[0] // 2, img_array.shape[1] // 2]
r, g, b, a = middle_pixel
assert r > g and r > b
assert g == 0 and b == 0
assert r == 255
scene.remove(cylinder_actor_2)


def test_square():
Expand Down

0 comments on commit 35f533a

Please sign in to comment.