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

fix the argsort that caused inconsistent results due to machine precision errors #114

Closed anilyil closed 2 years ago

anilyil commented 2 years ago

Purpose

This PR addresses #89. The underlying cause was an argsort flipping the order of some entries due to the differences on the order of machine precision. By rounding the array to 8 significant figures before the sorting algorithm, we prevent this behavior.

This might cause some existing runscripts to get a different ordering but as we saw with the test case that started failing, this means that these runscripts were susceptible to this issue anyways. If it shows up, this change will show up as a shuffled ordering of the FFD control points in shape variables.

Type of change

Testing

We'll see what azure says

Checklist

codecov[bot] commented 2 years ago

Codecov Report

Merging #114 (f6a8fb4) into master (1344987) will decrease coverage by 1.09%. The diff coverage is 100.00%.

:exclamation: Current head f6a8fb4 differs from pull request most recent head 5c2b7de. Consider uploading reports for the commit 5c2b7de to get more accurate results

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #114      +/-   ##
==========================================
- Coverage   60.43%   59.34%   -1.10%     
==========================================
  Files          40       40              
  Lines        9671     9669       -2     
==========================================
- Hits         5845     5738     -107     
- Misses       3826     3931     +105     
Impacted Files Coverage Δ
pygeo/geo_utils/remove_duplicates.py 76.63% <100.00%> (-0.22%) :arrow_down:
pygeo/constraints/areaConstraint.py 51.63% <0.00%> (-24.84%) :arrow_down:
pygeo/constraints/DVCon.py 63.97% <0.00%> (-3.24%) :arrow_down:
pygeo/parameterization/DVGeo.py 65.67% <0.00%> (-0.36%) :arrow_down:
pygeo/geo_utils/file_io.py 65.78% <0.00%> (-0.23%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 1344987...5c2b7de. Read the comment docs.