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