LSST Applications 27.0.0,g0265f82a02+469cd937ee,g02d81e74bb+21ad69e7e1,g1470d8bcf6+cbe83ee85a,g2079a07aa2+e67c6346a6,g212a7c68fe+04a9158687,g2305ad1205+94392ce272,g295015adf3+81dd352a9d,g2bbee38e9b+469cd937ee,g337abbeb29+469cd937ee,g3939d97d7f+72a9f7b576,g487adcacf7+71499e7cba,g50ff169b8f+5929b3527e,g52b1c1532d+a6fc98d2e7,g591dd9f2cf+df404f777f,g5a732f18d5+be83d3ecdb,g64a986408d+21ad69e7e1,g858d7b2824+21ad69e7e1,g8a8a8dda67+a6fc98d2e7,g99cad8db69+f62e5b0af5,g9ddcbc5298+d4bad12328,ga1e77700b3+9c366c4306,ga8c6da7877+71e4819109,gb0e22166c9+25ba2f69a1,gb6a65358fc+469cd937ee,gbb8dafda3b+69d3c0e320,gc07e1c2157+a98bf949bb,gc120e1dc64+615ec43309,gc28159a63d+469cd937ee,gcf0d15dbbd+72a9f7b576,gdaeeff99f8+a38ce5ea23,ge6526c86ff+3a7c1ac5f1,ge79ae78c31+469cd937ee,gee10cc3b42+a6fc98d2e7,gf1cff7945b+21ad69e7e1,gfbcc870c63+9a11dc8c8f
LSST Data Management Base Package
Loading...
Searching...
No Matches
Functions | Variables
lsst.sphgeom._yaml Namespace Reference

Functions

 region_representer (dumper, data)
 
 region_constructor (loader, node)
 
 pixel_representer (dumper, data)
 
 pixel_constructor (loader, node)
 

Variables

 yaml = None
 
 CLoader = None
 
tuple YamlLoaders = (yaml.Loader, yaml.FullLoader, yaml.SafeLoader, yaml.UnsafeLoader)
 
 region_constructor
 
 Loader
 
 pixel_constructor
 

Detailed Description

Add support for YAML serialization of regions.

Function Documentation

◆ pixel_constructor()

lsst.sphgeom._yaml.pixel_constructor ( loader,
node )
Construct a pixelization object from YAML.

Definition at line 109 of file _yaml.py.

109def pixel_constructor(loader, node):
110 """Construct a pixelization object from YAML."""
111 mapping = loader.construct_mapping(node)
112
113 className = node.tag
114 pixelMap = {
115 "lsst.sphgeom.Q3cPixelization": Q3cPixelization,
116 "lsst.sphgeom.Mq3cPixelization": Mq3cPixelization,
117 "lsst.sphgeom.HtmPixelization": HtmPixelization,
118 "lsst.sphgeom.HealpixPixelization": HealpixPixelization,
119 }
120
121 if className not in pixelMap:
122 raise RuntimeError(
123 f"Encountered unexpected class {className} associated with sphgeom pixelization YAML constructor"
124 )
125
126 return pixelMap[className](mapping["level"])
127
128
129# All the pixelization schemes use the same approach with getLevel

◆ pixel_representer()

lsst.sphgeom._yaml.pixel_representer ( dumper,
data )
Represent a pixelization in YAML.

Stored as the pixelization level in a mapping with a single key
``level``.

Definition at line 100 of file _yaml.py.

100def pixel_representer(dumper, data):
101 """Represent a pixelization in YAML.
102
103 Stored as the pixelization level in a mapping with a single key
104 ``level``.
105 """
106 return dumper.represent_mapping(f"lsst.sphgeom.{type(data).__name__}", {"level": data.getLevel()})
107
108

◆ region_constructor()

lsst.sphgeom._yaml.region_constructor ( loader,
node )
Construct a sphgeom region from YAML.

Definition at line 79 of file _yaml.py.

79def region_constructor(loader, node):
80 """Construct a sphgeom region from YAML."""
81 mapping = loader.construct_mapping(node)
82 encoded = bytes.fromhex(mapping["encoded"])
83 # The generic Region base class can instantiate a region of the
84 # correct type.
85 return Region.decode(encoded)
86
87
88# Register all the region classes with the same constructor and representer

◆ region_representer()

lsst.sphgeom._yaml.region_representer ( dumper,
data )
Represent a sphgeom region object in a form suitable for YAML.

Stores the region as a mapping with a single ``encoded`` key
storing the hex encoded byte string.

Definition at line 69 of file _yaml.py.

69def region_representer(dumper, data):
70 """Represent a sphgeom region object in a form suitable for YAML.
71
72 Stores the region as a mapping with a single ``encoded`` key
73 storing the hex encoded byte string.
74 """
75 encoded = data.encode()
76 return dumper.represent_mapping(f"lsst.sphgeom.{type(data).__name__}", {"encoded": encoded.hex()})
77
78

Variable Documentation

◆ CLoader

lsst.sphgeom._yaml.CLoader = None

Definition at line 59 of file _yaml.py.

◆ Loader

lsst.sphgeom._yaml.Loader

Definition at line 94 of file _yaml.py.

◆ pixel_constructor

lsst.sphgeom._yaml.pixel_constructor

Definition at line 134 of file _yaml.py.

◆ region_constructor

lsst.sphgeom._yaml.region_constructor

Definition at line 94 of file _yaml.py.

◆ yaml

lsst.sphgeom._yaml.yaml = None

Definition at line 38 of file _yaml.py.

◆ YamlLoaders

tuple lsst.sphgeom._yaml.YamlLoaders = (yaml.Loader, yaml.FullLoader, yaml.SafeLoader, yaml.UnsafeLoader)

Definition at line 61 of file _yaml.py.