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 fd104ad
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ This project adheres to [Semantic Versioning](http://semver.org/).

- Updated Plotly.js from version 2.35.0 to version 2.35.2. See the [plotly.js CHANGELOG](https://github.com/plotly/plotly.js/blob/master/CHANGELOG.md#2352----2024-09-10) for more information.

### Fixed
- Removed check for non-leaf nodes in dataframe for sunburst, treemap, and icicle [[#4776](https://github.com/plotly.plotly.py/pull/4776)]

## [5.24.0] - 2024-08-29

### Added
Expand Down
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] == 1
df.loc[0, "status"] = "ACTIVE_NOT_YET_COMPLETED"
fig = px.sunburst(df, path=["status", "next_step"], values="count")
assert fig.data[0].values[-1] == 1


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

0 comments on commit fd104ad

Please sign in to comment.