ftypes
FDType
Bases: FType
Source code in src/finch/algebra/ftypes.py
63 64 65 66 67 68 69 70 71 72 73 74 | |
dtype
abstractmethod
property
The NumPy dtype used to store values of this data type.
__promote__(other)
Return the result of promoting this type with another type.
Source code in src/finch/algebra/ftypes.py
70 71 72 73 74 | |
FDTypeBuiltin
Bases: FDType
Source code in src/finch/algebra/ftypes.py
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 | |
type
abstractmethod
property
The corresponding Python built-in type for this ftype.
__call__(val)
Create an instance of this ftype with the given value.
Source code in src/finch/algebra/ftypes.py
214 215 216 217 218 | |
FDTypeFloat
Bases: FDTypeNumeric
Source code in src/finch/algebra/ftypes.py
144 145 146 147 148 149 150 151 | |
finfo
abstractmethod
property
The finfo object for this float type.
FDTypeInteger
Bases: FDTypeNumeric
Source code in src/finch/algebra/ftypes.py
128 129 130 131 132 133 134 135 | |
iinfo
abstractmethod
property
The iinfo object for this integer type.
FDTypeNumpy
Bases: FDType
Source code in src/finch/algebra/ftypes.py
369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 | |
__call__(val)
Create an instance of this ftype with the given value.
Source code in src/finch/algebra/ftypes.py
376 377 378 379 380 | |
FDTypeNumpyFloat
Bases: FDTypeFloat, FDTypeNumpy
Source code in src/finch/algebra/ftypes.py
426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 | |
finfo
property
The finfo object for this float type.
type_max
property
The maximum value for this type.
type_min
property
The minimum value for this type.
FDTypeNumpyInteger
Bases: FDTypeInteger, FDTypeNumpy
Source code in src/finch/algebra/ftypes.py
393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 | |
iinfo
property
The iinfo object for this integer type.
type_max
property
The maximum value for this type.
type_min
property
The minimum value for this type.
FDTypeOrdered
Bases: FDType
Source code in src/finch/algebra/ftypes.py
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | |
type_max
abstractmethod
property
The maximum value for this type.
type_min
abstractmethod
property
The minimum value for this type.
FType
Bases: ABC
Source code in src/finch/algebra/ftypes.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | |
__call__(val)
abstractmethod
Perform type conversion or construction with the given value.
For numeric/scalar types, this converts the value to this type. For composite types, this may construct an instance of this type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
val
|
Any
|
The value to convert or use for construction |
required |
Returns:
| Type | Description |
|---|---|
Any
|
The converted/constructed value |
Source code in src/finch/algebra/ftypes.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | |
fisinstance(other)
Check if other is an instance of this ftype.
Source code in src/finch/algebra/ftypes.py
48 49 50 51 52 | |
FTyped
Bases: Generic[FT]
Abstract base class for objects that can be formatted.
Source code in src/finch/algebra/ftypes.py
708 709 710 711 712 713 714 715 716 717 718 719 | |
ftype
abstractmethod
property
The ftype of the object.
StructFType
Source code in src/finch/algebra/ftypes.py
722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 | |
__call__(*args, **kwargs)
Construct a struct instance from the given fields.
Can be called with positional arguments matching struct_fields order, or keyword arguments matching field names.
Source code in src/finch/algebra/ftypes.py
737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 | |
TupleFType
Bases: ImmutableStructFType, FDType
FType for Python tuples, with a struct-compatible interface.
Source code in src/finch/algebra/ftypes.py
803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 | |
fisinstance(x, f)
Check if x is an instance of f.
Source code in src/finch/algebra/ftypes.py
945 946 947 948 949 | |
ftype(x)
ftype(x: FinchOperator) -> FinchOperatorFType
ftype(x: Tensor) -> TensorFType
ftype(x: tuple) -> TupleFType
ftype(x: NumpyBuffer) -> NumpyBufferFType
ftype(x: np.integer) -> FDTypeInteger
ftype(x: FT) -> FT
ftype(x: FTyped[FT]) -> FT
ftype(x: Any) -> FType
Return the corresponding FType for a given object. Recognizes numpy, Python builtins, and Python tuples. Sometimes recognizes types. Override .ftype to customize the ftype of an object.
Source code in src/finch/algebra/ftypes.py
1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 | |
isdtype(dtype, kind)
Check if a dtype belongs to an Array API dtype kind.
Source code in src/finch/algebra/ftypes.py
952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 | |
promote_type(T1, T2)
Returns the data type with the smallest size and smallest scalar kind to which both type1 and type2 may be safely cast.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
T1
|
FDType
|
The first type to promote. |
required |
T2
|
FDType
|
The second type to promote. |
required |
Returns:
| Type | Description |
|---|---|
FDType
|
The common type of the given arguments. |
Source code in src/finch/algebra/ftypes.py
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | |