diff --git a/doc/gallery/cuboid.py b/doc/gallery/cuboid.py index c0e0761..b04660d 100644 --- a/doc/gallery/cuboid.py +++ b/doc/gallery/cuboid.py @@ -52,7 +52,5 @@ PIL.Image.fromarray(out[:], mode="RGBA").save("cuboid.png") if len(sys.argv) > 1 and sys.argv[1] == "hires": - out = fresnel.pathtrace( - scene, samples=256, light_samples=16, w=1380, h=1380 - ) + out = fresnel.pathtrace(scene, samples=256, light_samples=16, w=1380, h=1380) PIL.Image.fromarray(out[:], mode="RGBA").save("cuboid-hires.png") diff --git a/doc/gallery/gumballs.py b/doc/gallery/gumballs.py index 8c094db..6ce357a 100644 --- a/doc/gallery/gumballs.py +++ b/doc/gallery/gumballs.py @@ -25,9 +25,7 @@ "#ecb642", "#8a9441", ] -cmap = LinearSegmentedColormap.from_list( - name="gumball", colors=colors, N=len(colors) -) +cmap = LinearSegmentedColormap.from_list(name="gumball", colors=colors, N=len(colors)) rng = np.random.default_rng(123) @@ -63,9 +61,7 @@ scene.camera.focus_on = (0, 0, 5.6) scene.lights = fresnel.light.lightbox() scene.lights.append( - fresnel.light.Light( - direction=(0.3, -0.3, 1), color=(0.5, 0.5, 0.5), theta=np.pi - ) + fresnel.light.Light(direction=(0.3, -0.3, 1), color=(0.5, 0.5, 0.5), theta=np.pi) ) if "CI" in os.environ: @@ -78,7 +74,5 @@ PIL.Image.fromarray(out[:], mode="RGBA").save("gumballs.png") if len(sys.argv) > 1 and sys.argv[1] == "hires": - out = fresnel.pathtrace( - scene, w=1500, h=1500, samples=256, light_samples=64 - ) + out = fresnel.pathtrace(scene, w=1500, h=1500, samples=256, light_samples=64) PIL.Image.fromarray(out[:], mode="RGBA").save("gumballs-hires.png") diff --git a/doc/gallery/sphere.py b/doc/gallery/sphere.py index e6ea95e..3f85dfd 100644 --- a/doc/gallery/sphere.py +++ b/doc/gallery/sphere.py @@ -33,7 +33,5 @@ PIL.Image.fromarray(out[:], mode="RGBA").save("sphere.png") if len(sys.argv) > 1 and sys.argv[1] == "hires": - out = fresnel.pathtrace( - scene, samples=256, light_samples=16, w=1380, h=1380 - ) + out = fresnel.pathtrace(scene, samples=256, light_samples=16, w=1380, h=1380) PIL.Image.fromarray(out[:], mode="RGBA").save("sphere-hires.png") diff --git a/fresnel/__init__.py b/fresnel/__init__.py index fe0b0c9..c39a946 100644 --- a/fresnel/__init__.py +++ b/fresnel/__init__.py @@ -88,8 +88,7 @@ def __init__(self, mode="auto", n=None): selected_mode = "cpu" if not _common.cpu_built(): raise RuntimeError( - "No GPUs available AND CPU " - "implementation is not compiled" + "No GPUs available AND CPU " "implementation is not compiled" ) if mode == "gpu": diff --git a/fresnel/geometry.py b/fresnel/geometry.py index e4b9fe0..6a39b01 100644 --- a/fresnel/geometry.py +++ b/fresnel/geometry.py @@ -186,12 +186,8 @@ def get_extents(self): r = r.reshape(len(r), 1) res = numpy.array( [ - numpy.min( - [numpy.min(A - r, axis=0), numpy.min(B - r, axis=0)], axis=0 - ), - numpy.max( - [numpy.max(A + r, axis=0), numpy.max(B + r, axis=0)], axis=0 - ), + numpy.min([numpy.min(A - r, axis=0), numpy.min(B - r, axis=0)], axis=0), + numpy.max([numpy.max(A + r, axis=0), numpy.max(B + r, axis=0)], axis=0), ] ) return res @@ -249,9 +245,7 @@ class Box(Cylinder): """ def __init__(self, scene, box, box_radius=0.5, box_color=[0, 0, 0]): - super().__init__( - scene=scene, N=12, material=material.Material(solid=1.0) - ) + super().__init__(scene=scene, N=12, material=material.Material(solid=1.0)) self._box = self._from_box(box) self.points[:] = self._generate_points(self._box) @@ -316,9 +310,7 @@ def _generate_points(self, box): yz = box[5] # Follow hoomd convention - box_matrix = numpy.array( - [[Lx, xy * Ly, xz * Lz], [0, Ly, yz * Lz], [0, 0, Lz]] - ) + box_matrix = numpy.array([[Lx, xy * Ly, xz * Lz], [0, Ly, yz * Lz], [0, 0, Lz]]) a_1, a_2, a_3 = box_matrix.T # F--------------H # /| /| @@ -503,9 +495,7 @@ def get_extents(self): """ pos = self.position[:] r = self._geometry.getRadius() - res2d = numpy.array( - [numpy.min(pos - r, axis=0), numpy.max(pos + r, axis=0)] - ) + res2d = numpy.array([numpy.min(pos - r, axis=0), numpy.max(pos + r, axis=0)]) res = numpy.array( [ [res2d[0][0], res2d[0][1], -1e-5], @@ -606,9 +596,7 @@ def get_extents(self): pos = self.position[:] r = self.radius[:] r = r.reshape(len(r), 1) - res = numpy.array( - [numpy.min(pos - r, axis=0), numpy.max(pos + r, axis=0)] - ) + res = numpy.array([numpy.min(pos - r, axis=0), numpy.max(pos + r, axis=0)]) return res @property @@ -867,9 +855,7 @@ def get_extents(self): """ pos = self.position[:] r = self._radius - res = numpy.array( - [numpy.min(pos - r, axis=0), numpy.max(pos + r, axis=0)] - ) + res = numpy.array([numpy.min(pos - r, axis=0), numpy.max(pos + r, axis=0)]) return res @property diff --git a/fresnel/interact.py b/fresnel/interact.py index a236cf0..71a9639 100644 --- a/fresnel/interact.py +++ b/fresnel/interact.py @@ -4,6 +4,7 @@ """Interactive Qt widgets.""" import sys + import numpy # workaround bug in ipython that prevents pyside2 importing @@ -16,13 +17,12 @@ except: # noqa: E722 pass -from PySide2 import QtGui -from PySide2 import QtCore -from PySide2 import QtWidgets -import rowan import copy -from fresnel import tracer, camera +import rowan +from PySide2 import QtCore, QtGui, QtWidgets + +from fresnel import camera, tracer # initialize QApplication # but not in sphinx @@ -288,9 +288,7 @@ def paintEvent(self, event): # noqa: N802 - allow Qt style naming ) qp = QtGui.QPainter(self) target = QtCore.QRectF(0, 0, self.width(), self.height()) - source = QtCore.QRectF( - 0.0, 0.0, image_array.shape[1], image_array.shape[0] - ) + source = QtCore.QRectF(0.0, 0.0, image_array.shape[1], image_array.shape[0]) qp.drawImage(target, img, source) qp.end() diff --git a/fresnel/light.py b/fresnel/light.py index c7cd6db..73254a2 100644 --- a/fresnel/light.py +++ b/fresnel/light.py @@ -274,12 +274,8 @@ def cloudy(): list[Light]: The lights. """ res = [] - res.append( - Light(direction=(0, 1, 0), color=(0.9, 0.9, 0.9), theta=math.pi / 2) - ) - res.append( - Light(direction=(0, -1, 0), color=(0.1, 0.1, 0.1), theta=math.pi / 2) - ) + res.append(Light(direction=(0, 1, 0), color=(0.9, 0.9, 0.9), theta=math.pi / 2)) + res.append(Light(direction=(0, -1, 0), color=(0.1, 0.1, 0.1), theta=math.pi / 2)) return res @@ -294,7 +290,5 @@ def ring(): list[Light]: The lights. """ res = [] - res.append( - Light(direction=(0, 0, 1), color=(0.9, 0.9, 0.9), theta=math.pi / 4) - ) + res.append(Light(direction=(0, 0, 1), color=(0.9, 0.9, 0.9), theta=math.pi / 4)) return res diff --git a/fresnel/test/test_camera_perspective.py b/fresnel/test/test_camera_perspective.py index 018b3ca..53690e1 100644 --- a/fresnel/test/test_camera_perspective.py +++ b/fresnel/test/test_camera_perspective.py @@ -19,9 +19,7 @@ def scene(device): for j in range(-8, 8): position.append([i, 0, j]) - mat = fresnel.material.Material( - color=fresnel.color.linear([0.42, 0.267, 0.9]) - ) + mat = fresnel.material.Material(color=fresnel.color.linear([0.42, 0.267, 0.9])) fresnel.geometry.Sphere( scene, position=position, @@ -80,9 +78,7 @@ def test_perspective_attributes(): numpy.testing.assert_allclose(cam.focus_on, [0, 0, 5]) numpy.testing.assert_allclose(cam.focus_distance, 15) - numpy.testing.assert_allclose( - cam.vertical_field_of_view, 0.19933730498232408 - ) + numpy.testing.assert_allclose(cam.vertical_field_of_view, 0.19933730498232408) cam.vertical_field_of_view = 0.4 numpy.testing.assert_allclose(cam.focal_length, 0.6166443824768066) diff --git a/fresnel/test/test_geometry_box.py b/fresnel/test/test_geometry_box.py index 8c5327d..0559ab8 100644 --- a/fresnel/test/test_geometry_box.py +++ b/fresnel/test/test_geometry_box.py @@ -164,9 +164,7 @@ def test_box_update(scene_box_, generate=False): if generate: PIL.Image.fromarray(buf_proxy[:], mode="RGBA").save( - open( - f"output/test_geometry_box.test_render{box_index}.png", "wb" - ), + open(f"output/test_geometry_box.test_render{box_index}.png", "wb"), "png", ) else: diff --git a/fresnel/test/test_geometry_convex_polyhedron.py b/fresnel/test/test_geometry_convex_polyhedron.py index 720859f..78ed648 100644 --- a/fresnel/test/test_geometry_convex_polyhedron.py +++ b/fresnel/test/test_geometry_convex_polyhedron.py @@ -57,9 +57,7 @@ def scene_eight_polyhedra(device): "radius": math.sqrt(3), "face_color": fresnel.color.linear(colors), } - geometry = fresnel.geometry.ConvexPolyhedron( - scene, poly_info, position=position - ) + geometry = fresnel.geometry.ConvexPolyhedron(scene, poly_info, position=position) geometry.material = fresnel.material.Material( color=fresnel.color.linear([1.0, 0, 0]), @@ -84,23 +82,17 @@ def scene_eight_polyhedra_(device_): def test_render(scene_eight_polyhedra_, generate=False): """Test that convex polyhedra render properly.""" - buf_proxy = fresnel.preview( - scene_eight_polyhedra_, w=150, h=100, anti_alias=False - ) + buf_proxy = fresnel.preview(scene_eight_polyhedra_, w=150, h=100, anti_alias=False) if generate: PIL.Image.fromarray(buf_proxy[:], mode="RGBA").save( - open( - "output/test_geometry_convex_polyhedron.test_render.png", "wb" - ), + open("output/test_geometry_convex_polyhedron.test_render.png", "wb"), "png", ) else: conftest.assert_image_approx_equal( buf_proxy[:], - dir_path - / "reference" - / "test_geometry_convex_polyhedron.test_render.png", + dir_path / "reference" / "test_geometry_convex_polyhedron.test_render.png", ) @@ -109,39 +101,29 @@ def test_outline(scene_eight_polyhedra_, generate=False): geometry = scene_eight_polyhedra_.geometry[0] geometry.outline_width = 0.1 - buf_proxy = fresnel.preview( - scene_eight_polyhedra_, w=150, h=100, anti_alias=False - ) + buf_proxy = fresnel.preview(scene_eight_polyhedra_, w=150, h=100, anti_alias=False) if generate: PIL.Image.fromarray(buf_proxy[:], mode="RGBA").save( - open( - "output/test_geometry_convex_polyhedron.test_outline.png", "wb" - ), + open("output/test_geometry_convex_polyhedron.test_outline.png", "wb"), "png", ) else: conftest.assert_image_approx_equal( buf_proxy[:], - dir_path - / "reference" - / "test_geometry_convex_polyhedron.test_outline.png", + dir_path / "reference" / "test_geometry_convex_polyhedron.test_outline.png", ) def test_face_color(scene_eight_polyhedra_, generate=False): """Test that faces can be colored individually.""" - buf_proxy = fresnel.preview( - scene_eight_polyhedra_, w=150, h=100, anti_alias=False - ) + buf_proxy = fresnel.preview(scene_eight_polyhedra_, w=150, h=100, anti_alias=False) geometry = scene_eight_polyhedra_.geometry[0] geometry.color_by_face = 1.0 geometry.material.primitive_color_mix = 1.0 - buf_proxy = fresnel.preview( - scene_eight_polyhedra_, w=150, h=100, anti_alias=False - ) + buf_proxy = fresnel.preview(scene_eight_polyhedra_, w=150, h=100, anti_alias=False) if generate: PIL.Image.fromarray(buf_proxy[:], mode="RGBA").save( diff --git a/fresnel/test/test_geometry_cylinder.py b/fresnel/test/test_geometry_cylinder.py index 31ec574..f5bc97f 100644 --- a/fresnel/test/test_geometry_cylinder.py +++ b/fresnel/test/test_geometry_cylinder.py @@ -51,9 +51,7 @@ def scene_four_cylinders_(device_): def test_render(scene_four_cylinders_, generate=False): """Test that Cylinder renders properly.""" - buf_proxy = fresnel.preview( - scene_four_cylinders_, w=150, h=100, anti_alias=False - ) + buf_proxy = fresnel.preview(scene_four_cylinders_, w=150, h=100, anti_alias=False) if generate: PIL.Image.fromarray(buf_proxy[:], mode="RGBA").save( @@ -74,9 +72,7 @@ def test_radius(scene_four_cylinders_, generate=False): geometry.radius[:] = r numpy.testing.assert_array_equal(r, geometry.radius[:]) - buf_proxy = fresnel.preview( - scene_four_cylinders_, w=150, h=100, anti_alias=False - ) + buf_proxy = fresnel.preview(scene_four_cylinders_, w=150, h=100, anti_alias=False) if generate: PIL.Image.fromarray(buf_proxy[:], mode="RGBA").save( @@ -105,9 +101,7 @@ def test_points(scene_four_cylinders_, generate=False): geometry.points[:] = p numpy.testing.assert_array_equal(p, geometry.points[:]) - buf_proxy = fresnel.preview( - scene_four_cylinders_, w=150, h=100, anti_alias=False - ) + buf_proxy = fresnel.preview(scene_four_cylinders_, w=150, h=100, anti_alias=False) if generate: PIL.Image.fromarray(buf_proxy[:], mode="RGBA").save( @@ -137,9 +131,7 @@ def test_color(scene_four_cylinders_, generate=False): geometry.color[:] = c numpy.testing.assert_array_equal(c, geometry.color[:]) - buf_proxy = fresnel.preview( - scene_four_cylinders_, w=150, h=100, anti_alias=False - ) + buf_proxy = fresnel.preview(scene_four_cylinders_, w=150, h=100, anti_alias=False) if generate: PIL.Image.fromarray(buf_proxy[:], mode="RGBA").save( @@ -157,9 +149,7 @@ def test_outline(scene_four_cylinders_, generate=False): geometry = scene_four_cylinders_.geometry[0] geometry.outline_width = 0.3 - buf_proxy = fresnel.preview( - scene_four_cylinders_, w=150, h=100, anti_alias=False - ) + buf_proxy = fresnel.preview(scene_four_cylinders_, w=150, h=100, anti_alias=False) if generate: PIL.Image.fromarray(buf_proxy[:], mode="RGBA").save( diff --git a/fresnel/test/test_geometry_mesh.py b/fresnel/test/test_geometry_mesh.py index 7a67225..b70a1a7 100644 --- a/fresnel/test/test_geometry_mesh.py +++ b/fresnel/test/test_geometry_mesh.py @@ -112,9 +112,7 @@ def scene_tetrahedra_(device_): def test_render(scene_one_triangle_, generate=False): """Test that Mesh renders properly.""" - buf_proxy = fresnel.preview( - scene_one_triangle_, w=100, h=100, anti_alias=False - ) + buf_proxy = fresnel.preview(scene_one_triangle_, w=100, h=100, anti_alias=False) if generate: PIL.Image.fromarray(buf_proxy[:], mode="RGBA").save( @@ -132,9 +130,7 @@ def test_outline(scene_one_triangle_, generate=False): geometry = scene_one_triangle_.geometry[0] geometry.outline_width = 0.1 - buf_proxy = fresnel.preview( - scene_one_triangle_, w=100, h=100, anti_alias=False - ) + buf_proxy = fresnel.preview(scene_one_triangle_, w=100, h=100, anti_alias=False) if generate: PIL.Image.fromarray(buf_proxy[:], mode="RGBA").save( @@ -152,9 +148,7 @@ def test_color_interp(scene_one_triangle_, generate=False): geometry = scene_one_triangle_.geometry[0] geometry.material.primitive_color_mix = 1.0 - buf_proxy = fresnel.preview( - scene_one_triangle_, w=100, h=100, anti_alias=False - ) + buf_proxy = fresnel.preview(scene_one_triangle_, w=100, h=100, anti_alias=False) if generate: PIL.Image.fromarray(buf_proxy[:], mode="RGBA").save( @@ -169,9 +163,7 @@ def test_color_interp(scene_one_triangle_, generate=False): def test_multiple(scene_tetrahedra_, generate=False): """Test that Mesh supports multiple instances.""" - buf_proxy = fresnel.preview( - scene_tetrahedra_, w=100, h=100, anti_alias=False - ) + buf_proxy = fresnel.preview(scene_tetrahedra_, w=100, h=100, anti_alias=False) if generate: PIL.Image.fromarray(buf_proxy[:], mode="RGBA").save( diff --git a/fresnel/test/test_geometry_polygon.py b/fresnel/test/test_geometry_polygon.py index ea42118..1ef515c 100644 --- a/fresnel/test/test_geometry_polygon.py +++ b/fresnel/test/test_geometry_polygon.py @@ -99,9 +99,7 @@ def test_rounded(scene_rounded_polygons_, generate=False): geometry = scene_rounded_polygons_.geometry[0] geometry.outline_width = 0.1 - buf_proxy = fresnel.preview( - scene_rounded_polygons_, w=150, h=100, anti_alias=False - ) + buf_proxy = fresnel.preview(scene_rounded_polygons_, w=150, h=100, anti_alias=False) if generate: PIL.Image.fromarray(buf_proxy[:], mode="RGBA").save( diff --git a/fresnel/test/test_geometry_sphere.py b/fresnel/test/test_geometry_sphere.py index 9fa7532..4457621 100644 --- a/fresnel/test/test_geometry_sphere.py +++ b/fresnel/test/test_geometry_sphere.py @@ -19,9 +19,7 @@ def scene_four_spheres(device): """Create a test scene with four spheres.""" scene = fresnel.Scene(device, lights=conftest.test_lights()) - mat = fresnel.material.Material( - color=fresnel.color.linear([0.42, 0.267, 1]) - ) + mat = fresnel.material.Material(color=fresnel.color.linear([0.42, 0.267, 1])) fresnel.geometry.Sphere( scene, position=[[1, 0, 1], [1, 0, -1], [-1, 0, 1], [-1, 0, -1]], @@ -45,9 +43,7 @@ def scene_four_spheres_(device_): def test_render(scene_four_spheres_, generate=False): """Test that spheres render properly.""" - buf_proxy = fresnel.preview( - scene_four_spheres_, w=150, h=100, anti_alias=False - ) + buf_proxy = fresnel.preview(scene_four_spheres_, w=150, h=100, anti_alias=False) if generate: PIL.Image.fromarray(buf_proxy[:], mode="RGBA").save( @@ -68,9 +64,7 @@ def test_radius(scene_four_spheres_, generate=False): geometry.radius[:] = r numpy.testing.assert_array_equal(r, geometry.radius[:]) - buf_proxy = fresnel.preview( - scene_four_spheres_, w=150, h=100, anti_alias=False - ) + buf_proxy = fresnel.preview(scene_four_spheres_, w=150, h=100, anti_alias=False) if generate: PIL.Image.fromarray(buf_proxy[:], mode="RGBA").save( @@ -94,9 +88,7 @@ def test_position(scene_four_spheres_, generate=False): geometry.position[:] = p numpy.testing.assert_array_equal(p, geometry.position[:]) - buf_proxy = fresnel.preview( - scene_four_spheres_, w=150, h=100, anti_alias=False - ) + buf_proxy = fresnel.preview(scene_four_spheres_, w=150, h=100, anti_alias=False) if generate: PIL.Image.fromarray(buf_proxy[:], mode="RGBA").save( @@ -115,16 +107,12 @@ def test_color(scene_four_spheres_, generate=False): geometry.material.primitive_color_mix = 1.0 c = fresnel.color.linear( - numpy.array( - [[1, 1, 1], [0, 0, 1], [0, 1, 0], [1, 0, 0]], dtype=numpy.float32 - ) + numpy.array([[1, 1, 1], [0, 0, 1], [0, 1, 0], [1, 0, 0]], dtype=numpy.float32) ) geometry.color[:] = c numpy.testing.assert_array_equal(c, geometry.color[:]) - buf_proxy = fresnel.preview( - scene_four_spheres_, w=150, h=100, anti_alias=False - ) + buf_proxy = fresnel.preview(scene_four_spheres_, w=150, h=100, anti_alias=False) if generate: PIL.Image.fromarray(buf_proxy[:], mode="RGBA").save( @@ -142,9 +130,7 @@ def test_outline(scene_four_spheres_, generate=False): geometry = scene_four_spheres_.geometry[0] geometry.outline_width = 0.1 - buf_proxy = fresnel.preview( - scene_four_spheres_, w=150, h=100, anti_alias=False - ) + buf_proxy = fresnel.preview(scene_four_spheres_, w=150, h=100, anti_alias=False) if generate: PIL.Image.fromarray(buf_proxy[:], mode="RGBA").save( diff --git a/fresnel/test/test_light.py b/fresnel/test/test_light.py index e478a02..a5420e0 100644 --- a/fresnel/test/test_light.py +++ b/fresnel/test/test_light.py @@ -13,24 +13,14 @@ def test_lightlist(device_): l = scene.lights # noqa: E741 - allow l as a name assert len(l) == 0 l.append( - fresnel.light.Light( - direction=(1, 2, 3), color=(0.5, 0.125, 0.75), theta=2 - ) + fresnel.light.Light(direction=(1, 2, 3), color=(0.5, 0.125, 0.75), theta=2) ) assert len(l) == 1 - l.append( - fresnel.light.Light(direction=(5, 10, 2), color=(10, 18, 6), theta=1) - ) + l.append(fresnel.light.Light(direction=(5, 10, 2), color=(10, 18, 6), theta=1)) assert len(l) == 2 - l.append( - fresnel.light.Light( - direction=(4, 8, 16), color=(100, 1200, 7), theta=0.5 - ) - ) + l.append(fresnel.light.Light(direction=(4, 8, 16), color=(100, 1200, 7), theta=0.5)) assert len(l) == 3 - l.append( - fresnel.light.Light(direction=(5, 1, 2), color=(16, 32, 64), theta=0.75) - ) + l.append(fresnel.light.Light(direction=(5, 1, 2), color=(16, 32, 64), theta=0.75)) assert len(l) == 4 with pytest.raises(Exception): @@ -76,9 +66,7 @@ def test_lightlist(device_): scene.lights = [ fresnel.light.Light(direction=(1, 2, 3)), - fresnel.light.Light( - direction=(10, 20, 30), color=(1, 0, 0), theta=1.125 - ), + fresnel.light.Light(direction=(10, 20, 30), color=(1, 0, 0), theta=1.125), ] assert l[0].direction == (1, 2, 3) assert l[0].color == (1, 1, 1) diff --git a/fresnel/test/test_material.py b/fresnel/test/test_material.py index 913226d..8c92bcb 100644 --- a/fresnel/test/test_material.py +++ b/fresnel/test/test_material.py @@ -25,9 +25,7 @@ def test_set_material(scene_hex_sphere_, generate=False): assert geometry.material.color == tuple(fresnel.color.linear([1, 0, 0])) assert geometry.material.primitive_color_mix == 0.0 - buf_proxy = fresnel.preview( - scene_hex_sphere_, w=100, h=100, anti_alias=False - ) + buf_proxy = fresnel.preview(scene_hex_sphere_, w=100, h=100, anti_alias=False) if generate: PIL.Image.fromarray(buf_proxy[:], mode="RGBA").save( @@ -46,9 +44,7 @@ def test_solid(scene_hex_sphere_, generate=False): geometry.material.solid = 1.0 assert geometry.material.solid == 1.0 - buf_proxy = fresnel.preview( - scene_hex_sphere_, w=100, h=100, anti_alias=False - ) + buf_proxy = fresnel.preview(scene_hex_sphere_, w=100, h=100, anti_alias=False) if generate: PIL.Image.fromarray(buf_proxy[:], mode="RGBA").save( @@ -67,9 +63,7 @@ def test_color(scene_hex_sphere_, generate=False): geometry.material.color = fresnel.color.linear([0, 0, 1]) assert geometry.material.color == tuple(fresnel.color.linear([0, 0, 1])) - buf_proxy = fresnel.preview( - scene_hex_sphere_, w=100, h=100, anti_alias=False - ) + buf_proxy = fresnel.preview(scene_hex_sphere_, w=100, h=100, anti_alias=False) if generate: PIL.Image.fromarray(buf_proxy[:], mode="RGBA").save( @@ -88,9 +82,7 @@ def test_specular(scene_hex_sphere_, generate=False): geometry.material.specular = 1.0 assert geometry.material.specular == 1.0 - buf_proxy = fresnel.preview( - scene_hex_sphere_, w=100, h=100, anti_alias=False - ) + buf_proxy = fresnel.preview(scene_hex_sphere_, w=100, h=100, anti_alias=False) if generate: PIL.Image.fromarray(buf_proxy[:], mode="RGBA").save( @@ -109,9 +101,7 @@ def test_roughness(scene_hex_sphere_, generate=False): geometry.material.roughness = 1.0 assert geometry.material.roughness == 1.0 - buf_proxy = fresnel.preview( - scene_hex_sphere_, w=100, h=100, anti_alias=False - ) + buf_proxy = fresnel.preview(scene_hex_sphere_, w=100, h=100, anti_alias=False) if generate: PIL.Image.fromarray(buf_proxy[:], mode="RGBA").save( @@ -130,9 +120,7 @@ def test_metal(scene_hex_sphere_, generate=False): geometry.material.metal = 1.0 assert geometry.material.metal == 1.0 - buf_proxy = fresnel.preview( - scene_hex_sphere_, w=100, h=100, anti_alias=False - ) + buf_proxy = fresnel.preview(scene_hex_sphere_, w=100, h=100, anti_alias=False) if generate: PIL.Image.fromarray(buf_proxy[:], mode="RGBA").save( @@ -161,9 +149,7 @@ def test_primitive_color_mix(scene_hex_sphere_, generate=False): geometry.color[4] = fresnel.color.linear([0, 1, 1]) geometry.color[5] = fresnel.color.linear([0, 0, 0]) - buf_proxy = fresnel.preview( - scene_hex_sphere_, w=100, h=100, anti_alias=False - ) + buf_proxy = fresnel.preview(scene_hex_sphere_, w=100, h=100, anti_alias=False) if generate: PIL.Image.fromarray(buf_proxy[:], mode="RGBA").save( @@ -173,9 +159,7 @@ def test_primitive_color_mix(scene_hex_sphere_, generate=False): else: conftest.assert_image_approx_equal( buf_proxy[:], - dir_path - / "reference" - / "test_material.test_primitive_color_mix.png", + dir_path / "reference" / "test_material.test_primitive_color_mix.png", ) diff --git a/fresnel/test/test_outline_material.py b/fresnel/test/test_outline_material.py index 1b73944..b26f605 100644 --- a/fresnel/test/test_outline_material.py +++ b/fresnel/test/test_outline_material.py @@ -23,14 +23,10 @@ def test_set_material(scene_hex_sphere_, generate=False): primitive_color_mix=0.0, ) assert geometry.outline_material.solid == 0.0 - assert geometry.outline_material.color == tuple( - fresnel.color.linear([1, 0, 0]) - ) + assert geometry.outline_material.color == tuple(fresnel.color.linear([1, 0, 0])) assert geometry.outline_material.primitive_color_mix == 0.0 - buf_proxy = fresnel.preview( - scene_hex_sphere_, w=100, h=100, anti_alias=False - ) + buf_proxy = fresnel.preview(scene_hex_sphere_, w=100, h=100, anti_alias=False) if generate: PIL.Image.fromarray(buf_proxy[:], mode="RGBA").save( @@ -40,9 +36,7 @@ def test_set_material(scene_hex_sphere_, generate=False): else: conftest.assert_image_approx_equal( buf_proxy[:], - dir_path - / "reference" - / "test_outline_material.test_set_material.png", + dir_path / "reference" / "test_outline_material.test_set_material.png", ) @@ -53,9 +47,7 @@ def test_solid(scene_hex_sphere_, generate=False): geometry.outline_material.solid = 1.0 assert geometry.outline_material.solid == 1.0 - buf_proxy = fresnel.preview( - scene_hex_sphere_, w=100, h=100, anti_alias=False - ) + buf_proxy = fresnel.preview(scene_hex_sphere_, w=100, h=100, anti_alias=False) if generate: PIL.Image.fromarray(buf_proxy[:], mode="RGBA").save( @@ -73,13 +65,9 @@ def test_color(scene_hex_sphere_, generate=False): geometry = scene_hex_sphere_.geometry[0] geometry.outline_width = 0.3 geometry.outline_material.color = fresnel.color.linear([0, 0, 1]) - assert geometry.outline_material.color == tuple( - fresnel.color.linear([0, 0, 1]) - ) + assert geometry.outline_material.color == tuple(fresnel.color.linear([0, 0, 1])) - buf_proxy = fresnel.preview( - scene_hex_sphere_, w=100, h=100, anti_alias=False - ) + buf_proxy = fresnel.preview(scene_hex_sphere_, w=100, h=100, anti_alias=False) if generate: PIL.Image.fromarray(buf_proxy[:], mode="RGBA").save( @@ -109,9 +97,7 @@ def test_primitive_color_mix(scene_hex_sphere_, generate=False): geometry.color[4] = fresnel.color.linear([0, 1, 1]) geometry.color[5] = fresnel.color.linear([0, 0, 0]) - buf_proxy = fresnel.preview( - scene_hex_sphere_, w=100, h=100, anti_alias=False - ) + buf_proxy = fresnel.preview(scene_hex_sphere_, w=100, h=100, anti_alias=False) if generate: PIL.Image.fromarray(buf_proxy[:], mode="RGBA").save( diff --git a/fresnel/test/test_scene.py b/fresnel/test/test_scene.py index 8311329..9487b8e 100644 --- a/fresnel/test/test_scene.py +++ b/fresnel/test/test_scene.py @@ -49,18 +49,12 @@ def test_camera(scene_hex_sphere_, generate=False): position=(1, 0, 10), look_at=(1, 0, 0), up=(0, 1, 0), height=6 ) - numpy.testing.assert_array_equal( - scene_hex_sphere_.camera.position, (1, 0, 10) - ) - numpy.testing.assert_array_equal( - scene_hex_sphere_.camera.look_at, (1, 0, 0) - ) + numpy.testing.assert_array_equal(scene_hex_sphere_.camera.position, (1, 0, 10)) + numpy.testing.assert_array_equal(scene_hex_sphere_.camera.look_at, (1, 0, 0)) numpy.testing.assert_array_equal(scene_hex_sphere_.camera.up, (0, 1, 0)) assert scene_hex_sphere_.camera.height == 6 - buf_proxy = fresnel.preview( - scene_hex_sphere_, w=100, h=100, anti_alias=False - ) + buf_proxy = fresnel.preview(scene_hex_sphere_, w=100, h=100, anti_alias=False) if generate: PIL.Image.fromarray(buf_proxy[:], mode="RGBA").save( @@ -79,9 +73,7 @@ def test_light_dir(scene_hex_sphere_, generate=False): assert scene_hex_sphere_.lights[0].direction == (1, 0, 0) assert scene_hex_sphere_.lights[0].color == (0.5, 0.5, 0.5) - buf_proxy = fresnel.preview( - scene_hex_sphere_, w=100, h=100, anti_alias=False - ) + buf_proxy = fresnel.preview(scene_hex_sphere_, w=100, h=100, anti_alias=False) if generate: PIL.Image.fromarray(buf_proxy[:], mode="RGBA").save( diff --git a/ruff.toml b/ruff.toml index 2c0674e..87b1b9c 100644 --- a/ruff.toml +++ b/ruff.toml @@ -1,6 +1,6 @@ include = ["*.py", "*.ipynb"] exclude = [".git","__pycache__","doc/conf.py","run-clang-format.py","build"] -line-length = 80 +line-length = 88 indent-width = 4 [lint]