ftypes
FDType
¶
FDTypeBuiltin
¶
Bases: FDType
Source code in src/finch/algebra/ftypes.py
type
abstractmethod
property
¶
The corresponding Python built-in type for this ftype.
FDTypeFloat
¶
FDTypeInteger
¶
FDTypeNumpy
¶
Bases: FDType
Source code in src/finch/algebra/ftypes.py
FDTypeNumpyFloat
¶
Bases: FDTypeFloat, FDTypeNumpy
Source code in src/finch/algebra/ftypes.py
FDTypeNumpyInteger
¶
Bases: FDTypeInteger, FDTypeNumpy
Source code in src/finch/algebra/ftypes.py
FType
¶
Bases: ABC
Source code in src/finch/algebra/ftypes.py
__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
FTyped
¶
StructFType
¶
Source code in src/finch/algebra/ftypes.py
__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
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)
¶
ftype(x)
¶
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 1091 1092 | |
isdtype(dtype, kind)
¶
Check if a dtype belongs to an Array API dtype kind.
Source code in src/finch/algebra/ftypes.py
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. |