Skip to content

Commit 6d25e2a

Browse files
committed
move tablevalue to nodes
1 parent d40508c commit 6d25e2a

File tree

3 files changed

+34
-14
lines changed

3 files changed

+34
-14
lines changed

src/finchlite/finch_logic/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
Reorder,
1717
Subquery,
1818
Table,
19+
TableValue,
20+
TableValueFType,
1921
Value,
2022
)
2123

@@ -37,5 +39,7 @@
3739
"Reorder",
3840
"Subquery",
3941
"Table",
42+
"TableValue",
43+
"TableValueFType",
4044
"Value",
4145
]

src/finchlite/finch_logic/interpreter.py

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
from collections.abc import Iterable
2-
from dataclasses import dataclass
31
from itertools import product
4-
from typing import Any
52

63
import numpy as np
74

@@ -19,20 +16,11 @@
1916
Reorder,
2017
Subquery,
2118
Table,
19+
TableValue,
2220
Value,
2321
)
2422

2523

26-
@dataclass(eq=True, frozen=True)
27-
class TableValue:
28-
tns: Any
29-
idxs: Iterable[Any]
30-
31-
def __post_init__(self):
32-
if isinstance(self.tns, TableValue):
33-
raise ValueError("The tensor (tns) cannot be a TableValue")
34-
35-
3624
class FinchLogicInterpreter:
3725
def __init__(self, *, make_tensor=np.full, verbose=False):
3826
self.verbose = verbose

src/finchlite/finch_logic/nodes.py

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,38 @@
44
from dataclasses import asdict, dataclass
55
from typing import Any, Generic, Self, TypeVar
66

7-
from ..symbolic import Context, NamedTerm, Term, TermTree, literal_repr
7+
from ..symbolic import (
8+
Context,
9+
FType,
10+
FTyped,
11+
NamedTerm,
12+
Term,
13+
TermTree,
14+
ftype,
15+
literal_repr,
16+
)
817
from ..util import qual_str
918

1019

20+
@dataclass(eq=True, frozen=True)
21+
class TableValueFType(FType):
22+
tns_ftype: Any
23+
idxs: tuple[Field, ...] = ()
24+
25+
26+
@dataclass(eq=True, frozen=True)
27+
class TableValue(FTyped):
28+
tns: Any
29+
idxs: tuple[Field]
30+
31+
def ftype(self):
32+
return TableValueFType(ftype(self.tns), self.idxs)
33+
34+
def __post_init__(self):
35+
if isinstance(self.tns, TableValue):
36+
raise ValueError("The tensor (tns) cannot be a TableValue")
37+
38+
1139
@dataclass(eq=True, frozen=True)
1240
class LogicNode(Term, ABC):
1341
"""

0 commit comments

Comments
 (0)