| 111 | |
| 112 | @dataclass |
| 113 | class CompressionConfig: |
| 114 | # Use PLAS sort in compression or not |
| 115 | use_sort: bool = True |
| 116 | # Verbose or not |
| 117 | verbose: bool = True |
| 118 | # QP value for video coding |
| 119 | qp: Optional[int] = field(default=None) |
| 120 | # Number of cluster of VQ for shN compression |
| 121 | n_clusters: int = 32768 |
| 122 | # Maps attribute names to their codec functions |
| 123 | attribute_codec_registry: Optional[AttributeCodecs] = field(default_factory=lambda: AttributeCodecs()) |
| 124 | |
| 125 | def to_dict(self) -> Dict[str, Any]: |
| 126 | """ |
| 127 | Convert the CompressionConfig instance to a dictionary. |
| 128 | If attribute_codec_registry is not None, it will be converted to a dictionary using its to_dict method. |
| 129 | Fields with None values (use_sort, verbose) will be excluded from the resulting dictionary. |
| 130 | """ |
| 131 | result = { |
| 132 | "use_sort": self.use_sort, |
| 133 | "verbose": self.verbose, |
| 134 | "n_clusters": self.n_clusters, |
| 135 | } |
| 136 | |
| 137 | if self.qp is not None: |
| 138 | result["qp"] = self.qp |
| 139 | |
| 140 | # handle attribute_codec_registry |
| 141 | if self.attribute_codec_registry is not None: |
| 142 | result["attribute_codec_registry"] = self.attribute_codec_registry.to_dict() |
| 143 | |
| 144 | return result |
| 145 | |
| 146 | @dataclass |
| 147 | class Config: |
nothing calls this directly
no test coverage detected