Convert a tensor to a format that can be used in test specs.
(t)
| 158 | |
| 159 | |
| 160 | def format_result(t): |
| 161 | """Convert a tensor to a format that can be used in test specs.""" |
| 162 | if t.dtype.kind not in [np.dtype(np.string_).kind, np.dtype(np.object_).kind]: |
| 163 | # Output 9 digits after the point to ensure the precision is good enough. |
| 164 | values = ["{:.9f}".format(value) for value in list(t.flatten())] |
| 165 | return ",".join(values) |
| 166 | else: |
| 167 | return string_util_wrapper.SerializeAsHexString(t.flatten()) |
| 168 | |
| 169 | |
| 170 | def write_examples(fp, examples): |
no test coverage detected