Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Remove text around to_dict and JSON #1074

Merged
merged 4 commits into from
Apr 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
### Changed

- Include a copy of the `fields.json` file (for summaries) with each distribution of PySTAC ([#1045](https://github.com/stac-utils/pystac/pull/1045))
- Removed documentation references to `to_dict` methods returning JSON ([#1074](https://github.com/stac-utils/pystac/pull/1074))

### Deprecated

Expand Down
4 changes: 2 additions & 2 deletions pystac/asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,10 @@ def get_absolute_href(self) -> Optional[str]:
return None

def to_dict(self) -> Dict[str, Any]:
"""Generate a dictionary representing the JSON of this Asset.
"""Returns this Asset as a dictionary.

Returns:
dict: A serialization of the Asset that can be written out as JSON.
dict: A serialization of the Asset.
"""

d: Dict[str, Any] = {"href": self.href}
Expand Down
12 changes: 6 additions & 6 deletions pystac/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ def __init__(
self.extra_fields = extra_fields or {}

def to_dict(self) -> Dict[str, Any]:
"""Generate a dictionary representing the JSON of this SpatialExtent.
"""Returns this spatial extent as a dictionary.

Returns:
dict: A serialization of the SpatialExtent that can be written out as JSON.
dict: A serialization of the SpatialExtent.
"""
d = {"bbox": self.bboxes, **self.extra_fields}
return d
Expand Down Expand Up @@ -212,10 +212,10 @@ def __init__(
self.extra_fields = extra_fields or {}

def to_dict(self) -> Dict[str, Any]:
"""Generate a dictionary representing the JSON of this TemporalExtent.
"""Returns this temporal extent as a dictionary.

Returns:
dict: A serialization of the TemporalExtent that can be written out as JSON.
dict: A serialization of the TemporalExtent.
"""
encoded_intervals: List[List[Optional[str]]] = []
for i in self.intervals:
Expand Down Expand Up @@ -311,10 +311,10 @@ def __init__(
self.extra_fields = extra_fields or {}

def to_dict(self) -> Dict[str, Any]:
"""Generate a dictionary representing the JSON of this Extent.
"""Returns this extent as a dictionary.

Returns:
dict: A serialization of the Extent that can be written out as JSON.
dict: A serialization of the Extent.
"""
d = {
"spatial": self.spatial.to_dict(),
Expand Down
4 changes: 2 additions & 2 deletions pystac/extensions/eo.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,10 @@ def __repr__(self) -> str:
return "<Band name={}>".format(self.name)

def to_dict(self) -> Dict[str, Any]:
"""Returns the dictionary representing the JSON of this Band.
"""Returns this band as a dictionary.

Returns:
dict: The wrapped dict of the Band that can be written out as JSON.
dict: The serialization of this Band.
"""
return self.properties

Expand Down
2 changes: 1 addition & 1 deletion pystac/extensions/item_assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def roles(self, v: Optional[List[str]]) -> None:
self.properties[ASSET_ROLES_PROP] = v

def to_dict(self) -> Dict[str, Any]:
"""Returns a JSON-like dictionary representing this ``AssetDefinition``."""
"""Returns a dictionary representing this ``AssetDefinition``."""
return deepcopy(self.properties)

def create_asset(self, href: str) -> pystac.Asset:
Expand Down
8 changes: 4 additions & 4 deletions pystac/extensions/label.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def __eq__(self, o: object) -> bool:
return self.to_dict() == o

def to_dict(self) -> Dict[str, Any]:
"""Returns the dictionary representing the JSON of this instance."""
"""Returns this label classes object as a dictionary."""
return self.properties


Expand Down Expand Up @@ -197,7 +197,7 @@ def count(self, v: int) -> None:
self.properties["count"] = v

def to_dict(self) -> Dict[str, Any]:
"""Returns the dictionary representing the JSON of this instance."""
"""Returns this label count object as a dictionary."""
return self.properties

def __eq__(self, o: object) -> bool:
Expand Down Expand Up @@ -262,7 +262,7 @@ def value(self, v: float) -> None:
self.properties["value"] = v

def to_dict(self) -> Dict[str, Any]:
"""Returns the dictionary representing the JSON of this LabelStatistics."""
"""Returns this label statistics object as a dictionary."""
return self.properties

def __eq__(self, o: object) -> bool:
Expand Down Expand Up @@ -417,7 +417,7 @@ def add_counts(counts: List[LabelCount]) -> None:
return LabelOverview.create(self.property_key, counts=new_counts)

def to_dict(self) -> Dict[str, Any]:
"""Returns the dictionary representing the JSON of this LabelOverview."""
"""Returns this label overview as a dictionary."""
return self.properties

def __eq__(self, o: object) -> bool:
Expand Down
4 changes: 2 additions & 2 deletions pystac/extensions/pointcloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def __repr__(self) -> str:
)

def to_dict(self) -> Dict[str, Any]:
"""Returns a JSON-like dictionary representing this ``Schema``."""
"""Returns this schema as a dictionary."""
return self.properties


Expand Down Expand Up @@ -309,7 +309,7 @@ def __repr__(self) -> str:
return "<Statistic statistics={}>".format(str(self.properties))

def to_dict(self) -> Dict[str, Any]:
"""Returns a JSON-like dictionary representing this ``Statistic``."""
"""Returns this statistic as a dictionary."""
return self.properties

def __eq__(self, o: object) -> bool:
Expand Down
12 changes: 6 additions & 6 deletions pystac/extensions/raster.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,10 @@ def valid_percent(self, v: Optional[float]) -> None:
self.properties.pop("valid_percent", None)

def to_dict(self) -> Dict[str, Any]:
"""Returns the dictionary representing the JSON of those Statistics.
"""Returns these statistics as a dictionary.

Returns:
dict: The wrapped dict of the Statistics that can be written out as JSON.
dict: The serialization of the Statistics.
"""
return self.properties

Expand Down Expand Up @@ -328,10 +328,10 @@ def buckets(self, v: List[int]) -> None:
self.properties["buckets"] = v

def to_dict(self) -> Dict[str, Any]:
"""Returns the dictionary representing the JSON of this histogram.
"""Returns this histogram as a dictionary.

Returns:
dict: The wrapped dict of the Histogram that can be written out as JSON.
dict: The serialization of the Histogram.
"""
return self.properties

Expand Down Expand Up @@ -631,10 +631,10 @@ def __repr__(self) -> str:
return "<Raster Band>"

def to_dict(self) -> Dict[str, Any]:
"""Returns the dictionary representing the JSON of this Band.
"""Returns this band as a dictionary.

Returns:
dict: The wrapped dict of the Band that can be written out as JSON.
dict: The serialization of the Band.
"""
return self.properties

Expand Down
4 changes: 2 additions & 2 deletions pystac/extensions/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def col_type(self, v: Optional[str]) -> None:
self.properties[COL_TYPE_PROP] = v

def to_dict(self) -> Dict[str, Any]:
"""Returns a JSON-like dictionary representing this ``Column``."""
"""Returns a dictionary representing this ``Column``."""
return self.properties


Expand Down Expand Up @@ -111,7 +111,7 @@ def description(self, v: Optional[str]) -> None:
self.properties[COL_DESCRIPTION_PROP] = v

def to_dict(self) -> Dict[str, Any]:
"""Returns a JSON-like dictionary representing this ``Table``."""
"""Returns a dictionary representing this ``Table``."""
return self.properties


Expand Down
2 changes: 1 addition & 1 deletion pystac/item_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def __add__(self, other: object) -> "ItemCollection":
return ItemCollection(items=combined)

def to_dict(self, transform_hrefs: bool = False) -> Dict[str, Any]:
"""Serializes an :class:`ItemCollection` instance to a JSON-like dictionary.
"""Serializes an :class:`ItemCollection` instance to a dictionary.

Args:
transform_hrefs: If True, transform the HREF of hierarchical links
Expand Down
4 changes: 2 additions & 2 deletions pystac/link.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ def is_hierarchical(self) -> bool:
return self.rel in HIERARCHICAL_LINKS

def to_dict(self, transform_href: bool = True) -> Dict[str, Any]:
"""Generate a dictionary representing the JSON of this serialized Link.
"""Returns this link as a dictionary.

Args:
transform_href : If ``True``, transform the HREF based on the type of
Expand All @@ -368,7 +368,7 @@ def to_dict(self, transform_href: bool = True) -> Dict[str, Any]:
the HREF will be transformed to be relative to the catalog root
if this is a hierarchical link relation.
Returns:
dict : A serialization of the Link that can be written out as JSON.
dict : A serialization of the Link.
"""

d: Dict[str, Any] = {
Expand Down
4 changes: 2 additions & 2 deletions pystac/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ def _repr_html_(self) -> str:
return escape(repr(self))

def to_dict(self) -> Dict[str, Any]:
"""Generate a dictionary representing the JSON of this Provider.
"""Returns this provider as a dictionary.

Returns:
dict: A serialization of the Provider that can be written out as JSON.
dict: A serialization of the Provider.
"""
d: Dict[str, Any] = {"name": self.name}
if self.description is not None:
Expand Down
4 changes: 2 additions & 2 deletions pystac/stac_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ def _object_links(self) -> List[str]:
def to_dict(
self, include_self_link: bool = True, transform_hrefs: bool = True
) -> Dict[str, Any]:
"""Generate a dictionary representing the JSON of this serialized object.
"""Returns this object as a dictionary.

Args:
include_self_link : If True, the dict will contain a self link
Expand All @@ -527,7 +527,7 @@ def to_dict(
hierarchical link HREFs will be transformed to be relative to the
catalog root.

dict: A serialization of the object that can be written out as JSON.
dict: A serialization of the object.
"""
raise NotImplementedError

Expand Down