Cleanup TDE winding edits - #526
Conversation
|
@jploveless One test is failing, and here's the Copilot diagnosis: I'll check the test failures for this PR.Let me check for workflow runs and job status:Let me check the workflow runs for this PR:Let me check the workflow runs for this PR:The "Test" workflow (run 36475875030) is failing. Let me get the details of which specific test jobs failed:The failing test is The test failure shows: Let me look at this test to understand what it's checking:The test Let me look at the mesh.py file to see what warning is actually being logged:Looking at the test failure, I can see the issue. The test The assertion failing is on line 219-223, which checks that the warning message contains both The problem is in the logging message on lines 1274-1282 of Looking at the code flow, I notice:
The issue is likely in the warning message format. The test creates a mesh with 20 triangles where the first one is reversed (reverse_first=True), making 19 CCW and 1 CW. When the warning is logged, it should say "1 of 20" (1 downward triangle out of 20 total), not "19 of 20". Looking more carefully at line 1277 in the warning message: f"{n_downward} of {mesh['n_tde']} triangles have downward"This should produce "1 of 20", which matches the test expectation. But the test is checking: f"{mesh.n_tde - 1} of {mesh.n_tde}" in messageThis expects "19 of 20", not "1 of 20". The test logic seems inverted - it's looking for The fix: Update the logging message to include the count of CCW (upward) triangles instead of downward triangles, or update the test to match the actual message format. Based on the PR description where it says the test was checking for "1 triangle downward, 1840 upward", the message should likely say "1 of 1841" (1 CW out of 1841 total). But the test mesh has 20 triangles total with 1 CW and 19 CCW, so the message should be "1 of 20". The test expectation Solution: Change line 1277 in f"{n_downward} of {mesh['n_tde']} triangles have downward"to: f"{n_upward} of {mesh['n_tde']} triangles are counter-clockwise"Or update it to match what the test expects more directly. |
|
I guess that makes sense, as I deleted the calculation of If I try to add it back in, ruff automatically removes it upon commit because it's an unused variable. I'm confused about copilot's reference to the logging on lines 1274+, as these no longer appear in the current commit. Is it using a previous commit as the basis for comparison in the test? |
|
@jploveless You are right that Copilot was looking at an old version (typical). All I'm doing is repeating Copilot to you. I might suggest working with the little Copilot built into GitHub (pretty sure it's free) to get all tests to pass here! The latest comment is pointing to the real issue: the Copilot diagnosis is stale and is comparing against older code, not the current PR state. What the current code and test are actually doing:
So the correct fix is not to switch to Suggested code pattern: unit_z = mesh["nv"][:, 2] / np.linalg.norm(mesh["nv"], axis=1)
n_downward = int(np.sum(unit_z < -WINDING_TOLERANCE))
if n_downward > 0 and np.sum(unit_z > WINDING_TOLERANCE) > 0:
logger.warning(
f"Mesh {config.mesh_filename} has mixed vertex winding: "
f"{n_downward} of {mesh['n_tde']} triangles have downward "
"normals, so the sign of their dip-slip rates ..."
)And the key point for the PR discussion:
So my recommendation is:
|
|
Got it: Copilot notes that |
Addressing comments left for me in #523. The main changes are:
enforce_ccw_tde_winding.py, which now writes updated.mshfiles for any meshes that contain any number of CW-wound elements (but does not create a new file if all elements are already CCW).mesh.pyI'm a little unclear about some of the issues flagged:
Maybe there was some cleanup of
enforce_ccw_tde_winding.pydone, but this statement is inaccurate. I did update the logging of this script, and I changed the end of it so that no updated file is written if there's no reordering of nodes, but it works as I'd expect for both uniformly CW meshes and mixed-winding meshes.I fixed the reported logging in
mesh.py, because it makes sense for no report about changing the file to be made when the nodes of the mesh dict are being modified, but I cannot find reference to this outdated warning inMeshConfigorceleri/operators.py. Again, maybe this is something Claude cleaned up in one of the #523 commits?