-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
User driven getitem and construction
- Loading branch information
1 parent
b642d5a
commit 1e48baa
Showing
12 changed files
with
265 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Copyright (c) QuantCo 2023-2024 | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
|
||
from spox import Tensor, argument | ||
|
||
import ndonnx as ndx | ||
import ndonnx._data_types as dtypes | ||
from ndonnx._corearray import _CoreArray | ||
|
||
from ._interface import OperationsBlock | ||
from ._utils import validate_core | ||
|
||
|
||
class CoreOperationsImpl(OperationsBlock): | ||
def make_array(self, shape, dtype, eager_value=None): | ||
return ndx.Array._from_fields( | ||
dtype, | ||
data=_CoreArray( | ||
dtype._parse_input(eager_value)["data"] | ||
if eager_value is not None | ||
else argument(Tensor(dtype.to_numpy_dtype(), shape)) | ||
), | ||
) | ||
|
||
@validate_core | ||
def make_nullable(self, x, null): | ||
if null.dtype != ndx.bool: | ||
raise TypeError("'null' must be a boolean array") | ||
|
||
return ndx.Array._from_fields( | ||
dtypes.into_nullable(x.dtype), | ||
values=x.copy(), | ||
null=ndx.reshape(null, x.shape), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.