DisCoPy 連携¶
docstring はソースの言語(英語)のままです。
Convert an |
|
Convert a |
|
Wrap an |
|
Wrap an |
|
Convert a Markov box with array data to an |
|
Evaluate a Markov diagram as an |
|
Interpret |
- fxtensor_salmon.discopy.to_tensor(tensor)[ソース]¶
Convert an
FXTensorto adiscopy.tensor.Tensor.Axis order is domain factors then codomain factors, matching
Tensor.arrayasdom.inside + cod.inside. Empty domain or codomain becomes the monoidal unitDim(). Labels are dropped; restore them withfrom_tensor()or useto_box().- パラメータ:
tensor (FXTensor)
- 戻り値の型:
Tensor
- fxtensor_salmon.discopy.from_tensor(tensor, labels=None)[ソース]¶
Convert a
discopy.tensor.Tensorto anFXTensor.labelsis an optional(domain_labels, codomain_labels)pair in the same format asFXTensor.labels. Without it the result is unlabeled and usestensor.dom.inside/tensor.cod.inside.- パラメータ:
tensor (Tensor)
labels (Tuple[List[List[str]], List[List[str]]] | None)
- 戻り値の型:
- fxtensor_salmon.discopy.to_box(tensor, name='FXTensor')[ソース]¶
Wrap an
FXTensoras adiscopy.markov.Box.Each profile factor becomes one wire. Unlabeled factor
nis namedn; labeled factor['Sunny', 'Rainy']is stored as a JSON list on the type name sofrom_box()can restore it.- パラメータ:
tensor (FXTensor)
name (str)
- 戻り値の型:
Box
- fxtensor_salmon.discopy.to_diagram(tensor, name='FXTensor')[ソース]¶
Wrap an
FXTensoras a Markov diagram (a single box).- パラメータ:
tensor (FXTensor)
name (str)
- 戻り値の型:
Diagram
- fxtensor_salmon.discopy.from_box(box)[ソース]¶
Convert a Markov box with array data to an
FXTensor.Dimensions come from
box.data(reshaped todomthencod) and labels are restored from type names produced byto_box().- パラメータ:
box (Box)
- 戻り値の型:
- fxtensor_salmon.discopy.from_diagram(diagram, ob=None, ar=None)[ソース]¶
Evaluate a Markov diagram as an
FXTensor.A single box with data is converted directly. Composite diagrams are interpreted by
FXTensorFunctor. Object images are inferred from encoded type names whenobis omitted.
- class fxtensor_salmon.discopy.FXTensorFunctor(ob, ar=None)[ソース]¶
Interpret
discopy.markovdiagrams asFXTensormorphisms.Copy, Discard, Swap and Id are sent to
FXTensor.copy_tensor(),FXTensor.exclamation(),FXTensor.swap()andFXTensor.identity_tensor(). Custom boxes are read fromar(anFXTensor, a DisCoPyTensor, or an array).- パラメータ:
ob (Union[Mapping[Ty, ObImage], Callable[[Ob], ObImage]]) -- Atomic
Tyto a dimension (int), a label list, or aDim.ar (Optional[Union[Mapping[Box, ArImage], Callable[[Box], ArImage]]]) -- Generating
Boxto anFXTensoror array. Copy / Discard / Swap / Id are interpreted automatically and need no entry.