From 72cb40c98d991c6cca6e57816f6e5b7815693903 Mon Sep 17 00:00:00 2001 From: Jon Duckworth Date: Mon, 14 Jun 2021 20:36:32 -0400 Subject: [PATCH 01/12] Update docstrings for version extension --- docs/api.rst | 31 ++++----- pystac/extensions/version.py | 122 ++++++++++++++++++++++++----------- 2 files changed, 102 insertions(+), 51 deletions(-) diff --git a/docs/api.rst b/docs/api.rst index 0f3624742..a89bbed62 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -484,7 +484,7 @@ SingleFileSTACCatalogExt Version Extension ----------------- -Implements the :stac-ext:`Version Extension `. +Implements the :stac-ext:`Versioning Indicators Extension `. VersionRelType ~~~~~~~~~~~~~~ @@ -493,25 +493,26 @@ VersionRelType :members: :show-inheritance: -VersionCollectionExt -~~~~~~~~~~~~~~~~~~~~ +VersionExtension +~~~~~~~~~~~~~~~~ -**TEMPORARILY REMOVED** +.. autoclass:: pystac.extensions.version.VersionExtension + :members: + :show-inheritance: -.. .. autoclass:: pystac.extensions.version.VersionCollectionExt -.. :members: -.. :undoc-members: -.. :show-inheritance: +CollectionVersionExtension +~~~~~~~~~~~~~~~~~~~~~~~~~~ -VersionItemExt -~~~~~~~~~~~~~~ +.. autoclass:: pystac.extensions.version.CollectionVersionExtension + :members: + :show-inheritance: -**TEMPORARILY REMOVED** +ItemVersionExtension +~~~~~~~~~~~~~~~~~~~~ -.. .. autoclass:: pystac.extensions.version.VersionItemExt -.. :members: -.. :undoc-members: -.. :show-inheritance: +.. autoclass:: pystac.extensions.version.ItemVersionExtension + :members: + :show-inheritance: View Geometry Extension ----------------------- diff --git a/pystac/extensions/version.py b/pystac/extensions/version.py index ffa2ee3c3..028599eaa 100644 --- a/pystac/extensions/version.py +++ b/pystac/extensions/version.py @@ -1,6 +1,6 @@ -"""Implements the Version extension. +"""Implements the Versioning Indicators extension. -https://github.com/stac-extensions/version +:stac-ext:version """ from enum import Enum from pystac.utils import get_required, map_opt @@ -50,18 +50,19 @@ class VersionExtension( PropertiesExtension, ExtensionManagementMixin[Union[pystac.Collection, pystac.Item]], ): - """VersionItemExt extends Item to add version and deprecated properties - along with links to the latest, predecessor, and successor Items. + """An abstract class that can be used to extend the properties of an + :class:`~pystac.Item` or :class:`~pystac.Collection` with properties from the + :stac-ext:`Versioning Indicators Extension `. This class is generic over + the type of STAC Object to be extended (e.g. :class:`~pystac.Item`, + :class:`~pystac.Collection`). - Args: - item : The item to be extended. + To create a concrete instance of :class:`VersionExtension`, use the + :meth:`VersionExtension.ext` method. For example: - Attributes: - item : The item that is being extended. + .. code-block:: python - Note: - Using VersionItemExt to directly wrap an item will add the 'version' - extension ID to the item's stac_extensions. + >>> item: pystac.Item = ... + >>> version_ext = VersionExtension.ext(item) """ obj: pystac.STACObject @@ -77,16 +78,18 @@ def apply( predecessor: Optional[T] = None, successor: Optional[T] = None, ) -> None: - """Applies version extension properties to the extended Item. + """Applies version extension properties to the extended :class:`~pystac.Item` or + :class:`~pystac.Collection`. Args: version : The version string for the item. - deprecated : Optional flag set to True if an Item is - deprecated with the potential to be removed. Defaults to false - if not present. - latest : Item with the latest (e.g., current) version. - predecessor : Item with the previous version. - successor : Item with the next most recent version. + deprecated : Optional flag set to ``True`` if an Item is deprecated with the + potential to be removed. Defaults to ``False`` if not present. + latest : Item representing the latest (e.g., current) version. + predecessor : Item representing the resource containing the predecessor + version in the version history. + successor : Item representing the resource containing the successor version + in the version history. """ self.version = version if deprecated is not None: @@ -100,11 +103,8 @@ def apply( @property def version(self) -> str: - """Get or sets a version string of the item. - - Returns: - str - """ + """Get or sets a version string of the :class:`~pystac.Item` or + :class:`pystac.Collection`.""" return get_required(self._get_property(VERSION, str), self, VERSION) @version.setter @@ -113,7 +113,14 @@ def version(self, v: str) -> None: @property def deprecated(self) -> Optional[bool]: - """Get or sets is the item is deprecated.""" + """Get or sets whether the item is deprecated. + + A value of ``True`` specifies that the Collection or Item is deprecated with the + potential to be removed. It should be transitioned out of usage as soon as + possible and users should refrain from using it in new projects. A link with + relation type ``latest-version`` SHOULD be added to the links and MUST refer to + the resource that can be used instead. + """ return self._get_property(DEPRECATED, bool) @deprecated.setter @@ -122,50 +129,66 @@ def deprecated(self, v: Optional[bool]) -> None: @property def latest(self) -> Optional[T]: - """Get or sets the most recent version.""" + """Gets or sets the :class:`~pystac.Link` to the :class:`~pystac.Item` + representing the most recent version. + """ return map_opt( lambda x: cast(T, x), next(iter(self.obj.get_stac_objects(VersionRelType.LATEST)), None), ) @latest.setter - def latest(self, item: Optional[T]) -> None: + def latest(self, item_or_collection: Optional[T]) -> None: self.obj.clear_links(VersionRelType.LATEST) - if item is not None: + if item_or_collection is not None: self.obj.add_link( - pystac.Link(VersionRelType.LATEST, item, pystac.MediaType.JSON) + pystac.Link( + VersionRelType.LATEST, item_or_collection, pystac.MediaType.JSON + ) ) @property def predecessor(self) -> Optional[T]: - """Get or sets the previous item.""" + """Gets or sets the :class:`~pystac.Link` to the :class:`~pystac.Item` + representing the resource containing the predecessor version in the version + history. + """ return map_opt( lambda x: cast(T, x), next(iter(self.obj.get_stac_objects(VersionRelType.PREDECESSOR)), None), ) @predecessor.setter - def predecessor(self, item: Optional[T]) -> None: + def predecessor(self, item_or_collection: Optional[T]) -> None: self.obj.clear_links(VersionRelType.PREDECESSOR) - if item is not None: + if item_or_collection is not None: self.obj.add_link( - pystac.Link(VersionRelType.PREDECESSOR, item, pystac.MediaType.JSON) + pystac.Link( + VersionRelType.PREDECESSOR, + item_or_collection, + pystac.MediaType.JSON, + ) ) @property def successor(self) -> Optional[T]: - """Get or sets the next item.""" + """Gets or sets the :class:`~pystac.Link` to the :class:`~pystac.Item` + representing the resource containing the successor version in the version + history. + """ return map_opt( lambda x: cast(T, x), next(iter(self.obj.get_stac_objects(VersionRelType.SUCCESSOR)), None), ) @successor.setter - def successor(self, item: Optional[T]) -> None: + def successor(self, item_or_collection: Optional[T]) -> None: self.obj.clear_links(VersionRelType.SUCCESSOR) - if item is not None: + if item_or_collection is not None: self.obj.add_link( - pystac.Link(VersionRelType.SUCCESSOR, item, pystac.MediaType.JSON) + pystac.Link( + VersionRelType.SUCCESSOR, item_or_collection, pystac.MediaType.JSON + ) ) @classmethod @@ -174,6 +197,16 @@ def get_schema_uri(cls) -> str: @staticmethod def ext(obj: T) -> "VersionExtension[T]": + """Extends the given STAC Object with properties from the :stac-ext:`Versioning + Indicators Extension `. + + This extension can be applied to instances of :class:`~pystac.Item` or + :class:`~pystac.Collection`. + + Raises: + + pystac.ExtensionTypeError : If an invalid object type is passed. + """ if isinstance(obj, pystac.Collection): return cast(VersionExtension[T], CollectionVersionExtension(obj)) if isinstance(obj, pystac.Item): @@ -185,6 +218,15 @@ def ext(obj: T) -> "VersionExtension[T]": class CollectionVersionExtension(VersionExtension[pystac.Collection]): + """A concrete implementation of :class:`VersionExtension` on a + :class:`~pystac.Collection` that extends the properties of the Collection to + include properties defined in the :stac-ext:`Versioning Indicators Extension + `. + + This class should generally not be instantiated directly. Instead, call + :meth:`VersionExtension.ext` on an :class:`~pystac.Collection` to extend it. + """ + def __init__(self, collection: pystac.Collection): self.collection = collection self.properties = collection.extra_fields @@ -196,6 +238,14 @@ def __repr__(self) -> str: class ItemVersionExtension(VersionExtension[pystac.Item]): + """A concrete implementation of :class:`VersionExtension` on an + :class:`~pystac.Item` that extends the properties of the Item to include properties + defined in the :stac-ext:`Versioning Indicators Extension `. + + This class should generally not be instantiated directly. Instead, call + :meth:`VersionExtension.ext` on an :class:`~pystac.Item` to extend it. + """ + def __init__(self, item: pystac.Item): self.item = item self.properties = item.properties From e812001f3f59db45a7757f36726d57e711eef183 Mon Sep 17 00:00:00 2001 From: Jon Duckworth Date: Mon, 14 Jun 2021 20:36:32 -0400 Subject: [PATCH 02/12] Fix variable name in EO example --- pystac/extensions/eo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pystac/extensions/eo.py b/pystac/extensions/eo.py index 2c0928136..d266296b1 100644 --- a/pystac/extensions/eo.py +++ b/pystac/extensions/eo.py @@ -289,7 +289,7 @@ class EOExtension( .. code-block:: python >>> item: pystac.Item = ... - >>> view_ext = ViewExtension.ext(item) + >>> eo_ext = EOExtension.ext(item) """ def apply( From be5c2649e47707e61c8f676bbdf6877743e8aeef Mon Sep 17 00:00:00 2001 From: Jon Duckworth Date: Mon, 14 Jun 2021 20:36:32 -0400 Subject: [PATCH 03/12] Update docstrings for File Extension --- pystac/extensions/file.py | 88 +++++++++++++++++++++------------------ 1 file changed, 48 insertions(+), 40 deletions(-) diff --git a/pystac/extensions/file.py b/pystac/extensions/file.py index 5f44282d1..0f756a3e5 100644 --- a/pystac/extensions/file.py +++ b/pystac/extensions/file.py @@ -24,10 +24,11 @@ SCHEMA_URI = "https://stac-extensions.github.io/file/v1.0.0/schema.json" -DATA_TYPE_PROP = "file:data_type" -SIZE_PROP = "file:size" -NODATA_PROP = "file:nodata" -CHECKSUM_PROP = "file:checksum" +PREFIX = "file:" +DATA_TYPE_PROP = PREFIX + "data_type" +SIZE_PROP = PREFIX + "size" +NODATA_PROP = PREFIX + "nodata" +CHECKSUM_PROP = PREFIX + "checksum" class FileDataType(str, enum.Enum): @@ -55,18 +56,19 @@ def __str__(self) -> str: class FileExtension( Generic[T], PropertiesExtension, ExtensionManagementMixin[pystac.Item] ): - """FileItemExt is the extension of the Item in the file extension which - adds file related details such as checksum, data type and size for assets. + """An abstract class that can be used to extend the properties of an + :class:`~pystac.Item` or :class:`~pystac.Asset` with properties from the + :stac-ext:`File Info Extension `. This class is generic over the type of + STAC Object to be extended (e.g. :class:`~pystac.Item`, + :class:`~pystac.Asset`). - Args: - item : The item to be extended. + To create a concrete instance of :class:`FileExtension`, use the + :meth:`FileExtension.ext` method. For example: - Attributes: - item : The Item that is being extended. + .. code-block:: python - Note: - Using FileItemExt to directly wrap an item will add the 'file' extension ID to - the item's stac_extensions. + >>> item: pystac.Item = ... + >>> file_ext = FileExtension.ext(item) """ def apply( @@ -92,11 +94,7 @@ def apply( @property def data_type(self) -> Optional[FileDataType]: - """Get or sets the data_type of the file. - - Returns: - FileDataType - """ + """Get or sets the data_type of the file.""" return map_opt( lambda s: FileDataType(s), self._get_property(DATA_TYPE_PROP, str) ) @@ -107,11 +105,7 @@ def data_type(self, v: Optional[FileDataType]) -> None: @property def size(self) -> Optional[int]: - """Get or sets the size in bytes of the file - - Returns: - int or None - """ + """Get or sets the size in bytes of the file.""" return self._get_property(SIZE_PROP, int) @size.setter @@ -120,7 +114,7 @@ def size(self, v: Optional[int]) -> None: @property def nodata(self) -> Optional[List[Any]]: - """Get or sets the no data values""" + """Get or sets the no data values.""" return self._get_property(NODATA_PROP, List[Any]) @nodata.setter @@ -129,11 +123,7 @@ def nodata(self, v: Optional[List[Any]]) -> None: @property def checksum(self) -> Optional[str]: - """Get or sets the checksum - - Returns: - str or None - """ + """Get or sets the checksum""" return self._get_property(CHECKSUM_PROP, str) @checksum.setter @@ -146,6 +136,16 @@ def get_schema_uri(cls) -> str: @staticmethod def ext(obj: T) -> "FileExtension[T]": + """Extends the given STAC Object with properties from the :stac-ext:`File Info + Extension `. + + This extension can be applied to instances of :class:`~pystac.Item` or + :class:`~pystac.Asset`. + + Raises: + + pystac.ExtensionTypeError : If an invalid object type is passed. + """ if isinstance(obj, pystac.Item): return cast(FileExtension[T], ItemFileExtension(obj)) elif isinstance(obj, pystac.Asset): @@ -161,6 +161,14 @@ def summaries(obj: pystac.Collection) -> "SummariesFileExtension": class ItemFileExtension(FileExtension[pystac.Item]): + """A concrete implementation of :class:`FileExtension` on an :class:`~pystac.Item` + that extends the properties of the Item to include properties defined in the + :stac-ext:`File Info Extension `. + + This class should generally not be instantiated directly. Instead, call + :meth:`FileExtension.ext` on an :class:`~pystac.Item` to extend it. + """ + def __init__(self, item: pystac.Item): self.item = item self.properties = item.properties @@ -170,6 +178,14 @@ def __repr__(self) -> str: class AssetFileExtension(FileExtension[pystac.Asset]): + """A concrete implementation of :class:`FileExtension` on an :class:`~pystac.Asset` + that extends the Asset fields to include properties defined in the + :stac-ext:`File Info Extension `. + + This class should generally not be instantiated directly. Instead, call + :meth:`FileExtension.ext` on an :class:`~pystac.Asset` to extend it. + """ + def __init__(self, asset: pystac.Asset): self.asset_href = asset.href self.properties = asset.properties @@ -183,11 +199,7 @@ def __repr__(self) -> str: class SummariesFileExtension(SummariesExtension): @property def data_type(self) -> Optional[List[FileDataType]]: - """Get or sets the data_type of the file. - - Returns: - FileDataType - """ + """Get or sets the summary of data_type values for this Collection.""" return map_opt( lambda x: [FileDataType(t) for t in x], @@ -200,11 +212,7 @@ def data_type(self, v: Optional[List[FileDataType]]) -> None: @property def size(self) -> Optional[pystac.RangeSummary[int]]: - """Get or sets the size in bytes of the file - - Returns: - int or None - """ + """Get or sets the summary of size values for this Collection.""" return self.summaries.get_range(SIZE_PROP) @size.setter @@ -213,7 +221,7 @@ def size(self, v: Optional[pystac.RangeSummary[int]]) -> None: @property def nodata(self) -> Optional[List[Any]]: - """Get or sets the list of no data values""" + """Get or sets the summary of nodata values for this Collection.""" return self.summaries.get_list(NODATA_PROP) @nodata.setter From a9e884d751e359a4f57a60fd7ab02f84bef5b897 Mon Sep 17 00:00:00 2001 From: Jon Duckworth Date: Mon, 14 Jun 2021 20:36:32 -0400 Subject: [PATCH 04/12] Update docstrings for Label Extension --- pystac/extensions/label.py | 235 ++++++++++++----------------------- pystac/extensions/version.py | 2 +- 2 files changed, 82 insertions(+), 155 deletions(-) diff --git a/pystac/extensions/label.py b/pystac/extensions/label.py index 144c8539f..9b1a314ec 100644 --- a/pystac/extensions/label.py +++ b/pystac/extensions/label.py @@ -29,7 +29,7 @@ def __str__(self) -> str: class LabelType(str, Enum): - """Enumerates valid label types (RASTER or VECTOR).""" + """Enumerates valid label types ("raster" or "vector").""" def __str__(self) -> str: return str(self.value) @@ -42,9 +42,9 @@ def __str__(self) -> str: class LabelClasses: - """Defines the list of possible class names (e.g., tree, building, car, hippo) + """Defines the list of possible class names (e.g., tree, building, car, hippo). - Use LabelClasses.create to create a new instance of LabelClasses from + Use :meth:`LabelClasses.create` to create a new instance of ``LabelClasses`` from property values. """ @@ -56,11 +56,10 @@ def apply( classes: Union[List[str], List[int], List[float]], name: Optional[str] = None, ) -> None: - """Sets the properties for this LabelClasses. + """Sets the properties for this instance. Args: - classes : The different possible - class values. + classes : The different possible class values. name : The property key within the asset's each Feature corresponding to class labels. If labels are raster-formatted, do not supply; required otherwise. @@ -74,17 +73,13 @@ def create( classes: Union[List[str], List[int], List[float]], name: Optional[str] = None, ) -> "LabelClasses": - """Creates a new LabelClasses. + """Creates a new ``LabelClasses`` instance. Args: - classes : The different possible - class values. + classes : The different possible class values. name : The property key within the asset's each Feature corresponding to class labels. If labels are raster-formatted, do not supply; required otherwise. - - Returns: - LabelClasses """ c = cls({}) c.apply(classes, name) @@ -92,11 +87,7 @@ class values. @property def classes(self) -> Union[List[str], List[int], List[float]]: - """Get or sets the class values. - - Returns: - List[str] or List[int] or List[float] - """ + """Gets or sets the class values.""" result: Optional[ Union[List[str], List[int], List[float]] ] = self.properties.get("classes") @@ -117,8 +108,9 @@ def classes(self, v: Union[List[str], List[int], List[float]]) -> None: @property def name(self) -> Optional[str]: - """Get or sets the property key within the asset's each Feature corresponding to - class labels. If labels are raster-formatted, do not supply; required otherwise. + """Gets or sets the property key within each Feature in the asset corresponding + to class labels. If labels are raster-formatted, do not supply; required + otherwise. """ return self.properties.get("name") @@ -135,18 +127,14 @@ def __repr__(self) -> str: ) def to_dict(self) -> Dict[str, Any]: - """Returns the dictionary representing the JSON of this LabelClasses. - - Returns: - dict: The wrapped dict of the LabelClasses that can be written out as JSON. - """ + """Returns the dictionary representing the JSON of this LabelClasses.""" return self.properties class LabelCount: """Contains counts for categorical data. - Use LabelCount.create to create a new LabelCount + Use :meth:`LabelCount.create` to create a new instance. """ def __init__(self, properties: Dict[str, Any]): @@ -164,7 +152,7 @@ def apply(self, name: str, count: int) -> None: @classmethod def create(cls, name: str, count: int) -> "LabelCount": - """Creates a LabelCount. + """Creates a ``LabelCount`` instance. Args: name : One of the different possible classes within the property. @@ -176,11 +164,7 @@ def create(cls, name: str, count: int) -> "LabelCount": @property def name(self) -> str: - """Get or sets the class that this count represents. - - Returns: - str - """ + """Gets or sets the class that this count represents.""" result: Optional[str] = self.properties.get("name") if result is None: raise pystac.STACError( @@ -194,11 +178,7 @@ def name(self, v: str) -> None: @property def count(self) -> int: - """Get or sets the number of occurrences of the class. - - Returns: - int - """ + """Get or sets the number of occurrences of the class.""" result: Optional[int] = self.properties.get("count") if result is None: raise pystac.STACError( @@ -211,18 +191,14 @@ def count(self, v: int) -> None: self.properties["count"] = v def to_dict(self) -> Dict[str, Any]: - """Returns the dictionary representing the JSON of this LabelCount. - - Returns: - dict: The wrapped dict of the LabelCount that can be written out as JSON. - """ + """Returns the dictionary representing the JSON of this instance.""" return {"name": self.name, "count": self.count} class LabelStatistics: """Contains statistics for regression/continuous numeric value data. - Use LabelStatistics.create to create a new instance. + Use :meth:`LabelStatistics.create` to create a new instance. """ def __init__(self, properties: Dict[str, Any]) -> None: @@ -252,11 +228,7 @@ def create(cls, name: str, value: float) -> "LabelStatistics": @property def name(self) -> str: - """Get or sets the name of the statistic being reported. - - Returns: - str - """ + """Gets or sets the name of the statistic being reported.""" result: Optional[str] = self.properties.get("name") if result is None: raise pystac.STACError( @@ -270,11 +242,7 @@ def name(self, v: str) -> None: @property def value(self) -> float: - """Get or sets the value of the statistic - - Returns: - float - """ + """Gets or sets the value of the statistic.""" result: Optional[float] = self.properties.get("value") if result is None: raise pystac.STACError( @@ -287,12 +255,7 @@ def value(self, v: float) -> None: self.properties["value"] = v def to_dict(self) -> Dict[str, Any]: - """Returns the dictionary representing the JSON of this LabelStatistics. - - Returns: - dict: The wrapped dict of the LabelStatistics that can be written out as - JSON. - """ + """Returns the dictionary representing the JSON of this LabelStatistics.""" return {"name": self.name, "value": self.value} @@ -300,7 +263,7 @@ class LabelOverview: """Stores counts (for classification-type data) or summary statistics (for continuous numerical/regression data). - Use LabelOverview.create to create a new LabelOverview. + Use :meth:`LabelOverview.create` to create a new instance. """ def __init__(self, properties: Dict[str, Any]): @@ -312,7 +275,7 @@ def apply( counts: Optional[List[LabelCount]] = None, statistics: Optional[List[LabelStatistics]] = None, ) -> None: - """Sets the properties for this LabelOverview. + """Sets the properties for this instance. Either ``counts`` or ``statistics``, or both, can be placed in an overview; at least one is required. @@ -321,10 +284,10 @@ def apply( property_key : The property key within the asset corresponding to class labels that these counts or statistics are referencing. If the label data is raster data, this should be None. - counts: Optional list of LabelCounts containing counts + counts: Optional list of :class:`LabelCounts` containing counts for categorical data. - statistics: Optional list of statistics containing statistics for - regression/continuous numeric value data. + statistics: Optional list of :class:`LabelStatistics` containing statistics + for regression/continuous numeric value data. """ self.property_key = property_key self.counts = counts @@ -337,7 +300,7 @@ def create( counts: Optional[List[LabelCount]] = None, statistics: Optional[List[LabelStatistics]] = None, ) -> "LabelOverview": - """Creates a new LabelOverview. + """Creates a new instance. Either ``counts`` or ``statistics``, or both, can be placed in an overview; at least one is required. @@ -345,10 +308,10 @@ def create( Args: property_key : The property key within the asset corresponding to class labels. - counts: Optional list of LabelCounts containing counts for + counts: Optional list of :class:`LabelCounts` containing counts for categorical data. - statistics: Optional list of Statistics containing statistics for - regression/continuous numeric value data. + statistics: Optional list of :class:`LabelStatistics` containing statistics + for regression/continuous numeric value data. """ x = LabelOverview({}) x.apply(property_key, counts, statistics) @@ -356,11 +319,8 @@ class labels. @property def property_key(self) -> Optional[str]: - """Get or sets the property key within the asset corresponding to class labels. - - Returns: - str - """ + """Gets or sets the property key within the asset corresponding to class + labels.""" return self.properties.get("property_key") @property_key.setter @@ -369,11 +329,8 @@ def property_key(self, v: Optional[str]) -> None: @property def counts(self) -> Optional[List[LabelCount]]: - """Get or sets the list of LabelCounts containing counts for categorical data. - - Returns: - List[LabelCount] - """ + """Gets or sets the list of :class:`LabelCounts` containing counts for + categorical data.""" counts = self.properties.get("counts") if counts is None: return None @@ -393,12 +350,8 @@ def counts(self, v: Optional[List[LabelCount]]) -> None: @property def statistics(self) -> Optional[List[LabelStatistics]]: - """Get or sets the list of Statistics containing statistics for - regression/continuous numeric value data. - - Returns: - List[Statistics] - """ + """Gets or sets the list of :class:`LabelStatistics` containing statistics for + regression/continuous numeric value data.""" statistics = self.properties.get("statistics") if statistics is None: return None @@ -419,13 +372,13 @@ def statistics(self, v: Optional[List[LabelStatistics]]) -> None: def merge_counts(self, other: "LabelOverview") -> "LabelOverview": """Merges the counts associated with this overview with another overview. - Creates a new LabelOverview. + Creates a new instance. Args: other : The other LabelOverview to merge. Returns: - LabelOverview: A new LabelOverview with the counts merged. This will + A new LabelOverview with the counts merged. This will drop any statistics associated with either of the LabelOverviews. """ assert self.property_key == other.property_key @@ -452,32 +405,22 @@ def add_counts(counts: List[LabelCount]) -> None: return LabelOverview.create(self.property_key, counts=new_counts) def to_dict(self) -> Dict[str, Any]: - """Returns the dictionary representing the JSON of this LabelOverview. - - Returns: - dict: The wrapped dict of the LabelOverview that can be written out as JSON. - """ + """Returns the dictionary representing the JSON of this LabelOverview.""" return self.properties class LabelExtension(ExtensionManagementMixin[pystac.Item]): - """A LabelItemExt is the extension of the Item in the label extension which - represents a polygon, set of polygons, or raster data defining - labels and label metadata and should be part of a Collection. + """An abstract class that can be used to extend the properties of an + :class:`~pystac.Item` with properties from the :stac-ext:`Label Extension