MCPcopy
hub / github.com/ContextLab/hypertools / reshape_data

Function reshape_data

hypertools/_shared/helpers.py:122–132  ·  view source on GitHub ↗
(x, hue, labels)

Source from the content-addressed store, hash-verified

120
121
122def reshape_data(x, hue, labels):
123 categories = list(sorted(set(hue), key=list(hue).index))
124 x_stacked = np.vstack(x)
125 x_reshaped = [[] for _ in categories]
126 labels_reshaped = [[] for _ in categories]
127 if labels is None:
128 labels = [None]*len(hue)
129 for idx, (point, label) in enumerate(zip(hue, labels)):
130 x_reshaped[categories.index(point)].append(x_stacked[idx])
131 labels_reshaped[categories.index(point)].append(labels[idx])
132 return [np.vstack(i) for i in x_reshaped], labels_reshaped
133
134
135def patch_lines(x):

Callers 1

plotFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected