(self, variable: Variable, name: T_Name = None)
| 583 | """Code boolean values.""" |
| 584 | |
| 585 | def encode(self, variable: Variable, name: T_Name = None) -> Variable: |
| 586 | if ( |
| 587 | (variable.dtype == bool) |
| 588 | and ("dtype" not in variable.encoding) |
| 589 | and ("dtype" not in variable.attrs) |
| 590 | ): |
| 591 | dims, data, attrs, encoding = unpack_for_encoding(variable) |
| 592 | attrs["dtype"] = "bool" |
| 593 | data = duck_array_ops.astype(data, dtype="i1", copy=True) |
| 594 | |
| 595 | return Variable(dims, data, attrs, encoding, fastpath=True) |
| 596 | else: |
| 597 | return variable |
| 598 | |
| 599 | def decode(self, variable: Variable, name: T_Name = None) -> Variable: |
| 600 | if variable.attrs.get("dtype", False) == "bool": |
nothing calls this directly
no test coverage detected