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

refactor: Split long lines #536

Merged
merged 1 commit into from
Jul 8, 2021
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
27 changes: 16 additions & 11 deletions pystac/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,26 +46,29 @@ def __str__(self) -> str:
local computer, so all links need to be relative.

See:
:stac-spec:`The best practices documentation on self-contained catalogs <best-practices.md#self-contained-catalogs>`
""" # noqa E501
:stac-spec:`The best practices documentation on self-contained catalogs
<best-practices.md#self-contained-catalogs>`
"""

ABSOLUTE_PUBLISHED = "ABSOLUTE_PUBLISHED"
"""
Absolute Published Catalog is a catalog that uses absolute links for everything,
both in the links objects and in the asset hrefs.

See:
:stac-spec:`The best practices documentation on published catalogs <best-practices.md#published-catalogs>`
""" # noqa E501
:stac-spec:`The best practices documentation on published catalogs
<best-practices.md#published-catalogs>`
"""

RELATIVE_PUBLISHED = "RELATIVE_PUBLISHED"
"""
Relative Published Catalog is a catalog that uses relative links for everything,
but includes an absolute self link at the root catalog, to identify its online location.
Relative Published Catalog is a catalog that uses relative links for everything, but
includes an absolute self link at the root catalog, to identify its online location.

See:
:stac-spec:`The best practices documentation on published catalogs <best-practices.md#published-catalogs>`
""" # noqa E501
:stac-spec:`The best practices documentation on published catalogs
<best-practices.md#published-catalogs>`
"""

@classmethod
def determine_type(cls, stac_json: Dict[str, Any]) -> Optional["CatalogType"]:
Expand Down Expand Up @@ -564,11 +567,13 @@ def normalize_hrefs(
Args:
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`
for this catalog. Defaults to
:class:`~pystac.layout.BestPracticesLayoutStrategy`

See:
:stac-spec:`STAC best practices document <best-practices.md#catalog-layout>` for the canonical layout of a STAC.
""" # noqa E501
:stac-spec:`STAC best practices document <best-practices.md#catalog-layout>`
for the canonical layout of a STAC.
"""
if strategy is None:
_strategy: HrefLayoutStrategy = BestPracticesLayoutStrategy()
else:
Expand Down
22 changes: 11 additions & 11 deletions pystac/extensions/eo.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ def apply(
of accepted common names <eo#common-band-names>`.
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).
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).
solar_illumination: The solar illumination of the band,
as measured at half the maximum transmission, in W/m2/micrometers.
""" # noqa
"""
self.name = name
self.common_name = common_name
self.description = description
Expand Down Expand Up @@ -98,11 +98,11 @@ def create(
accepted common names <eo#common-band-names>`.
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).
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).
solar_illumination: The solar illumination of the band,
as measured at half the maximum transmission, in W/m2/micrometers.
""" # noqa
"""
b = cls({})
b.apply(
name=name,
Expand Down Expand Up @@ -135,7 +135,7 @@ def common_name(self) -> Optional[str]:

Returns:
Optional[str]
""" # noqa
"""
return self.properties.get("common_name")

@common_name.setter
Expand Down Expand Up @@ -234,7 +234,7 @@ def band_range(common_name: str) -> Optional[Tuple[float, float]]:
Returns:
Tuple[float, float] or None: The band range for this name as (min, max), or
None if this is not a recognized common name.
""" # noqa E501
"""
name_to_range = {
"coastal": (0.40, 0.45),
"blue": (0.45, 0.50),
Expand Down Expand Up @@ -265,9 +265,9 @@ def band_description(common_name: str) -> Optional[str]:
accepted common names <eo#common-band-names>`.

Returns:
str or None: If a recognized common name, returns a description including the
band range. Otherwise returns None.
""" # noqa E501
str or None: If a recognized common name, returns a description including
the band range. Otherwise returns None.
"""
r = Band.band_range(common_name)
if r is not None:
return "Common name: {}, Range: {} to {}".format(common_name, r[0], r[1])
Expand Down
15 changes: 8 additions & 7 deletions pystac/extensions/projection.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,13 +220,14 @@ def transform(self) -> Optional[List[float]]:
"""Get or sets the the affine transformation coefficients for the default grid.

The transform is a linear mapping from pixel coordinate space (Pixel, Line) to
projection coordinate space (Xp, Yp). It is a 3x3 matrix stored as a flat array of 9
elements in row major order. Since the last row is always 0,0,1 it can be omitted, in
which case only 6 elements are recorded. This mapping can be obtained from
GDAL `GetGeoTransform <https://gdal.org/api/gdaldataset_cpp.html#_CPPv4N11GDALDataset15GetGeoTransformEPd>`_
or the
Rasterio `Transform <https://rasterio.readthedocs.io/en/stable/api/rasterio.io.html#rasterio.io.BufferedDatasetWriter.transform>`_.
""" # noqa: E501
projection coordinate space (Xp, Yp). It is a 3x3 matrix stored as a flat array
of 9 elements in row major order. Since the last row is always 0,0,1 it can be
omitted, in which case only 6 elements are recorded. This mapping can be
obtained from GDAL `GetGeoTransform <https://gdal.org/api/gdaldataset_cpp.html\
#_CPPv4N11GDALDataset15GetGeoTransformEPd>`_
or the Rasterio `Transform <https://rasterio.readthedocs.io/en/stable/api\
/rasterio.io.html#rasterio.io.BufferedDatasetWriter.transform>`_.
"""
return self._get_property(TRANSFORM_PROP, List[float])

@transform.setter
Expand Down
58 changes: 33 additions & 25 deletions pystac/extensions/raster.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def apply(
mean : Mean value of all the pixels in the band.
stddev : Standard Deviation value of all the pixels in the band.
valid_percent : Percentage of valid (not nodata) pixel.
""" # noqa
"""
self.minimum = minimum
self.maximum = maximum
self.mean = mean
Expand All @@ -100,7 +100,7 @@ def create(
mean : Mean value of all the pixels in the band.
stddev : Standard Deviation value of all the pixels in the band.
valid_percent : Percentage of valid (not nodata) pixel.
""" # noqa
"""
b = cls({})
b.apply(
minimum=minimum,
Expand Down Expand Up @@ -236,7 +236,7 @@ def apply(
Also the mean value of the last bucket.
buckets : Array of integer indicating the number
of pixels included in the bucket.
""" # noqa
"""
self.count = count
self.min = min
self.max = max
Expand All @@ -261,7 +261,7 @@ def create(
Also the mean value of the last bucket.
buckets : Array of integer indicating the number
of pixels included in the bucket.
""" # noqa
"""
b = cls({})
b.apply(
count=count,
Expand Down Expand Up @@ -370,22 +370,26 @@ def apply(

Args:
nodata : Pixel values used to identify pixels that are nodata in the assets.
sampling : One of area or point. Indicates whether a pixel value should be assumed
to represent a sampling over the region of the pixel or a point sample at the center of the pixel.
sampling : One of area or point. Indicates whether a pixel value should be
assumed to represent a sampling over the region of the pixel or a point
sample at the center of the pixel.
data_type :The data type of the band.
One of the data types as described in <https://github.com/stac-extensions/raster/#data-types>.
One of the data types as described in
<https://github.com/stac-extensions/raster/#data-types>.
bits_per_sample : The actual number of bits used for this band.
Normally only present when the number of bits is non-standard for the datatype,
such as when a 1 bit TIFF is represented as byte
spatial_resolution : Average spatial resolution (in meters) of the pixels in the band.
Normally only present when the number of bits is non-standard for the
datatype, such as when a 1 bit TIFF is represented as byte
spatial_resolution : Average spatial resolution (in meters) of the pixels in
the band.
statistics: Statistics of all the pixels in the band
unit: unit denomination of the pixel value
scale: multiplicator factor of the pixel value to transform into the value
(i.e. translate digital number to reflectance).
offset: number to be added to the pixel value (after scaling) to transform into the value
(i.e. translate digital number to reflectance).
histogram: Histogram distribution information of the pixels values in the band
""" # noqa
offset: number to be added to the pixel value (after scaling) to transform
into the value (i.e. translate digital number to reflectance).
histogram: Histogram distribution information of the pixels values in the
band
"""
self.nodata = nodata
self.sampling = sampling
self.data_type = data_type
Expand Down Expand Up @@ -416,22 +420,26 @@ def create(

Args:
nodata : Pixel values used to identify pixels that are nodata in the assets.
sampling : One of area or point. Indicates whether a pixel value should be assumed
to represent a sampling over the region of the pixel or a point sample at the center of the pixel.
sampling : One of area or point. Indicates whether a pixel value should be
assumed to represent a sampling over the region of the pixel or a point
sample at the center of the pixel.
data_type :The data type of the band.
One of the data types as described in <https://github.com/stac-extensions/raster/#data-types>.
One of the data types as described in
<https://github.com/stac-extensions/raster/#data-types>.
bits_per_sample : The actual number of bits used for this band.
Normally only present when the number of bits is non-standard for the datatype,
such as when a 1 bit TIFF is represented as byte
spatial_resolution : Average spatial resolution (in meters) of the pixels in the band.
Normally only present when the number of bits is non-standard for the
datatype, such as when a 1 bit TIFF is represented as byte
spatial_resolution : Average spatial resolution (in meters) of the pixels in
the band.
statistics: Statistics of all the pixels in the band
unit: unit denomination of the pixel value
scale: multiplicator factor of the pixel value to transform into the value
(i.e. translate digital number to reflectance).
offset: number to be added to the pixel value (after scaling) to transform into the value
(i.e. translate digital number to reflectance).
histogram: Histogram distribution information of the pixels values in the band
""" # noqa
offset: number to be added to the pixel value (after scaling) to transform
into the value (i.e. translate digital number to reflectance).
histogram: Histogram distribution information of the pixels values in the
band
"""
b = cls({})
b.apply(
nodata=nodata,
Expand Down Expand Up @@ -471,7 +479,7 @@ def sampling(self) -> Optional[Sampling]:

Returns:
Optional[Sampling]
""" # noqa
"""
return self.properties.get("sampling")

@sampling.setter
Expand Down
2 changes: 1 addition & 1 deletion pystac/serialization/migrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def _get_removed_extension_migrations() -> Dict[
]
],
],
]: # noqa
]:
"""Handles removed extensions.

This does not handle renamed extension or extensions that were absorbed
Expand Down
7 changes: 4 additions & 3 deletions tests/utils/test_cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
ARBITRARY_EXTENT = Extent(
spatial=SpatialExtent.from_coordinates(ARBITRARY_GEOM["coordinates"]),
temporal=TemporalExtent.from_now(),
) # noqa: E126
)


class ExampleInfo:
Expand Down Expand Up @@ -206,8 +206,9 @@ def test_case_3() -> Catalog:
def test_case_4() -> Catalog:
"""Test case that is based on a local copy of the Tier 1 dataset from
DrivenData's OpenCities AI Challenge.
See: https://www.drivendata.org/competitions/60/building-segmentation-disaster-resilience
""" # noqa
See: https://www.drivendata.org/competitions/60/building-segmentation-disaster\
-resilience
"""
return Catalog.from_file(
TestCases.get_path("data-files/catalogs/test-case-4/catalog.json")
)
Expand Down