From d48ecf238849dc8c470be1c03b63c688fe52a45f Mon Sep 17 00:00:00 2001 From: RichardScottOZ <72196131+RichardScottOZ@users.noreply.github.com> Date: Mon, 26 Apr 2021 15:20:40 +0930 Subject: [PATCH 01/23] Update how-to-create-stac-catalogs.ipynb That --- docs/tutorials/how-to-create-stac-catalogs.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/tutorials/how-to-create-stac-catalogs.ipynb b/docs/tutorials/how-to-create-stac-catalogs.ipynb index a7b7852f0..73ec1899a 100644 --- a/docs/tutorials/how-to-create-stac-catalogs.ipynb +++ b/docs/tutorials/how-to-create-stac-catalogs.ipynb @@ -295,7 +295,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Using [rasterio](https://rasterio.readthedocs.io/en/stable/), we can pull out the bounding box of the image to use for the image metadata. If the image contained a NoData border, we would ideally pull out the footprint and save it as the geometry; in this case, we're working with a small chip the most likely has no NoData values." + "Using [rasterio](https://rasterio.readthedocs.io/en/stable/), we can pull out the bounding box of the image to use for the image metadata. If the image contained a NoData border, we would ideally pull out the footprint and save it as the geometry; in this case, we're working with a small chip that most likely has no NoData values." ] }, { From c3f497e7ab23fa3ffdb5c7436e202a374d42f6ec Mon Sep 17 00:00:00 2001 From: RichardScottOZ <72196131+RichardScottOZ@users.noreply.github.com> Date: Mon, 26 Apr 2021 15:35:59 +0930 Subject: [PATCH 02/23] Update creating-a-landsat-stac.ipynb Level --- docs/tutorials/creating-a-landsat-stac.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/tutorials/creating-a-landsat-stac.ipynb b/docs/tutorials/creating-a-landsat-stac.ipynb index 3311364e4..fe5810c54 100644 --- a/docs/tutorials/creating-a-landsat-stac.ipynb +++ b/docs/tutorials/creating-a-landsat-stac.ipynb @@ -1080,7 +1080,7 @@ "source": [ "#### Add Ground Sample Distance to common metadata\n", "\n", - "We'll add the Ground Sample Distance that is defined as part of the Item [Common Metadata](https://github.com/radiantearth/stac-spec/blob/v1.0.0-beta.2/item-spec/common-metadata.md). We define this on the Item leve as 30 meters, which is the GSD for most of the bands of Landsat 8. However, there are some bands that have a different resolution; we will account for this by setting the GSD explicitly for each of those bands below." + "We'll add the Ground Sample Distance that is defined as part of the Item [Common Metadata](https://github.com/radiantearth/stac-spec/blob/v1.0.0-beta.2/item-spec/common-metadata.md). We define this on the Item level as 30 meters, which is the GSD for most of the bands of Landsat 8. However, there are some bands that have a different resolution; we will account for this by setting the GSD explicitly for each of those bands below." ] }, { From eaf705646bc1f39e2e419103a4c7309b012fd288 Mon Sep 17 00:00:00 2001 From: RichardScottOZ <72196131+RichardScottOZ@users.noreply.github.com> Date: Mon, 26 Apr 2021 15:40:45 +0930 Subject: [PATCH 03/23] Update creating-a-landsat-stac.ipynb Thumbnail --- docs/tutorials/creating-a-landsat-stac.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/tutorials/creating-a-landsat-stac.ipynb b/docs/tutorials/creating-a-landsat-stac.ipynb index fe5810c54..d32bc0c85 100644 --- a/docs/tutorials/creating-a-landsat-stac.ipynb +++ b/docs/tutorials/creating-a-landsat-stac.ipynb @@ -1361,7 +1361,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Here we see the tumbnail asset, which does not include the band information for the `eo` extension as it does not represent any of the Item's bands:" + "Here we see the thumbnail asset, which does not include the band information for the `eo` extension as it does not represent any of the Item's bands:" ] }, { From 793a0ff194af8cfb4183bdf846e8eb466cea397c Mon Sep 17 00:00:00 2001 From: RichardScottOZ <72196131+RichardScottOZ@users.noreply.github.com> Date: Mon, 26 Apr 2021 15:46:56 +0930 Subject: [PATCH 04/23] Update creating-a-landsat-stac.ipynb Minor edits --- docs/tutorials/creating-a-landsat-stac.ipynb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/tutorials/creating-a-landsat-stac.ipynb b/docs/tutorials/creating-a-landsat-stac.ipynb index d32bc0c85..2af2de0df 100644 --- a/docs/tutorials/creating-a-landsat-stac.ipynb +++ b/docs/tutorials/creating-a-landsat-stac.ipynb @@ -1888,7 +1888,7 @@ "source": [ "### Write the catalog locally\n", "\n", - "Now that we have our complete, validated STAC in memory, let's write it out. This is a simple as calling `save` on the Collection. We need to specify the type of catalog in order to property write out links - these types are described again in the STAC [Best Practices](https://github.com/radiantearth/stac-spec/blob/master/best-practices.md#use-of-links) documentation.\n", + "Now that we have our complete, validated STAC in memory, let's write it out. This is as simple as calling `save` on the Collection. We need to specify the type of catalog in order to property write out links - these types are described again in the STAC [Best Practices](https://github.com/radiantearth/stac-spec/blob/master/best-practices.md#use-of-links) documentation.\n", "\n", "We'll use the \"self contained\" type, which uses relative paths and does not specify absolute \"self\" links to any object. This makes the catalog more portable, as it remains valid even if you copy the STAC to new locations." ] @@ -2242,7 +2242,7 @@ "source": [ "### Acknowledgements\n", "\n", - "Credit to [sat-stac-landsat](https://github.com/sat-utils/sat-stac-landsat) off of which a lot of this code was based." + "Credit to [sat-stac-landsat](https://github.com/sat-utils/sat-stac-landsat) from which a lot of this code was based." ] } ], From 2a16ab6b0be8c77467ea577ce48dc928cac593a9 Mon Sep 17 00:00:00 2001 From: RichardScottOZ <72196131+RichardScottOZ@users.noreply.github.com> Date: Mon, 26 Apr 2021 15:54:35 +0930 Subject: [PATCH 05/23] Update catalog.py Minor edits --- pystac/catalog.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pystac/catalog.py b/pystac/catalog.py index ce32c2df8..34e340c13 100644 --- a/pystac/catalog.py +++ b/pystac/catalog.py @@ -17,7 +17,7 @@ def __str__(self): SELF_CONTAINED = 'SELF_CONTAINED' """A 'self-contained catalog' is one that is designed for portability. - Users may want to download a catalog from online and be able to use it on their + Users may want to download an online catalog from and be able to use it on their local computer, so all links need to be relative. See: @@ -322,7 +322,7 @@ def get_items(self): """Return all items of this catalog. Return: - Generator[Item]: Generator of items who's parent is this catalog. + Generator[Item]: Generator of items whose parent is this catalog. """ return self.get_stac_objects('item') From 7db11e1508b379762fc79500a04ca756d7c51256 Mon Sep 17 00:00:00 2001 From: RichardScottOZ <72196131+RichardScottOZ@users.noreply.github.com> Date: Mon, 26 Apr 2021 16:01:53 +0930 Subject: [PATCH 06/23] Update item.py Minor edits for redundancy --- pystac/item.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pystac/item.py b/pystac/item.py index 3de409b1b..bf789a94c 100644 --- a/pystac/item.py +++ b/pystac/item.py @@ -941,7 +941,7 @@ def get_created(self, asset=None): Note: ``created`` and ``updated`` have different meaning depending on where they are used. - If those fields are available in the Item `properties`, it's referencing to the + If those fields are available in the Item `properties`, it's referencing the creation and update times of the metadata. Having those fields in the Item `assets` refers to the creation and update times of the actual data linked to in the Asset Object. @@ -978,7 +978,7 @@ def updated(self): Note: ``created`` and ``updated`` have different meaning depending on where they are used. - If those fields are available in the Item `properties`, it's referencing to the + If those fields are available in the Item `properties`, it's referencing the creation and update times of the metadata. Having those fields in the Item `assets` refers to the creation and update times of the actual data linked to in the Asset Object. @@ -1002,7 +1002,7 @@ def get_updated(self, asset=None): Note: ``created`` and ``updated`` have different meaning depending on where they are used. - If those fields are available in the Item `properties`, it's referencing to the + If those fields are available in the Item `properties`, it's referencing the creation and update times of the metadata. Having those fields in the Item `assets` refers to the creation and update times of the actual data linked to in the Asset Object. From d5f61f877c537ef73f1c66c548bca834eb760bd0 Mon Sep 17 00:00:00 2001 From: volaya Date: Mon, 17 May 2021 09:36:19 +0200 Subject: [PATCH 07/23] Removed type information from docstrings fixes #323 --- pystac/__init__.py | 14 ++-- pystac/asset.py | 22 +++--- pystac/cache.py | 22 +++--- pystac/catalog.py | 76 ++++++++++---------- pystac/collection.py | 86 +++++++++++------------ pystac/errors.py | 2 +- pystac/extensions/eo.py | 32 ++++----- pystac/extensions/file.py | 12 ++-- pystac/extensions/label.py | 66 ++++++++--------- pystac/extensions/pointcloud.py | 60 ++++++++-------- pystac/extensions/projection.py | 20 +++--- pystac/extensions/sar.py | 30 ++++---- pystac/extensions/sat.py | 8 +-- pystac/extensions/scientific.py | 8 +-- pystac/extensions/timestamps.py | 6 +- pystac/extensions/version.py | 14 ++-- pystac/extensions/view.py | 14 ++-- pystac/item.py | 50 ++++++------- pystac/layout.py | 24 +++---- pystac/link.py | 26 +++---- pystac/serialization/__init__.py | 6 +- pystac/serialization/common_properties.py | 4 +- pystac/serialization/identify.py | 10 +-- pystac/serialization/migrate.py | 4 +- pystac/stac_io.py | 32 ++++----- pystac/stac_object.py | 40 +++++------ pystac/utils.py | 18 ++--- pystac/validation/__init__.py | 18 ++--- pystac/validation/schema_uri_map.py | 4 +- pystac/validation/stac_validator.py | 48 ++++++------- pystac/version.py | 2 +- 31 files changed, 389 insertions(+), 389 deletions(-) diff --git a/pystac/__init__.py b/pystac/__init__.py index d9a17eb5f..091acbf35 100644 --- a/pystac/__init__.py +++ b/pystac/__init__.py @@ -79,7 +79,7 @@ def read_file(href: str) -> STACObject: This is a convenience method for :meth:`STACObject.from_file ` Args: - href (str): The HREF to read the object from. + href : The HREF to read the object from. Returns: The specific STACObject implementation class that is represented @@ -104,10 +104,10 @@ def write_file( Convenience method for :meth:`STACObject.from_file ` Args: - obj (STACObject): The STACObject to save. - include_self_link (bool): If this is true, include the 'self' link with this object. + obj : The STACObject to save. + include_self_link : If this is true, include the 'self' link with this object. Otherwise, leave out the self link. - dest_href (str): Optional HREF to save the file to. If None, the object will be saved + dest_href : Optional HREF to save the file to. If None, the object will be saved to the object's self href. """ obj.save_object(include_self_link=include_self_link, dest_href=dest_href) @@ -128,10 +128,10 @@ def read_dict( This is a convenience method for :meth:`pystac.serialization.stac_object_from_dict` Args: - d (dict): The dict to parse. - href (str): Optional href that is the file location of the object being + d : The dict to parse. + href : Optional href that is the file location of the object being parsed. - root (Catalog or Collection): Optional root of the catalog for this object. + root : Optional root of the catalog for this object. If provided, the root's resolved object cache can be used to search for previously resolved instances of the STAC object. stac_io: Optional StacIO instance to use for reading. If None, the diff --git a/pystac/asset.py b/pystac/asset.py index 7c8353df3..63d281838 100644 --- a/pystac/asset.py +++ b/pystac/asset.py @@ -14,30 +14,30 @@ class Asset: can be downloaded or streamed. Args: - href (str): Link to the asset object. Relative and absolute links are both + href : Link to the asset object. Relative and absolute links are both allowed. - title (str): Optional displayed title for clients and users. - description (str): A description of the Asset providing additional details, + title : Optional displayed title for clients and users. + description : A description of the Asset providing additional details, such as how it was processed or created. CommonMark 0.29 syntax MAY be used for rich text representation. - media_type (str): Optional description of the media type. Registered Media Types + media_type : Optional description of the media type. Registered Media Types are preferred. See :class:`~pystac.MediaType` for common media types. - roles ([str]): Optional, Semantic roles (i.e. thumbnail, overview, + roles : Optional, Semantic roles (i.e. thumbnail, overview, data, metadata) of the asset. - properties (dict): Optional, additional properties for this asset. This is used + properties : Optional, additional properties for this asset. This is used by extensions as a way to serialize and deserialize properties on asset object JSON. Attributes: - href (str): Link to the asset object. Relative and absolute links are both + href : Link to the asset object. Relative and absolute links are both allowed. - title (str): Optional displayed title for clients and users. - description (str): A description of the Asset providing additional details, + title : Optional displayed title for clients and users. + description : A description of the Asset providing additional details, such as how it was processed or created. CommonMark 0.29 syntax MAY be used for rich text representation. - media_type (str): Optional description of the media type. Registered Media Types + media_type : Optional description of the media type. Registered Media Types are preferred. See :class:`~pystac.MediaType` for common media types. - properties (dict): Optional, additional properties for this asset. This is used + properties : Optional, additional properties for this asset. This is used by extensions as a way to serialize and deserialize properties on asset object JSON. owner: The Item or Collection this asset belongs to, or None if it has no owner. diff --git a/pystac/cache.py b/pystac/cache.py index 117b0f23d..c4b4aee78 100644 --- a/pystac/cache.py +++ b/pystac/cache.py @@ -50,12 +50,12 @@ class ResolvedObjectCache: them with their copies. Args: - id_keys_to_objects (Dict[str, STACObject]): Existing cache of + id_keys_to_objects : Existing cache of a key made up of the STACObject and it's parents IDs mapped to the cached STACObject. - hrefs_to_objects (Dict[str, STACObject]): STAC Object HREFs matched to + hrefs_to_objects : STAC Object HREFs matched to their cached object. - ids_to_collections (Dict[str, Collection]): Map of collection IDs + ids_to_collections : Map of collection IDs to collections. """ @@ -76,7 +76,7 @@ def get_or_cache(self, obj: "STACObject_Type") -> "STACObject_Type": none exists, sets the cached object to the given object. Args: - obj (STACObject): The given object who's cache key will be checked + obj : The given object who's cache key will be checked against the cache. Returns: @@ -101,7 +101,7 @@ def get(self, obj: "STACObject_Type") -> Optional["STACObject_Type"]: """Get the cached object that has the same cache key as the given object. Args: - obj (STACObject): The given object who's cache key will be checked against + obj : The given object who's cache key will be checked against the cache. Returns: @@ -118,7 +118,7 @@ def get_by_href(self, href: str) -> Optional["STACObject_Type"]: """Gets the cached object at href. Args: - href (str): The href to use as the key for the cached object. + href : The href to use as the key for the cached object. Returns: STACObject or None: Returns the STACObject if cached, otherwise None. @@ -129,7 +129,7 @@ def get_collection_by_id(self, id: str) -> Optional["Collection_Type"]: """Retrieved a cached Collection by its ID. Args: - id (str): The ID of the collection. + id : The ID of the collection. Returns: Collection or None: Returns the collection if there is one cached @@ -141,7 +141,7 @@ def cache(self, obj: "STACObject_Type") -> None: """Set the given object into the cache. Args: - obj (STACObject): The object to cache + obj : The object to cache """ key, is_href = get_cache_key(obj) if is_href: @@ -156,7 +156,7 @@ def remove(self, obj: "STACObject_Type") -> None: """Removes any cached object that matches the given object's cache key. Args: - obj (STACObject): The object to remove + obj : The object to remove """ key, is_href = get_cache_key(obj) @@ -194,9 +194,9 @@ def merge( in the first will be cached in the resulting merged ResolvedObjectCache. Args: - first (ResolvedObjectCache): The first cache to merge. This cache will be + first : The first cache to merge. This cache will be the preferred cache for objects in the case of ID conflicts. - second (ResolvedObjectCache): The second cache to merge. + second : The second cache to merge. Returns: ResolvedObjectCache: The resulting merged cache. diff --git a/pystac/catalog.py b/pystac/catalog.py index 428f9c84c..f6b461655 100644 --- a/pystac/catalog.py +++ b/pystac/catalog.py @@ -68,7 +68,7 @@ def determine_type(cls, stac_json: Dict[str, Any]) -> Optional["CatalogType"]: Only applies to Catalogs or Collections Args: - stac_json (dict): The STAC JSON dict to determine the catalog type + stac_json : The STAC JSON dict to determine the catalog type Returns: Optional[CatalogType]: The catalog type of the catalog or collection. @@ -102,28 +102,28 @@ class Catalog(STACObject): as well as :class:`~pystac.Item` s. Args: - id (str): Identifier for the catalog. Must be unique within the STAC. - description (str): Detailed multi-line description to fully explain the catalog. + id : Identifier for the catalog. Must be unique within the STAC. + description : Detailed multi-line description to fully explain the catalog. `CommonMark 0.28 syntax `_ MAY be used for rich text representation. - title (str or None): Optional short descriptive one-line title for the catalog. - stac_extensions (List[str]): Optional list of extensions the Catalog implements. - href (str or None): Optional HREF for this catalog, which be set as the + title : Optional short descriptive one-line title for the catalog. + stac_extensions : Optional list of extensions the Catalog implements. + href : Optional HREF for this catalog, which be set as the catalog's self link's HREF. - catalog_type (str or None): Optional catalog type for this catalog. Must + catalog_type : Optional catalog type for this catalog. Must be one of the values in :class`~pystac.CatalogType`. Attributes: - id (str): Identifier for the catalog. - description (str): Detailed multi-line description to fully explain the catalog. - title (str or None): Optional short descriptive one-line title for the catalog. - stac_extensions (List[str] or None): Optional list of extensions the Catalog + id : Identifier for the catalog. + description : Detailed multi-line description to fully explain the catalog. + title : Optional short descriptive one-line title for the catalog. + stac_extensions : Optional list of extensions the Catalog implements. - extra_fields (dict or None): Extra fields that are part of the top-level JSON + extra_fields : Extra fields that are part of the top-level JSON properties of the Catalog. - links (List[Link]): A list of :class:`~pystac.Link` objects representing + links : A list of :class:`~pystac.Link` objects representing all links associated with this Catalog. - catalog_type (str): The catalog type. Defaults to ABSOLUTE_PUBLISHED + catalog_type : The catalog type. Defaults to ABSOLUTE_PUBLISHED """ STAC_OBJECT_TYPE = pystac.STACObjectType.CATALOG @@ -197,9 +197,9 @@ def add_child( this Catalog's root. Args: - child (Catalog or Collection): The child to add. - title (str): Optional title to give to the :class:`~pystac.Link` - strategy (HrefLayoutStrategy): The layout strategy to use for setting the + child : The child to add. + title : Optional title to give to the :class:`~pystac.Link` + strategy : The layout strategy to use for setting the self href of the child. """ @@ -229,7 +229,7 @@ def add_children( this Catalog's root. Args: - children (Iterable[Catalog or Collection]): The children to add. + children : The children to add. """ for child in children: self.add_child(child) @@ -245,8 +245,8 @@ def add_item( this Catalog's root. Args: - item (Item): The item to add. - title (str): Optional title to give to the :class:`~pystac.Link` + item : The item to add. + title : Optional title to give to the :class:`~pystac.Link` """ # Prevent typo confusion @@ -273,7 +273,7 @@ def add_items(self, items: Iterable["Item_Type"]) -> None: this Catalog's root. Args: - items (Iterable[Item]): The items to add. + items : The items to add. """ for item in items: self.add_item(item) @@ -284,8 +284,8 @@ def get_child( """Gets the child of this catalog with the given ID, if it exists. Args: - id (str): The ID of the child to find. - recursive (bool): If True, search this catalog and all children for the + id : The ID of the child to find. + recursive : If True, search this catalog and all children for the item; otherwise, only search the children of this catalog. Defaults to False. @@ -336,7 +336,7 @@ def remove_child(self, child_id: str) -> None: """Removes an child from this catalog. Args: - child_id (str): The ID of the child to remove. + child_id : The ID of the child to remove. """ new_links: List[pystac.Link] = [] root = self.get_root() @@ -357,8 +357,8 @@ def get_item(self, id: str, recursive: bool = False) -> Optional["Item_Type"]: """Returns an item with a given ID. Args: - id (str): The ID of the item to find. - recursive (bool): If True, search this catalog and all children for the + id : The ID of the item to find. + recursive : If True, search this catalog and all children for the item; otherwise, only search the items of this catalog. Defaults to False. @@ -400,7 +400,7 @@ def remove_item(self, item_id: str) -> None: """Removes an item from this catalog. Args: - item_id (str): The ID of the item to remove. + item_id : The ID of the item to remove. """ new_links: List[pystac.Link] = [] root = self.get_root() @@ -515,13 +515,13 @@ def normalize_and_save( in sequence. Args: - root_href (str): The absolute HREF that all links will be normalized + root_href : The absolute HREF that all links will be normalized against. - catalog_type (str): The catalog type that dictates the structure of + catalog_type : The catalog type that dictates the structure of the catalog to save. Use a member of :class:`~pystac.CatalogType`. Defaults to the root catalog.catalog_type or the current catalog catalog_type if there is no root catalog. - strategy (HrefLayoutStrategy): The layout strategy to use in setting the + strategy : The layout strategy to use in setting the HREFS for this catalog. Defaults to :class:`~pystac.layout.BestPracticesLayoutStrategy` """ @@ -538,8 +538,8 @@ def normalize_hrefs( This method mutates the entire catalog tree. Args: - root_href (str): The absolute HREF that all links will be normalized against. - strategy (HrefLayoutStrategy): The layout strategy to use in setting the HREFS + root_href : The absolute HREF that all links will be normalized against. + strategy : The layout strategy to use in setting the HREFS for this catalog. Defaults to :class:`~pystac.layout.BestPracticesLayoutStrategy` See: @@ -611,12 +611,12 @@ def generate_subcatalogs( and organize the items based on template values. Args: - template (str): A template string that + template : A template string that can be consumed by a :class:`~pystac.layout.LayoutTemplate` - defaults (dict): Default values for the template variables + defaults : Default values for the template variables that will be used if the property cannot be found on the item. - parent_ids (List[str]): Optional list of the parent catalogs' + parent_ids : Optional list of the parent catalogs' identifiers. If the bottom-most subcatalogs already match the template, no subcatalog is added. @@ -683,7 +683,7 @@ def save(self, catalog_type: Optional[CatalogType] = None) -> None: self link HREF. Args: - catalog_type (str): The catalog type that dictates the structure of + catalog_type : The catalog type that dictates the structure of the catalog to save. Use a member of :class:`~pystac.CatalogType`. If not supplied, the catalog_type of this catalog will be used. If that attribute is not set, an exception will be raised. @@ -783,7 +783,7 @@ def map_items( item_mapper function. Args: - item_mapper (Callable): A function that takes in an item, and returns + item_mapper : A function that takes in an item, and returns either an item or list of items. The item that is passed into the item_mapper is a copy, so the method can mutate it safely. @@ -829,7 +829,7 @@ def map_assets( through the asset_mapper function. Args: - asset_mapper (Callable): A function that takes in an key and an Asset, and + asset_mapper : A function that takes in an key and an Asset, and returns either an Asset, a (key, Asset), or a dictionary of Assets with unique keys. The Asset that is passed into the item_mapper is a copy, so the method can mutate it safely. diff --git a/pystac/collection.py b/pystac/collection.py index 0dafe09b7..117754db8 100644 --- a/pystac/collection.py +++ b/pystac/collection.py @@ -36,13 +36,13 @@ class SpatialExtent: """Describes the spatial extent of a Collection. Args: - bboxes (List[List[float]]): A list of bboxes that represent the spatial + bboxes : A list of bboxes that represent the spatial extent of the collection. Each bbox can be 2D or 3D. The length of the bbox array must be 2*n where n is the number of dimensions. For example, a 2D Collection with only one bbox would be [[xmin, ymin, xmax, ymax]] Attributes: - bboxes (List[List[float]]): A list of bboxes that represent the spatial + bboxes : A list of bboxes that represent the spatial extent of the collection. Each bbox can be 2D or 3D. The length of the bbox array must be 2*n where n is the number of dimensions. For example, a 2D Collection with only one bbox would be [[xmin, ymin, xmax, ymax]] @@ -90,7 +90,7 @@ def from_coordinates(coordinates: List[Any]) -> "SpatialExtent": in the coordinate set. Args: - coordinates (List[float]): Coordinates to derive the bbox from. + coordinates : Coordinates to derive the bbox from. Returns: SpatialExtent: A SpatialExtent with a single bbox that covers the @@ -135,14 +135,14 @@ class TemporalExtent: """Describes the temporal extent of a Collection. Args: - intervals (List[List[datetime]]): A list of two datetimes wrapped in a list, + intervals : A list of two datetimes wrapped in a list, representing the temporal extent of a Collection. Open date ranges are supported by setting either the start (the first element of the interval) or the end (the second element of the interval) to None. Attributes: - intervals (List[List[datetime]]): A list of two datetimes wrapped in a list, + intervals : A list of two datetimes wrapped in a list, representing the temporal extent of a Collection. Open date ranges are represented by either the start (the first element of the interval) or the end (the second element of the interval) being None. @@ -229,12 +229,12 @@ class Extent: """Describes the spatiotemporal extents of a Collection. Args: - spatial (SpatialExtent): Potential spatial extent covered by the collection. - temporal (TemporalExtent): Potential temporal extent covered by the collection. + spatial : Potential spatial extent covered by the collection. + temporal : Potential temporal extent covered by the collection. Attributes: - spatial (SpatialExtent): Potential spatial extent covered by the collection. - temporal (TemporalExtent): Potential temporal extent covered by the collection. + spatial : Potential spatial extent covered by the collection. + temporal : Potential temporal extent covered by the collection. """ def __init__(self, spatial: SpatialExtent, temporal: TemporalExtent): @@ -291,7 +291,7 @@ def from_items(items: Iterable["Item_Type"]) -> "Extent": """Create an Extent based on the datetimes and bboxes of a list of items. Args: - items (List[Item]): A list of items to derive the extent from. + items : A list of items to derive the extent from. Returns: Extent: An Extent that spatially and temporally covers all of the @@ -359,23 +359,23 @@ class Provider: the final storage provider hosting the data. Args: - name (str): The name of the organization or the individual. - description (str): Optional multi-line description to add further provider + name : The name of the organization or the individual. + description : Optional multi-line description to add further provider information such as processing details for processors and producers, hosting details for hosts or basic contact information. - roles (List[str]): Optional roles of the provider. Any of + roles : Optional roles of the provider. Any of licensor, producer, processor or host. - url (str): Optional homepage on which the provider describes the dataset + url : Optional homepage on which the provider describes the dataset and publishes contact information. Attributes: - name (str): The name of the organization or the individual. - description (str): Optional multi-line description to add further provider + name : The name of the organization or the individual. + description : Optional multi-line description to add further provider information such as processing details for processors and producers, hosting details for hosts or basic contact information. - roles (List[str]): Optional roles of the provider. Any of + roles : Optional roles of the provider. Any of licensor, producer, processor or host. - url (str): Optional homepage on which the provider describes the dataset + url : Optional homepage on which the provider describes the dataset and publishes contact information. """ @@ -506,52 +506,52 @@ class Collection(Catalog): enable discovery. Args: - id (str): Identifier for the collection. Must be unique within the STAC. - description (str): Detailed multi-line description to fully explain the + id : Identifier for the collection. Must be unique within the STAC. + description : Detailed multi-line description to fully explain the collection. `CommonMark 0.28 syntax `_ MAY be used for rich text representation. - extent (Extent): Spatial and temporal extents that describe the bounds of + extent : Spatial and temporal extents that describe the bounds of all items contained within this Collection. - title (str or None): Optional short descriptive one-line title for the + title : Optional short descriptive one-line title for the collection. - stac_extensions (List[str]): Optional list of extensions the Collection + stac_extensions : Optional list of extensions the Collection implements. - href (str or None): Optional HREF for this collection, which be set as the + href : Optional HREF for this collection, which be set as the collection's self link's HREF. - catalog_type (str or None): Optional catalog type for this catalog. Must + catalog_type : Optional catalog type for this catalog. Must be one of the values in :class`~pystac.CatalogType`. - license (str): Collection's license(s) as a + license : Collection's license(s) as a `SPDX License identifier `_, `various`, or `proprietary`. If collection includes data with multiple different licenses, use `various` and add a link for each. Defaults to 'proprietary'. - keywords (List[str]): Optional list of keywords describing the collection. - providers (List[Provider]): Optional list of providers of this Collection. - summaries (dict): An optional map of property summaries, + keywords : Optional list of keywords describing the collection. + providers : Optional list of providers of this Collection. + summaries : An optional map of property summaries, either a set of values or statistics such as a range. - extra_fields (dict or None): Extra fields that are part of the top-level + extra_fields : Extra fields that are part of the top-level JSON properties of the Collection. Attributes: - id (str): Identifier for the collection. - description (str): Detailed multi-line description to fully explain the + id : Identifier for the collection. + description : Detailed multi-line description to fully explain the collection. - extent (Extent): Spatial and temporal extents that describe the bounds of + extent : Spatial and temporal extents that describe the bounds of all items contained within this Collection. - title (str or None): Optional short descriptive one-line title for the + title : Optional short descriptive one-line title for the collection. - stac_extensions (List[str]): Optional list of extensions the Collection + stac_extensions : Optional list of extensions the Collection implements. - keywords (List[str] or None): Optional list of keywords describing the + keywords : Optional list of keywords describing the collection. - providers (List[Provider] or None): Optional list of providers of this + providers : Optional list of providers of this Collection. - assets (Optional[Dict[str, Asset]]): Optional map of Assets - summaries (dict or None): An optional map of property summaries, + assets : Optional map of Assets + summaries : An optional map of property summaries, either a set of values or statistics such as a range. - links (List[Link]): A list of :class:`~pystac.Link` objects representing + links : A list of :class:`~pystac.Link` objects representing all links associated with this Collection. - extra_fields (dict or None): Extra fields that are part of the top-level + extra_fields : Extra fields that are part of the top-level JSON properties of the Catalog. """ @@ -731,8 +731,8 @@ def add_asset(self, key: str, asset: Asset) -> None: """Adds an Asset to this item. Args: - key (str): The unique key of this asset. - asset (Asset): The Asset to add. + key : The unique key of this asset. + asset : The Asset to add. """ asset.set_owner(self) self.assets[key] = asset diff --git a/pystac/errors.py b/pystac/errors.py index 39bad4c7a..488ae781b 100644 --- a/pystac/errors.py +++ b/pystac/errors.py @@ -60,7 +60,7 @@ class STACValidationError(Exception): is invalid. Args: - source (object): Source of the exception. Type will be determined by the + source : Source of the exception. Type will be determined by the validation implementation. For the default JsonSchemaValidator this will a the ``jsonschema.ValidationError``. """ diff --git a/pystac/extensions/eo.py b/pystac/extensions/eo.py index 56209f54d..026635250 100644 --- a/pystac/extensions/eo.py +++ b/pystac/extensions/eo.py @@ -47,13 +47,13 @@ def apply( Sets the properties for this Band. Args: - name (str): The name of the band (e.g., "B01", "B02", "B1", "B5", "QA"). - common_name (str): The name commonly used to refer to the band to make it + name : The name of the band (e.g., "B01", "B02", "B1", "B5", "QA"). + common_name : The name commonly used to refer to the band to make it easier to search for bands across instruments. See the `list of accepted common names `_. - description (str): Description to fully explain the band. - center_wavelength (float): The center wavelength of the band, in micrometers (μm). - full_width_half_max (float): Full width at half maximum (FWHM). The width of the band, + description : Description to fully explain the band. + center_wavelength : The center wavelength of the band, in micrometers (μm). + full_width_half_max : Full width at half maximum (FWHM). The width of the band, as measured at half the maximum transmission, in micrometers (μm). """ # noqa self.name = name @@ -75,13 +75,13 @@ def create( Creates a new band. Args: - name (str): The name of the band (e.g., "B01", "B02", "B1", "B5", "QA"). - common_name (str): The name commonly used to refer to the band to make it easier + name : The name of the band (e.g., "B01", "B02", "B1", "B5", "QA"). + common_name : The name commonly used to refer to the band to make it easier to search for bands across instruments. See the `list of accepted common names `_. - description (str): Description to fully explain the band. - center_wavelength (float): The center wavelength of the band, in micrometers (μm). - full_width_half_max (float): Full width at half maximum (FWHM). The width of the band, + description : Description to fully explain the band. + center_wavelength : The center wavelength of the band, in micrometers (μm). + full_width_half_max : Full width at half maximum (FWHM). The width of the band, as measured at half the maximum transmission, in micrometers (μm). """ # noqa b = cls({}) @@ -191,7 +191,7 @@ def band_range(common_name: str) -> Optional[Tuple[float, float]]: """Gets the band range for a common band name. Args: - common_name (str): The common band name. Must be one of the `list of accepted common names `_. + common_name : The common band name. Must be one of the `list of accepted common names `_. Returns: Tuple[float, float] or None: The band range for this name as (min, max), or @@ -223,7 +223,7 @@ def band_description(common_name: str) -> Optional[str]: """Returns a description of the band for one with a common name. Args: - common_name (str): The common band name. Must be one of the `list of accepted common names `_. + common_name : The common band name. Must be one of the `list of accepted common names `_. Returns: str or None: If a recognized common name, returns a description including the @@ -242,10 +242,10 @@ class EOExtension( represents a snapshot of the earth for a single date and time. Args: - item (Item): The item to be extended. + item : The item to be extended. Attributes: - item (Item): The Item that is being extended. + item : The Item that is being extended. Note: Using EOItemExt to directly wrap an item will add the 'eo' extension ID to @@ -256,9 +256,9 @@ def apply(self, bands: List[Band], cloud_cover: Optional[float] = None) -> None: """Applies label extension properties to the extended Item. Args: - bands (List[Band]): a list of :class:`~pystac.Band` objects that represent + bands : a list of :class:`~pystac.Band` objects that represent the available bands. - cloud_cover (float or None): The estimate of cloud cover as a percentage + cloud_cover : The estimate of cloud cover as a percentage (0-100) of the entire scene. If not available the field should not be provided. """ diff --git a/pystac/extensions/file.py b/pystac/extensions/file.py index 1ce4bc2c7..264ad5fdf 100644 --- a/pystac/extensions/file.py +++ b/pystac/extensions/file.py @@ -59,10 +59,10 @@ class FileExtension( adds file related details such as checksum, data type and size for assets. Args: - item (Item): The item to be extended. + item : The item to be extended. Attributes: - item (Item): The Item that is being extended. + item : The Item that is being extended. Note: Using FileItemExt to directly wrap an item will add the 'file' extension ID to @@ -79,10 +79,10 @@ def apply( """Applies file extension properties to the extended Item. Args: - data_type (FileDataType): The data type of the file. - size (int or None): size of the file in bytes. - nodata (List[Object] or None): Value(s) for no-data. - checksum (str or None): Multihash for the corresponding file, + data_type : The data type of the file. + size : size of the file in bytes. + nodata : Value(s) for no-data. + checksum : Multihash for the corresponding file, encoded as hexadecimal (base 16) string with lowercase letters. """ self.data_type = data_type diff --git a/pystac/extensions/label.py b/pystac/extensions/label.py index a8d9ae9b8..49ff258d7 100644 --- a/pystac/extensions/label.py +++ b/pystac/extensions/label.py @@ -45,9 +45,9 @@ def apply( """Sets the properties for this LabelClasses. Args: - classes (List[str] or List[int] or List[float]): The different possible + classes : The different possible class values. - name (str): The property key within the asset's each Feature corresponding + name : The property key within the asset's each Feature corresponding to class labels. If labels are raster-formatted, do not supply; required otherwise. """ @@ -63,9 +63,9 @@ def create( """Creates a new LabelClasses. Args: - classes (List[str] or List[int] or List[float]): The different possible + classes : The different possible class values. - name (str): The property key within the asset's each Feature corresponding + name : The property key within the asset's each Feature corresponding to class labels. If labels are raster-formatted, do not supply; required otherwise. @@ -140,8 +140,8 @@ def apply(self, name: str, count: int) -> None: """Sets the properties for this LabelCount. Args: - name (str): One of the different possible classes within the property. - count (int): The number of occurrences of the class. + name : One of the different possible classes within the property. + count : The number of occurrences of the class. """ self.name = name self.count = count @@ -151,8 +151,8 @@ def create(cls, name: str, count: int) -> "LabelCount": """Creates a LabelCount. Args: - name (str): One of the different possible classes within the property. - count (int): The number of occurrences of the class. + name : One of the different possible classes within the property. + count : The number of occurrences of the class. """ x = cls({}) x.apply(name, count) @@ -216,8 +216,8 @@ def apply(self, name: str, value: float) -> None: """Sets the property values for this instance. Args: - name (str): The name of the statistic being reported. - value (float): The value of the statistic + name : The name of the statistic being reported. + value : The value of the statistic """ self.name = name self.value = value @@ -227,8 +227,8 @@ def create(cls, name: str, value: float) -> "LabelStatistics": """Sets the property values for this instance. Args: - name (str): The name of the statistic being reported. - value (float): The value of the statistic + name : The name of the statistic being reported. + value : The value of the statistic """ x = cls({}) x.apply(name, value) @@ -302,7 +302,7 @@ def apply( at least one is required. Args: - property_key (str): The property key within the asset corresponding to + 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 @@ -327,7 +327,7 @@ def create( at least one is required. Args: - property_key (str): The property key within the asset corresponding to + property_key : The property key within the asset corresponding to class labels. counts: Optional list of LabelCounts containing counts for categorical data. @@ -406,7 +406,7 @@ def merge_counts(self, other: "LabelOverview") -> "LabelOverview": Creates a new LabelOverview. Args: - other (LabelOverview): The other LabelOverview to merge. + other : The other LabelOverview to merge. Returns: LabelOverview: A new LabelOverview with the counts merged. This will @@ -450,10 +450,10 @@ class LabelExtension(ExtensionManagementMixin[pystac.Item]): labels and label metadata and should be part of a Collection. Args: - item (Item): The item to be extended. + item : The item to be extended. Attributes: - item (Item): The Item that is being extended. + item : The Item that is being extended. See: `Item fields in the label extension spec `_ @@ -480,22 +480,22 @@ def apply( """Applies label extension properties to the extended Item. Args: - label_description (str): A description of the label, how it was created, + label_description : A description of the label, how it was created, and what it is recommended for - label_type (str): An ENUM of either vector label type or raster label type. Use + label_type : An ENUM of either vector label type or raster label type. Use one of :class:`~pystac.LabelType`. - label_properties (list or None): These are the names of the property field(s) in each + label_properties : These are the names of the property field(s) in each Feature of the label asset's FeatureCollection that contains the classes (keywords from label:classes if the property defines classes). If labels are rasters, this should be None. - label_classes (List[LabelClass]): Optional, but required if using categorical data. + label_classes : Optional, but required if using categorical data. A list of LabelClasses defining the list of possible class names for each label:properties. (e.g., tree, building, car, hippo) - label_tasks (List[str]): Recommended to be a subset of 'regression', 'classification', + label_tasks : Recommended to be a subset of 'regression', 'classification', 'detection', or 'segmentation', but may be an arbitrary value. label_methods: Recommended to be a subset of 'automated' or 'manual', but may be an arbitrary value. - label_overviews (List[LabelOverview]): Optional list of LabelOverview classes + label_overviews : Optional list of LabelOverview classes that store counts (for classification-type data) or summary statistics (for continuous numerical/regression data). """ # noqa E501 @@ -681,9 +681,9 @@ def add_source( """Adds a link to a source item. Args: - source_item (Item): Source imagery that the LabelItem applies to. - title (str): Optional title for the link. - assets (List[str]): Optional list of assets that determine what + source_item : Source imagery that the LabelItem applies to. + title : Optional title for the link. + assets : Optional list of assets that determine what assets in the source item this label item data applies to. """ properties = None @@ -718,13 +718,13 @@ def add_labels( """Adds a label asset to this LabelItem. Args: - href (str): Link to the asset object. Relative and absolute links are both + href : Link to the asset object. Relative and absolute links are both allowed. - title (str): Optional displayed title for clients and users. - media_type (str): Optional description of the media type. Registered Media + title : Optional displayed title for clients and users. + media_type : Optional description of the media type. Registered Media Types are preferred. See :class:`~pystac.MediaType` for common media types. - properties (dict): Optional, additional properties for this asset. This is + properties : Optional, additional properties for this asset. This is used by extensions as a way to serialize and deserialize properties on asset object JSON. """ @@ -745,10 +745,10 @@ def add_geojson_labels( """Adds a GeoJSON label asset to this LabelItem. Args: - href (str): Link to the asset object. Relative and absolute links are both + href : Link to the asset object. Relative and absolute links are both allowed. - title (str): Optional displayed title for clients and users. - properties (dict): Optional, additional properties for this asset. This is + title : Optional displayed title for clients and users. + properties : Optional, additional properties for this asset. This is used by extensions as a way to serialize and deserialize properties on asset object JSON. """ diff --git a/pystac/extensions/pointcloud.py b/pystac/extensions/pointcloud.py index 466c7ee98..fc922cd55 100644 --- a/pystac/extensions/pointcloud.py +++ b/pystac/extensions/pointcloud.py @@ -39,9 +39,9 @@ def apply(self, name: str, size: int, type: str) -> None: """Sets the properties for this PointCloudSchema. Args: - name (str): The name of dimension. - size (int): The size of the dimension in bytes. Whole bytes are supported. - type (str): Dimension type. Valid values are `floating`, `unsigned`, and + name : The name of dimension. + size : The size of the dimension in bytes. Whole bytes are supported. + type : Dimension type. Valid values are `floating`, `unsigned`, and `signed` """ self.properties["name"] = name @@ -53,9 +53,9 @@ def create(cls, name: str, size: int, type: str) -> "PointcloudSchema": """Creates a new PointCloudSchema. Args: - name (str): The name of dimension. - size (int): The size of the dimension in bytes. Whole bytes are supported. - type (str): Dimension type. Valid values are `floating`, `unsigned`, and + name : The name of dimension. + size : The size of the dimension in bytes. Whole bytes are supported. + type : Dimension type. Valid values are `floating`, `unsigned`, and `signed` Returns: @@ -161,14 +161,14 @@ def apply( """Sets the properties for this PointcloudStatistic. Args: - name (str): REQUIRED. The name of the channel. - position (int): Position of the channel in the schema. - average (float): The average of the channel. - count (int): The number of elements in the channel. - maximum (float): The maximum value of the channel. - minimum (float): The minimum value of the channel. - stddev (float): The standard deviation of the channel. - variance (float): The variance of the channel. + name : REQUIRED. The name of the channel. + position : Position of the channel in the schema. + average : The average of the channel. + count : The number of elements in the channel. + maximum : The maximum value of the channel. + minimum : The minimum value of the channel. + stddev : The standard deviation of the channel. + variance : The variance of the channel. """ self.properties["name"] = name self.properties["position"] = position @@ -194,14 +194,14 @@ def create( """Creates a new PointcloudStatistic class. Args: - name (str): REQUIRED. The name of the channel. - position (int): Position of the channel in the schema. + name : REQUIRED. The name of the channel. + position : Position of the channel in the schema. average (float) The average of the channel. - count (int): The number of elements in the channel. - maximum (float): The maximum value of the channel. - minimum (float): The minimum value of the channel. - stddev (float): The standard deviation of the channel. - variance (float): The variance of the channel. + count : The number of elements in the channel. + maximum : The maximum value of the channel. + minimum : The minimum value of the channel. + stddev : The standard deviation of the channel. + variance : The variance of the channel. Returns: LabelClasses @@ -372,10 +372,10 @@ class PointcloudExtension( The Pointclout extension adds pointcloud information to STAC Items. Args: - item (Item): The item to be extended. + item : The item to be extended. Attributes: - item (Item): The Item that is being extended. + item : The Item that is being extended. """ @@ -392,18 +392,18 @@ def apply( """Applies Pointcloud extension properties to the extended Item. Args: - count (int): REQUIRED. The number of points in the cloud. - type (str): REQUIRED. Phenomenology type for the point cloud. Possible valid + count : REQUIRED. The number of points in the cloud. + type : REQUIRED. Phenomenology type for the point cloud. Possible valid values might include lidar, eopc, radar, sonar, or otherThe type of file or data format of the cloud. - encoding (str): REQUIRED. Content encoding or format of the data. - schemas (List[PointcloudSchema]): REQUIRED. A sequential array of items + encoding : REQUIRED. Content encoding or format of the data. + schemas : REQUIRED. A sequential array of items that define the dimensions and their types. - density (float or None): Number of points per square unit area. - statistics (List[int] or None): A sequential array of items mapping to + density : Number of points per square unit area. + statistics : A sequential array of items mapping to pc:schemas defines per-channel statistics. - epsg (str): An EPSG code for the projected coordinates of the pointcloud. + epsg : An EPSG code for the projected coordinates of the pointcloud. """ self.count = count self.type = type diff --git a/pystac/extensions/projection.py b/pystac/extensions/projection.py index a90df7c2d..2f58de818 100644 --- a/pystac/extensions/projection.py +++ b/pystac/extensions/projection.py @@ -33,10 +33,10 @@ class ProjectionExtension( The Projection extension adds projection information to STAC Items. Args: - item (Item): The item to be extended. + item : The item to be extended. Attributes: - item (Item): The Item that is being extended. + item : The Item that is being extended. Note: Using ProjectionItemExt to directly wrap an item will add the 'proj' extension @@ -60,23 +60,23 @@ def apply( """Applies Projection extension properties to the extended Item. Args: - epsg (int or None): REQUIRED. EPSG code of the datasource. - wkt2 (str or None): WKT2 string representing the Coordinate Reference + epsg : REQUIRED. EPSG code of the datasource. + wkt2 : WKT2 string representing the Coordinate Reference System (CRS) that the ``geometry`` and ``bbox`` fields represent - projjson (dict or None): PROJJSON dict representing the + projjson : PROJJSON dict representing the Coordinate Reference System (CRS) that the ``geometry`` and ``bbox`` fields represent - geometry (dict or None): GeoJSON Polygon dict that defines the footprint of + geometry : GeoJSON Polygon dict that defines the footprint of this Item. - bbox (List[float] or None): Bounding box of the Item in the asset CRS in + bbox : Bounding box of the Item in the asset CRS in 2 or 3 dimensions. - centroid (dict or None): A dict with members 'lat' and 'lon' that defines + centroid : A dict with members 'lat' and 'lon' that defines coordinates representing the centroid of the item in the asset data CRS. Coordinates are defined in latitude and longitude, even if the data coordinate system may not use lat/long. - shape (List[int] or None): Number of pixels in Y and X directions for the + shape : Number of pixels in Y and X directions for the default grid. - transform (List[float] or None): The affine transformation coefficients for + transform : The affine transformation coefficients for the default grid """ self.epsg = epsg diff --git a/pystac/extensions/sar.py b/pystac/extensions/sar.py index 62e7f97fb..8c1a5f5b1 100644 --- a/pystac/extensions/sar.py +++ b/pystac/extensions/sar.py @@ -64,10 +64,10 @@ class SarExtension( """SarItemExt extends Item to add sar properties to a STAC Item. Args: - item (Item): The item to be extended. + item : The item to be extended. Attributes: - item (Item): The item that is being extended. + item : The item that is being extended. Note: Using SarItemExt to directly wrap an item will add the 'sar' @@ -93,36 +93,36 @@ def apply( """Applies sar extension properties to the extended Item. Args: - instrument_mode (str): The name of the sensor acquisition mode that is + instrument_mode : The name of the sensor acquisition mode that is commonly used. This should be the short name, if available. For example, WV for "Wave mode." - frequency_band (FrequencyBand): The common name for the frequency band to + frequency_band : The common name for the frequency band to make it easier to search for bands across instruments. See section "Common Frequency Band Names" for a list of accepted names. - polarizations (List[Polarization]): Any combination of polarizations. - product_type (str): The product type, for example SSC, MGD, or SGC. - center_frequency (float): Optional center frequency of the instrument in + polarizations : Any combination of polarizations. + product_type : The product type, for example SSC, MGD, or SGC. + center_frequency : Optional center frequency of the instrument in gigahertz (GHz). - resolution_range (float): Optional range resolution, which is the maximum + resolution_range : Optional range resolution, which is the maximum ability to distinguish two adjacent targets perpendicular to the flight path, in meters (m). - resolution_azimuth (float): Optional azimuth resolution, which is the + resolution_azimuth : Optional azimuth resolution, which is the maximum ability to distinguish two adjacent targets parallel to the flight path, in meters (m). - pixel_spacing_range (float): Optional range pixel spacing, which is the + pixel_spacing_range : Optional range pixel spacing, which is the distance between adjacent pixels perpendicular to the flight path, in meters (m). Strongly RECOMMENDED to be specified for products of type GRD. - pixel_spacing_azimuth (float): Optional azimuth pixel spacing, which is the + pixel_spacing_azimuth : Optional azimuth pixel spacing, which is the distance between adjacent pixels parallel to the flight path, in meters (m). Strongly RECOMMENDED to be specified for products of type GRD. - looks_range (int): Optional number of groups of signal samples (looks) + looks_range : Optional number of groups of signal samples (looks) perpendicular to the flight path. - looks_azimuth (int): Optional number of groups of signal samples (looks) + looks_azimuth : Optional number of groups of signal samples (looks) parallel to the flight path. - looks_equivalent_number (float): Optional equivalent number of looks (ENL). - observation_direction (ObservationDirection): Optional Antenna pointing + looks_equivalent_number : Optional equivalent number of looks (ENL). + observation_direction : Optional Antenna pointing direction relative to the flight trajectory of the satellite. """ self.instrument_mode = instrument_mode diff --git a/pystac/extensions/sat.py b/pystac/extensions/sat.py index ce0cd3460..4c61a3527 100644 --- a/pystac/extensions/sat.py +++ b/pystac/extensions/sat.py @@ -34,10 +34,10 @@ class SatExtension( """SatItemExt extends Item to add sat properties to a STAC Item. Args: - item (Item): The item to be extended. + item : The item to be extended. Attributes: - item (Item): The item that is being extended. + item : The item that is being extended. Note: Using SatItemExt to directly wrap an item will add the 'sat' @@ -55,10 +55,10 @@ def apply( for the sat extension to properties to be valid. Args: - orbit_state (OrbitState): Optional state of the orbit. Either ascending or + orbit_state : Optional state of the orbit. Either ascending or descending for polar orbiting satellites, or geostationary for geosynchronous satellites. - relative_orbit (int): Optional non-negative integer of the orbit number at + relative_orbit : Optional non-negative integer of the orbit number at the time of acquisition. """ diff --git a/pystac/extensions/scientific.py b/pystac/extensions/scientific.py index 26cc719a9..9174ef6a5 100644 --- a/pystac/extensions/scientific.py +++ b/pystac/extensions/scientific.py @@ -95,9 +95,9 @@ def apply( """Applies scientific extension properties to the extended Item. Args: - doi (str): Optional DOI string for the item. Must not be a DOI link. - citation (str): Optional human-readable reference. - publications (List[Publication]): Optional list of relevant publications + doi : Optional DOI string for the item. Must not be a DOI link. + citation : Optional human-readable reference. + publications : Optional list of relevant publications referencing and describing the data. """ self.doi = doi @@ -164,7 +164,7 @@ def remove_publication(self, publication: Optional[Publication] = None) -> None: """Removes publications from the item. Args: - publication (Publication): The specific publication to remove of None to + publication : The specific publication to remove of None to remove all. """ if PUBLICATIONS not in self.properties: diff --git a/pystac/extensions/timestamps.py b/pystac/extensions/timestamps.py index e05b1db25..7516ff47d 100644 --- a/pystac/extensions/timestamps.py +++ b/pystac/extensions/timestamps.py @@ -39,11 +39,11 @@ def apply( """Applies timestamps extension properties to the extended Item. Args: - published (datetime or None): Date and time the corresponding data + published : Date and time the corresponding data was published the first time. - expires (datetime or None): Date and time the corresponding data + expires : Date and time the corresponding data expires (is not valid any longer). - unpublished (datetime or None): Date and time the corresponding data + unpublished : Date and time the corresponding data was unpublished. """ self.published = published diff --git a/pystac/extensions/version.py b/pystac/extensions/version.py index d41133008..85ee2aa08 100644 --- a/pystac/extensions/version.py +++ b/pystac/extensions/version.py @@ -40,10 +40,10 @@ class VersionExtension( along with links to the latest, predecessor, and successor Items. Args: - item (Item): The item to be extended. + item : The item to be extended. Attributes: - item (Item): The item that is being extended. + item : The item that is being extended. Note: Using VersionItemExt to directly wrap an item will add the 'version' @@ -66,13 +66,13 @@ def apply( """Applies version extension properties to the extended Item. Args: - version (str): The version string for the item. - deprecated (bool): Optional flag set to True if an Item is + 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): Item with the latest (e.g., current) version. - predecessor (Item): Item with the previous version. - successor (Item): Item with the next most recent version. + latest : Item with the latest (e.g., current) version. + predecessor : Item with the previous version. + successor : Item with the next most recent version. """ self.version = version if deprecated is not None: diff --git a/pystac/extensions/view.py b/pystac/extensions/view.py index f164c04c1..77c26b34d 100644 --- a/pystac/extensions/view.py +++ b/pystac/extensions/view.py @@ -33,10 +33,10 @@ class ViewExtension( extensions that describe the actual data, such as the eo, sat or sar extensions. Args: - item (Item): The item to be extended. + item : The item to be extended. Attributes: - item (Item): The Item that is being extended. + item : The Item that is being extended. Note: Using ViewItemExt to directly wrap an item will add the 'view' extension ID to @@ -54,19 +54,19 @@ def apply( """Applies View Geometry extension properties to the extended Item. Args: - off_nadir (float): The angle from the sensor between nadir (straight down) + off_nadir : The angle from the sensor between nadir (straight down) and the scene center. Measured in degrees (0-90). - incidence_angle (float): The incidence angle is the angle between the + incidence_angle : The incidence angle is the angle between the vertical (normal) to the intercepting surface and the line of sight back to the satellite at the scene center. Measured in degrees (0-90). - azimuth (float): Viewing azimuth angle. The angle measured from the + azimuth : Viewing azimuth angle. The angle measured from the sub-satellite point (point on the ground below the platform) between the scene center and true north. Measured clockwise from north in degrees (0-360). - sun_azimuth (float): Sun azimuth angle. From the scene center point on the + sun_azimuth : Sun azimuth angle. From the scene center point on the ground, this is the angle between truth north and the sun. Measured clockwise in degrees (0-360). - sun_elevation (float): Sun elevation angle. The angle from the tangent of + sun_elevation : Sun elevation angle. The angle from the tangent of the scene center point to the sun. Measured from the horizon in degrees (0-90). """ diff --git a/pystac/item.py b/pystac/item.py index 2b319d028..5836962c6 100644 --- a/pystac/item.py +++ b/pystac/item.py @@ -26,7 +26,7 @@ class CommonMetadata: this item and are optional Args: - properties (dict): Dictionary of attributes that is the Item's properties + properties : Dictionary of attributes that is the Item's properties """ def __init__(self, properties: Dict[str, Any]): @@ -590,48 +590,48 @@ class Item(STACObject): satellite imagery, derived data, DEM's, etc. Args: - id (str): Provider identifier. Must be unique within the STAC. - geometry (dict): Defines the full footprint of the asset represented by this + id : Provider identifier. Must be unique within the STAC. + geometry : Defines the full footprint of the asset represented by this item, formatted according to `RFC 7946, section 3.1 (GeoJSON) `_. - bbox (List[float] or None): Bounding Box of the asset represented by this item + bbox : Bounding Box of the asset represented by this item using either 2D or 3D geometries. The length of the array must be 2*n where n is the number of dimensions. Could also be None in the case of a null geometry. - datetime (datetime or None): Datetime associated with this item. If None, + datetime : Datetime associated with this item. If None, a start_datetime and end_datetime must be supplied in the properties. - properties (dict): A dictionary of additional metadata for the item. - stac_extensions (List[str]): Optional list of extensions the Item implements. - href (str or None): Optional HREF for this item, which be set as the item's + properties : A dictionary of additional metadata for the item. + stac_extensions : Optional list of extensions the Item implements. + href : Optional HREF for this item, which be set as the item's self link's HREF. - collection (Collection or str): The Collection or Collection ID that this item + collection : The Collection or Collection ID that this item belongs to. - extra_fields (dict or None): Extra fields that are part of the top-level JSON + extra_fields : Extra fields that are part of the top-level JSON properties of the Item. Attributes: - id (str): Provider identifier. Unique within the STAC. - geometry (dict): Defines the full footprint of the asset represented by this + id : Provider identifier. Unique within the STAC. + geometry : Defines the full footprint of the asset represented by this item, formatted according to `RFC 7946, section 3.1 (GeoJSON) `_. - bbox (List[float] or None): Bounding Box of the asset represented by this item + bbox : Bounding Box of the asset represented by this item using either 2D or 3D geometries. The length of the array is 2*n where n is the number of dimensions. Could also be None in the case of a null geometry. - datetime (datetime or None): Datetime associated with this item. If None, + datetime : Datetime associated with this item. If None, the start_datetime and end_datetime in the common_metadata will supply the datetime range of the Item. - properties (dict): A dictionary of additional metadata for the item. - stac_extensions (List[str] or None): Optional list of extensions the Item + properties : A dictionary of additional metadata for the item. + stac_extensions : Optional list of extensions the Item implements. - collection (Collection or None): Collection that this item is a part of. - links (List[Link]): A list of :class:`~pystac.Link` objects representing + collection : Collection that this item is a part of. + links : A list of :class:`~pystac.Link` objects representing all links associated with this STACObject. - assets (Dict[str, Asset]): Dictionary of asset objects that can be downloaded, + assets : Dictionary of asset objects that can be downloaded, each with a unique key. - collection_id (str or None): The Collection ID that this item belongs to, if + collection_id : The Collection ID that this item belongs to, if any. - extra_fields (dict or None): Extra fields that are part of the top-level JSON + extra_fields : Extra fields that are part of the top-level JSON properties of the Item. """ @@ -700,7 +700,7 @@ def set_self_href(self, href: Optional[str]) -> None: as the old location. Args: - href (str): The absolute HREF of this object. If the given HREF + href : The absolute HREF of this object. If the given HREF is not absolute, it will be transformed to an absolute HREF based on the current working directory. If this is None the call will clear the self HREF link. @@ -759,8 +759,8 @@ def add_asset(self, key: str, asset: Asset) -> None: """Adds an Asset to this item. Args: - key (str): The unique key of this asset. - asset (Asset): The Asset to add. + key : The unique key of this asset. + asset : The Asset to add. """ asset.set_owner(self) self.assets[key] = asset @@ -817,7 +817,7 @@ def set_collection(self, collection: Optional[Collection]) -> "Item": this item. Args: - collection (Collection or None): The collection to set as this + collection : The collection to set as this item's collection. If None, will clear the collection. Returns: diff --git a/pystac/layout.py b/pystac/layout.py index da6dd48ea..8cb703563 100644 --- a/pystac/layout.py +++ b/pystac/layout.py @@ -66,8 +66,8 @@ class LayoutTemplate: template = LayoutTemplate("${collection}/${common_metadata.license}") Args: - template (str): The template string to use. - defaults (dict): A dictionary of template vars to values. These values + template : The template string to use. + defaults : A dictionary of template vars to values. These values will be used in case a value cannot be derived from a stac object. """ @@ -184,7 +184,7 @@ def get_template_values(self, stac_object: "STACObject_Type") -> Dict[str, Any]: value is used; if there is no default then this will raise an error. Args: - stac_object (STACObject): The STACObject to derive template + stac_object : The STACObject to derive template variable values from. Returns: @@ -207,7 +207,7 @@ def substitute(self, stac_object: "STACObject_Type") -> str: the template string for this template. Args: - stac_object (STACObject): The STACObject to derive template + stac_object : The STACObject to derive template variable values from. Returns: @@ -265,18 +265,18 @@ class CustomLayoutStrategy(HrefLayoutStrategy): stac object paths. Args: - catalog_func (Callable[Catalog, str, bool] -> str): A function that takes + catalog_func : A function that takes an catalog, a parent directory, and a flag specifying whether or not this catalog is the root. If it is the root, its usually best to not create a subdirectory and put the Catalog file directly in the parent directory. Must return the string path. - collection_func (Callable[Catalog, str, bool] -> str): A function that + collection_func : A function that is used for collections in the same manner at ``catalog_func``. This takes the same parameters. - item_func (Callable[Catalog, str] -> str): A function that takes + item_func : A function that takes an item and a parent directory and returns the path to be used for the item. - fallback_strategy (HrefLayoutStrategy): The fallback strategy to + fallback_strategy : The fallback strategy to use if a function is not provided for a stac object type. Defaults to :class:`~pystac.layout.BestPracticesLayoutStrategy` """ @@ -332,16 +332,16 @@ class TemplateLayoutStrategy(HrefLayoutStrategy): object. Args: - catalog_template (str): The template string to use for catalog paths. + catalog_template : The template string to use for catalog paths. Must be a valid template string that can be used by :class:`~pystac.layout.LayoutTemplate` - collection_template (str): The template string to use for collection paths. + collection_template : The template string to use for collection paths. Must be a valid template string that can be used by :class:`~pystac.layout.LayoutTemplate` - item_template (str): The template string to use for item paths. + item_template : The template string to use for item paths. Must be a valid template string that can be used by :class:`~pystac.layout.LayoutTemplate` - fallback_strategy (HrefLayoutStrategy): The fallback strategy to + fallback_strategy : The fallback strategy to use if a template is not provided. Defaults to :class:`~pystac.layout.BestPracticesLayoutStrategy` """ diff --git a/pystac/link.py b/pystac/link.py index 3e7be46f4..db7ff68a4 100644 --- a/pystac/link.py +++ b/pystac/link.py @@ -28,30 +28,30 @@ class Link: ideally the lazy deserialization of STACObjects is transparent to clients of PySTAC. Args: - rel (str): The relation of the link (e.g. 'child', 'item') - target (str or STACObject): The target of the link. If the link is + rel : The relation of the link (e.g. 'child', 'item') + target : The target of the link. If the link is unresolved, or the link is to something that is not a STACObject, the target is an HREF. If resolved, the target is a STACObject. - media_type (str): Optional description of the media type. Registered Media Types + media_type : Optional description of the media type. Registered Media Types are preferred. See :class:`~pystac.MediaType` for common media types. - title (str): Optional title for this link. - properties (dict): Optional, additional properties for this link. This is used + title : Optional title for this link. + properties : Optional, additional properties for this link. This is used by extensions as a way to serialize and deserialize properties on link object JSON. Attributes: - rel (str): The relation of the link (e.g. 'child', 'item') - target (str or STACObject): The target of the link. If the link is + rel : The relation of the link (e.g. 'child', 'item') + target : The target of the link. If the link is unresolved, or the link is to something that is not a STACObject, the target is an HREF. If resolved, the target is a STACObject. - media_type (str or None): Optional description of the media type. + media_type : Optional description of the media type. Registered Media Types are preferred. See :class:`~pystac.MediaType` for common media types. - title (str or None): Optional title for this link. - properties (dict or None): Optional, additional properties for this link. + title : Optional title for this link. + properties : Optional, additional properties for this link. This is used by extensions as a way to serialize and deserialize properties on link object JSON. - owner (STACObject or None): The owner of this link. The link will use + owner : The owner of this link. The link will use its owner's root catalog :class:`~pystac.resolved_object_cache.ResolvedObjectCache` to resolve objects, and will create absolute HREFs from relative HREFs against @@ -161,7 +161,7 @@ def resolve_stac_object(self, root: Optional["Catalog_Type"] = None) -> "Link": already resolved. Args: - root (Catalog or Collection): Optional root of the catalog for this link. + root : Optional root of the catalog for this link. If provided, the root's resolved object cache is used to search for previously resolved instances of the STAC object. """ @@ -273,7 +273,7 @@ def from_dict(d: Dict[str, Any]) -> "Link": """Deserializes a Link from a dict. Args: - d (dict): The dict that represents the Link in JSON + d : The dict that represents the Link in JSON Returns: Link: Link instance constructed from the dict. diff --git a/pystac/serialization/__init__.py b/pystac/serialization/__init__.py index ad1d6999a..94cda503d 100644 --- a/pystac/serialization/__init__.py +++ b/pystac/serialization/__init__.py @@ -21,10 +21,10 @@ def stac_object_from_dict( """Determines how to deserialize a dictionary into a STAC object. Args: - d (dict): The dict to parse. - href (str): Optional href that is the file location of the object being + d : The dict to parse. + href : Optional href that is the file location of the object being parsed. - root (Catalog or Collection): Optional root of the catalog for this object. + root : Optional root of the catalog for this object. If provided, the root's resolved object cache can be used to search for previously resolved instances of the STAC object. diff --git a/pystac/serialization/common_properties.py b/pystac/serialization/common_properties.py index 4da6eadee..d7501c904 100644 --- a/pystac/serialization/common_properties.py +++ b/pystac/serialization/common_properties.py @@ -16,9 +16,9 @@ def merge_common_properties( Note: This is only applicable to reading old STAC versions (pre 1.0.0-beta.1). Args: - item_dict (dict): JSON dict of the Item which properties should be merged + item_dict : JSON dict of the Item which properties should be merged into. - collection_cache (CollectionCache): Optional CollectionCache + collection_cache : Optional CollectionCache that will be used to read and write cached collections. json_href: The HREF of the file that this JSON comes from. Used to resolve relative paths. diff --git a/pystac/serialization/identify.py b/pystac/serialization/identify.py index da20ad139..3ba86dad4 100644 --- a/pystac/serialization/identify.py +++ b/pystac/serialization/identify.py @@ -141,11 +141,11 @@ class STACJSONDescription: """Describes the STAC object information for a STAC object represented in JSON Attributes: - object_type (str): Describes the STAC object type. One of + object_type : Describes the STAC object type. One of :class:`~pystac.STACObjectType`. - version_range (STACVersionRange): The STAC version range that describes what + version_range : The STAC version range that describes what has been identified as potential valid versions of the stac object. - extensions (List[str]): List of extension schema URIs for extensions this + extensions : List of extension schema URIs for extensions this object implements """ @@ -302,7 +302,7 @@ def identify_stac_object_type(json_dict: Dict[str, Any]) -> "STACObjectType_Type """Determines the STACObjectType of the provided JSON dict. Args: - json_dict (dict): The dict of STAC JSON to identify. + json_dict : The dict of STAC JSON to identify. Returns: STACObjectType: The object type represented by the JSON. @@ -338,7 +338,7 @@ def identify_stac_object(json_dict: Dict[str, Any]) -> STACJSONDescription: """Determines the STACJSONDescription of the provided JSON dict. Args: - json_dict (dict): The dict of STAC JSON to identify. + json_dict : The dict of STAC JSON to identify. Returns: STACJSONDescription: The description of the STAC object serialized in the diff --git a/pystac/serialization/migrate.py b/pystac/serialization/migrate.py index 79b5be6a6..d1afdccec 100644 --- a/pystac/serialization/migrate.py +++ b/pystac/serialization/migrate.py @@ -171,8 +171,8 @@ def migrate_to_latest( """Migrates the STAC JSON to the latest version Args: - json_dict (dict): The dict of STAC JSON to identify. - info (STACJSONDescription): The info from + json_dict : The dict of STAC JSON to identify. + info : The info from :func:`~pystac.serialization.identify.identify_stac_object` that describes the STAC object contained in the JSON dict. diff --git a/pystac/stac_io.py b/pystac/stac_io.py index 94e391875..ccfba4ced 100644 --- a/pystac/stac_io.py +++ b/pystac/stac_io.py @@ -49,7 +49,7 @@ def read_text( e.g. the "post" information in a pagination link from a STAC API search. Args: - source (str or pystac.Link): The source to read from. + source : The source to read from. Returns: str: The text contained in the file at the location specified by the uri. @@ -68,8 +68,8 @@ def write_text( link body. Args: - dest (str or pystac.Link): The destination to write to. - txt (str): The text to write. + dest : The destination to write to. + txt : The text to write. """ raise NotImplementedError("write_text not implemented") @@ -107,7 +107,7 @@ def read_json(self, source: Union[str, "Link_Type"]) -> Dict[str, Any]: str vs Link as a parameter. Args: - source (str or Link): The source from which to read. + source : The source from which to read. Returns: dict: A dict representation of the JSON contained in the file at the @@ -125,8 +125,8 @@ def read_stac_object( str vs Link as a parameter. Args: - source (str or pystac.Link): The source from which to read. - root (Catalog or Collection): Optional root of the catalog for this object. + source : The source from which to read. + root : Optional root of the catalog for this object. If provided, the root's resolved object cache can be used to search for previously resolved instances of the STAC object. @@ -147,8 +147,8 @@ def save_json( str vs Link as a parameter. Args: - dest (str or pystac.Link): The destination file to write the text to. - json_dict (dict): The JSON dict to write. + dest : The destination file to write the text to. + json_dict : The JSON dict to write. """ txt = self._json_dumps(json_dict, dest) self.write_text(dest, txt) @@ -295,7 +295,7 @@ def read_text(cls, uri: str) -> str: """Read text from the given URI. Args: - uri (str): The URI from which to read text. + uri : The URI from which to read text. Returns: str: The text contained in the file at the location specified by the uri. @@ -313,8 +313,8 @@ def write_text(cls, uri: str, txt: str) -> None: """Write the given text to a file at the given URI. Args: - uri (str): The URI of the file to write the text to. - txt (str): The text to write. + uri : The URI of the file to write the text to. + txt : The text to write. Note: This method uses the :func:`STAC_IO.write_text_method @@ -329,7 +329,7 @@ def read_json(cls, uri: str) -> Dict[str, Any]: """Read a dict from the given URI. Args: - uri (str): The URI from which to read. + uri : The URI from which to read. Returns: dict: A dict representation of the JSON contained in the file at the @@ -350,8 +350,8 @@ def read_stac_object( """Read a STACObject from a JSON file at the given URI. Args: - uri (str): The URI from which to read. - root (Catalog or Collection): Optional root of the catalog for this object. + uri : The URI from which to read. + root : Optional root of the catalog for this object. If provided, the root's resolved object cache can be used to search for previously resolved instances of the STAC object. @@ -373,8 +373,8 @@ def save_json(cls, uri: str, json_dict: Dict[str, Any]) -> None: """Write a dict to the given URI as JSON. Args: - uri (str): The URI of the file to write the text to. - json_dict (dict): The JSON dict to write. + uri : The URI of the file to write the text to. + json_dict : The JSON dict to write. Note: This method uses the :func:`STAC_IO.write_text_method diff --git a/pystac/stac_object.py b/pystac/stac_object.py index 8a303a665..aa14b7453 100644 --- a/pystac/stac_object.py +++ b/pystac/stac_object.py @@ -28,7 +28,7 @@ class STACObject(ABC): JSON, and can be cloned or copied. Attributes: - links (List[Link]): A list of :class:`~pystac.Link` objects representing + links : A list of :class:`~pystac.Link` objects representing all links associated with this STACObject. """ @@ -58,7 +58,7 @@ def add_link(self, link: Link) -> None: """Add a link to this object's set of links. Args: - link (Link): The link to add. + link : The link to add. """ link.set_owner(cast(STACObject, self)) self.links.append(link) @@ -67,7 +67,7 @@ def add_links(self, links: List[Link]) -> None: """Add links to this object's set of links. Args: - links (List[Link]): The links to add. + links : The links to add. """ for link in links: @@ -77,7 +77,7 @@ def remove_links(self, rel: str) -> None: """Remove links to this object's set of links that match the given ``rel``. Args: - rel (str): The :class:`~pystac.Link` ``rel`` to match on. + rel : The :class:`~pystac.Link` ``rel`` to match on. """ self.links = [link for link in self.links if link.rel != rel] @@ -86,7 +86,7 @@ def get_single_link(self, rel: str) -> Optional[Link]: """Get single link that match the given ``rel``. Args: - rel (str): The :class:`~pystac.Link` ``rel`` to match on. + rel : The :class:`~pystac.Link` ``rel`` to match on. """ return next((link for link in self.links if link.rel == rel), None) @@ -95,7 +95,7 @@ def get_links(self, rel: Optional[str] = None) -> List[Link]: """Gets the :class:`~pystac.Link` instances associated with this object. Args: - rel (str or None): If set, filter links such that only those + rel : If set, filter links such that only those matching this relationship are returned. Returns: @@ -111,7 +111,7 @@ def clear_links(self, rel: Optional[str] = None) -> None: """Clears all :class:`~pystac.Link` instances associated with this object. Args: - rel (str or None): If set, only clear links that match this relationship. + rel : If set, only clear links that match this relationship. """ if rel is not None: self.links = [link for link in self.links if link.rel != rel] @@ -168,7 +168,7 @@ def set_self_href(self, href: Optional[str]) -> None: :class:`~pystac.Link`. Args: - href (str): The absolute HREF of this object. If the given HREF + href : The absolute HREF of this object. If the given HREF is not absolute, it will be transformed to an absolute HREF based on the current working directory. If this is None the call will clear the self HREF link. @@ -212,7 +212,7 @@ def set_root(self, root: Optional["Catalog_Type"]) -> None: for this object. Args: - root (Catalog, Collection or None): The root + root : The root object to set. Passing in None will clear the root. """ root_link_index = next( @@ -257,7 +257,7 @@ def set_parent(self, parent: Optional["Catalog_Type"]) -> None: for this object. Args: - parent (Catalog, Collection or None): The parent + parent : The parent object to set. Passing in None will clear the parent. """ @@ -270,7 +270,7 @@ def get_stac_objects(self, rel: str) -> Iterable["STACObject"]: by links with their ``rel`` property matching the passed in argument. Args: - rel (str): The relation to match each :class:`~pystac.Link`'s + rel : The relation to match each :class:`~pystac.Link`'s ``rel`` property against. Returns: @@ -293,9 +293,9 @@ def save_object( """Saves this STAC Object to it's 'self' HREF. Args: - include_self_link (bool): If this is true, include the 'self' link with + include_self_link : If this is true, include the 'self' link with this object. Otherwise, leave out the self link. - dest_href (str): Optional HREF to save the file to. If None, the object + dest_href : Optional HREF to save the file to. If None, the object will be saved to the object's self href. stac_io: Optional instance of StacIO to use. If not provided, will use the instance set on the object's root if available, otherwise will use the @@ -340,9 +340,9 @@ def full_copy( this object. Args: - root (STACObject): Optional root to set as the root of the copied object, + root : Optional root to set as the root of the copied object, and any other copies that are contained by this object. - parent (STACObject): Optional parent to set as the parent of the copy + parent : Optional parent to set as the parent of the copy of this object. Returns: @@ -412,7 +412,7 @@ def to_dict(self, include_self_link: bool = True) -> Dict[str, Any]: """Generate a dictionary representing the JSON of this serialized object. Args: - include_self_link (bool): If True, the dict will contain a self link + include_self_link : If True, the dict will contain a self link to this object. If False, the self link will be omitted. dict: A serialization of the object that can be written out as JSON. @@ -440,7 +440,7 @@ def from_file( """Reads a STACObject implementation from a file. Args: - href (str): The HREF to read the object from. + href : The HREF to read the object from. stac_io: Optional instance of StacIO to use. If not provided, will use the default instance. @@ -480,10 +480,10 @@ def from_dict( """Parses this STACObject from the passed in dictionary. Args: - d (dict): The dict to parse. - href (str): Optional href that is the file location of the object being + d : The dict to parse. + href : Optional href that is the file location of the object being parsed. - root (Catalog or Collection): Optional root of the catalog for this object. + root : Optional root of the catalog for this object. If provided, the root's resolved object cache can be used to search for previously resolved instances of the STAC object. migrate: Use True if this dict represents JSON from an older STAC object, diff --git a/pystac/utils.py b/pystac/utils.py index d1c9a78af..0a0f626ea 100644 --- a/pystac/utils.py +++ b/pystac/utils.py @@ -49,10 +49,10 @@ def make_relative_href( """Makes a given HREF relative to the given starting HREF. Args: - source_href (str): The HREF to make relative. - start_href (str): The HREF that the resulting HREF will be relative with + source_href : The HREF to make relative. + start_href : The HREF that the resulting HREF will be relative with respect to. - start_is_dir (str): If True, the start_href is treated as a directory. + start_is_dir : If True, the start_href is treated as a directory. Otherwise, the start_href is considered to be a file HREF. Defaults to False. @@ -90,11 +90,11 @@ def make_absolute_href( """Makes a given HREF absolute based on the given starting HREF. Args: - source_href (str): The HREF to make absolute. - start_href (str): The HREF that will be used as the basis for which to resolve + source_href : The HREF to make absolute. + start_href : The HREF that will be used as the basis for which to resolve relative paths, if source_href is a relative path. Defaults to the current working directory. - start_is_dir (str): If True, the start_href is treated as a directory. + start_is_dir : If True, the start_href is treated as a directory. Otherwise, the start_href is considered to be a file HREF. Defaults to False. @@ -142,7 +142,7 @@ def is_absolute_href(href: str) -> bool: """Determines if an HREF is absolute or not. Args: - href (str): The HREF to consider. + href : The HREF to consider. Returns: bool: True if the given HREF is absolute, False if it is relative. @@ -155,7 +155,7 @@ def datetime_to_str(dt: datetime) -> str: """Convert a python datetime to an ISO8601 string Args: - dt (datetime): The datetime to convert. + dt : The datetime to convert. Returns: str: The ISO8601 formatted string representing the datetime. @@ -179,7 +179,7 @@ def geometry_to_bbox(geometry: Dict[str, Any]) -> List[float]: """Extract the bounding box from a geojson geometry Args: - geometry (dict): GeoJSON geometry dict + geometry : GeoJSON geometry dict Returns: list: Bounding box of geojson geometry, formatted according to: diff --git a/pystac/validation/__init__.py b/pystac/validation/__init__.py index b56e244f1..29dca4048 100644 --- a/pystac/validation/__init__.py +++ b/pystac/validation/__init__.py @@ -19,7 +19,7 @@ def validate(stac_object: "STACObject_Type") -> List[Any]: """Validates a :class:`~pystac.STACObject`. Args: - stac_object (STACObject): The stac object to validate. + stac_object : The stac object to validate. Returns: List[Object]: List of return values from the validation calls for the @@ -52,15 +52,15 @@ def validate_dict( :class:`~pystac.validation.JsonSchemaSTACValidator` by default. Args: - stac_dict (dict): Dictionary that is the STAC json of the object. - stac_object_type (str): The stac object type of the object encoded in stac_dict. + stac_dict : Dictionary that is the STAC json of the object. + stac_object_type : The stac object type of the object encoded in stac_dict. One of :class:`~pystac.STACObjectType`. If not supplied, this will use PySTAC's identification logic to identify the object type. - stac_version (str): The version of STAC to validate the object against. If not supplied, + stac_version : The version of STAC to validate the object against. If not supplied, this will use PySTAC's identification logic to identify the stac version - extensions (List[str]): Extension IDs for this stac object. If not supplied, + extensions : Extension IDs for this stac object. If not supplied, PySTAC's identification logic to identify the extensions. - href (str): Optional HREF of the STAC object being validated. + href : Optional HREF of the STAC object being validated. Returns: List[Object]: List of return values from the validation calls for the @@ -113,8 +113,8 @@ def validate_all( Args: - stac_dict (dict): Dictionary that is the STAC json of the object. - href (str): HREF of the STAC object being validated. Used for error + stac_dict : Dictionary that is the STAC json of the object. + href : HREF of the STAC object being validated. Used for error reporting and resolving relative links. stac_io: Optional StacIO instance to use for reading hrefs. If None, the StacIO.default() instance is used. @@ -184,7 +184,7 @@ def set_validator(validator: STACValidator) -> None: """Sets the STACValidator to use in PySTAC. Args: - validator (STACValidator): The STACValidator implementation to use for + validator : The STACValidator implementation to use for validation. """ RegisteredValidator.set_validator(validator) diff --git a/pystac/validation/schema_uri_map.py b/pystac/validation/schema_uri_map.py index a2d62841b..1ad488731 100644 --- a/pystac/validation/schema_uri_map.py +++ b/pystac/validation/schema_uri_map.py @@ -21,9 +21,9 @@ def get_object_schema_uri( """Get the schema URI for the given object type and stac version. Args: - object_type (STACObjectType): STAC object type. One of + object_type : STAC object type. One of :class:`~pystac.STACObjectType` - stac_version (str): The STAC version of the schema to return. + stac_version : The STAC version of the schema to return. Returns: str: The URI of the schema, or None if not found. diff --git a/pystac/validation/stac_validator.py b/pystac/validation/stac_validator.py index 777b4307d..1e544467a 100644 --- a/pystac/validation/stac_validator.py +++ b/pystac/validation/stac_validator.py @@ -38,11 +38,11 @@ def validate_core( Return value can be None or specific to the implementation. Args: - stac_dict (dict): Dictionary that is the STAC json of the object. - stac_object_type (str): The stac object type of the object encoded + stac_dict : Dictionary that is the STAC json of the object. + stac_object_type : The stac object type of the object encoded in stac_dict. One of :class:`~pystac.STACObjectType`. - stac_version (str): The version of STAC to validate the object against. - href (str): Optional HREF of the STAC object being validated. + stac_version : The version of STAC to validate the object against. + href : Optional HREF of the STAC object being validated. """ pass @@ -60,12 +60,12 @@ def validate_extension( Return value can be None or specific to the implementation. Args: - stac_dict (dict): Dictionary that is the STAC json of the object. - stac_object_type (str): The stac object type of the object encoded in + stac_dict : Dictionary that is the STAC json of the object. + stac_object_type : The stac object type of the object encoded in stac_dict. One of :class:`~pystac.STACObjectType`. - stac_version (str): The version of STAC to validate the object against. - extension_id (str): The extension ID of the extension to validate against. - href (str): Optional HREF of the STAC object being validated. + stac_version : The version of STAC to validate the object against. + extension_id : The extension ID of the extension to validate against. + href : Optional HREF of the STAC object being validated. """ pass @@ -80,12 +80,12 @@ def validate( """Validate a STAC object JSON. Args: - stac_dict (dict): Dictionary that is the STAC json of the object. - stac_object_type (str): The stac object type of the object encoded in + stac_dict : Dictionary that is the STAC json of the object. + stac_object_type : The stac object type of the object encoded in stac_dict. One of :class:`~pystac.STACObjectType`. - stac_version (str): The version of STAC to validate the object against. - extensions (List[str]): Extension IDs for this stac object. - href (str): Optional href of the STAC object being validated. + stac_version : The version of STAC to validate the object against. + extensions : Extension IDs for this stac object. + href : Optional href of the STAC object being validated. Returns: List[Any]: List of return values from the validation calls for the @@ -122,7 +122,7 @@ class JsonSchemaSTACValidator(STACValidator): objects and extensions. Args: - schema_uri_map (SchemaUriMap): The SchemaUriMap that defines where + schema_uri_map : The SchemaUriMap that defines where the validator will retrieve the JSON schemas for validation. Defaults to an instance of :class:`~pystac.validation.schema_uri_map.DefaultSchemaUriMap` @@ -195,11 +195,11 @@ def validate_core( Return value can be None or specific to the implementation. Args: - stac_dict (dict): Dictionary that is the STAC json of the object. - stac_object_type (str): The stac object type of the object encoded in + stac_dict : Dictionary that is the STAC json of the object. + stac_object_type : The stac object type of the object encoded in stac_dict. One of :class:`~pystac.STACObjectType`. - stac_version (str): The version of STAC to validate the object against. - href (str): Optional HREF of the STAC object being validated. + stac_version : The version of STAC to validate the object against. + href : Optional HREF of the STAC object being validated. Returns: str: URI for the JSON schema that was validated against, or None if @@ -234,12 +234,12 @@ def validate_extension( Return value can be None or specific to the implementation. Args: - stac_dict (dict): Dictionary that is the STAC json of the object. - stac_object_type (str): The stac object type of the object encoded in + stac_dict : Dictionary that is the STAC json of the object. + stac_object_type : The stac object type of the object encoded in stac_dict. One of :class:`~pystac.STACObjectType`. - stac_version (str): The version of STAC to validate the object against. - extension_id (str): The extension ID to validate against. - href (str): Optional HREF of the STAC object being validated. + stac_version : The version of STAC to validate the object against. + extension_id : The extension ID to validate against. + href : Optional HREF of the STAC object being validated. Returns: str: URI for the JSON schema that was validated against, or None if diff --git a/pystac/version.py b/pystac/version.py index 4176f0428..d73a3bfa6 100644 --- a/pystac/version.py +++ b/pystac/version.py @@ -57,7 +57,7 @@ def set_stac_version(stac_version: Optional[str]) -> None: the version. Args: - stac_version (str): The STAC version to use instead of the latest STAC version + stac_version : The STAC version to use instead of the latest STAC version that PySTAC supports (described in STACVersion.DEFAULT_STAC_VERSION). If None, clear to use the default for this version of PySTAC. From bc47d46d387c4736c61e535408f8d46a49bb4c6f Mon Sep 17 00:00:00 2001 From: Pete Gadomski Date: Wed, 19 May 2021 07:46:07 -0600 Subject: [PATCH 08/23] Remove duplicate `read_text` without orjson If orjson was not present, the `_json_loads` method on `StacIO` would try to read the text again, which would lead to the read text method being called with json (bad). This slipped through CI because one of the requirements-dev.txt dependencies installs orjson, so the non-orjson case wasn't being tested. This commit also includes a new build job to install+test without requirements-dev.txt to try and protect against regression. Also includes a scripts comment fix to s/yapf/black, and a comment to make pylance ignore a missing orjson import. I didn't update the docs re the yapf->black switch b/c @lossyrob said that some other folks were working on the docs upgrades. --- .github/workflows/continuous-integration.yml | 11 +++++++++++ .style.yapf | 2 -- pystac/stac_io.py | 4 ++-- scripts/format | 2 +- tests/test_stac_io.py | 6 ++++++ 5 files changed, 20 insertions(+), 5 deletions(-) delete mode 100644 .style.yapf diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 91c98d54d..7ae18723b 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -39,3 +39,14 @@ jobs: token: ${{ secrets.CODECOV_TOKEN }} file: ./coverage.xml fail_ci_if_error: false + vanilla: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + with: + python-version: "3.8" + - name: Install without orjson + run: pip install '.[validation]' + - name: Run unittests + run: python -m unittest discover tests diff --git a/.style.yapf b/.style.yapf deleted file mode 100644 index a5af27342..000000000 --- a/.style.yapf +++ /dev/null @@ -1,2 +0,0 @@ -[style] -column_limit = 100 \ No newline at end of file diff --git a/pystac/stac_io.py b/pystac/stac_io.py index 94e391875..dde2985d9 100644 --- a/pystac/stac_io.py +++ b/pystac/stac_io.py @@ -23,7 +23,7 @@ # Use orjson if available try: - import orjson + import orjson # type: ignore except ImportError: orjson = None @@ -77,7 +77,7 @@ def _json_loads(self, txt: str, source: Union[str, "Link_Type"]) -> Dict[str, An if orjson is not None: return orjson.loads(txt) else: - return json.loads(self.read_text(txt)) + return json.loads(txt) def _json_dumps( self, json_dict: Dict[str, Any], source: Union[str, "Link_Type"] diff --git a/scripts/format b/scripts/format index 640929c39..95676126a 100755 --- a/scripts/format +++ b/scripts/format @@ -9,7 +9,7 @@ fi function usage() { echo -n \ "Usage: $(basename "$0") -Format code with yapf +Format code with black " } diff --git a/tests/test_stac_io.py b/tests/test_stac_io.py index b744ca4ee..97b18649c 100644 --- a/tests/test_stac_io.py +++ b/tests/test_stac_io.py @@ -1,6 +1,7 @@ import unittest import warnings +import pystac from pystac.stac_io import STAC_IO from tests.utils import TestCases @@ -18,3 +19,8 @@ def test_stac_io_issues_warnings(self): # Verify some things self.assertEqual(len(w), 1) self.assertTrue(issubclass(w[-1].category, DeprecationWarning)) + + def test_read_text(self): + _ = pystac.read_file( + TestCases.get_path("data-files/collections/multi-extent.json") + ) From 9deb0f7d8eca11f817b61f4b876b5ff5e2078ca9 Mon Sep 17 00:00:00 2001 From: Pete Gadomski Date: Wed, 19 May 2021 08:29:00 -0600 Subject: [PATCH 09/23] Update CHANGELOG for #348 --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 88ca123ff..158335842 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ ### Changed +### Fixed + +- Reading json without orjson ([#348](https://github.com/stac-utils/pystac/pull/348)) + ### Remove ## [1.0.0-beta.1] From 63911a6246af5ea3fe6717ff047c76a1d04ab049 Mon Sep 17 00:00:00 2001 From: Jon Duckworth Date: Thu, 20 May 2021 08:39:03 -0400 Subject: [PATCH 10/23] Pin jinja2 to fix nbsphinx build issue See https://github.com/pydata/xarray/issues/5299 --- requirements-dev.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/requirements-dev.txt b/requirements-dev.txt index 3b00ec452..9a996c384 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -12,5 +12,8 @@ sphinxcontrib-fulltoc==1.2.0 nbsphinx==0.7.1 coverage==5.2.* +# https://github.com/pydata/xarray/issues/5299#issuecomment-840730954 +jinja2<3.0 + # optional dependencies orjson==3.5.2 From 093001f2b9ca7267867f816fa635011c0bbd0d30 Mon Sep 17 00:00:00 2001 From: Jon Duckworth Date: Thu, 20 May 2021 08:39:28 -0400 Subject: [PATCH 11/23] Fix reference to ExtensionError in API docs --- docs/api.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/api.rst b/docs/api.rst index 9279dfbb1..c19c78656 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -178,10 +178,10 @@ STACError .. autoclass:: pystac.STACError -ExtensionError -~~~~~~~~~~~~~~ +ExtensionTypeError +~~~~~~~~~~~~~~~~~~ -.. autoclass:: pystac.extensions.ExtensionError +.. autoclass:: pystac.ExtensionTypeError Extensions ---------- From 35aafd504465f8793506b4f58004b9f1f10b0bbf Mon Sep 17 00:00:00 2001 From: Jon Duckworth Date: Thu, 20 May 2021 13:20:28 -0400 Subject: [PATCH 12/23] Update branch names and cache in CI --- .github/workflows/continuous-integration.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 91c98d54d..b6e70e2e8 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -3,8 +3,7 @@ name: CI on: push: branches: - - develop - - master + - main pull_request: jobs: @@ -26,8 +25,7 @@ jobs: uses: actions/cache@v2 with: path: ~/.cache/pip - key: pip-${{ hashFiles('requirements-dev.txt') }} - restore-keys: pip- + key: pip-python${{ matrix.python-version }}-${{ hashFiles('requirements-dev.txt') }} - name: Execute linters and test suites run: ./scripts/cibuild From 7b27a16fa86ad116e8414f588328d35d385e54c8 Mon Sep 17 00:00:00 2001 From: Jon Duckworth Date: Thu, 20 May 2021 13:39:28 -0400 Subject: [PATCH 13/23] More specific cache key --- .github/workflows/continuous-integration.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index b6e70e2e8..a9c4a0cfa 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -25,7 +25,8 @@ jobs: uses: actions/cache@v2 with: path: ~/.cache/pip - key: pip-python${{ matrix.python-version }}-${{ hashFiles('requirements-dev.txt') }} + # Cache based on OS, Python version, and dependency hash + key: pip-${{ runner.os }}-python${{ matrix.python-version }}-${{ hashFiles('requirements-dev.txt') }} - name: Execute linters and test suites run: ./scripts/cibuild From 98845e93e5856d5adb90032e8229acda0c2de4f1 Mon Sep 17 00:00:00 2001 From: Jon Duckworth Date: Thu, 20 May 2021 13:40:11 -0400 Subject: [PATCH 14/23] Only upload coverage for 1 matrix job --- .github/workflows/continuous-integration.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index a9c4a0cfa..9f3814d7a 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -30,10 +30,11 @@ jobs: - name: Execute linters and test suites run: ./scripts/cibuild - - + - name: Upload All coverage to Codecov uses: codecov/codecov-action@v1 + # Only upload this once... + if: ${{ matrix.os == 'Linux' && matrix.python-version == "3.8"}} with: token: ${{ secrets.CODECOV_TOKEN }} file: ./coverage.xml From 2e8bc2b9c9299b0122d998ce7102cb9255160446 Mon Sep 17 00:00:00 2001 From: Jon Duckworth Date: Thu, 20 May 2021 13:40:27 -0400 Subject: [PATCH 15/23] Add Windows and Mac tests --- .github/workflows/continuous-integration.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 9f3814d7a..0b67e2619 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -9,10 +9,13 @@ on: jobs: build: name: build - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} strategy: + # Allow other matrix jobs to complete if 1 fails + fail-fast: false matrix: python-version: ["3.6", "3.7", "3.8"] + os: [ubuntu-latest, windows-latest, macos-latest] steps: - uses: actions/checkout@v2 From 6007d6a9bf8e0ff924c7ac0c4c2b455fc88fc2ff Mon Sep 17 00:00:00 2001 From: Jon Duckworth Date: Thu, 20 May 2021 14:29:04 -0400 Subject: [PATCH 16/23] Fix syntax --- .github/workflows/continuous-integration.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 0b67e2619..323e9b73d 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -37,7 +37,7 @@ jobs: - name: Upload All coverage to Codecov uses: codecov/codecov-action@v1 # Only upload this once... - if: ${{ matrix.os == 'Linux' && matrix.python-version == "3.8"}} + if: ${{ matrix.os == 'Linux' && matrix.python-version == '3.8'}} with: token: ${{ secrets.CODECOV_TOKEN }} file: ./coverage.xml From 554b0539a715450530d8dbf2c121fbd508b082ab Mon Sep 17 00:00:00 2001 From: Jon Duckworth Date: Thu, 20 May 2021 14:40:22 -0400 Subject: [PATCH 17/23] Fix OS match for coverage upload --- .github/workflows/continuous-integration.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 323e9b73d..b5355f982 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -37,7 +37,7 @@ jobs: - name: Upload All coverage to Codecov uses: codecov/codecov-action@v1 # Only upload this once... - if: ${{ matrix.os == 'Linux' && matrix.python-version == '3.8'}} + if: ${{ matrix.os == 'ubuntu-latest' && matrix.python-version == '3.8'}} with: token: ${{ secrets.CODECOV_TOKEN }} file: ./coverage.xml From 9b95c3531801dcafca900a3643d2284696ae5769 Mon Sep 17 00:00:00 2001 From: Pete Gadomski Date: Fri, 21 May 2021 11:01:14 -0600 Subject: [PATCH 18/23] Split default IO down into to/from href methods This allows subclasses of DefaultStacIO to not have to re-impelment link resolution if they don't want to. --- pystac/stac_io.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pystac/stac_io.py b/pystac/stac_io.py index 5e829cfb8..d7e67cfa0 100644 --- a/pystac/stac_io.py +++ b/pystac/stac_io.py @@ -176,7 +176,9 @@ def read_text( href = source.get_absolute_href() if href is None: raise IOError(f"Could not get an absolute HREF from link {source}") + return self.read_text_from_href(href, *args, **kwargs) + def read_text_from_href(self, href: str, *args: Any, **kwargs: Any) -> str: parsed = urlparse(href) if parsed.scheme != "": try: @@ -197,7 +199,11 @@ def write_text( href = dest.get_absolute_href() if href is None: raise IOError(f"Could not get an absolute HREF from link {dest}") + return self.write_text_to_href(href, txt, *args, **kwargs) + def write_text_to_href( + self, href: str, txt: str, *args: Any, **kwargs: Any + ) -> None: dirname = os.path.dirname(href) if dirname != "" and not os.path.isdir(dirname): os.makedirs(dirname) From 8cedba579f56dd0ef1f916ecd454db540b5d3f07 Mon Sep 17 00:00:00 2001 From: Pete Gadomski Date: Fri, 21 May 2021 11:08:20 -0600 Subject: [PATCH 19/23] Update CHANGELOG for #354 --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 158335842..31397cf59 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ ### Changed +- Split `DefaultStacIO`'s reading and writing into two methods to allow subclasses to use the default link resolution behavior ([#354](https://github.com/stac-utils/pystac/pull/354)) + ### Fixed - Reading json without orjson ([#348](https://github.com/stac-utils/pystac/pull/348)) From 6df6671908275267d91ae6b9761941c8a6a0a221 Mon Sep 17 00:00:00 2001 From: Pete Gadomski Date: Fri, 21 May 2021 07:52:08 -0600 Subject: [PATCH 20/23] Add more pointcloud extension tests Fixes #248 --- tests/extensions/test_pointcloud.py | 89 +++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) diff --git a/tests/extensions/test_pointcloud.py b/tests/extensions/test_pointcloud.py index b2435c983..c43d3e32b 100644 --- a/tests/extensions/test_pointcloud.py +++ b/tests/extensions/test_pointcloud.py @@ -5,7 +5,10 @@ # from copy import deepcopy import pystac +from pystac.asset import Asset +from pystac.errors import ExtensionTypeError, STACError from pystac.extensions.pointcloud import ( + AssetPointcloudExtension, PointcloudExtension, PointcloudSchema, PointcloudStatistic, @@ -178,6 +181,22 @@ def test_pointcloud_schema(self): setattr(schema, k, val) self.assertEqual(getattr(schema, k), val) + schema = PointcloudSchema.create("intensity", 16, "unsigned") + self.assertEqual(schema.name, "intensity") + self.assertEqual(schema.size, 16) + self.assertEqual(schema.type, "unsigned") + + with self.assertRaises(STACError): + schema.size = 0.5 # type: ignore + + empty_schema = PointcloudSchema({}) + with self.assertRaises(STACError): + empty_schema.size + with self.assertRaises(STACError): + empty_schema.name + with self.assertRaises(STACError): + empty_schema.type + def test_pointcloud_statistics(self): props: Dict[str, Any] = { "average": 1, @@ -201,6 +220,76 @@ def test_pointcloud_statistics(self): setattr(stat, k, val) self.assertEqual(getattr(stat, k), val) + stat = PointcloudStatistic.create("foo", 1, 2, 3, 4, 5, 6, 7) + self.assertEqual(stat.name, "foo") + self.assertEqual(stat.position, 1) + self.assertEqual(stat.average, 2) + self.assertEqual(stat.count, 3) + self.assertEqual(stat.maximum, 4) + self.assertEqual(stat.minimum, 5) + self.assertEqual(stat.stddev, 6) + self.assertEqual(stat.variance, 7) + + stat.name = None # type: ignore + self.assertNotIn("name", stat.properties) + stat.position = None + self.assertNotIn("position", stat.properties) + stat.average = None + self.assertNotIn("average", stat.properties) + stat.count = None + self.assertNotIn("count", stat.properties) + stat.maximum = None + self.assertNotIn("maximum", stat.properties) + stat.minimum = None + self.assertNotIn("minimum", stat.properties) + stat.stddev = None + self.assertNotIn("stddev", stat.properties) + stat.variance = None + self.assertNotIn("variance", stat.properties) + + empty_stat = PointcloudStatistic({}) + with self.assertRaises(STACError): + empty_stat.name + def test_statistics_accessor_when_no_stats(self): pc_item = pystac.Item.from_file(self.example_uri_no_statistics) self.assertEqual(PointcloudExtension.ext(pc_item).statistics, None) + + def test_asset_extension(self): + asset = Asset( + "https://github.com/PDAL/PDAL/blob" + "/a6c986f68458e92414a66c664408bee4737bbb08/test/data/laz" + "/autzen_trim.laz", + "laz file", + "The laz data", + "application/octet-stream", + ["data"], + {"foo": "bar"}, + ) + pc_item = pystac.Item.from_file(self.example_uri_no_statistics) + pc_item.add_asset("data", asset) + ext = AssetPointcloudExtension(asset) + self.assertEqual(ext.asset_href, asset.href) + self.assertEqual(ext.properties, asset.properties) + self.assertEqual(ext.additional_read_properties, [pc_item.properties]) + + def test_ext(self): + pc_item = pystac.Item.from_file(self.example_uri_no_statistics) + PointcloudExtension.ext(pc_item) + asset = Asset( + "https://github.com/PDAL/PDAL/blob" + "/a6c986f68458e92414a66c664408bee4737bbb08/test/data/laz" + "/autzen_trim.laz", + "laz file", + "The laz data", + "application/octet-stream", + ["data"], + {"foo": "bar"}, + ) + PointcloudExtension.ext(asset) + + class RandomObject: + pass + + with self.assertRaises(ExtensionTypeError): + PointcloudExtension.ext(RandomObject()) # type: ignore From 3e2d51ce10100fc9037e7780f32f54230b100a21 Mon Sep 17 00:00:00 2001 From: Pete Gadomski Date: Mon, 24 May 2021 06:30:36 -0600 Subject: [PATCH 21/23] Update CHANGELOG for #352 --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 31397cf59..16490c362 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ ### Changed - Split `DefaultStacIO`'s reading and writing into two methods to allow subclasses to use the default link resolution behavior ([#354](https://github.com/stac-utils/pystac/pull/354)) +- Increased test coverage for the pointcloud extension ([#352](https://github.com/stac-utils/pystac/pull/352)) ### Fixed From ede7cf99a6bc8e0928cfefaf812f2ffd5ae9c633 Mon Sep 17 00:00:00 2001 From: Jon Duckworth Date: Mon, 24 May 2021 14:23:18 -0400 Subject: [PATCH 22/23] PySTAC version 1.0.0-beta.2 --- CHANGELOG.md | 15 +++++++++++++-- pystac/version.py | 2 +- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 16490c362..7389f4b13 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,16 @@ ### Changed +### Fixed + +### Remove + +## [1.0.0-beta.2] + +### Added + +### Changed + - Split `DefaultStacIO`'s reading and writing into two methods to allow subclasses to use the default link resolution behavior ([#354](https://github.com/stac-utils/pystac/pull/354)) - Increased test coverage for the pointcloud extension ([#352](https://github.com/stac-utils/pystac/pull/352)) @@ -13,7 +23,7 @@ - Reading json without orjson ([#348](https://github.com/stac-utils/pystac/pull/348)) -### Remove +### Removed ## [1.0.0-beta.1] @@ -302,7 +312,8 @@ use `Band.create` Initial release. -[Unreleased]: +[Unreleased]: +[v1.0.0-beta.2]: [v1.0.0-beta.1]: [v0.5.6]: [v0.5.5]: diff --git a/pystac/version.py b/pystac/version.py index 51831f601..e6bd69494 100644 --- a/pystac/version.py +++ b/pystac/version.py @@ -1,7 +1,7 @@ import os from typing import Optional -__version__ = "1.0.0-beta.1" +__version__ = "1.0.0-beta.2" """Library version""" From f71576116553836cde1cfa52b0ca9fd7fe3ef2b2 Mon Sep 17 00:00:00 2001 From: Jon Duckworth Date: Mon, 24 May 2021 14:42:11 -0400 Subject: [PATCH 23/23] Entry for docstring type removal. Also gets rid of empty Added section --- CHANGELOG.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7389f4b13..718f27d8f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,12 +8,10 @@ ### Fixed -### Remove +### Removed ## [1.0.0-beta.2] -### Added - ### Changed - Split `DefaultStacIO`'s reading and writing into two methods to allow subclasses to use the default link resolution behavior ([#354](https://github.com/stac-utils/pystac/pull/354)) @@ -25,6 +23,9 @@ ### Removed +- Removed type information from docstrings, since it is redundant with function type + annotations ([#342](https://github.com/stac-utils/pystac/pull/342)) + ## [1.0.0-beta.1] ### Added