MCPcopy
hub / github.com/jwohlwend/boltz / pad_dim

Function pad_dim

src/boltz/data/pad.py:6–32  ·  view source on GitHub ↗

Pad a tensor along a given dimension. Parameters ---------- data : Tensor The input tensor. dim : int The dimension to pad. pad_len : float The padding length. value : int, optional The value to pad with. Returns ------- Tensor

(data: Tensor, dim: int, pad_len: float, value: float = 0)

Source from the content-addressed store, hash-verified

4
5
6def pad_dim(data: Tensor, dim: int, pad_len: float, value: float = 0) -> Tensor:
7 """Pad a tensor along a given dimension.
8
9 Parameters
10 ----------
11 data : Tensor
12 The input tensor.
13 dim : int
14 The dimension to pad.
15 pad_len : float
16 The padding length.
17 value : int, optional
18 The value to pad with.
19
20 Returns
21 -------
22 Tensor
23 The padded tensor.
24
25 """
26 if pad_len == 0:
27 return data
28
29 total_dims = len(data.shape)
30 padding = [0] * (2 * (total_dims - dim))
31 padding[2 * (total_dims - 1 - dim) + 1] = pad_len
32 return pad(data, tuple(padding), value=value)
33
34
35def pad_to_max(data: list[Tensor], value: float = 0) -> tuple[Tensor, Tensor]:

Callers 9

minimum_symmetry_coordsFunction · 0.90
process_token_featuresFunction · 0.90
process_atom_featuresFunction · 0.90
process_msa_featuresFunction · 0.90
process_token_featuresFunction · 0.90
process_atom_featuresFunction · 0.90
process_msa_featuresFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected