| 209 | """ |
| 210 | |
| 211 | def __init__( |
| 212 | self, |
| 213 | num_dimensions: int, |
| 214 | indices: Union[list, array.array], |
| 215 | values: Union[list, array.array], |
| 216 | ): |
| 217 | if not isinstance(indices, array.array) or indices.typecode != "I": |
| 218 | indices = array.array("I", indices) |
| 219 | if not isinstance(values, array.array): |
| 220 | values = array.array("d", values) |
| 221 | if len(indices) != len(values): |
| 222 | raise TypeError("indices and values must be of the same length!") |
| 223 | |
| 224 | self.num_dimensions = num_dimensions |
| 225 | self.indices = indices |
| 226 | self.values = values |
| 227 | |
| 228 | def __str__(self): |
| 229 | return ( |