34
34
import geopandas as gpd
35
35
import numpy as np
36
36
from fs .base import FS
37
+ from typing_extensions import deprecated
37
38
38
39
from sentinelhub import CRS , BBox , parse_time
39
- from sentinelhub .exceptions import deprecated_function
40
40
41
41
from .constants import FEATURETYPE_DEPRECATION_MSG , TIMESTAMP_COLUMN , FeatureType , OverwritePermission
42
42
from .eodata_io import FeatureIO , load_eopatch_content , save_eopatch
@@ -427,7 +427,10 @@ def __contains__(self, key: object) -> bool:
427
427
"`(feature_type, feature_name)` pairs."
428
428
)
429
429
430
- @deprecated_function (EODeprecationWarning , "Use the `merge` method instead." )
430
+ @deprecated (
431
+ "The `+` operator for EOPatches has been deprecated. Use the function `eolearn.core.merge_eopatches` instead." ,
432
+ category = EODeprecationWarning ,
433
+ )
431
434
def __add__ (self , other : EOPatch ) -> EOPatch :
432
435
"""Merges two EOPatches into a new EOPatch."""
433
436
return self .merge (other )
@@ -499,7 +502,7 @@ def __copy__(
499
502
"""Returns a new EOPatch with shallow copies of given features.
500
503
501
504
:param features: A collection of features or feature types that will be copied into new EOPatch.
502
- :param copy_timestamps: Whether to copy timestamps to the new EOPatch. By default copies them over if all
505
+ :param copy_timestamps: Copy timestamps to the new EOPatch. By default copies them over if all
503
506
features are copied or if any temporal features are getting copied.
504
507
"""
505
508
if not features : # For some reason deepcopy and copy pass {} by default
@@ -526,7 +529,7 @@ def __deepcopy__(
526
529
527
530
:param memo: built-in parameter for memoization
528
531
:param features: A collection of features or feature types that will be copied into new EOPatch.
529
- :param copy_timestamps: Whether to copy timestamps to the new EOPatch. By default copies them over if all
532
+ :param copy_timestamps: Copy timestamps to the new EOPatch. By default copies them over if all
530
533
features are copied or if any temporal features are getting copied.
531
534
"""
532
535
if not features : # For some reason deepcopy and copy pass {} by default
@@ -564,7 +567,7 @@ def copy(
564
567
:param features: Features to be copied into a new `EOPatch`. By default, all features will be copied.
565
568
:param deep: If `True` it will make a deep copy of all data inside the `EOPatch`. Otherwise, only a shallow copy
566
569
of `EOPatch` will be made. Note that `BBOX` and `TIMESTAMPS` will be copied even with a shallow copy.
567
- :param copy_timestamps: Whether to copy timestamps to the new EOPatch. By default copies them over if all
570
+ :param copy_timestamps: Copy timestamps to the new EOPatch. By default copies them over if all
568
571
features are copied or if any temporal features are getting copied.
569
572
:return: An EOPatch copy.
570
573
"""
@@ -591,14 +594,14 @@ def get_features(self) -> list[Feature]:
591
594
592
595
:return: List of non-empty features
593
596
"""
594
- feature_list : list [Feature ] = []
595
597
with warnings .catch_warnings ():
596
598
warnings .filterwarnings ("ignore" , message = FEATURETYPE_DEPRECATION_MSG .format (".*?" , ".*?" ))
597
599
removed_ftypes = {FeatureType .BBOX , FeatureType .TIMESTAMPS } # list comprehensions make ignoring hard
598
- for feature_type in (ftype for ftype in FeatureType if ftype not in removed_ftypes ):
599
- for feature_name in self [feature_type ]:
600
- feature_list .append ((feature_type , feature_name ))
601
- return feature_list
600
+ return [
601
+ (feature_type , feature_name )
602
+ for feature_type in (ftype for ftype in FeatureType if ftype not in removed_ftypes )
603
+ for feature_name in self [feature_type ]
604
+ ]
602
605
603
606
def save (
604
607
self ,
@@ -620,7 +623,7 @@ def save(
620
623
:param overwrite_permission: A level of permission for overwriting an existing EOPatch
621
624
:param filesystem: An existing filesystem object. If not given it will be initialized according to the `path`
622
625
parameter.
623
- :save_timestamps: Whether to save the timestamps of the EOPatch. With the `"auto"` setting timestamps are saved
626
+ :save_timestamps: Save the timestamps of the EOPatch. With the `"auto"` setting timestamps are saved
624
627
if `features=...` or if other temporal features are being saved.
625
628
:param use_zarr: Saves numpy-array based features into Zarr files. Requires ZARR extra dependencies.
626
629
:param temporal_selection: Writes all of the data to the chosen temporal indices of preexisting arrays. Can be
@@ -666,7 +669,7 @@ def load(
666
669
:param lazy_loading: If `True` features will be lazy loaded.
667
670
:param filesystem: An existing filesystem object. If not given it will be initialized according to the `path`
668
671
parameter.
669
- :load_timestamps: Whether to load the timestamps of the EOPatch. With the `"auto"` setting timestamps are loaded
672
+ :load_timestamps: Load the timestamps of the EOPatch. With the `"auto"` setting timestamps are loaded
670
673
if `features=...` or if other temporal features are being loaded.
671
674
:param temporal_selection: Only loads data corresponding to the chosen indices. Can also be a callable that,
672
675
given a list of timestamps, returns a list of booleans declaring which temporal slices to load.
@@ -688,7 +691,10 @@ def load(
688
691
_trigger_loading_for_eopatch_features (eopatch )
689
692
return eopatch
690
693
691
- @deprecated_function (EODeprecationWarning , "Use the function `eolearn.core.merge_eopatches` instead." )
694
+ @deprecated (
695
+ "The EOPatch method `merge` has been deprecated. Use the function `eolearn.core.merge_eopatches` instead." ,
696
+ category = EODeprecationWarning ,
697
+ )
692
698
def merge (
693
699
self ,
694
700
* eopatches : EOPatch ,
@@ -727,7 +733,10 @@ def merge(
727
733
self , * eopatches , features = features , time_dependent_op = time_dependent_op , timeless_op = timeless_op
728
734
)
729
735
730
- @deprecated_function (EODeprecationWarning , "Please use the method `temporal_subset` instead." )
736
+ @deprecated (
737
+ "The method `consolidate_timestamps` has been deprecated. Use the method `temporal_subset` instead." ,
738
+ category = EODeprecationWarning ,
739
+ )
731
740
def consolidate_timestamps (self , timestamps : list [dt .datetime ]) -> set [dt .datetime ]:
732
741
"""Removes all frames from the EOPatch with a date not found in the provided timestamps list.
733
742
0 commit comments