MCPcopy
hub / github.com/google-deepmind/penzai / canonicalize

Method canonicalize

penzai/core/named_axes.py:1012–1019  ·  view source on GitHub ↗

Ensures that the named axes are stored in a canonical order. Returns: Equivalent `NamedArray` whose data array contains the positional axes followed by the named axes in sorted order.

(self)

Source from the content-addressed store, hash-verified

1010 return self.broadcast_to(shape, {})
1011
1012 def canonicalize(self) -> NamedArray:
1013 """Ensures that the named axes are stored in a canonical order.
1014
1015 Returns:
1016 Equivalent `NamedArray` whose data array contains the positional axes
1017 followed by the named axes in sorted order.
1018 """
1019 return self.order_as(*sorted(self.named_shape.keys()))
1020
1021 # Indexing.
1022 def __getitem__(self, indexer) -> NamedArray | NamedArrayView:

Callers 13

test_order_likeMethod · 0.80
test_tree_order_likeMethod · 0.80
test_auto_nmapMethod · 0.80
test_knock_out_headsMethod · 0.80
test_stack_callMethod · 0.80
test_knock_out_headsMethod · 0.80

Calls 1

order_asMethod · 0.95

Tested by 13

test_order_likeMethod · 0.64
test_tree_order_likeMethod · 0.64
test_auto_nmapMethod · 0.64
test_knock_out_headsMethod · 0.64
test_stack_callMethod · 0.64
test_knock_out_headsMethod · 0.64