Skip to content

Commit

Permalink
Merge remote-tracking branch 'simcenter/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
ioannis-vm committed May 7, 2024
2 parents 119dabe + bab6c24 commit 5cbe940
Show file tree
Hide file tree
Showing 22 changed files with 174 additions and 367 deletions.
3 changes: 1 addition & 2 deletions pelicun/assessment.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ def scale_factor(self, unit):
-------
float
Scale factor
Raises
------
ValueError
Expand All @@ -278,7 +278,6 @@ def scale_factor(self, unit):
"""

if unit is not None:

if unit in self.unit_conversion_factors:
scale_factor = self.unit_conversion_factors[unit]

Expand Down
2 changes: 1 addition & 1 deletion pelicun/auto.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def auto_populate(
If the configuration dictionary does not contain necessary
asset information under 'GeneralInformation'.
"""

# try to get the AIM attributes
AIM = config.get('GeneralInformation', None)
if AIM is None:
Expand Down
15 changes: 1 addition & 14 deletions pelicun/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,9 +460,7 @@ def log_file(self, value):
self._log_file = None

else:

try:

filepath = Path(value).resolve()

self._log_file = str(filepath)
Expand Down Expand Up @@ -530,7 +528,6 @@ def msg(self, msg='', prepend_timestamp=True, prepend_blank_space=True):
msg_lines = msg.split('\n')

for msg_i, msg_line in enumerate(msg_lines):

if prepend_timestamp and (msg_i == 0):
formatted_msg = '{} {}'.format(
datetime.now().strftime(self.log_time_format), msg_line
Expand Down Expand Up @@ -772,17 +769,14 @@ def convert_to_SimpleIndex(data, axis=0, inplace=False):
"""

if axis in {0, 1}:

if inplace:
data_mod = data
else:
data_mod = data.copy()

if axis == 0:

# only perform this if there are multiple levels
if data.index.nlevels > 1:

simple_name = '-'.join(
[n if n is not None else "" for n in data.index.names]
)
Expand All @@ -794,10 +788,8 @@ def convert_to_SimpleIndex(data, axis=0, inplace=False):
data_mod.index.name = simple_name

elif axis == 1:

# only perform this if there are multiple levels
if data.columns.nlevels > 1:

simple_name = '-'.join(
[n if n is not None else "" for n in data.columns.names]
)
Expand Down Expand Up @@ -848,7 +840,6 @@ def convert_to_MultiIndex(data, axis=0, inplace=False):
if ((axis == 0) and (isinstance(data.index, pd.MultiIndex))) or (
(axis == 1) and (isinstance(data.columns, pd.MultiIndex))
):

# if yes, return the data unchanged
return data

Expand All @@ -864,7 +855,6 @@ def convert_to_MultiIndex(data, axis=0, inplace=False):
max_lbl_len = np.max([len(labels) for labels in index_labels])

for l_i, labels in enumerate(index_labels):

if len(labels) != max_lbl_len:
labels += [
'',
Expand All @@ -874,7 +864,6 @@ def convert_to_MultiIndex(data, axis=0, inplace=False):
index_labels = np.array(index_labels)

if index_labels.shape[1] > 1:

if inplace:
data_mod = data
else:
Expand Down Expand Up @@ -932,9 +921,7 @@ def show_matrix(data, use_describe=False):
If False, simply prints the matrix as is.
"""
if use_describe:
pp.pprint(
pd.DataFrame(data).describe(percentiles=[0.01, 0.1, 0.5, 0.9, 0.99])
)
pp.pprint(pd.DataFrame(data).describe(percentiles=[0.01, 0.1, 0.5, 0.9, 0.99]))
else:
pp.pprint(pd.DataFrame(data))

Expand Down
Loading

0 comments on commit 5cbe940

Please sign in to comment.