Fix CUSTOM_OBJFUNC support in Python layer#2756
Fix CUSTOM_OBJFUNC support in Python layer#2756riddhi1228 wants to merge 12 commits intosu2code:developfrom
Conversation
- Register CUSTOM_OBJFUNC in historyMap - Normalize Custom_ObjFunc header to CUSTOM_OBJFUNC key - Prevent KeyError when evaluating custom objective functions Fixes su2code#2586
|
|
Fixed — the indentation error on line 92 has been corrected and black formatting applied. Thanks for catching it. |
|
The black formatting check is failing on historyMap.py even though black 22.6.0 reports no changes needed locally and the file is unchanged on the develop branch. This appears to be a pre-existing formatting issue in the repo rather than something introduced by this PR. Happy to investigate further if you can point me to what the CI is reformatting exactly. |
|
It's ok. The bigger issue is that this historyMap.py file should be generated, not edited manually. |
…n test - Add if (false) AddHistoryOutput for CUSTOM_OBJFUNC in CFlowOutput.cpp so updateHistoryMap.py registers it correctly - Fix updateHistoryMap.py parser to handle 'if (false) AddHistoryOutput' pattern - Fix multi-line AddHistoryOutput in CFlowIncOutput.cpp for BGS_ENTHALPY - Regenerate historyMap.py with CUSTOM_OBJFUNC entry - Fix regression test configs: rename AVG_TOTALTEMP to SURFACE_TOTAL_TEMPERATURE (AVG_TOTALTEMP was renamed in the C++ output layer but configs were never updated) Fixes su2code#2586
|
Hi @pcarruscag, updated the PR based on your feedback:
|
|
There are errors in the tests |
…ion calls - Skip AddHistoryOutput calls where field name contains '+' (dynamic calls) - Regenerate historyMap.py with correct entries, no malformed keys - CUSTOM_OBJFUNC now correctly registered
|
I ran updateHistoryMap.py as requested, but the script appears to produce a different historyMap.py than what's currently in develop — it adds 28 new keys and removes 14 existing ones (including RMS_ENTHALPY, RMS_TEMPERATURE) which breaks the regression tests. This seems to be a pre-existing issue where the generator is out of sync with the current codebase. The CUSTOM_OBJFUNC fix in CFlowOutput.cpp and updateHistoryMap.py parser changes are correct. Should I:
|
|
ok let's go back to what you had before then, I don't want to waste more time with python scripts |
Per maintainer feedback, reverting to direct edit approach. The updateHistoryMap.py generator is out of sync with the current codebase and produces incorrect output. Fixes su2code#2586
This PR fixes the handling of CUSTOM_OBJFUNC in the Python interface.
Problem
When evaluating custom objective functions, the Python layer could raise
a KeyError because CUSTOM_OBJFUNC was missing from historyMap.py
Solution
so updateHistoryMap.py registers it correctly
Fixes #2586