Skip to content

Commit

Permalink
fix FutureWarning: ChainedAssignmentError
Browse files Browse the repository at this point in the history
  • Loading branch information
quant12345 committed Dec 18, 2024
1 parent e27e90e commit cc2d3d1
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions tests/test_plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def test_line_color_fill_between(plot_df):
@pytest.mark.mpl_image_compare(**MPL_KWARGS)
def test_line_color_fill_between_interpolate(plot_df):
# designed to create the sawtooth behavior at a midpoint with missing data
df = pyam.IamDataFrame(plot_df.data.copy())
df = plot_df.data.copy()
fig, ax = plt.subplots(figsize=(8, 8))
newdata = [
"test_model1",
Expand All @@ -150,7 +150,7 @@ def test_line_color_fill_between_interpolate(plot_df):
2010,
3.50,
]
df.data.loc[len(df.data) - 1] = newdata
df.loc[len(df) - 1] = newdata
newdata = [
"test_model1",
"test_scenario1",
Expand All @@ -160,7 +160,7 @@ def test_line_color_fill_between_interpolate(plot_df):
2012,
3.50,
]
df.data.loc[len(df.data)] = newdata
df.loc[len(df)] = newdata
newdata = [
"test_model1",
"test_scenario1",
Expand All @@ -170,7 +170,10 @@ def test_line_color_fill_between_interpolate(plot_df):
2015,
3.50,
]
df.data.loc[len(df.data) + 1] = newdata
df.loc[len(df) + 1] = newdata
columns_ = ['model', 'scenario', 'region', 'variable', 'unit', 'year']
df = df.drop_duplicates(subset=columns_)
df = pyam.IamDataFrame(df)
df.plot(ax=ax, color="model", fill_between=True, legend=True)
return fig

Expand Down

0 comments on commit cc2d3d1

Please sign in to comment.