Skip to content

Commit

Permalink
IFSBENCH-27: Updated references to external code.
Browse files Browse the repository at this point in the history
  • Loading branch information
johannesbulin committed Oct 11, 2024
1 parent 4f4f5c2 commit 5084cdd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
5 changes: 5 additions & 0 deletions ifsbench/runrecord.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@

def _h5store(filename, key, df, **kwargs):
"""
From the pandas cookbook: https://pandas.pydata.org/pandas-docs/dev/user_guide/cookbook.html.
More information on this here:
https://stackoverflow.com/questions/29129095/save-additional-attributes-in-pandas-dataframe/29130146#29130146
"""
store = pd.HDFStore(filename)
store.put(key, df)
Expand All @@ -31,6 +34,8 @@ def _h5store(filename, key, df, **kwargs):

def _h5load(store, key):
"""
From the pandas cookbook: https://pandas.pydata.org/pandas-docs/dev/user_guide/cookbook.html.
More information on this here:
https://stackoverflow.com/questions/29129095/save-additional-attributes-in-pandas-dataframe/29130146#29130146
"""
data = store[key]
Expand Down
14 changes: 8 additions & 6 deletions ifsbench/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,11 @@ def Timer(name=None):

def as_tuple(item, dtype=None, length=None):
"""
Force item to a tuple.
Partly extracted from: https://github.com/OP2/PyOP2/.
Force item to a tuple, even if `None` is provided.
"""
# Stop complaints about `type` in this function
# pylint: disable=redefined-builtin

# Empty list if we get passed None
if item is None:
t = ()
Expand All @@ -220,9 +221,9 @@ def as_tuple(item, dtype=None, length=None):
except (TypeError, NotImplementedError):
t = (item,) * (length or 1)
if length and not len(t) == length:
raise ValueError(f'Tuple needs to be of length {length}')
raise ValueError(f'Tuple needs to be of length {length: d}')
if dtype and not all(isinstance(i, dtype) for i in t):
raise TypeError('Items need to be of type {dtype}')
raise TypeError(f'Items need to be of type {dtype}')
return t


Expand Down Expand Up @@ -274,7 +275,8 @@ def auto_post_mortem_debugger(type, value, tb): # pylint: disable=redefined-bui
Activate by setting ``sys.excepthook = auto_post_mortem_debugger``
Adapted from https://code.activestate.com/recipes/65287/
Adapted from
https://code.activestate.com/recipes/65287-automatically-start-the-debugger-on-an-exception/
"""
is_interactive = hasattr(sys, 'ps1')
no_tty = not sys.stderr.isatty() or not sys.stdin.isatty() or not sys.stdout.isatty()
Expand Down

0 comments on commit 5084cdd

Please sign in to comment.