Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@typecheck_promote((Int, Float))
def buffer(self, distance):
return Geometry._from_apply("buffer", self, distance)
@typecheck_promote(None, back=Int, fwd=Int)
def map_window(self, func, back=0, fwd=0):
"""
Map a function over a sliding window of this `ImageCollection`.
The function must take 3 arguments:
* ``back``: `ImageCollection` of N prior images
* ``current``: current `Image`
* ``fwd``: `ImageCollection` of N subsequent images
The window slides over the `ImageCollection`, starting at
index ``back`` and ending ``fwd`` images before the end.
Note that the total length of the window is ``back + 1 + fwd``.
Specifying a window longer than the `ImageCollection` will cause an error.
@typecheck_promote((Image, lambda: ImageCollection, Int, Float))
def __rsub__(self, other):
return self._from_apply("sub", other, self)
return obj
elif callable(obj):
return Function.from_callable(obj)
elif isinstance(obj, (tuple, list)):
contents = [proxify(x) for x in obj]
types = tuple(type(x) for x in contents)
if (
isinstance(obj, list)
and len(types) > 0
and all(t is types[0] for t in types[1:])
):
return List[types[0]](contents)
else:
return Tuple[types](contents)
elif isinstance(obj, int):
return Int(obj)
elif isinstance(obj, float):
return Float(obj)
elif isinstance(obj, bool):
return Bool(obj)
elif isinstance(obj, str):
return Str(obj)
elif obj is None:
return NoneType(obj)
elif isinstance(obj, (datetime.datetime, datetime.date)):
return Datetime._promote(obj)
elif isinstance(obj, datetime.timedelta):
return Timedelta._promote(obj)
else:
try:
return Any._promote(obj)
except ProxyTypeError:
@typecheck_promote((Int, Float))
def buffer(self, distance):
return self._from_apply("buffer", self, distance)
isinstance(condition, Bool)
and isinstance(x, (Int, Float))
and isinstance(y, (Int, Float))
):
raise ValueError(
"Can't call workflows.where with a boolean condition and scalar x, y; currently not supported."
)
args = [condition, x, y]
if any(isinstance(arg, ImageCollection) for arg in args):
return_type = ImageCollection
elif any(isinstance(arg, Image) for arg in args):
return_type = Image
elif isinstance(x, Float) or isinstance(y, Float):
return_type = Float
else:
return_type = Int
return return_type._from_apply("where", condition, x, y)
def length(self):
"""Length is equivalent to the Python ``len`` operator.
Returns
-------
Int
An Int Proxytype
"""
return Int._from_apply("length", self)