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
122 stars 54 forks source link

Fix shape handling in `nom_addGlobalDV` #194

Closed A-CGray closed 1 year ago

A-CGray commented 1 year ago

Purpose

This PR fixes the nom_addGlobalDV method in the MPhys wrapper so that it accepts scalar arguments to the value argument, just like the actual addGlobalDV method does. Previously this would fail because nom_addGlobalDV would try and evaluate len(value). The shape of the DV is now automatically extracted from the DV after it is added to the DVGeo object.

Also, I added a docstring because docs are nice.

Expected time until merged

1 week

Type of change

Testing

Checklist

codecov[bot] commented 1 year ago

Codecov Report

Merging #194 (5e2827f) into main (0e6b356) will decrease coverage by 0.02%. The diff coverage is 0.00%.

@@            Coverage Diff             @@
##             main     #194      +/-   ##
==========================================
- Coverage   64.88%   64.87%   -0.02%     
==========================================
  Files          47       47              
  Lines       11939    11941       +2     
==========================================
  Hits         7747     7747              
- Misses       4192     4194       +2     
Impacted Files Coverage Δ
pygeo/mphys/mphys_dvgeo.py 0.00% <0.00%> (ø)

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

A-CGray commented 1 year ago

I have no idea what is going on with the docs build

WARNING: autodoc: failed to import class 'mphys.mphys_dvgeo.OM_DVGEOCOMP' from module 'pygeo'; the following exception was raised:
Traceback (most recent call last):
  File "/home/docs/checkouts/readthedocs.org/user_builds/mdolab-pygeo/envs/194/lib/python3.7/site-packages/sphinx/ext/autodoc/importer.py", line 58, in import_module
    return importlib.import_module(modname)
  File "/home/docs/checkouts/readthedocs.org/user_builds/mdolab-pygeo/envs/194/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/docs/checkouts/readthedocs.org/user_builds/mdolab-pygeo/checkouts/194/pygeo/mphys/__init__.py", line 1, in <module>
    from .mphys_dvgeo import OM_DVGEOCOMP
  File "/home/docs/checkouts/readthedocs.org/user_builds/mdolab-pygeo/checkouts/194/pygeo/mphys/mphys_dvgeo.py", line 4, in <module>
    import openmdao.api as om
  File "/home/docs/checkouts/readthedocs.org/user_builds/mdolab-pygeo/envs/194/lib/python3.7/site-packages/openmdao/api.py", line 20, in <module>
    from openmdao.components.exec_comp import ExecComp
  File "/home/docs/checkouts/readthedocs.org/user_builds/mdolab-pygeo/envs/194/lib/python3.7/site-packages/openmdao/components/exec_comp.py", line 1266, in <module>
    if Version(scipy.__version__) >= Version("1.5.0"):
  File "/home/docs/checkouts/readthedocs.org/user_builds/mdolab-pygeo/envs/194/lib/python3.7/site-packages/packaging/version.py", line 195, in __init__
    match = self._regex.search(version)
TypeError: expected string or bytes-like object
eirikurj commented 1 year ago

Seems to be missing the mphys module here https://github.com/mdolab/pygeo/blob/0e6b35609cd79eaa9c3f163ef90f0cf20352c7b1/doc/conf.py#L33

eirikurj commented 1 year ago

Hmm, actually, reading this again I think its openmdao that is the issue. Let me push something quick.

A-CGray commented 1 year ago

Oh nice, thanks for fixing that. This is ready to go now @bernardopacini @hajdik