mdolab / pygeo

pyGeo provides geometric design variables and constraints suitable for gradient-based optimization.
https://mdolab-pygeo.readthedocs-hosted.com/en/latest/?badge=latest
Apache License 2.0
124 stars 55 forks source link

Fixing import errors, adding isort, cleaned up regression tests, and added unit tests for new import procedure. #180

Closed lamkina closed 1 year ago

lamkina commented 1 year ago

Purpose

This PR adds the following features:

  1. Improved import handling: The imports in DVGeometryESP, DVGeometryVSP, DVGeometryMulti, and DVGeometryCST all have optional dependencies required to function properly. Previously, pyGeo suppressed the import errors leaving users confused as to why their code wasn't working with pyGeo. In this PR, the import suppression was replaced in favor of logic control in the import statements that will throw an error if the user tries to initialize any of the classes listed above. Using this new procedure, the correct errors will be thrown with descriptions when the user tries to use one of the classes, without suppression.
  2. Added iSort: All of the import statements have been cleaned using the iSort package. To properly format the imports with iSort, make a link from the .isort.cfg file here to the root of the the pyGeo repo. I added iSort the the azure pipeline yaml file as well.
  3. Unit Test Cleaning: As part of the changes to imports, I also fixed the inconsistencies with the regression tests and standardized how we handle imports in the tests.
  4. Additional Unit Tests: I added unit tests that test the new import handling logic in the four DVGeometry classes listed above. These tests do not require the optional dependencies because they use mock modules instead of the actual modules.

This PR will close issue #176

Expected time until merged

This is a quality of life PR, so not urgent. I would estimate a few weeks or less to merge.

Type of change

Testing

To test the new changes, run the new unit tests with either pyTest or testflo.

Checklist

codecov[bot] commented 1 year ago

Codecov Report

Merging #180 (1740ed3) into main (94909eb) will increase coverage by 0.12%. The diff coverage is 95.95%.

@@            Coverage Diff             @@
##             main     #180      +/-   ##
==========================================
+ Coverage   64.61%   64.74%   +0.12%     
==========================================
  Files          47       47              
  Lines       11954    11941      -13     
==========================================
+ Hits         7724     7731       +7     
+ Misses       4230     4210      -20     
Impacted Files Coverage Δ
pygeo/constraints/circularityConstraint.py 79.71% <ø> (ø)
pygeo/constraints/colinearityConstraint.py 85.91% <ø> (ø)
pygeo/constraints/gearPostConstraint.py 16.36% <ø> (ø)
pygeo/constraints/locationConstraint.py 74.35% <ø> (ø)
pygeo/constraints/planarityConstraint.py 82.85% <ø> (ø)
pygeo/constraints/radiusConstraint.py 80.00% <ø> (ø)
pygeo/constraints/thicknessConstraint.py 82.50% <ø> (ø)
pygeo/geo_utils/bilinear_map.py 8.57% <ø> (ø)
pygeo/geo_utils/ffd_generation.py 83.89% <ø> (ø)
pygeo/geo_utils/file_io.py 37.83% <ø> (ø)
... and 35 more

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more