diff options
author | Daniel Friesel <daniel.friesel@uos.de> | 2021-10-26 13:18:59 +0200 |
---|---|---|
committer | Daniel Friesel <daniel.friesel@uos.de> | 2021-10-26 13:18:59 +0200 |
commit | d6a19d976b699e0b230b2e6c8fdd11a0c832ae83 (patch) | |
tree | 5f098fbf57df782482914a71edc9df291474c355 /lib/utils.py | |
parent | ae8eef185bdfe54e12b9a6be142e8c1c7cdbf079 (diff) |
kconfig loader: load kconfig from its base directory
this ensures that source statements are handled correctly
Diffstat (limited to 'lib/utils.py')
-rw-r--r-- | lib/utils.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/utils.py b/lib/utils.py index 86829b3..10f0172 100644 --- a/lib/utils.py +++ b/lib/utils.py @@ -2,13 +2,25 @@ import json import numpy as np +import os import re import logging +from contextlib import contextmanager from sklearn.metrics import r2_score logger = logging.getLogger(__name__) +@contextmanager +def cd(path): + old_dir = os.getcwd() + os.chdir(path) + try: + yield + finally: + os.chdir(old_dir) + + class NpEncoder(json.JSONEncoder): def default(self, obj): if isinstance(obj, np.integer): |