MCPcopy Create free account
hub / github.com/dcharatan/flowmap / cat_sliceable

Method cat_sliceable

flowmap/misc/manipulable.py:109–123  ·  view source on GitHub ↗
(values: list[Sliceable], dim: int)

Source from the content-addressed store, hash-verified

107
108 @staticmethod
109 def cat_sliceable(values: list[Sliceable], dim: int) -> Sliceable:
110 model = values[0]
111 if isinstance(model, Tensor):
112 return torch.cat(values, dim=dim)
113 if isinstance(model, np.ndarray):
114 return np.concatenate(values, axis=dim)
115
116 # Handle lists and tuples.
117 was_tuple = isinstance(model, tuple)
118 values = [np.array(value) for value in values]
119 values = np.concatenate(values, axis=dim)
120 values = values.tolist()
121 if was_tuple:
122 values = to_tuple(values)
123 return values

Callers 1

catMethod · 0.80

Calls 2

to_tupleFunction · 0.85
catMethod · 0.80

Tested by

no test coverage detected