Skip to content

Reorganize Python unit tests for modmesh::universe#705

Merged
yungyuc merged 2 commits intosolvcon:masterfrom
yungyuc:refactor/test-universe
Mar 29, 2026
Merged

Reorganize Python unit tests for modmesh::universe#705
yungyuc merged 2 commits intosolvcon:masterfrom
yungyuc:refactor/test-universe

Conversation

@yungyuc
Copy link
Copy Markdown
Member

@yungyuc yungyuc commented Mar 28, 2026

Python unit test cases for C++ modmesh::universe scattered in test_universe.py, test_polygon3d.py, and test_universe_trap.py, and were not organized well. This PR reorganize the tests to test_universe_shape0d.py, test_universe_shape1d.py, and test_universe_shape2d.py.

Note

There are not unit tests for 3-D shapes yet. Then file test_universe_shape3d.py is not created.

Factor out the tests in test_universe.py to distinct files:

  • test_universe_shape0d.py:
    • BersteinTB, BersteinPolynomialTC, BernsteinInterpolationTC
    • Point3dTB, Point3dFp32TC, Point3dFp64TC
  • test_universe_shape1d.py:
    • Segment3dTB, Segment3dFp32TC, Segment3dFp64TC
    • Bezier3dTB, Bezier3dFp32TC, Segment3dFp64TC
    • SegmentPadTB, SegmentPadFp32TC, SegmentPadFp64TC
    • CurvePadTB, CurvePadFp32TC, CurvePadFp64TC
  • test_universe_shape2d.py
    • Triangle3dTB, Triangle3dFp32TC, Triangle3dFp64TC
    • TrianglePadTB, TrianglePadFp32TC, TrianglePadFp64TC

Merge 2-D shape test cases to test_universe_shape2d.py:

  • From test_polygon3d.py:
    • Polygon3dTB, Polygon3dFp32TC, Polygon3dFp64TC
  • Form test_universe_trap.py:
    • TrapezoidalDecomposerTB, TrapezoidalDecomposerFp32TC, TrapezoidalDecomposerFp64TC

The tests that remains in test_universe.py:

  • WorldTB, WorldFp32TC, WorldFp64TC

I have manually diff'ed to confirm the moved code is identical.


Note

The prompts used through clion claude plugin are:

  • Split the tests in test_universe.py into test_universe_shape0d.py,
    test_universe_shape1d.py, test_universe_shape2d.py,
    test_universe_shape3d.py based on the wrapped C++ classes that are wrapped
    in wrap_shape0d.cpp, wrap_shape1d.cpp, wrap_shape2d.cpp,
    wrap_shape3d.cpp under cpp/modmesh/universe/pymod/.

@yungyuc yungyuc self-assigned this Mar 28, 2026
@yungyuc yungyuc added refactor Change code without changing tests geometry Geometry entities and manipulation labels Mar 28, 2026
@yungyuc yungyuc force-pushed the refactor/test-universe branch from d924e27 to 0693f66 Compare March 28, 2026 15:46
yungyuc added 2 commits March 28, 2026 23:48
* `test_universe_shape0d.py`:
  * `BersteinTB`, `BersteinPolynomialTC`, `BernsteinInterpolationTC`
  * `Point3dTB`, `Point3dFp32TC`, `Point3dFp64TC`
* `test_universe_shape1d.py`:
  * `Segment3dTB`, `Segment3dFp32TC`, `Segment3dFp64TC`
  * `Bezier3dTB`, `Bezier3dFp32TC`, `Segment3dFp64TC`
  * `SegmentPadTB`, `SegmentPadFp32TC`, `SegmentPadFp64TC`
  * `CurvePadTB`, `CurvePadFp32TC`, `CurvePadFp64TC`
* `test_universe_shape2d.py`
  * `Triangle3dTB`, `Triangle3dFp32TC`, `Triangle3dFp64TC`
  * `TrianglePadTB`, `TrianglePadFp32TC`, `TrianglePadFp64TC`

There is not unit tests for 3-D shapes yet.

The prompts used through clion claude plugin are:
- Split the tests in `test_universe.py` into `test_universe_shape0d.py`,
  `test_universe_shape1d.py`, `test_universe_shape2d.py`,
  `test_universe_shape3d.py` based on the wrapped C++ classes that are wrapped
  in `wrap_shape0d.cpp`, `wrap_shape1d.cpp`, `wrap_shape2d.cpp`,
  `wrap_shape3d.cpp` under `cpp/modmesh/universe/pymod/`.
…erse_shape2d.py`

* From `test_polygon3d.py`:
  * `Polygon3dTB`, `Polygon3dFp32TC`, `Polygon3dFp64TC`
* Form `test_universe_trap.py`:
  * `TrapezoidalDecomposerTB`, `TrapezoidalDecomposerFp32TC`, `TrapezoidalDecomposerFp64TC`
@yungyuc yungyuc force-pushed the refactor/test-universe branch from 0693f66 to d82d036 Compare March 28, 2026 15:48
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Contents in this file test_universe_shape0d.py come from test_universe.py:

  • BersteinTB, BersteinPolynomialTC, BernsteinInterpolationTC
  • Point3dTB, Point3dFp32TC, Point3dFp64TC

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Contents in this file test_universe_shape1d.py come from test_universe.py:

  • Segment3dTB, Segment3dFp32TC, Segment3dFp64TC
  • Bezier3dTB, Bezier3dFp32TC, Segment3dFp64TC
  • SegmentPadTB, SegmentPadFp32TC, SegmentPadFp64TC
  • CurvePadTB, CurvePadFp32TC, CurvePadFp64TC

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Contents in this file test_universe_shape2d.py come from:

  • Extracted from test_universe.py:
    • Triangle3dTB, Triangle3dFp32TC, Triangle3dFp64TC
    • TrianglePadTB, TrianglePadFp32TC, TrianglePadFp64TC
  • Moved from test_polygon3d.py:
    • Polygon3dTB, Polygon3dFp32TC, Polygon3dFp64TC
  • Moved test_universe_trap.py:
    • TrapezoidalDecomposerTB, TrapezoidalDecomposerFp32TC, TrapezoidalDecomposerFp64TC

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test_universe_trap.py contents are moved to test_universe_shape0d.py.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests that remains in this file test_universe.py:

  • WorldTB, WorldFp32TC, WorldFp64TC

Tests factor out from this file test_universe.py:

  • To test_universe_shape0d.py:
    • BersteinTB, BersteinPolynomialTC, BernsteinInterpolationTC
    • Point3dTB, Point3dFp32TC, Point3dFp64TC
  • To test_universe_shape1d.py:
    • Segment3dTB, Segment3dFp32TC, Segment3dFp64TC
    • Bezier3dTB, Bezier3dFp32TC, Segment3dFp64TC
    • SegmentPadTB, SegmentPadFp32TC, SegmentPadFp64TC
    • CurvePadTB, CurvePadFp32TC, CurvePadFp64TC
  • To test_universe_shape2d.py
    • Triangle3dTB, Triangle3dFp32TC, Triangle3dFp64TC
    • TrianglePadTB, TrianglePadFp32TC, TrianglePadFp64TC

@yungyuc yungyuc marked this pull request as ready for review March 29, 2026 00:33
@yungyuc yungyuc moved this from Todo to In Progress in pilot 2D drawing basic GUI Mar 29, 2026
@yungyuc yungyuc requested review from c1ydehhx and tigercosmos March 29, 2026 00:34
@yungyuc
Copy link
Copy Markdown
Member Author

yungyuc commented Mar 29, 2026

I am merging the PR. @tigercosmos @c1ydehhx please take a look.

@yungyuc yungyuc merged commit 3b6d9a6 into solvcon:master Mar 29, 2026
14 checks passed
@github-project-automation github-project-automation bot moved this from In Progress to Done in pilot 2D drawing basic GUI Mar 29, 2026
@yungyuc yungyuc deleted the refactor/test-universe branch March 29, 2026 00:35
@yungyuc yungyuc linked an issue Mar 29, 2026 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

geometry Geometry entities and manipulation refactor Change code without changing tests

Projects

Development

Successfully merging this pull request may close these issues.

Make a prototype for drawing 2D graphics

1 participant