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

Method __init__

lib/matplotlib/colors.py:2280–2300  ·  view source on GitHub ↗
(self, lut, shape='square', origin=(0, 0), name='from image')

Source from the content-addressed store, hash-verified

2278 """
2279
2280 def __init__(self, lut, shape='square', origin=(0, 0), name='from image'):
2281 # We can allow for a PIL.Image as input in the following way, but importing
2282 # matplotlib.image.pil_to_array() results in a circular import
2283 # For now, this function only accepts numpy arrays.
2284 # i.e.:
2285 # if isinstance(Image, lut):
2286 # lut = image.pil_to_array(lut)
2287 lut = np.array(lut, copy=True)
2288 if lut.ndim != 3 or lut.shape[2] not in (3, 4):
2289 raise ValueError("The lut must be an array of shape (n, m, 3) or (n, m, 4)",
2290 " or a PIL.image encoded as RGB or RGBA")
2291
2292 if lut.dtype == np.uint8:
2293 lut = lut.astype(np.float32)/255
2294 if lut.shape[2] == 3:
2295 new_lut = np.empty((lut.shape[0], lut.shape[1], 4), dtype=lut.dtype)
2296 new_lut[:, :, :3] = lut
2297 new_lut[:, :, 3] = 1.
2298 lut = new_lut
2299 self._lut = lut
2300 super().__init__(lut.shape[0], lut.shape[1], shape, origin, name=name)
2301
2302 def _init(self):
2303 self._isinit = True

Callers

nothing calls this directly

Calls 1

__init__Method · 0.45

Tested by

no test coverage detected