| 404 | assert narr_int.dtype == dtype_int |
| 405 | |
| 406 | class Variable( |
| 407 | NamedArray[_ShapeType_co, _DType_co], Generic[_ShapeType_co, _DType_co] |
| 408 | ): |
| 409 | @overload |
| 410 | def _new( |
| 411 | self, |
| 412 | dims: _DimsLike | Default = ..., |
| 413 | data: duckarray[Any, _DType] = ..., |
| 414 | attrs: _AttrsLike | Default = ..., |
| 415 | ) -> Variable[Any, _DType]: ... |
| 416 | |
| 417 | @overload |
| 418 | def _new( |
| 419 | self, |
| 420 | dims: _DimsLike | Default = ..., |
| 421 | data: Default = ..., |
| 422 | attrs: _AttrsLike | Default = ..., |
| 423 | ) -> Variable[_ShapeType_co, _DType_co]: ... |
| 424 | |
| 425 | def _new( |
| 426 | self, |
| 427 | dims: _DimsLike | Default = _default, |
| 428 | data: duckarray[Any, _DType] | Default = _default, |
| 429 | attrs: _AttrsLike | Default = _default, |
| 430 | ) -> Variable[Any, _DType] | Variable[_ShapeType_co, _DType_co]: |
| 431 | dims_ = copy.copy(self._dims) if dims is _default else dims |
| 432 | |
| 433 | attrs_: Mapping[Any, Any] | None |
| 434 | if attrs is _default: |
| 435 | attrs_ = None if self._attrs is None else self._attrs.copy() |
| 436 | else: |
| 437 | attrs_ = attrs |
| 438 | |
| 439 | if data is _default: |
| 440 | return type(self)(dims_, copy.copy(self._data), attrs_) |
| 441 | cls_ = cast("type[Variable[Any, _DType]]", type(self)) |
| 442 | return cls_(dims_, data, attrs_) |
| 443 | |
| 444 | var_float: Variable[Any, np.dtype[np.float32]] |
| 445 | var_float = Variable(("x",), np.array([1.5, 3.2], dtype=dtype_float)) |
no outgoing calls
searching dependent graphs…