MCPcopy Index your code
hub / github.com/tensorpack/tensorpack / __init__

Method __init__

tensorpack/dataflow/common.py:338–348  ·  view source on GitHub ↗

Args: ds (DataFlow): input DataFlow which produces either list or dict. func (TYPE -> TYPE|None): takes ``dp[index]``, returns a new value for ``dp[index]``. Return None to discard/skip this datapoint. index (int or str): index or key of t

(self, ds, func, index=0)

Source from the content-addressed store, hash-verified

336 ds = MapDataComponent(ds, lambda img: img * 255, 0) # map the 0th component
337 """
338 def __init__(self, ds, func, index=0):
339 """
340 Args:
341 ds (DataFlow): input DataFlow which produces either list or dict.
342 func (TYPE -> TYPE|None): takes ``dp[index]``, returns a new value for ``dp[index]``.
343 Return None to discard/skip this datapoint.
344 index (int or str): index or key of the component.
345 """
346 self._index = index
347 self._func = func
348 super(MapDataComponent, self).__init__(ds, self._mapper)
349
350 def _mapper(self, dp):
351 r = self._func(dp[self._index])

Callers

nothing calls this directly

Calls 1

__init__Method · 0.45

Tested by

no test coverage detected