Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docstring and typing fixes #54

Merged
merged 1 commit into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions sankee/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@

import ee
import pandas as pd
import plotly.graph_objects as go

from sankee import themes
from sankee.plotting import sankify
from sankee.plotting import SankeyPlot, sankify


class Dataset:
Expand Down Expand Up @@ -113,7 +112,7 @@ def sankify(
exclude: None = None,
label_type: str = "class",
theme: str | themes.Theme = themes.DEFAULT,
) -> go.Figure:
) -> SankeyPlot:
"""
Generate an interactive Sankey plot showing land cover change over time from a series of
years in the dataset.
Expand All @@ -124,11 +123,6 @@ def sankify(
The years to include in the plot. Select at least two unique years.
region : ee.Geometry
A region to generate samples within. The region must overlap all images.
exclude : list[int], default None
An optional list of pixel values to exclude from the plot. Excluded values must be raw
pixel values rather than class labels. This can be helpful if the region is dominated by
one or more unchanging classes and the goal is to visualize changes in smaller classes.
No-data classes are always excluded automatically.
max_classes : int, default None
If a value is provided, small classes will be removed until max_classes remain. Class
size is calculated based on total times sampled in the time series.
Expand All @@ -150,11 +144,14 @@ def sankify(
Selecting "class" will use the class label, "percent" will use the proportion of
sampled pixels in each class, and "count" will use the number of sampled pixels in each
class.
theme : str or Theme
The theme to apply to the Sankey diagram. Can be the name of a built-in theme
(e.g. "d3") or a custom `sankee.Theme` object.

Returns
-------
plotly.graph_objs._figure.Figure
An interactive Sankey plot.
SankeyPlot
An interactive Sankey plot widget.
"""
if len(years) < 2:
raise ValueError("Select at least two years.")
Expand Down
6 changes: 3 additions & 3 deletions sankee/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def sankify(
seed: int = 0,
label_type: None | str = "class",
theme: str | themes.Theme = "default",
) -> go.Figure:
) -> SankeyPlot:
"""
Generate an interactive Sankey plot showing land cover change over time from a series of images.

Expand Down Expand Up @@ -87,8 +87,8 @@ def sankify(

Returns
-------
plotly.graph_objs._figure.Figure
An interactive Sankey plot.
SankeyPlot
An interactive Sankey plot widget.
"""
if region is None:
region = image_list[0].geometry()
Expand Down
Loading