Skip to content

Commit

Permalink
showcases: avoid setting values with chained assignment in inet.scave…
Browse files Browse the repository at this point in the history
….plot to eliminate warnings
  • Loading branch information
adamgeorge309 committed Mar 22, 2024
1 parent feeb819 commit 2b1108b
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions python/inet/scave/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -688,9 +688,9 @@ def remove_zero_index_if_present(df):

if default_dict is not None:
for i in range(0,len(df)):
# if (df['additional_style'][i] == None):
# if (df.loc[i, 'additional_style'] == None):
logger.debug('adding default stuff')
df['additional_style'][i] = str(default_dict)
df.loc[i, 'additional_style'] = str(default_dict)

if style_tuple_list is not None:
for i in style_tuple_list:
Expand All @@ -710,16 +710,17 @@ def remove_zero_index_if_present(df):
# print(" value:", value)
# print(" match:", match.group())
logger.debug(f"MATCH FOUND:\n column: {column}\n value: {value}\n match: {match.group()}")
if (df['additional_style'][i] == None):
df['additional_style'][i] = str(style_tuple)
if (df.loc[i, 'additional_style'] == None):
df.loc[i, 'additional_style'] = str(style_tuple)
logger.debug(f"Adding style tuple: {str(style_tuple)}\n")
else:
orig_style_dict = ast.literal_eval(df['additional_style'][i]) # convert already added style to dict
orig_style_dict = ast.literal_eval(df.loc[i, 'additional_style']) # convert already added style to dict
logger.debug(f"Adding style tuple to existing style dict {orig_style_dict}, {type(orig_style_dict)}")
orig_style_dict.update(style_tuple) # add new style to dict
logger.debug(f"New style dict {orig_style_dict}, {type(orig_style_dict)}")
# if debug: add_separator()
df['additional_style'][i] = str(orig_style_dict) # add to dataframe as string
# df.loc[i, 'additional_style'] = str(orig_style_dict) # add to dataframe as string
df.loc[i, 'additional_style'] = str(orig_style_dict)

if order is not None:
# order the dataframe
Expand Down

0 comments on commit 2b1108b

Please sign in to comment.