Skip to content

Tests : Created unit tests for _functions.py#169

Open
20086080 wants to merge 1 commit intocamUrban:mainfrom
20086080:Issue-146
Open

Tests : Created unit tests for _functions.py#169
20086080 wants to merge 1 commit intocamUrban:mainfrom
20086080:Issue-146

Conversation

@20086080
Copy link
Copy Markdown
Contributor

@20086080 20086080 commented May 7, 2026

Description

Add targeted unit tests for four utility functions in _functions.py that were previously flagged with # TEST comments.

These tests improve confidence in the mathematical utility layer of PteraSoftware by validating interpolation, centroid calculation, cosine spacing, and vector cross-product behavior using deterministic analytical cases.

Motivation

The flagged utility functions perform low-level numerical and geometric operations that are reused throughout the codebase. Although relatively compact, they contain mathematical logic where regressions or subtle numerical errors could propagate into higher-level aerodynamic calculations.

Adding focused unit tests improves maintainability and makes future refactoring safer by validating expected numerical behavior in isolation.

Relevant Issues

Closes Issue #146

Changes

New Tests

Added dedicated unit tests in test_functions.py for the following utility functions in _functions.py:

  • cosspace
  • numba_centroid_of_quadrilateral
  • numba_1d_explicit_cross
  • interp_between_points

Test Coverage

TestCosspace

  • Verifies minimum and maximum endpoints are included by default.
  • Verifies endpoint exclusion behavior when endpoint=False.
  • Verifies correct number of output points.
  • Verifies symmetry properties of cosine spacing.
  • Verifies single-point edge-case behavior.

TestNumbaCentroidOfQuadrilateral

  • Verifies centroid computation for a unit square.
  • Verifies translation consistency.
  • Verifies centroid calculation for nonplanar quadrilaterals.
  • Verifies identical-point edge case behavior.

TestNumba1dExplicitCross

  • Verifies analytically known cross-product results.
  • Verifies parallel vectors produce zero cross products.
  • Verifies agreement with numpy.cross.
  • Verifies empty-input behavior.

TestInterpBetweenPoints

  • Verifies linear interpolation between point pairs.
  • Verifies interpolation across multiple point pairs.
  • Verifies zero normalized spacing returns start points.
  • Verifies unit normalized spacing returns end points.

Testing Methodology

Tests are deterministic and numerically validated using analytical expectations and invariant-based checks.

The testing approach focuses on:

  • Known geometric and vector identities.
  • Numerical correctness using numpy.testing.assert_allclose.
  • Edge-case handling.
  • Reproducible fixed-input validation rather than randomized testing.

Note - Tight tolerances (atol=1e-14) were used where appropriate to ensure numerical precision.

Validation

  • Ran the full test suite locally to ensure no regressions.
  • All existing tests pass.

Dependency Updates

None

Change Magnitude

Minor: Adds focused unit tests for existing utility functions without modifying runtime behavior.

Checklist (check each item when completed or not applicable)

  • I am familiar with the current contribution guidelines.
  • PR description links all relevant issues and follows this template.
  • My branch is based on main and is up to date with the upstream main branch.
  • All calculations use S.I. units.
  • Code is formatted with black (line length = 88).
  • Code is well documented with block comments where appropriate.
  • Any external code, algorithms, or equations used have been cited in comments or docstrings.
  • All new modules, classes, functions, and methods have docstrings in reStructuredText format, and are formatted using docformatter (--in-place --black). See the style guide for type hints and docstrings for more details.
  • All new classes, functions, and methods in the pterasoftware package use type hints. See the style guide for type hints and docstrings for more details.
  • If any major functionality was added or significantly changed, I have added or updated tests in the tests package.
  • Code locally passes all tests in the tests package.
  • This PR passes the ReadTheDocs build check (this runs automatically with the other workflows).
  • This PR passes the black, codespell, and isort GitHub actions.
  • This PR passes the mypy GitHub action.
  • This PR passes all the tests GitHub actions.

@20086080 20086080 requested a review from camUrban as a code owner May 7, 2026 05:34
@codecov
Copy link
Copy Markdown

codecov Bot commented May 7, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.69%. Comparing base (81c73b3) to head (7a10118).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #169   +/-   ##
=======================================
  Coverage   91.69%   91.69%           
=======================================
  Files          35       35           
  Lines        6828     6828           
=======================================
  Hits         6261     6261           
  Misses        567      567           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant