Skip to content

Commit

Permalink
remove check for non-leaf node
Browse files Browse the repository at this point in the history
fixes #4774 and #3589
  • Loading branch information
EpigeneMax committed Oct 2, 2024
1 parent 673c19c commit da0a4f4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
9 changes: 0 additions & 9 deletions packages/python/plotly/plotly/express/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1633,15 +1633,6 @@ def _check_dataframe_all_leaves(df):
"None entries cannot have not-None children",
df_sorted.iloc[null_row_index],
)
df_sorted[null_mask] = ""
row_strings = list(df_sorted.apply(lambda x: "".join(x), axis=1))
for i, row in enumerate(row_strings[:-1]):
if row_strings[i + 1] in row and (i + 1) in null_indices:
raise ValueError(
"Non-leaves rows are not permitted in the dataframe \n",
df_sorted.iloc[i + 1],
"is not a leaf.",
)


def process_dataframe_hierarchy(args):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,13 +320,25 @@ def test_sunburst_treemap_with_path_non_rectangular():
)
)
path = ["total", "regions", "sectors", "vendors"]
msg = "Non-leaves rows are not permitted in the dataframe"
with pytest.raises(ValueError, match=msg):
fig = px.sunburst(df, path=path, values="values")
fig = px.sunburst(df, path=path, values="values")
assert fig.data[0].values[-1] == np.sum(values)
df.loc[df["vendors"].isnull(), "sectors"] = "Other"
fig = px.sunburst(df, path=path, values="values")
assert fig.data[0].values[-1] == np.sum(values)

df = pd.DataFrame(
{
"status": ["NOT_YET_COMPLETED", "COMPLETED"],
"next_step": ["Wrapup", None],
"count": [1, 2],
}
)
fig = px.sunburst(df, path=["status", "next_step"], values="count")
assert fig.data[0].values[-1] == 3
df.loc[0, "status"] = "ACTIVE_NOT_YET_COMPLETED"
fig = px.sunburst(df, path=["status", "next_step"], values="count")
assert fig.data[0].values[-1] == 3


def test_pie_funnelarea_colorscale():
labels = ["A", "B", "C", "D"]
Expand Down

0 comments on commit da0a4f4

Please sign in to comment.