Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(
self,
days=0,
seconds=0,
microseconds=0,
milliseconds=0,
minutes=0,
hours=0,
weeks=0,
):
self.graft = client.apply_graft(
"timedelta.from_components",
days=days,
seconds=seconds,
microseconds=microseconds,
milliseconds=milliseconds,
minutes=minutes,
hours=hours,
weeks=weeks,
)
func: Function
Key function which takes an `Image` and returns which group the `Image` belongs to.
Must return an instance of ``self.key_type``.
Returns
-------
grouped: ImageCollectionGroupby
"""
if self._type_params is None:
raise TypeError(
"Cannot instantiate a generic {}; the item type must be specified".format(
type(self).__name__
)
)
self.graft = client.apply_graft("ImageCollectionGroupby.create", imgs, func)
# store this once so that repeated calls to `.groups` refer to the same object in the graft
self._groups = Dict[self.key_type, ImageCollection]._from_apply(
"ImageCollectionGroupby.groups", self
)
"Expected Dict values of type {}, but got {}".format(vt, val)
)
if is_str_dict:
promoted[key] = promoted_val
# note we use the unpromoted key, which should be a string
# this is an optimization that produces a cleaner graph for the case of string-keyed dicts
else:
promoted += [promoted_key, promoted_val]
# for non-string dicts, we just give varargs of key, value, key, value, ...
# since that's a much simpler graft representation than constructing a list
# of tuples
if is_str_dict:
self.graft = client.apply_graft("dict.create", **promoted)
else:
self.graft = client.apply_graft("dict.create", *promoted)
def _from_apply(cls, function, *args, **kwargs):
"Shorthand for ``cls._from_graft(client.apply_graft(function, *args, **kwargs))``"
return cls._from_graft(client.apply_graft(function, *args, **kwargs))