MCPcopy Create free account
hub / github.com/dask/dask / __str__

Method __str__

dask/array/rechunk.py:757–787  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

755 self.blocks = blocks
756
757 def __str__(self):
758 runs = []
759 run = []
760 repeats = 0
761 for c in self.blocks:
762 if run and run[-1] == c:
763 if repeats == 0 and len(run) > 1:
764 runs.append((None, run[:-1]))
765 run = run[-1:]
766 repeats += 1
767 else:
768 if repeats > 0:
769 assert len(run) == 1
770 runs.append((repeats + 1, run[-1]))
771 run = []
772 repeats = 0
773 run.append(c)
774 if run:
775 if repeats == 0:
776 runs.append((None, run))
777 else:
778 assert len(run) == 1
779 runs.append((repeats + 1, run[-1]))
780
781 parts = []
782 for repeats, run in runs:
783 if repeats is None:
784 parts.append(str(run))
785 else:
786 parts.append(f"{repeats}*[{run}]")
787 return " | ".join(parts)
788
789 __repr__ = __str__
790

Callers

nothing calls this directly

Calls 1

joinMethod · 0.45

Tested by

no test coverage detected