From b4d77778f10d65d15317b7e539cf0484c0cdc67e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 6 Jan 2025 20:53:34 +0000 Subject: [PATCH 1/7] chore: update pre-commit hooks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/asottile/blacken-docs: 1.18.0 → 1.19.1](https://github.com/asottile/blacken-docs/compare/1.18.0...1.19.1) - [github.com/astral-sh/ruff-pre-commit: v0.6.9 → v0.8.6](https://github.com/astral-sh/ruff-pre-commit/compare/v0.6.9...v0.8.6) - [github.com/mgedmin/check-manifest: 0.49 → 0.50](https://github.com/mgedmin/check-manifest/compare/0.49...0.50) - [github.com/kynan/nbstripout: 0.7.1 → 0.8.1](https://github.com/kynan/nbstripout/compare/0.7.1...0.8.1) - [github.com/pre-commit/mirrors-clang-format: v19.1.1 → v19.1.6](https://github.com/pre-commit/mirrors-clang-format/compare/v19.1.1...v19.1.6) --- .pre-commit-config.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 20456fc53..f45244a83 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -28,19 +28,19 @@ repos: args: ["--line-length", "100"] - repo: https://github.com/asottile/blacken-docs - rev: "1.18.0" + rev: "1.19.1" hooks: - id: blacken-docs additional_dependencies: [black==23.3.0] - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.6.9" + rev: "v0.8.6" hooks: - id: ruff args: ["--fix", "--show-fixes"] - repo: https://github.com/mgedmin/check-manifest - rev: "0.49" + rev: "0.50" hooks: - id: check-manifest stages: [manual] @@ -76,7 +76,7 @@ repos: types_or: [yaml, markdown, html, css, scss, javascript, json] - repo: https://github.com/kynan/nbstripout - rev: "0.7.1" + rev: "0.8.1" hooks: - id: nbstripout args: @@ -87,7 +87,7 @@ repos: ] - repo: https://github.com/pre-commit/mirrors-clang-format - rev: "v19.1.1" + rev: "v19.1.6" hooks: - id: clang-format types_or: [c++, c, cuda] From d0d27cb9e6bae6d573c75f54461ae31ce9d3fe70 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 6 Jan 2025 20:54:47 +0000 Subject: [PATCH 2/7] style: pre-commit fixes --- src/pyg4ometry/fluka/body.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/pyg4ometry/fluka/body.py b/src/pyg4ometry/fluka/body.py index 849064e8e..840949f59 100644 --- a/src/pyg4ometry/fluka/body.py +++ b/src/pyg4ometry/fluka/body.py @@ -1,27 +1,27 @@ """Set of classes for FLUKA bodies.""" __all__ = [ - "RPP", + "ARB", "BOX", - "SPH", + "ELL", + "PLA", + "QUA", + "RAW", "RCC", "REC", + "RPP", + "SPH", "TRC", - "ELL", "WED", - "RAW", - "ARB", + "XCC", + "XEC", "XYP", "XZP", - "YZP", - "PLA", - "XCC", "YCC", - "ZCC", - "XEC", "YEC", + "YZP", + "ZCC", "ZEC", - "QUA", ] from math import degrees From 697513223ed5cef48878e49a1a99902da2e58334 Mon Sep 17 00:00:00 2001 From: Stewart Boogert Date: Mon, 13 Jan 2025 10:43:07 +0000 Subject: [PATCH 3/7] cicd: skip opencascade tests on linux --- tests/pyoce/test_pyoce.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/pyoce/test_pyoce.py b/tests/pyoce/test_pyoce.py index d799a5393..60d80c4cc 100644 --- a/tests/pyoce/test_pyoce.py +++ b/tests/pyoce/test_pyoce.py @@ -19,61 +19,75 @@ def commonCode(fileName, mats={}, skip=[], mesh={}): return r +@pytest.mark.skipif(sys.platform == "linux", reason="Test not supported on Linux") def test_1_BasicSolids_Bodies(testdata): commonCode(testdata["step/1_BasicSolids_Bodies.step"]) +@pytest.mark.skipif(sys.platform == "linux", reason="Test not supported on Linux") def test_2_BasicSolids_Components(testdata): commonCode(testdata["step/2_BasicSolids_Components.step"]) +@pytest.mark.skipif(sys.platform == "linux", reason="Test not supported on Linux") def test_3_BasicSolids_Components_Copied(testdata): commonCode(testdata["step/3_BasicSolids_Components_Copied.step"]) +@pytest.mark.skipif(sys.platform == "linux", reason="Test not supported on Linux") def test_4_BasicSolids_Components_ManyBodies(testdata): commonCode(testdata["step/4_BasicSolids_Components_ManyBodies.step"]) +@pytest.mark.skipif(sys.platform == "linux", reason="Test not supported on Linux") def test_5_BasicSolids_Components_NestedComponents(testdata): commonCode(testdata["step/5_BasicSolids_Components_NestedComponents.step"]) +@pytest.mark.skipif(sys.platform == "linux", reason="Test not supported on Linux") def test_6_SolidFromSketch(testdata): commonCode(testdata["step/6_SolidFromSketch.step"]) +@pytest.mark.skipif(sys.platform == "linux", reason="Test not supported on Linux") def test_7_Booleans(testdata): commonCode(testdata["step/7_Booleans.step"]) +@pytest.mark.skipif(sys.platform == "linux", reason="Test not supported on Linux") def test_8_rotationTest(testdata): commonCode(testdata["step/8_rotationTest.step"]) +@pytest.mark.skipif(sys.platform == "linux", reason="Test not supported on Linux") def test_9_AshTray(testdata): commonCode(testdata["step/9_AshTray.step"]) +@pytest.mark.skipif(sys.platform == "linux", reason="Test not supported on Linux") def test_10_SectorBendSmall(testdata): commonCode(testdata["step/10_SectorBendSmall.step"]) +@pytest.mark.skipif(sys.platform == "linux", reason="Test not supported on Linux") def test_11_Material(testdata): mats = {"0:1:1:1:1": "G4_H", "0:1:1:1:4": "G4_He"} commonCode(testdata["step/10_SectorBendSmall.step"], mats=mats) +@pytest.mark.skipif(sys.platform == "linux", reason="Test not supported on Linux") def test_12_Skip(testdata): skip = ["0:1:1:1:4"] commonCode(testdata["step/10_SectorBendSmall.step"], skip=skip) +@pytest.mark.skipif(sys.platform == "linux", reason="Test not supported on Linux") def test_13_Mesh(testdata): mesh = {"0:1:1:1:2": (0.05, 0.05)} commonCode(testdata["step/10_SectorBendSmall.step"], mesh=mesh) +@pytest.mark.skipif(sys.platform == "linux", reason="Test not supported on Linux") def test_14_MonolithicConversion(testdata): r = _pyg4.pyoce.Reader(str(testdata["step/1_BasicSolids_Bodies.step"])) ls = r.freeShapes() @@ -83,6 +97,7 @@ def test_14_MonolithicConversion(testdata): _pyg4.convert.oceShape_Geant4_Tessellated("world", worldShape, greg) +@pytest.mark.skipif(sys.platform == "linux", reason="Test not supported on Linux") def test_15_xcaf(testdata): # create application app = _pyg4.pyoce.XCAFApp.XCAFApp_Application.GetApplication() @@ -105,6 +120,7 @@ def test_15_xcaf(testdata): # w.WriteFile("output.step") +@pytest.mark.skipif(sys.platform == "linux", reason="Test not supported on Linux") def test_16_CurveAndSurface_Extraction(testdata): from pyg4ometry.pyoce.TopAbs import TopAbs_ShapeEnum from pyg4ometry.pyoce.TopExp import TopExp_Explorer From 99c540692c416626fbc36da81662a542a3b45592 Mon Sep 17 00:00:00 2001 From: Stewart Boogert Date: Mon, 13 Jan 2025 10:45:34 +0000 Subject: [PATCH 4/7] cicd: forgot to add the sys import --- tests/pyoce/test_pyoce.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/pyoce/test_pyoce.py b/tests/pyoce/test_pyoce.py index 60d80c4cc..487d60c21 100644 --- a/tests/pyoce/test_pyoce.py +++ b/tests/pyoce/test_pyoce.py @@ -1,3 +1,4 @@ +import sys import pyg4ometry as _pyg4 From 84ed802a516ba36f00d38a688102becd513f4e8e Mon Sep 17 00:00:00 2001 From: Stewart Boogert Date: Mon, 13 Jan 2025 10:49:50 +0000 Subject: [PATCH 5/7] cicd: forgot to add the pytest import --- tests/pyoce/test_pyoce.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/pyoce/test_pyoce.py b/tests/pyoce/test_pyoce.py index 487d60c21..94cfedff7 100644 --- a/tests/pyoce/test_pyoce.py +++ b/tests/pyoce/test_pyoce.py @@ -1,4 +1,5 @@ import sys +import pytest import pyg4ometry as _pyg4 From a7a31b43a14add51090c1311d68b5dd83da399e9 Mon Sep 17 00:00:00 2001 From: Stewart Boogert Date: Mon, 13 Jan 2025 11:01:18 +0000 Subject: [PATCH 6/7] chore: precommit % -> format --- src/pyg4ometry/analysis/flukaData.py | 6 +++--- src/pyg4ometry/freecad/Reader.py | 11 +++++------ src/pyg4ometry/geant4/LogicalVolume.py | 6 ++---- src/pyg4ometry/geant4/ReplicaVolume.py | 6 ++---- 4 files changed, 12 insertions(+), 17 deletions(-) diff --git a/src/pyg4ometry/analysis/flukaData.py b/src/pyg4ometry/analysis/flukaData.py index d2b68ec4e..afdfa04a4 100644 --- a/src/pyg4ometry/analysis/flukaData.py +++ b/src/pyg4ometry/analysis/flukaData.py @@ -287,14 +287,14 @@ def read_stats(self, fd): for det in self.detector: data = fortran_read(fd) - data = _struct.unpack("=%df" % (len(data) // 4), data) + data = _struct.unpack(f"={len(data) // 4}f", data) det.total = data[0] det.totalError = data[1] det.error = [] for i in range(6): data = fortran_read(fd) - det.error.append(_struct.unpack("=%df" % (len(data) // 4), data)) + det.error.append(_struct.unpack(f"={len(data) // 4}f", data)) def read_header(self, fd): pos = fd.tell() @@ -424,7 +424,7 @@ def read_event(self, fd, ievent=0): etrack = edum wtrack = wdum data = fortran_read(fd) - data = list(_struct.unpack("=%df" % (3 * (ntrack + 1) + mtrack + 1), data)) + data = list(_struct.unpack(f"={3 * (ntrack + 1) + mtrack + 1}f", data)) self.track_data.append(data) # energy elif ndum == 0: diff --git a/src/pyg4ometry/freecad/Reader.py b/src/pyg4ometry/freecad/Reader.py index 7a47e3de1..deaef70a3 100644 --- a/src/pyg4ometry/freecad/Reader.py +++ b/src/pyg4ometry/freecad/Reader.py @@ -396,8 +396,7 @@ def recurseObjectTree(self, obj): if obj.TypeId == "App::Part": # mapped to logical volume, group objects mapped to physical _log.info( - "freecad.reader.recurseObjectTree> App::Part label=%s grouplen=%d placement=%s" - % (obj.Label, len(obj.Group), obj.Placement) + f"freecad.reader.recurseObjectTree> App::Part label={obj.Label} grouplen={len(obj.Group)} placement={obj.Placement}" ) bSolid = pyg4ometry.geant4.solid.Box( @@ -515,18 +514,18 @@ def WriteSMeshFile(mesh, filename): wind = mesh[1] f.write("# part 1 - node list\n") - f.write("%i 3 0 0 \n" % (len(verts))) + f.write(f"{len(verts)} 3 0 0 \n") iv = 0 for v in verts: - f.write("%i %f %f %f\n" % (iv, v[0], v[1], v[2])) + f.write(f"{iv} {v[0]} {v[1]} {v[2]}\n") iv = iv + 1 f.write("# part 2 - facet list\n") - f.write("%i 0\n" % (len(wind))) + f.write(f"{len(wind)} 0\n") iw = 0 for w in wind: - f.write("3 %i %i %i\n" % (w[0], w[1], w[2])) + f.write(f"3 {w[0]} {w[1]} {w[2]}\n") f.write("# part 3 - hole list\n") f.write("0\n") diff --git a/src/pyg4ometry/geant4/LogicalVolume.py b/src/pyg4ometry/geant4/LogicalVolume.py index d7b8f79d6..62cb0442a 100644 --- a/src/pyg4ometry/geant4/LogicalVolume.py +++ b/src/pyg4ometry/geant4/LogicalVolume.py @@ -732,8 +732,7 @@ def checkOverlaps( # bounding meshes collide, so check full mesh properly interMesh = transformedMeshes[i].intersect(transformedMeshes[j]) _log.info( - "LogicalVolume.checkOverlaps> full daughter-daughter intersection test: %d %d %d %d" - % (i, j, interMesh.vertexCount(), interMesh.polygonCount()) + f"LogicalVolume.checkOverlaps> full daughter-daughter intersection test: {i} {j} {interMesh.vertexCount()} {interMesh.polygonCount()}" ) if interMesh.vertexCount() != 0: nOverlapsDetected[0] += 1 @@ -785,8 +784,7 @@ def checkOverlaps( interMesh = transformedMeshes[i].subtract(self.mesh.localmesh) _log.info( - "LogicalVolume.checkOverlaps> daughter container %d %d %d" - % (i, interMesh.vertexCount(), interMesh.polygonCount()) + f"LogicalVolume.checkOverlaps> daughter container {i} {interMesh.vertexCount()} {interMesh.polygonCount()}" ) if interMesh.vertexCount() != 0: diff --git a/src/pyg4ometry/geant4/ReplicaVolume.py b/src/pyg4ometry/geant4/ReplicaVolume.py index a8a6298f6..79ee6edb8 100644 --- a/src/pyg4ometry/geant4/ReplicaVolume.py +++ b/src/pyg4ometry/geant4/ReplicaVolume.py @@ -96,8 +96,7 @@ def _checkInternalOverlaps(self, debugIO=False, nOverlapsDetected=[0]): interMesh = tempMeshes[i].subtract(self.motherVolume.mesh.localboundingmesh) _log.info( - "ReplicaVolume.checkOverlaps> daughter container %d %d %d" - % (i, interMesh.vertexCount(), interMesh.polygonCount()) + f"ReplicaVolume.checkOverlaps> daughter container {i} {interMesh.vertexCount()} {interMesh.polygonCount()}" ) if interMesh.vertexCount() != 0: @@ -123,8 +122,7 @@ def _checkInternalOverlaps(self, debugIO=False, nOverlapsDetected=[0]): # bounding meshes collide, so check full mesh properly interMesh = tempMeshes[i].intersect(tempMeshes[j]) _log.info( - "ReplicaVolume.checkOverlaps> full daughter-daughter intersection test: %d %d %d %d" - % (i, j, interMesh.vertexCount(), interMesh.polygonCount()) + f"ReplicaVolume.checkOverlaps> full daughter-daughter intersection test: {i} {j} {interMesh.vertexCount()} {interMesh.polygonCount()}" ) if interMesh.vertexCount() != 0: nOverlapsDetected[0] += 1 From f5656a9a962dcbbc407fd007f27c4f1beea03a46 Mon Sep 17 00:00:00 2001 From: Stewart Boogert Date: Mon, 13 Jan 2025 11:12:02 +0000 Subject: [PATCH 7/7] cicd: skip step file cli test in linux --- tests/cli/test_cli.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/cli/test_cli.py b/tests/cli/test_cli.py index 7a4050dcd..1b185000e 100644 --- a/tests/cli/test_cli.py +++ b/tests/cli/test_cli.py @@ -3,6 +3,7 @@ from optparse import OptParseError import os import pytest +import sys _skip_root_tests = False try: @@ -195,6 +196,7 @@ def test_cli_load_stl(testdata): _cli.main(["-i", testdata["stl/dog.stl"]], testing=True) +@pytest.mark.skipif(sys.platform == "linux", reason="Test not supported on Linux") def test_cli_load_stp(testdata): _cli.main(["-i", testdata["step/1_BasicSolids_Bodies.step"]], testing=True)