Skip to content

Commit

Permalink
Delete obsolete _robust_bool and get_parent_attr (#265)
Browse files Browse the repository at this point in the history
  • Loading branch information
spencerkclark authored and Spencer Hill committed Apr 4, 2018
1 parent 8f4c34e commit f240c72
Showing 1 changed file with 0 additions and 30 deletions.
30 changes: 0 additions & 30 deletions aospy/utils/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,6 @@
import numpy as np


def _robust_bool(obj):
try:
return bool(obj)
except ValueError:
return obj.any()


def get_parent_attr(obj, attr, strict=False):
"""Search recursively through an object and its parent for an attribute.
Check if the object has the given attribute and it is non-empty. If not,
check each parent object for the attribute and use the first one found.
"""
attr_val = getattr(obj, attr, False)
if _robust_bool(attr_val):
return attr_val

else:
for parent in ('parent', 'run', 'model', 'proj'):
parent_obj = getattr(obj, parent, False)
if parent_obj:
return get_parent_attr(parent_obj, attr, strict=strict)

if strict:
raise AttributeError('Attribute %s not found in parent of %s'
% (attr, obj))
else:
return None


def data_in_label(intvl_in, dtype_in_time, dtype_in_vert=False):
"""Create string label specifying the input data of a calculation."""
intvl_lbl = intvl_in
Expand Down

0 comments on commit f240c72

Please sign in to comment.