maxframe 2.0.0b2__cp39-cp39-win_amd64.whl → 2.3.0rc1__cp39-cp39-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of maxframe might be problematic. Click here for more details.
- maxframe/__init__.py +1 -0
- maxframe/_utils.cp39-win_amd64.pyd +0 -0
- maxframe/_utils.pyx +14 -1
- maxframe/codegen/core.py +9 -8
- maxframe/codegen/spe/core.py +1 -1
- maxframe/codegen/spe/dataframe/__init__.py +1 -0
- maxframe/codegen/spe/dataframe/accessors/base.py +18 -0
- maxframe/codegen/spe/dataframe/accessors/dict_.py +25 -130
- maxframe/codegen/spe/dataframe/accessors/list_.py +12 -48
- maxframe/codegen/spe/dataframe/accessors/struct_.py +28 -0
- maxframe/codegen/spe/dataframe/arithmetic.py +7 -2
- maxframe/codegen/spe/dataframe/groupby.py +88 -0
- maxframe/codegen/spe/dataframe/indexing.py +99 -4
- maxframe/codegen/spe/dataframe/merge.py +38 -1
- maxframe/codegen/spe/dataframe/misc.py +11 -33
- maxframe/codegen/spe/dataframe/reduction.py +32 -9
- maxframe/codegen/spe/dataframe/reshape.py +46 -0
- maxframe/codegen/spe/dataframe/sort.py +39 -18
- maxframe/codegen/spe/dataframe/tests/accessors/test_dict.py +9 -15
- maxframe/codegen/spe/dataframe/tests/accessors/test_list.py +4 -7
- maxframe/codegen/spe/dataframe/tests/accessors/test_struct.py +75 -0
- maxframe/codegen/spe/dataframe/tests/indexing/test_iloc.py +20 -1
- maxframe/codegen/spe/dataframe/tests/indexing/test_loc.py +35 -0
- maxframe/codegen/spe/dataframe/tests/misc/test_misc.py +0 -32
- maxframe/codegen/spe/dataframe/tests/test_groupby.py +81 -18
- maxframe/codegen/spe/dataframe/tests/test_merge.py +27 -1
- maxframe/codegen/spe/dataframe/tests/test_reduction.py +13 -0
- maxframe/codegen/spe/dataframe/tests/test_reshape.py +79 -0
- maxframe/codegen/spe/dataframe/tests/test_sort.py +20 -0
- maxframe/codegen/spe/dataframe/tseries.py +9 -0
- maxframe/codegen/spe/learn/contrib/lightgbm.py +4 -3
- maxframe/codegen/spe/learn/contrib/tests/test_xgboost.py +2 -1
- maxframe/codegen/spe/learn/metrics/__init__.py +1 -1
- maxframe/codegen/spe/learn/metrics/_ranking.py +76 -0
- maxframe/codegen/spe/learn/metrics/pairwise.py +51 -0
- maxframe/codegen/spe/learn/metrics/tests/test_pairwise.py +36 -0
- maxframe/codegen/spe/learn/metrics/tests/test_ranking.py +59 -0
- maxframe/codegen/spe/tensor/__init__.py +3 -0
- maxframe/codegen/spe/tensor/datasource.py +1 -0
- maxframe/codegen/spe/tensor/fft.py +74 -0
- maxframe/codegen/spe/tensor/linalg.py +29 -2
- maxframe/codegen/spe/tensor/misc.py +79 -25
- maxframe/codegen/spe/tensor/spatial.py +45 -0
- maxframe/codegen/spe/tensor/statistics.py +44 -0
- maxframe/codegen/spe/tensor/tests/test_fft.py +64 -0
- maxframe/codegen/spe/tensor/tests/test_linalg.py +15 -1
- maxframe/codegen/spe/tensor/tests/test_misc.py +52 -2
- maxframe/codegen/spe/tensor/tests/test_spatial.py +33 -0
- maxframe/codegen/spe/tensor/tests/test_statistics.py +15 -1
- maxframe/codegen/spe/tests/test_spe_codegen.py +6 -12
- maxframe/codegen/spe/utils.py +2 -0
- maxframe/config/config.py +73 -9
- maxframe/config/tests/test_validators.py +13 -1
- maxframe/config/validators.py +49 -0
- maxframe/conftest.py +54 -17
- maxframe/core/accessor.py +2 -2
- maxframe/core/base.py +2 -1
- maxframe/core/entity/core.py +5 -0
- maxframe/core/entity/tileables.py +3 -1
- maxframe/core/graph/core.cp39-win_amd64.pyd +0 -0
- maxframe/core/graph/entity.py +8 -3
- maxframe/core/mode.py +6 -1
- maxframe/core/operator/base.py +9 -2
- maxframe/core/operator/core.py +10 -2
- maxframe/core/operator/utils.py +13 -0
- maxframe/dataframe/__init__.py +12 -5
- maxframe/dataframe/accessors/__init__.py +1 -1
- maxframe/dataframe/accessors/compat.py +45 -0
- maxframe/dataframe/accessors/datetime_/__init__.py +4 -1
- maxframe/dataframe/accessors/dict_/contains.py +7 -16
- maxframe/dataframe/accessors/dict_/core.py +48 -0
- maxframe/dataframe/accessors/dict_/getitem.py +17 -21
- maxframe/dataframe/accessors/dict_/length.py +7 -16
- maxframe/dataframe/accessors/dict_/remove.py +6 -18
- maxframe/dataframe/accessors/dict_/setitem.py +8 -18
- maxframe/dataframe/accessors/dict_/tests/test_dict_accessor.py +62 -22
- maxframe/dataframe/accessors/list_/__init__.py +2 -2
- maxframe/dataframe/accessors/list_/core.py +48 -0
- maxframe/dataframe/accessors/list_/getitem.py +12 -19
- maxframe/dataframe/accessors/list_/length.py +7 -16
- maxframe/dataframe/accessors/list_/tests/test_list_accessor.py +11 -9
- maxframe/dataframe/accessors/string_/__init__.py +4 -1
- maxframe/dataframe/accessors/struct_/__init__.py +37 -0
- maxframe/dataframe/accessors/struct_/accessor.py +39 -0
- maxframe/dataframe/accessors/struct_/core.py +43 -0
- maxframe/dataframe/accessors/struct_/dtypes.py +53 -0
- maxframe/dataframe/accessors/struct_/field.py +123 -0
- maxframe/dataframe/accessors/struct_/tests/__init__.py +13 -0
- maxframe/dataframe/accessors/struct_/tests/test_struct_accessor.py +91 -0
- maxframe/dataframe/arithmetic/__init__.py +18 -4
- maxframe/dataframe/arithmetic/between.py +106 -0
- maxframe/dataframe/arithmetic/dot.py +237 -0
- maxframe/dataframe/arithmetic/maximum.py +33 -0
- maxframe/dataframe/arithmetic/minimum.py +33 -0
- maxframe/dataframe/arithmetic/{around.py → round.py} +11 -7
- maxframe/dataframe/core.py +161 -224
- maxframe/dataframe/datasource/__init__.py +18 -0
- maxframe/dataframe/datasource/core.py +6 -0
- maxframe/dataframe/datasource/direct.py +57 -0
- maxframe/dataframe/datasource/from_dict.py +124 -0
- maxframe/dataframe/datasource/from_index.py +1 -1
- maxframe/dataframe/datasource/from_records.py +77 -0
- maxframe/dataframe/datasource/from_tensor.py +109 -41
- maxframe/dataframe/datasource/read_csv.py +21 -14
- maxframe/dataframe/datasource/read_odps_query.py +29 -6
- maxframe/dataframe/datasource/read_odps_table.py +32 -10
- maxframe/dataframe/datasource/read_parquet.py +38 -39
- maxframe/dataframe/datasource/tests/test_datasource.py +37 -0
- maxframe/dataframe/datastore/__init__.py +11 -1
- maxframe/dataframe/datastore/direct.py +268 -0
- maxframe/dataframe/datastore/to_csv.py +29 -41
- maxframe/dataframe/datastore/to_odps.py +36 -4
- maxframe/dataframe/extensions/__init__.py +20 -4
- maxframe/dataframe/extensions/apply_chunk.py +32 -6
- maxframe/dataframe/extensions/cartesian_chunk.py +153 -0
- maxframe/dataframe/extensions/collect_kv.py +126 -0
- maxframe/dataframe/extensions/extract_kv.py +177 -0
- maxframe/dataframe/extensions/flatjson.py +2 -1
- maxframe/dataframe/extensions/map_reduce.py +263 -0
- maxframe/dataframe/extensions/rebalance.py +62 -0
- maxframe/dataframe/extensions/tests/test_apply_chunk.py +9 -2
- maxframe/dataframe/extensions/tests/test_extensions.py +54 -0
- maxframe/dataframe/extensions/tests/test_map_reduce.py +135 -0
- maxframe/dataframe/groupby/__init__.py +17 -2
- maxframe/dataframe/groupby/aggregation.py +86 -49
- maxframe/dataframe/groupby/apply.py +1 -1
- maxframe/dataframe/groupby/apply_chunk.py +19 -5
- maxframe/dataframe/groupby/core.py +116 -16
- maxframe/dataframe/groupby/cum.py +4 -25
- maxframe/dataframe/groupby/expanding.py +264 -0
- maxframe/dataframe/groupby/fill.py +1 -1
- maxframe/dataframe/groupby/getitem.py +12 -5
- maxframe/dataframe/groupby/head.py +11 -1
- maxframe/dataframe/groupby/rank.py +136 -0
- maxframe/dataframe/groupby/rolling.py +206 -0
- maxframe/dataframe/groupby/shift.py +114 -0
- maxframe/dataframe/groupby/tests/test_groupby.py +0 -5
- maxframe/dataframe/indexing/__init__.py +22 -2
- maxframe/dataframe/indexing/droplevel.py +195 -0
- maxframe/dataframe/indexing/filter.py +169 -0
- maxframe/dataframe/indexing/get_level_values.py +76 -0
- maxframe/dataframe/indexing/iat.py +45 -0
- maxframe/dataframe/indexing/iloc.py +152 -12
- maxframe/dataframe/indexing/insert.py +46 -18
- maxframe/dataframe/indexing/loc.py +287 -7
- maxframe/dataframe/indexing/reindex.py +14 -5
- maxframe/dataframe/indexing/rename.py +6 -0
- maxframe/dataframe/indexing/rename_axis.py +2 -2
- maxframe/dataframe/indexing/reorder_levels.py +143 -0
- maxframe/dataframe/indexing/reset_index.py +33 -6
- maxframe/dataframe/indexing/sample.py +8 -0
- maxframe/dataframe/indexing/setitem.py +3 -3
- maxframe/dataframe/indexing/swaplevel.py +185 -0
- maxframe/dataframe/indexing/take.py +99 -0
- maxframe/dataframe/indexing/truncate.py +140 -0
- maxframe/dataframe/indexing/where.py +0 -11
- maxframe/dataframe/indexing/xs.py +148 -0
- maxframe/dataframe/merge/__init__.py +15 -1
- maxframe/dataframe/merge/append.py +97 -98
- maxframe/dataframe/merge/combine.py +244 -0
- maxframe/dataframe/merge/combine_first.py +120 -0
- maxframe/dataframe/merge/compare.py +387 -0
- maxframe/dataframe/merge/concat.py +183 -0
- maxframe/dataframe/merge/update.py +271 -0
- maxframe/dataframe/misc/__init__.py +28 -11
- maxframe/dataframe/misc/_duplicate.py +10 -4
- maxframe/dataframe/misc/apply.py +1 -1
- maxframe/dataframe/misc/check_unique.py +82 -0
- maxframe/dataframe/misc/clip.py +145 -0
- maxframe/dataframe/misc/describe.py +175 -9
- maxframe/dataframe/misc/drop.py +31 -0
- maxframe/dataframe/misc/drop_duplicates.py +2 -2
- maxframe/dataframe/misc/duplicated.py +2 -2
- maxframe/dataframe/misc/get_dummies.py +5 -1
- maxframe/dataframe/misc/infer_dtypes.py +251 -0
- maxframe/dataframe/misc/isin.py +2 -2
- maxframe/dataframe/misc/map.py +125 -18
- maxframe/dataframe/misc/repeat.py +159 -0
- maxframe/dataframe/misc/tests/test_misc.py +48 -3
- maxframe/dataframe/misc/to_numeric.py +3 -0
- maxframe/dataframe/misc/transform.py +12 -5
- maxframe/dataframe/misc/transpose.py +13 -1
- maxframe/dataframe/misc/valid_index.py +115 -0
- maxframe/dataframe/misc/value_counts.py +38 -4
- maxframe/dataframe/missing/checkna.py +14 -6
- maxframe/dataframe/missing/dropna.py +5 -0
- maxframe/dataframe/missing/fillna.py +1 -1
- maxframe/dataframe/missing/replace.py +7 -4
- maxframe/dataframe/reduction/__init__.py +35 -16
- maxframe/dataframe/reduction/aggregation.py +43 -14
- maxframe/dataframe/reduction/all.py +2 -2
- maxframe/dataframe/reduction/any.py +2 -2
- maxframe/dataframe/reduction/argmax.py +103 -0
- maxframe/dataframe/reduction/argmin.py +103 -0
- maxframe/dataframe/reduction/core.py +80 -24
- maxframe/dataframe/reduction/count.py +13 -9
- maxframe/dataframe/reduction/cov.py +166 -0
- maxframe/dataframe/reduction/cummax.py +2 -2
- maxframe/dataframe/reduction/cummin.py +2 -2
- maxframe/dataframe/reduction/cumprod.py +2 -2
- maxframe/dataframe/reduction/cumsum.py +2 -2
- maxframe/dataframe/reduction/custom_reduction.py +2 -2
- maxframe/dataframe/reduction/idxmax.py +185 -0
- maxframe/dataframe/reduction/idxmin.py +185 -0
- maxframe/dataframe/reduction/kurtosis.py +37 -30
- maxframe/dataframe/reduction/max.py +2 -2
- maxframe/dataframe/reduction/mean.py +9 -7
- maxframe/dataframe/reduction/median.py +2 -2
- maxframe/dataframe/reduction/min.py +2 -2
- maxframe/dataframe/reduction/mode.py +144 -0
- maxframe/dataframe/reduction/nunique.py +19 -11
- maxframe/dataframe/reduction/prod.py +18 -13
- maxframe/dataframe/reduction/reduction_size.py +2 -2
- maxframe/dataframe/reduction/sem.py +13 -9
- maxframe/dataframe/reduction/skew.py +31 -27
- maxframe/dataframe/reduction/str_concat.py +10 -7
- maxframe/dataframe/reduction/sum.py +18 -14
- maxframe/dataframe/reduction/tests/test_reduction.py +12 -0
- maxframe/dataframe/reduction/unique.py +20 -3
- maxframe/dataframe/reduction/var.py +16 -12
- maxframe/dataframe/reshape/__init__.py +38 -0
- maxframe/dataframe/{misc → reshape}/pivot.py +1 -0
- maxframe/dataframe/{misc → reshape}/pivot_table.py +1 -0
- maxframe/dataframe/reshape/unstack.py +114 -0
- maxframe/dataframe/sort/__init__.py +16 -1
- maxframe/dataframe/sort/argsort.py +68 -0
- maxframe/dataframe/sort/core.py +2 -1
- maxframe/dataframe/sort/nlargest.py +238 -0
- maxframe/dataframe/sort/nsmallest.py +228 -0
- maxframe/dataframe/sort/rank.py +147 -0
- maxframe/dataframe/statistics/__init__.py +3 -3
- maxframe/dataframe/statistics/corr.py +1 -0
- maxframe/dataframe/statistics/quantile.py +2 -2
- maxframe/dataframe/tests/test_typing.py +104 -0
- maxframe/dataframe/tests/test_utils.py +66 -2
- maxframe/dataframe/tseries/__init__.py +19 -0
- maxframe/dataframe/tseries/at_time.py +61 -0
- maxframe/dataframe/tseries/between_time.py +122 -0
- maxframe/dataframe/typing_.py +185 -0
- maxframe/dataframe/utils.py +125 -52
- maxframe/dataframe/window/aggregation.py +8 -4
- maxframe/dataframe/window/core.py +14 -1
- maxframe/dataframe/window/ewm.py +1 -3
- maxframe/dataframe/window/expanding.py +37 -35
- maxframe/dataframe/window/rolling.py +49 -39
- maxframe/dataframe/window/tests/test_expanding.py +1 -7
- maxframe/dataframe/window/tests/test_rolling.py +1 -1
- maxframe/env.py +7 -4
- maxframe/errors.py +2 -2
- maxframe/io/odpsio/schema.py +9 -3
- maxframe/io/odpsio/tableio.py +7 -2
- maxframe/io/odpsio/tests/test_schema.py +198 -83
- maxframe/learn/__init__.py +10 -2
- maxframe/learn/cluster/__init__.py +15 -0
- maxframe/learn/cluster/_kmeans.py +782 -0
- maxframe/learn/contrib/llm/core.py +18 -7
- maxframe/learn/contrib/llm/deploy/__init__.py +13 -0
- maxframe/learn/contrib/llm/deploy/config.py +221 -0
- maxframe/learn/contrib/llm/deploy/core.py +247 -0
- maxframe/learn/contrib/llm/deploy/framework.py +35 -0
- maxframe/learn/contrib/llm/deploy/loader.py +360 -0
- maxframe/learn/contrib/llm/deploy/tests/__init__.py +13 -0
- maxframe/learn/contrib/llm/deploy/tests/test_register_models.py +359 -0
- maxframe/learn/contrib/llm/models/__init__.py +1 -0
- maxframe/learn/contrib/llm/models/dashscope.py +12 -6
- maxframe/learn/contrib/llm/models/managed.py +76 -11
- maxframe/learn/contrib/llm/models/openai.py +72 -0
- maxframe/learn/contrib/llm/tests/__init__.py +13 -0
- maxframe/learn/contrib/llm/tests/test_core.py +34 -0
- maxframe/learn/contrib/llm/tests/test_openai.py +187 -0
- maxframe/learn/contrib/llm/tests/test_text_gen.py +155 -0
- maxframe/learn/contrib/llm/text.py +348 -42
- maxframe/learn/contrib/models.py +4 -1
- maxframe/learn/contrib/xgboost/classifier.py +2 -0
- maxframe/learn/contrib/xgboost/core.py +113 -4
- maxframe/learn/contrib/xgboost/predict.py +4 -2
- maxframe/learn/contrib/xgboost/regressor.py +5 -0
- maxframe/learn/contrib/xgboost/train.py +7 -2
- maxframe/learn/core.py +66 -0
- maxframe/learn/linear_model/_base.py +58 -1
- maxframe/learn/linear_model/_lin_reg.py +1 -1
- maxframe/learn/metrics/__init__.py +6 -0
- maxframe/learn/metrics/_classification.py +145 -0
- maxframe/learn/metrics/_ranking.py +477 -0
- maxframe/learn/metrics/_scorer.py +60 -0
- maxframe/learn/metrics/pairwise/__init__.py +21 -0
- maxframe/learn/metrics/pairwise/core.py +77 -0
- maxframe/learn/metrics/pairwise/cosine.py +115 -0
- maxframe/learn/metrics/pairwise/euclidean.py +176 -0
- maxframe/learn/metrics/pairwise/haversine.py +96 -0
- maxframe/learn/metrics/pairwise/manhattan.py +80 -0
- maxframe/learn/metrics/pairwise/pairwise.py +127 -0
- maxframe/learn/metrics/pairwise/pairwise_distances_topk.py +121 -0
- maxframe/learn/metrics/pairwise/rbf_kernel.py +51 -0
- maxframe/learn/metrics/tests/__init__.py +13 -0
- maxframe/learn/metrics/tests/test_scorer.py +26 -0
- maxframe/learn/preprocessing/_data/min_max_scaler.py +34 -23
- maxframe/learn/preprocessing/_data/standard_scaler.py +34 -25
- maxframe/learn/utils/__init__.py +2 -1
- maxframe/learn/utils/checks.py +1 -2
- maxframe/learn/utils/core.py +59 -0
- maxframe/learn/utils/extmath.py +79 -9
- maxframe/learn/utils/odpsio.py +262 -0
- maxframe/learn/utils/validation.py +2 -2
- maxframe/lib/compat.py +40 -0
- maxframe/lib/dtypes_extension/__init__.py +16 -1
- maxframe/lib/dtypes_extension/_fake_arrow_dtype.py +604 -0
- maxframe/lib/dtypes_extension/blob.py +304 -0
- maxframe/lib/dtypes_extension/dtypes.py +40 -0
- maxframe/lib/dtypes_extension/tests/test_blob.py +88 -0
- maxframe/lib/dtypes_extension/tests/test_dtypes.py +16 -1
- maxframe/lib/dtypes_extension/tests/test_fake_arrow_dtype.py +75 -0
- maxframe/lib/filesystem/_oss_lib/common.py +124 -50
- maxframe/lib/filesystem/_oss_lib/glob.py +1 -1
- maxframe/lib/filesystem/_oss_lib/handle.py +21 -25
- maxframe/lib/filesystem/base.py +1 -1
- maxframe/lib/filesystem/core.py +1 -1
- maxframe/lib/filesystem/oss.py +115 -46
- maxframe/lib/filesystem/tests/test_oss.py +74 -36
- maxframe/lib/mmh3.cp39-win_amd64.pyd +0 -0
- maxframe/lib/wrapped_pickle.py +10 -0
- maxframe/opcodes.py +41 -15
- maxframe/protocol.py +12 -0
- maxframe/remote/core.py +4 -0
- maxframe/serialization/__init__.py +11 -2
- maxframe/serialization/arrow.py +38 -13
- maxframe/serialization/blob.py +32 -0
- maxframe/serialization/core.cp39-win_amd64.pyd +0 -0
- maxframe/serialization/core.pyx +39 -1
- maxframe/serialization/exception.py +2 -4
- maxframe/serialization/numpy.py +11 -0
- maxframe/serialization/pandas.py +46 -9
- maxframe/serialization/serializables/core.py +2 -2
- maxframe/serialization/tests/test_serial.py +31 -4
- maxframe/tensor/__init__.py +38 -8
- maxframe/tensor/arithmetic/__init__.py +19 -10
- maxframe/tensor/arithmetic/core.py +2 -2
- maxframe/tensor/arithmetic/iscomplexobj.py +53 -0
- maxframe/tensor/arithmetic/tests/test_arithmetic.py +6 -9
- maxframe/tensor/core.py +6 -2
- maxframe/tensor/datasource/tests/test_datasource.py +2 -1
- maxframe/tensor/extensions/__init__.py +2 -0
- maxframe/tensor/extensions/apply_chunk.py +3 -3
- maxframe/tensor/extensions/rebalance.py +65 -0
- maxframe/tensor/fft/__init__.py +32 -0
- maxframe/tensor/fft/core.py +168 -0
- maxframe/tensor/fft/fft.py +112 -0
- maxframe/tensor/fft/fft2.py +118 -0
- maxframe/tensor/fft/fftfreq.py +80 -0
- maxframe/tensor/fft/fftn.py +123 -0
- maxframe/tensor/fft/fftshift.py +79 -0
- maxframe/tensor/fft/hfft.py +112 -0
- maxframe/tensor/fft/ifft.py +114 -0
- maxframe/tensor/fft/ifft2.py +115 -0
- maxframe/tensor/fft/ifftn.py +123 -0
- maxframe/tensor/fft/ifftshift.py +73 -0
- maxframe/tensor/fft/ihfft.py +93 -0
- maxframe/tensor/fft/irfft.py +118 -0
- maxframe/tensor/fft/irfft2.py +62 -0
- maxframe/tensor/fft/irfftn.py +114 -0
- maxframe/tensor/fft/rfft.py +116 -0
- maxframe/tensor/fft/rfft2.py +63 -0
- maxframe/tensor/fft/rfftfreq.py +87 -0
- maxframe/tensor/fft/rfftn.py +113 -0
- maxframe/tensor/indexing/fill_diagonal.py +1 -7
- maxframe/tensor/linalg/__init__.py +7 -0
- maxframe/tensor/linalg/_einsumfunc.py +1025 -0
- maxframe/tensor/linalg/cholesky.py +117 -0
- maxframe/tensor/linalg/einsum.py +339 -0
- maxframe/tensor/linalg/lstsq.py +100 -0
- maxframe/tensor/linalg/matrix_norm.py +75 -0
- maxframe/tensor/linalg/norm.py +249 -0
- maxframe/tensor/linalg/solve.py +72 -0
- maxframe/tensor/linalg/solve_triangular.py +2 -2
- maxframe/tensor/linalg/vector_norm.py +113 -0
- maxframe/tensor/misc/__init__.py +24 -1
- maxframe/tensor/misc/argwhere.py +72 -0
- maxframe/tensor/misc/array_split.py +46 -0
- maxframe/tensor/misc/broadcast_arrays.py +57 -0
- maxframe/tensor/misc/copyto.py +130 -0
- maxframe/tensor/misc/delete.py +104 -0
- maxframe/tensor/misc/dsplit.py +68 -0
- maxframe/tensor/misc/ediff1d.py +74 -0
- maxframe/tensor/misc/expand_dims.py +85 -0
- maxframe/tensor/misc/flip.py +90 -0
- maxframe/tensor/misc/fliplr.py +64 -0
- maxframe/tensor/misc/flipud.py +68 -0
- maxframe/tensor/misc/hsplit.py +85 -0
- maxframe/tensor/misc/insert.py +139 -0
- maxframe/tensor/misc/moveaxis.py +83 -0
- maxframe/tensor/misc/result_type.py +88 -0
- maxframe/tensor/misc/roll.py +124 -0
- maxframe/tensor/misc/rollaxis.py +77 -0
- maxframe/tensor/misc/shape.py +89 -0
- maxframe/tensor/misc/split.py +190 -0
- maxframe/tensor/misc/tile.py +109 -0
- maxframe/tensor/misc/vsplit.py +74 -0
- maxframe/tensor/reduction/array_equal.py +2 -1
- maxframe/tensor/sort/__init__.py +2 -0
- maxframe/tensor/sort/argpartition.py +98 -0
- maxframe/tensor/sort/partition.py +228 -0
- maxframe/tensor/spatial/__init__.py +15 -0
- maxframe/tensor/spatial/distance/__init__.py +17 -0
- maxframe/tensor/spatial/distance/cdist.py +421 -0
- maxframe/tensor/spatial/distance/pdist.py +398 -0
- maxframe/tensor/spatial/distance/squareform.py +153 -0
- maxframe/tensor/special/__init__.py +159 -21
- maxframe/tensor/special/airy.py +55 -0
- maxframe/tensor/special/bessel.py +199 -0
- maxframe/tensor/special/core.py +65 -4
- maxframe/tensor/special/ellip_func_integrals.py +155 -0
- maxframe/tensor/special/ellip_harm.py +55 -0
- maxframe/tensor/special/err_fresnel.py +223 -0
- maxframe/tensor/special/gamma_funcs.py +303 -0
- maxframe/tensor/special/hypergeometric_funcs.py +69 -0
- maxframe/tensor/special/info_theory.py +189 -0
- maxframe/tensor/special/misc.py +21 -0
- maxframe/tensor/statistics/__init__.py +6 -0
- maxframe/tensor/statistics/corrcoef.py +77 -0
- maxframe/tensor/statistics/cov.py +222 -0
- maxframe/tensor/statistics/digitize.py +126 -0
- maxframe/tensor/statistics/histogram.py +520 -0
- maxframe/tensor/statistics/median.py +85 -0
- maxframe/tensor/statistics/ptp.py +89 -0
- maxframe/tensor/utils.py +3 -3
- maxframe/tests/test_udf.py +61 -0
- maxframe/tests/test_utils.py +51 -6
- maxframe/tests/utils.py +0 -2
- maxframe/typing_.py +2 -0
- maxframe/udf.py +130 -9
- maxframe/utils.py +254 -27
- {maxframe-2.0.0b2.dist-info → maxframe-2.3.0rc1.dist-info}/METADATA +3 -3
- {maxframe-2.0.0b2.dist-info → maxframe-2.3.0rc1.dist-info}/RECORD +442 -264
- maxframe_client/fetcher.py +35 -4
- maxframe_client/session/odps.py +7 -2
- maxframe_client/session/task.py +8 -1
- maxframe_client/tests/test_fetcher.py +76 -3
- maxframe_client/tests/test_session.py +28 -1
- maxframe/dataframe/arrays.py +0 -864
- /maxframe/dataframe/{misc → reshape}/melt.py +0 -0
- /maxframe/dataframe/{misc → reshape}/stack.py +0 -0
- {maxframe-2.0.0b2.dist-info → maxframe-2.3.0rc1.dist-info}/WHEEL +0 -0
- {maxframe-2.0.0b2.dist-info → maxframe-2.3.0rc1.dist-info}/top_level.txt +0 -0
maxframe/__init__.py
CHANGED
|
Binary file
|
maxframe/_utils.pyx
CHANGED
|
@@ -299,6 +299,18 @@ cdef inline _extract_range_index_attr(object range_index, str attr):
|
|
|
299
299
|
return getattr(range_index, '_' + attr)
|
|
300
300
|
|
|
301
301
|
|
|
302
|
+
cdef list tokenize_type(ob):
|
|
303
|
+
try:
|
|
304
|
+
pickle.dumps(ob)
|
|
305
|
+
return [ob]
|
|
306
|
+
except:
|
|
307
|
+
pass
|
|
308
|
+
try:
|
|
309
|
+
return [cloudpickle.dumps(ob)]
|
|
310
|
+
except:
|
|
311
|
+
raise TypeError(f'Cannot generate token for {ob}, type: {type(ob)}') from None
|
|
312
|
+
|
|
313
|
+
|
|
302
314
|
cdef list tokenize_pandas_index(ob):
|
|
303
315
|
cdef long long start
|
|
304
316
|
cdef long long stop
|
|
@@ -411,7 +423,7 @@ def tokenize_cudf(ob):
|
|
|
411
423
|
cdef Tokenizer tokenize_handler = Tokenizer()
|
|
412
424
|
|
|
413
425
|
cdef set _primitive_types = {
|
|
414
|
-
int, float, str, unicode, bytes, complex, type(None),
|
|
426
|
+
int, float, str, unicode, bytes, complex, type(None), slice, date, datetime, timedelta
|
|
415
427
|
}
|
|
416
428
|
for t in _primitive_types:
|
|
417
429
|
tokenize_handler.register(t, lambda ob: ob)
|
|
@@ -422,6 +434,7 @@ for t in (np.dtype, np.generic):
|
|
|
422
434
|
for t in (list, tuple, dict, set):
|
|
423
435
|
tokenize_handler.register(t, iterative_tokenize)
|
|
424
436
|
|
|
437
|
+
tokenize_handler.register(type, tokenize_type)
|
|
425
438
|
tokenize_handler.register(np.ndarray, tokenize_numpy)
|
|
426
439
|
tokenize_handler.register(np.random.RandomState, lambda ob: iterative_tokenize(ob.get_state()))
|
|
427
440
|
tokenize_handler.register(memoryview, lambda ob: mmh3_hash_from_buffer(ob))
|
maxframe/codegen/core.py
CHANGED
|
@@ -23,7 +23,7 @@ from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Type, Union
|
|
|
23
23
|
from odps.types import OdpsSchema
|
|
24
24
|
from odps.utils import camel_to_underline
|
|
25
25
|
|
|
26
|
-
from ..core import OperatorType, Tileable, TileableGraph
|
|
26
|
+
from ..core import OperatorType, Tileable, TileableGraph, enter_mode
|
|
27
27
|
from ..core.operator import Fetch, Operator
|
|
28
28
|
from ..extension import iter_extensions
|
|
29
29
|
from ..io.odpsio import build_dataframe_table_meta
|
|
@@ -148,31 +148,31 @@ class UserCodeMixin:
|
|
|
148
148
|
def generate_pickled_codes(
|
|
149
149
|
cls,
|
|
150
150
|
code_to_pickle: Any,
|
|
151
|
-
|
|
151
|
+
main_entry_var_name: Union[str, None] = "udf_main_entry",
|
|
152
152
|
) -> str:
|
|
153
153
|
"""
|
|
154
|
-
Generate pickled codes. The final pickled variable is called '
|
|
154
|
+
Generate pickled codes. The final pickled variable is called 'udf_main_entry'.
|
|
155
155
|
|
|
156
156
|
Parameters
|
|
157
157
|
----------
|
|
158
158
|
code_to_pickle: Any
|
|
159
159
|
The code to be pickled.
|
|
160
|
-
|
|
160
|
+
main_entry_var_name: str
|
|
161
161
|
The variables in code used to hold the loads object from the cloudpickle
|
|
162
162
|
|
|
163
163
|
Returns
|
|
164
164
|
-------
|
|
165
165
|
str :
|
|
166
166
|
The code snippets of pickling, the final variable is called
|
|
167
|
-
'
|
|
167
|
+
'udf_main_entry' by default.
|
|
168
168
|
"""
|
|
169
169
|
pickled, buffers = cls.dump_pickled_data(code_to_pickle)
|
|
170
170
|
pickle_loads_expr = (
|
|
171
171
|
f"cloudpickle.loads({cls.obj_to_python_expr(pickled)}, "
|
|
172
172
|
f"buffers={cls.obj_to_python_expr(buffers)})"
|
|
173
173
|
)
|
|
174
|
-
if
|
|
175
|
-
return f"{
|
|
174
|
+
if main_entry_var_name:
|
|
175
|
+
return f"{main_entry_var_name} = {pickle_loads_expr}"
|
|
176
176
|
|
|
177
177
|
return pickle_loads_expr
|
|
178
178
|
|
|
@@ -465,6 +465,7 @@ class DAGCodeGenerator(metaclass=abc.ABCMeta):
|
|
|
465
465
|
def _generate_delete_code(self, var_name: str) -> List[str]:
|
|
466
466
|
return []
|
|
467
467
|
|
|
468
|
+
@enter_mode(build=True)
|
|
468
469
|
def generate_code(self, dag: TileableGraph) -> List[str]:
|
|
469
470
|
"""
|
|
470
471
|
Generate the code of the input dag.
|
|
@@ -494,7 +495,7 @@ class DAGCodeGenerator(metaclass=abc.ABCMeta):
|
|
|
494
495
|
code_lines.extend(adapter.generate_pre_op_code(op, self._context))
|
|
495
496
|
if self._generate_comments_enabled:
|
|
496
497
|
code_lines.extend(adapter.generate_comment(op, self._context))
|
|
497
|
-
code_lines.extend(adapter.generate_code(op, self._context))
|
|
498
|
+
code_lines.extend(adapter.generate_code(op, self._context) or [])
|
|
498
499
|
code_lines.extend(adapter.generate_post_op_code(op, self._context))
|
|
499
500
|
code_lines.append("") # Append an empty line to separate operators
|
|
500
501
|
|
maxframe/codegen/spe/core.py
CHANGED
|
@@ -299,7 +299,7 @@ class SPECodeGenerator(DAGCodeGenerator):
|
|
|
299
299
|
udf_codes = list()
|
|
300
300
|
for func in self.get_udfs():
|
|
301
301
|
udf_codes.extend(func.encoded_content)
|
|
302
|
-
udf_codes.append(f"{func.name} =
|
|
302
|
+
udf_codes.append(f"{func.name} = udf_main_entry")
|
|
303
303
|
return udf_codes
|
|
304
304
|
|
|
305
305
|
|
|
@@ -51,3 +51,21 @@ class SeriesStringMethodAdapter(SPEOperatorAdapter):
|
|
|
51
51
|
)
|
|
52
52
|
args = ", ".join(args_list)
|
|
53
53
|
return [f"{res_var_name} = {method_str}({args})"]
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
class SeriesTemplateMethodAdapter(SPEOperatorAdapter):
|
|
57
|
+
_templates = None
|
|
58
|
+
|
|
59
|
+
def generate_code(self, op, context: SPECodeContext) -> List[str]:
|
|
60
|
+
kw = {
|
|
61
|
+
"input_var": context.get_input_tileable_variable(op.inputs[0]),
|
|
62
|
+
"output_var": context.get_output_tileable_variable(op.outputs[0]),
|
|
63
|
+
"output_name_var": self.translate_var(context, op.outputs[0].name),
|
|
64
|
+
"output_dtype_var": context.register_operator_constants(
|
|
65
|
+
op.outputs[0].dtype
|
|
66
|
+
),
|
|
67
|
+
}
|
|
68
|
+
kw.update(
|
|
69
|
+
{k: self.translate_var(context, v) for k, v in op.method_kwargs.items()}
|
|
70
|
+
)
|
|
71
|
+
return [self._templates.get(op.method).format(**kw)]
|
|
@@ -12,30 +12,25 @@
|
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
|
-
from
|
|
16
|
-
|
|
17
|
-
from
|
|
18
|
-
from .....dataframe.accessors.dict_.getitem import SeriesDictGetItemOperator
|
|
19
|
-
from .....dataframe.accessors.dict_.length import SeriesDictLengthOperator
|
|
20
|
-
from .....dataframe.accessors.dict_.remove import SeriesDictRemoveOperator
|
|
21
|
-
from .....dataframe.accessors.dict_.setitem import SeriesDictSetItemOperator
|
|
22
|
-
from ...core import SPECodeContext, SPEOperatorAdapter, register_op_adapter
|
|
15
|
+
from .....dataframe.accessors.dict_.core import SeriesDictMethod
|
|
16
|
+
from ...core import register_op_adapter
|
|
17
|
+
from .base import SeriesTemplateMethodAdapter
|
|
23
18
|
|
|
24
19
|
_get_template = """
|
|
25
20
|
def _inner_get(data):
|
|
26
21
|
found = False
|
|
27
22
|
for tup in data:
|
|
28
|
-
if tup[0] == {
|
|
23
|
+
if tup[0] == {query_key}:
|
|
29
24
|
found = True
|
|
30
25
|
return tup[1]
|
|
31
26
|
if not found:
|
|
32
|
-
if {
|
|
33
|
-
return {
|
|
27
|
+
if {ignore_key_error}:
|
|
28
|
+
return {default_value}
|
|
34
29
|
else:
|
|
35
|
-
raise KeyError({
|
|
30
|
+
raise KeyError({query_key})
|
|
36
31
|
|
|
37
32
|
{output_var} = {input_var}.map(_inner_get, na_action="ignore").astype({output_dtype_var})
|
|
38
|
-
{output_var}.name = {
|
|
33
|
+
{output_var}.name = {query_key}
|
|
39
34
|
"""
|
|
40
35
|
|
|
41
36
|
_set_template = """
|
|
@@ -43,19 +38,19 @@ def _inner_set(row):
|
|
|
43
38
|
found = False
|
|
44
39
|
value = list()
|
|
45
40
|
for tup in row:
|
|
46
|
-
if tup[0] == {
|
|
47
|
-
value.append((tup[0], {
|
|
41
|
+
if tup[0] == {query_key}:
|
|
42
|
+
value.append((tup[0], {value}))
|
|
48
43
|
found = True
|
|
49
44
|
else:
|
|
50
45
|
value.append(tup)
|
|
51
46
|
if not found:
|
|
52
|
-
value.append(({
|
|
47
|
+
value.append(({query_key}, {value}))
|
|
53
48
|
return value
|
|
54
49
|
|
|
55
50
|
{output_var} = {input_var}.map(_inner_set, na_action="ignore").astype({output_dtype_var})
|
|
56
51
|
"""
|
|
57
52
|
|
|
58
|
-
|
|
53
|
+
_len_template = """
|
|
59
54
|
{output_var} = {input_var}.map(len, na_action="ignore").astype({output_dtype_var})
|
|
60
55
|
{output_var}.name = None
|
|
61
56
|
"""
|
|
@@ -66,129 +61,29 @@ def _inner_remove(value):
|
|
|
66
61
|
row = list()
|
|
67
62
|
found = False
|
|
68
63
|
for tup in value:
|
|
69
|
-
if tup[0] == {
|
|
64
|
+
if tup[0] == {query_key}:
|
|
70
65
|
found = True
|
|
71
66
|
else:
|
|
72
67
|
row.append(tup)
|
|
73
|
-
if not found and not {
|
|
74
|
-
raise KeyError({
|
|
68
|
+
if not found and not {ignore_key_error}:
|
|
69
|
+
raise KeyError({query_key})
|
|
75
70
|
return row
|
|
76
71
|
|
|
77
72
|
{output_var} = {input_var}.map(_inner_remove, na_action="ignore").astype({output_dtype_var})
|
|
78
73
|
"""
|
|
79
74
|
|
|
80
75
|
_contains_template = """
|
|
81
|
-
{output_var} = {input_var}.map(lambda x: any({
|
|
76
|
+
{output_var} = {input_var}.map(lambda x: any({query_key} in tup[0] for tup in x), na_action="ignore").astype({output_dtype_var})
|
|
82
77
|
{output_var}.name = None
|
|
83
78
|
"""
|
|
84
79
|
|
|
85
80
|
|
|
86
|
-
@register_op_adapter(
|
|
87
|
-
class
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
default_value_var = self.translate_var(context, op.default_value)
|
|
96
|
-
ignore_key_error_var = self.translate_var(context, op.ignore_key_error)
|
|
97
|
-
output_dtype_var = context.register_operator_constants(op.outputs[0].dtype)
|
|
98
|
-
return [
|
|
99
|
-
_get_template.format(
|
|
100
|
-
input_var=input_var,
|
|
101
|
-
output_var=output_var,
|
|
102
|
-
key_var=key_var,
|
|
103
|
-
default_value_var=default_value_var,
|
|
104
|
-
ignore_key_error_var=ignore_key_error_var,
|
|
105
|
-
output_name_var=output_name_var,
|
|
106
|
-
output_dtype_var=output_dtype_var,
|
|
107
|
-
)
|
|
108
|
-
]
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
@register_op_adapter(SeriesDictSetItemOperator)
|
|
112
|
-
class SeriesDictSetItemOperatorAdapter(SPEOperatorAdapter):
|
|
113
|
-
def generate_code(
|
|
114
|
-
self, op: SeriesDictSetItemOperator, context: SPECodeContext
|
|
115
|
-
) -> List[str]:
|
|
116
|
-
input_var = context.get_input_tileable_variable(op.inputs[0])
|
|
117
|
-
output_var = context.get_output_tileable_variable(op.outputs[0])
|
|
118
|
-
key_var = self.translate_var(context, op.query_key)
|
|
119
|
-
value_var = self.translate_var(context, op.value)
|
|
120
|
-
output_name_var = self.translate_var(context, op.outputs[0].name)
|
|
121
|
-
output_dtype_var = context.register_operator_constants(op.outputs[0].dtype)
|
|
122
|
-
return [
|
|
123
|
-
_set_template.format(
|
|
124
|
-
input_var=input_var,
|
|
125
|
-
output_var=output_var,
|
|
126
|
-
key_var=key_var,
|
|
127
|
-
value_var=value_var,
|
|
128
|
-
output_name_var=output_name_var,
|
|
129
|
-
output_dtype_var=output_dtype_var,
|
|
130
|
-
)
|
|
131
|
-
]
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
@register_op_adapter(SeriesDictLengthOperator)
|
|
135
|
-
class SeriesDictLengthOperatorAdapter(SPEOperatorAdapter):
|
|
136
|
-
def generate_code(
|
|
137
|
-
self, op: SeriesDictLengthOperator, context: SPECodeContext
|
|
138
|
-
) -> List[str]:
|
|
139
|
-
input_var = context.get_input_tileable_variable(op.inputs[0])
|
|
140
|
-
output_var = context.get_output_tileable_variable(op.outputs[0])
|
|
141
|
-
output_name_var = self.translate_var(context, op.outputs[0].name)
|
|
142
|
-
output_dtype_var = context.register_operator_constants(op.outputs[0].dtype)
|
|
143
|
-
return [
|
|
144
|
-
_length_template.format(
|
|
145
|
-
input_var=input_var,
|
|
146
|
-
output_var=output_var,
|
|
147
|
-
output_name_var=output_name_var,
|
|
148
|
-
output_dtype_var=output_dtype_var,
|
|
149
|
-
)
|
|
150
|
-
]
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
@register_op_adapter(SeriesDictRemoveOperator)
|
|
154
|
-
class SeriesDictRemoveOperatorAdapter(SPEOperatorAdapter):
|
|
155
|
-
def generate_code(
|
|
156
|
-
self, op: SeriesDictRemoveOperator, context: SPECodeContext
|
|
157
|
-
) -> List[str]:
|
|
158
|
-
input_var = context.get_input_tileable_variable(op.inputs[0])
|
|
159
|
-
output_var = context.get_output_tileable_variable(op.outputs[0])
|
|
160
|
-
output_name_var = self.translate_var(context, op.outputs[0].name)
|
|
161
|
-
output_dtype_var = context.register_operator_constants(op.outputs[0].dtype)
|
|
162
|
-
key_var = self.translate_var(context, op.query_key)
|
|
163
|
-
ignore_key_error_var = self.translate_var(context, op.ignore_key_error)
|
|
164
|
-
return [
|
|
165
|
-
_remove_template.format(
|
|
166
|
-
input_var=input_var,
|
|
167
|
-
output_var=output_var,
|
|
168
|
-
key_var=key_var,
|
|
169
|
-
ignore_key_error_var=ignore_key_error_var,
|
|
170
|
-
output_name_var=output_name_var,
|
|
171
|
-
output_dtype_var=output_dtype_var,
|
|
172
|
-
)
|
|
173
|
-
]
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
@register_op_adapter(SeriesDictContainsOperator)
|
|
177
|
-
class SeriesDictContainsOperatorAdapter(SPEOperatorAdapter):
|
|
178
|
-
def generate_code(
|
|
179
|
-
self, op: SeriesDictContainsOperator, context: SPECodeContext
|
|
180
|
-
) -> List[str]:
|
|
181
|
-
input_var = context.get_input_tileable_variable(op.inputs[0])
|
|
182
|
-
output_var = context.get_output_tileable_variable(op.outputs[0])
|
|
183
|
-
output_name_var = self.translate_var(context, op.outputs[0].name)
|
|
184
|
-
output_dtype_var = context.register_operator_constants(op.outputs[0].dtype)
|
|
185
|
-
key_var = self.translate_var(context, op.query_key)
|
|
186
|
-
return [
|
|
187
|
-
_contains_template.format(
|
|
188
|
-
input_var=input_var,
|
|
189
|
-
output_var=output_var,
|
|
190
|
-
key_var=key_var,
|
|
191
|
-
output_name_var=output_name_var,
|
|
192
|
-
output_dtype_var=output_dtype_var,
|
|
193
|
-
)
|
|
194
|
-
]
|
|
81
|
+
@register_op_adapter(SeriesDictMethod)
|
|
82
|
+
class SeriesDictMethodAdapter(SeriesTemplateMethodAdapter):
|
|
83
|
+
_templates = {
|
|
84
|
+
"contains": _contains_template,
|
|
85
|
+
"getitem": _get_template,
|
|
86
|
+
"len": _len_template,
|
|
87
|
+
"setitem": _set_template,
|
|
88
|
+
"remove": _remove_template,
|
|
89
|
+
}
|
|
@@ -12,18 +12,16 @@
|
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
|
-
from
|
|
16
|
-
|
|
17
|
-
from
|
|
18
|
-
from .....dataframe.accessors.list_.length import SeriesListLengthOperator
|
|
19
|
-
from ...core import SPECodeContext, SPEOperatorAdapter, register_op_adapter
|
|
15
|
+
from .....dataframe.accessors.list_.core import SeriesListMethod
|
|
16
|
+
from ...core import register_op_adapter
|
|
17
|
+
from .base import SeriesTemplateMethodAdapter
|
|
20
18
|
|
|
21
19
|
_get_template = """
|
|
22
20
|
def _inner_get(data):
|
|
23
21
|
try:
|
|
24
|
-
return data[{
|
|
22
|
+
return data[{query_index}]
|
|
25
23
|
except IndexError:
|
|
26
|
-
if {
|
|
24
|
+
if {ignore_index_error}:
|
|
27
25
|
return None
|
|
28
26
|
else:
|
|
29
27
|
raise
|
|
@@ -32,49 +30,15 @@ def _inner_get(data):
|
|
|
32
30
|
{output_var}.name = None
|
|
33
31
|
"""
|
|
34
32
|
|
|
35
|
-
|
|
33
|
+
_len_template = """
|
|
36
34
|
{output_var} = {input_var}.map(len, na_action="ignore").astype({output_dtype_var})
|
|
37
35
|
{output_var}.name = None
|
|
38
36
|
"""
|
|
39
37
|
|
|
40
38
|
|
|
41
|
-
@register_op_adapter(
|
|
42
|
-
class
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
output_var = context.get_output_tileable_variable(op.outputs[0])
|
|
48
|
-
index_var = self.translate_var(context, op.query_index)
|
|
49
|
-
output_name_var = self.translate_var(context, op.outputs[0].name)
|
|
50
|
-
ignore_index_error_var = self.translate_var(context, op.ignore_index_error)
|
|
51
|
-
output_dtype_var = context.register_operator_constants(op.outputs[0].dtype)
|
|
52
|
-
return [
|
|
53
|
-
_get_template.format(
|
|
54
|
-
input_var=input_var,
|
|
55
|
-
output_var=output_var,
|
|
56
|
-
index_var=index_var,
|
|
57
|
-
ignore_index_error_var=ignore_index_error_var,
|
|
58
|
-
output_name_var=output_name_var,
|
|
59
|
-
output_dtype_var=output_dtype_var,
|
|
60
|
-
)
|
|
61
|
-
]
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
@register_op_adapter(SeriesListLengthOperator)
|
|
65
|
-
class SeriesListLengthOperatorAdapter(SPEOperatorAdapter):
|
|
66
|
-
def generate_code(
|
|
67
|
-
self, op: SeriesListLengthOperator, context: SPECodeContext
|
|
68
|
-
) -> List[str]:
|
|
69
|
-
input_var = context.get_input_tileable_variable(op.inputs[0])
|
|
70
|
-
output_var = context.get_output_tileable_variable(op.outputs[0])
|
|
71
|
-
output_name_var = self.translate_var(context, op.outputs[0].name)
|
|
72
|
-
output_dtype_var = context.register_operator_constants(op.outputs[0].dtype)
|
|
73
|
-
return [
|
|
74
|
-
_length_template.format(
|
|
75
|
-
input_var=input_var,
|
|
76
|
-
output_var=output_var,
|
|
77
|
-
output_name_var=output_name_var,
|
|
78
|
-
output_dtype_var=output_dtype_var,
|
|
79
|
-
)
|
|
80
|
-
]
|
|
39
|
+
@register_op_adapter(SeriesListMethod)
|
|
40
|
+
class SeriesListMethodAdapter(SeriesTemplateMethodAdapter):
|
|
41
|
+
_templates = {
|
|
42
|
+
"getitem": _get_template,
|
|
43
|
+
"len": _len_template,
|
|
44
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Copyright 1999-2025 Alibaba Group Holding Ltd.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
from .....dataframe.accessors.struct_.core import SeriesStructMethod
|
|
16
|
+
from ...core import register_op_adapter
|
|
17
|
+
from .base import SeriesTemplateMethodAdapter
|
|
18
|
+
|
|
19
|
+
_field_template = """
|
|
20
|
+
{output_var} = {input_var}.struct.field({name_or_index})
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
@register_op_adapter(SeriesStructMethod)
|
|
25
|
+
class SeriesStructMethodAdapter(SeriesTemplateMethodAdapter):
|
|
26
|
+
_templates = {
|
|
27
|
+
"field": _field_template,
|
|
28
|
+
}
|
|
@@ -17,13 +17,15 @@ from typing import Dict, List, Type
|
|
|
17
17
|
from ....core import ENTITY_TYPE
|
|
18
18
|
from ....dataframe.arithmetic import (
|
|
19
19
|
DataFrameAnd,
|
|
20
|
-
|
|
20
|
+
DataFrameDot,
|
|
21
21
|
DataFrameOr,
|
|
22
|
+
DataFrameRound,
|
|
22
23
|
DataFrameXor,
|
|
23
24
|
)
|
|
24
25
|
from ....dataframe.arithmetic.core import DataFrameBinOp, DataFrameUnaryOp
|
|
25
26
|
from ....dataframe.core import SERIES_TYPE
|
|
26
27
|
from ..core import SPECodeContext, SPEOperatorAdapter, register_op_adapter
|
|
28
|
+
from ..utils import build_method_call_adapter
|
|
27
29
|
|
|
28
30
|
|
|
29
31
|
@register_op_adapter(DataFrameUnaryOp)
|
|
@@ -34,7 +36,7 @@ class DataFrameUnaryFuncAdapter(SPEOperatorAdapter):
|
|
|
34
36
|
inp_var = context.get_input_tileable_variable(op.inputs[0])
|
|
35
37
|
res_var_name = context.get_output_tileable_variable(op.outputs[0])
|
|
36
38
|
func = getattr(op, "_func_name")
|
|
37
|
-
if isinstance(op,
|
|
39
|
+
if isinstance(op, DataFrameRound):
|
|
38
40
|
decimals_var = self.translate_var(context, op.decimals)
|
|
39
41
|
return [f"{res_var_name} = {inp_var}.round({decimals_var})"]
|
|
40
42
|
else:
|
|
@@ -82,3 +84,6 @@ class DataFrameBitwiseBinOpAdapter(SPEOperatorAdapter):
|
|
|
82
84
|
res_var = context.get_output_tileable_variable(op.outputs[0])
|
|
83
85
|
right_var = self._translate_call_args(context, rhs)[0]
|
|
84
86
|
return [f"{res_var} = {left_var} {self._python_op[type(op)]} {right_var}"]
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
DataFrameDotAdapter = build_method_call_adapter(DataFrameDot, "dot", "rhs")
|
|
@@ -21,12 +21,15 @@ from ....dataframe.groupby.apply import GroupByApply
|
|
|
21
21
|
from ....dataframe.groupby.apply_chunk import GroupByApplyChunk
|
|
22
22
|
from ....dataframe.groupby.core import DataFrameGroupByOp
|
|
23
23
|
from ....dataframe.groupby.cum import GroupByCumcount, GroupByCumReductionOperator
|
|
24
|
+
from ....dataframe.groupby.expanding import GroupByExpandingAgg
|
|
24
25
|
from ....dataframe.groupby.fill import GroupByFill
|
|
25
26
|
from ....dataframe.groupby.getitem import GroupByIndex
|
|
26
27
|
from ....dataframe.groupby.head import GroupByHead
|
|
28
|
+
from ....dataframe.groupby.rolling import GroupByRollingAgg
|
|
27
29
|
from ....dataframe.groupby.sample import GroupBySample
|
|
28
30
|
from ....dataframe.groupby.transform import GroupByTransform
|
|
29
31
|
from ....dataframe.utils import make_column_list
|
|
32
|
+
from ....dataframe.window.rolling import Rolling
|
|
30
33
|
from ....lib.version import parse as parse_version
|
|
31
34
|
from ..core import SPECodeContext, SPEOperatorAdapter, register_op_adapter
|
|
32
35
|
from ..utils import build_method_call_adapter
|
|
@@ -141,6 +144,8 @@ class GroupByApplyChunkAdapter(SPEGroupByOperatorAdapter):
|
|
|
141
144
|
|
|
142
145
|
@register_op_adapter(GroupByCumReductionOperator)
|
|
143
146
|
class GroupByCumReductionAdapter(SPEOperatorAdapter):
|
|
147
|
+
# legacy adapter kept for compatibility
|
|
148
|
+
|
|
144
149
|
def generate_code(
|
|
145
150
|
self, op: GroupByCumReductionOperator, context: SPECodeContext
|
|
146
151
|
) -> List[str]:
|
|
@@ -222,3 +227,86 @@ class GroupByTransformAdapter(SPEOperatorAdapter):
|
|
|
222
227
|
args_list = self._translate_call_args(context, op.func, *op.args, **op.kwds)
|
|
223
228
|
args = ", ".join(args_list)
|
|
224
229
|
return [f"{res_var_name} = {input_var_name}.transform({args})"]
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
@register_op_adapter(GroupByExpandingAgg)
|
|
233
|
+
class GroupByExpandingAggAdapter(SPEGroupByOperatorAdapter):
|
|
234
|
+
def generate_code(
|
|
235
|
+
self, op: GroupByExpandingAgg, context: SPECodeContext
|
|
236
|
+
) -> List[str]:
|
|
237
|
+
input_var_name = context.get_input_tileable_variable(op.inputs[0])
|
|
238
|
+
res_var_name = context.get_output_tileable_variable(op.outputs[0])
|
|
239
|
+
|
|
240
|
+
by_call = self.build_groupby_call(context, op.groupby_params)
|
|
241
|
+
op_kwargs = (op.kwargs or dict()).copy()
|
|
242
|
+
op_kwargs.pop("cumcount", None)
|
|
243
|
+
func_kw_str = ", ".join(self._translate_call_args(context, **op_kwargs))
|
|
244
|
+
|
|
245
|
+
min_periods = op.window_params.get("min_periods", 1)
|
|
246
|
+
shift = op.window_params.get("shift", 0)
|
|
247
|
+
reverse_range = op.window_params.get("reverse_range", False)
|
|
248
|
+
|
|
249
|
+
if (
|
|
250
|
+
min_periods == 1
|
|
251
|
+
and shift == 0
|
|
252
|
+
and not reverse_range
|
|
253
|
+
and op.func in ("count", "sum", "prod", "min", "max")
|
|
254
|
+
):
|
|
255
|
+
# can be simplified as cumxxx function
|
|
256
|
+
cumfunc = "cum" + op.func
|
|
257
|
+
return [
|
|
258
|
+
f"{res_var_name} = {input_var_name}.{by_call}.{cumfunc}({func_kw_str})"
|
|
259
|
+
]
|
|
260
|
+
|
|
261
|
+
agg_func_str = self.translate_var(context, op.func)
|
|
262
|
+
min_periods_str = self.translate_var(context, min_periods)
|
|
263
|
+
inv_shift_str = self.translate_var(context, -shift)
|
|
264
|
+
|
|
265
|
+
# need to call groupby.apply() as groupby.expanding() is not a standard API
|
|
266
|
+
func_kw_str = (", " + func_kw_str) if func_kw_str else ""
|
|
267
|
+
lines = [
|
|
268
|
+
f"def _exp_fun_{res_var_name}(frame, **_):",
|
|
269
|
+
f' func = {agg_func_str} if func != "prod" else lambda x: x.prod()',
|
|
270
|
+
f" frame = frame.shift({inv_shift_str})" if shift else None,
|
|
271
|
+
f" frame = frame.iloc[::-1]" if reverse_range else None,
|
|
272
|
+
f" out_frame = frame.expanding(min_periods={min_periods_str}).agg(func{func_kw_str})",
|
|
273
|
+
f" out_frame = out_frame.iloc[::-1]" if reverse_range else None,
|
|
274
|
+
f" return out_frame",
|
|
275
|
+
f"{res_var_name} = {input_var_name}.{by_call}.apply("
|
|
276
|
+
f"_exp_fun_{res_var_name}, include_groups=False)",
|
|
277
|
+
]
|
|
278
|
+
return [line for line in lines if line is not None]
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
@register_op_adapter(GroupByRollingAgg)
|
|
282
|
+
class GroupByRollingAggAdapter(SPEGroupByOperatorAdapter):
|
|
283
|
+
def generate_code(
|
|
284
|
+
self, op: GroupByRollingAgg, context: SPECodeContext
|
|
285
|
+
) -> List[str]:
|
|
286
|
+
input_var_name = context.get_input_tileable_variable(op.inputs[0])
|
|
287
|
+
res_var_name = context.get_output_tileable_variable(op.outputs[0])
|
|
288
|
+
|
|
289
|
+
by_call = self.build_groupby_call(context, op.groupby_params)
|
|
290
|
+
agg_func_str = self.translate_var(context, op.func)
|
|
291
|
+
|
|
292
|
+
window_params = op.window_params.copy()
|
|
293
|
+
shift = window_params.pop("shift", 0)
|
|
294
|
+
for key in Rolling._mf_specific_fields:
|
|
295
|
+
window_params.pop(key, None)
|
|
296
|
+
|
|
297
|
+
window_params_kw_str = ", ".join(
|
|
298
|
+
self._translate_call_args(context, **window_params)
|
|
299
|
+
)
|
|
300
|
+
func_kw_str = ", ".join(self._translate_call_args(context, **op.kwargs))
|
|
301
|
+
func_kw_str = (", " + func_kw_str) if func_kw_str else ""
|
|
302
|
+
inv_shift_str = self.translate_var(context, -shift)
|
|
303
|
+
|
|
304
|
+
# need to call groupby.apply() as groupby.rolling() is not a standard API
|
|
305
|
+
return [
|
|
306
|
+
f"def _roll_fun_{res_var_name}(frame, **_):",
|
|
307
|
+
f' func = {agg_func_str} if func != "prod" else lambda x: x.prod()',
|
|
308
|
+
f" frame = frame.shift({inv_shift_str})",
|
|
309
|
+
f" return frame.rolling({window_params_kw_str}).agg(func{func_kw_str})",
|
|
310
|
+
f"{res_var_name} = {input_var_name}.{by_call}.apply("
|
|
311
|
+
f"_roll_fun_{res_var_name}, include_groups=False)",
|
|
312
|
+
]
|