-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixing logging level and option issues (#60)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Lucas Boucinha <[email protected]> Co-authored-by: Revathy Venugopal <[email protected]>
- Loading branch information
1 parent
f3aa544
commit a1062f5
Showing
4 changed files
with
60 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import os | ||
|
||
from pytwin import PYTWIN_LOGGING_OPT_NOLOGGING, TwinModel | ||
from pytwin.settings import get_pytwin_log_file, modify_pytwin_logging | ||
|
||
COUPLE_CLUTCHES_FILEPATH = os.path.join(os.path.dirname(__file__), "data", "CoupleClutches_22R2_other.twin") | ||
UNIT_TEST_WD = os.path.join(os.path.dirname(__file__), "unit_test_wd") | ||
|
||
|
||
def reinit_settings(): | ||
import shutil | ||
|
||
from pytwin.settings import reinit_settings_for_unit_tests | ||
|
||
reinit_settings_for_unit_tests() | ||
if os.path.exists(UNIT_TEST_WD): | ||
shutil.rmtree(UNIT_TEST_WD) | ||
return UNIT_TEST_WD | ||
|
||
|
||
class TestTwinModelLogging: | ||
def test_twin_model_no_logging(self): | ||
# Init unit test | ||
reinit_settings() | ||
# Twin Model does not log anything if PYTWIN_LOGGING_OPT_NOLOGGING | ||
modify_pytwin_logging(new_option=PYTWIN_LOGGING_OPT_NOLOGGING) | ||
log_file = get_pytwin_log_file() | ||
assert log_file is None | ||
twin = TwinModel(model_filepath=COUPLE_CLUTCHES_FILEPATH) | ||
twin.initialize_evaluation() | ||
for i in range(100): | ||
new_inputs = {"Clutch1_in": 1.0 * i / 100, "Clutch2_in": 1.0 * i / 100} | ||
twin.evaluate_step_by_step(step_size=0.01, inputs=new_inputs) | ||
temp_dir = twin.model_temp | ||
assert os.path.exists(temp_dir) | ||
assert len(os.listdir(temp_dir)) == 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters