MCPcopy Index your code
hub / github.com/plotly/plotly.py / _bytes_to_values

Method _bytes_to_values

_plotly_utils/png.py:1534–1555  ·  view source on GitHub ↗

Convert a packed row of bytes into a row of values. Result will be a freshly allocated object, not shared with the argument.

(self, bs, width=None)

Source from the content-addressed store, hash-verified

1532 yield self._bytes_to_values(row)
1533
1534 def _bytes_to_values(self, bs, width=None):
1535 """Convert a packed row of bytes into a row of values.
1536 Result will be a freshly allocated object,
1537 not shared with the argument.
1538 """
1539
1540 if self.bitdepth == 8:
1541 return bytearray(bs)
1542 if self.bitdepth == 16:
1543 return array("H", struct.unpack("!%dH" % (len(bs) // 2), bs))
1544
1545 assert self.bitdepth < 8
1546 if width is None:
1547 width = self.width
1548 # Samples per byte
1549 spb = 8 // self.bitdepth
1550 out = bytearray()
1551 mask = 2**self.bitdepth - 1
1552 shifts = [self.bitdepth * i for i in reversed(list(range(spb)))]
1553 for o in bs:
1554 out.extend([mask & (o >> i) for i in shifts])
1555 return out[:width]
1556
1557 def _iter_straight_packed(self, byte_blocks):
1558 """Iterator that undoes the effect of filtering;

Callers 2

_deinterlaceMethod · 0.95
_iter_bytes_to_valuesMethod · 0.95

Calls 2

unpackMethod · 0.45
extendMethod · 0.45

Tested by

no test coverage detected