maxframe 2.0.0b2__cp37-cp37m-win32.whl → 2.3.0rc1__cp37-cp37m-win32.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.cp37-win32.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.cp37-win32.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.cp37-win32.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.cp37-win32.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
|
@@ -15,7 +15,11 @@
|
|
|
15
15
|
from ..... import tensor as mt
|
|
16
16
|
from ...core import SPECodeContext
|
|
17
17
|
from ..misc import (
|
|
18
|
+
TensorCopyToAdapter,
|
|
19
|
+
TensorGetShapeAdapter,
|
|
20
|
+
TensorInsertAdapter,
|
|
18
21
|
TensorIsInAdapter,
|
|
22
|
+
TensorSplitAdapter,
|
|
19
23
|
TensorSqueezeAdapter,
|
|
20
24
|
TensorTransposeAdapter,
|
|
21
25
|
TensorUniqueAdapter,
|
|
@@ -40,7 +44,7 @@ def test_transpose():
|
|
|
40
44
|
adapter = TensorTransposeAdapter()
|
|
41
45
|
context = SPECodeContext()
|
|
42
46
|
results = adapter.generate_code(result.op, context)
|
|
43
|
-
expected_results = ["
|
|
47
|
+
expected_results = ["var_0 = np.transpose(var_1, axes=[1, 0, 2])"]
|
|
44
48
|
assert results == expected_results
|
|
45
49
|
|
|
46
50
|
|
|
@@ -50,7 +54,7 @@ def test_squeeze():
|
|
|
50
54
|
adapter = TensorSqueezeAdapter()
|
|
51
55
|
context = SPECodeContext()
|
|
52
56
|
results = adapter.generate_code(result.op, context)
|
|
53
|
-
expected_results = ["
|
|
57
|
+
expected_results = ["var_0 = np.squeeze(var_1, axis=(0,))"]
|
|
54
58
|
assert results == expected_results
|
|
55
59
|
|
|
56
60
|
|
|
@@ -92,3 +96,49 @@ def test_unique():
|
|
|
92
96
|
"np.unique(var_0, return_index=True, return_inverse=True, return_counts=True, axis=0)"
|
|
93
97
|
]
|
|
94
98
|
assert results == expected_results
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
def test_insert():
|
|
102
|
+
result = mt.insert(mt.array([[1, 1], [2, 2], [3, 3]]), 1, 5)
|
|
103
|
+
|
|
104
|
+
adapter = TensorInsertAdapter()
|
|
105
|
+
context = SPECodeContext()
|
|
106
|
+
results = adapter.generate_code(result.op, context)
|
|
107
|
+
expected_results = ["var_0 = np.insert(var_1, 1, values=5)"]
|
|
108
|
+
assert results == expected_results
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
def test_split():
|
|
112
|
+
res_tp = mt.split(mt.array([1, 2, 3, 4, 5, 6]), 3)
|
|
113
|
+
|
|
114
|
+
adapter = TensorSplitAdapter()
|
|
115
|
+
context = SPECodeContext()
|
|
116
|
+
results = adapter.generate_code(res_tp[0].op, context)
|
|
117
|
+
expected_results = ["var_1, var_2, var_3 = np.split(var_0, 3 axis=0)"]
|
|
118
|
+
assert results == expected_results
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
def test_get_shape():
|
|
122
|
+
inp = mt.array([[1, 1], [2, 2], [3, 3]])
|
|
123
|
+
res = mt.shape(inp[:, inp[0, :] == 1])
|
|
124
|
+
|
|
125
|
+
adapter = TensorGetShapeAdapter()
|
|
126
|
+
context = SPECodeContext()
|
|
127
|
+
results = adapter.generate_code(res[0].op, context)
|
|
128
|
+
expected_results = ["var_1, var_2 = np.shape(var_0)"]
|
|
129
|
+
assert results == expected_results
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
def test_copyto():
|
|
133
|
+
dest = mt.array([[1, 1], [2, 2], [3, 3]])
|
|
134
|
+
src = mt.array([[1, 1], [2, 2], [3, 4]])
|
|
135
|
+
mt.copyto(dest, src)
|
|
136
|
+
|
|
137
|
+
adapter = TensorCopyToAdapter()
|
|
138
|
+
context = SPECodeContext()
|
|
139
|
+
results = adapter.generate_code(dest.op, context)
|
|
140
|
+
expected_results = [
|
|
141
|
+
"var_2 = var_0.copy()",
|
|
142
|
+
"np.copyto(var_2, var_1, casting='same_kind')",
|
|
143
|
+
]
|
|
144
|
+
assert results == expected_results
|
|
@@ -0,0 +1,33 @@
|
|
|
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 ..... import tensor as mt
|
|
16
|
+
from ...core import SPECodeContext
|
|
17
|
+
from ..spatial import TensorCDistAdapter
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def test_cdist():
|
|
21
|
+
xa = mt.random.rand(100, 10)
|
|
22
|
+
xb = mt.random.rand(89, 10)
|
|
23
|
+
VI = mt.random.rand(10, 10)
|
|
24
|
+
dist = mt.spatial.distance.cdist(xa, xb, metric="mahalanobis", VI=VI)
|
|
25
|
+
|
|
26
|
+
adapter = TensorCDistAdapter()
|
|
27
|
+
context = SPECodeContext()
|
|
28
|
+
results = adapter.generate_code(dist.op, context)
|
|
29
|
+
expected_results = [
|
|
30
|
+
"var_0 = scipy.spatial.distance.cdist("
|
|
31
|
+
"var_1, var_2, metric='mahalanobis', VI=var_3)"
|
|
32
|
+
]
|
|
33
|
+
assert results == expected_results
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
from ..... import tensor as mt
|
|
16
16
|
from ...core import SPECodeContext
|
|
17
|
-
from ..statistics import TensorBinCountAdapter
|
|
17
|
+
from ..statistics import TensorBinCountAdapter, TensorHistogramAdapter
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
def test_bincount():
|
|
@@ -27,3 +27,17 @@ def test_bincount():
|
|
|
27
27
|
results = adapter.generate_code(result.op, context)
|
|
28
28
|
expected_results = ["var_0 = np.bincount(var_1, weights=var_2, minlength=0)"]
|
|
29
29
|
assert results == expected_results
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def test_histogram():
|
|
33
|
+
arr = mt.arange(5)
|
|
34
|
+
result, _bins = mt.histogram(arr, bins=3)
|
|
35
|
+
|
|
36
|
+
adapter = TensorHistogramAdapter()
|
|
37
|
+
context = SPECodeContext()
|
|
38
|
+
results = adapter.generate_code(result.op, context)
|
|
39
|
+
expected_results = [
|
|
40
|
+
"var_1, _ = np.histogram(var_0, bins=var_2, range=None, density=None, "
|
|
41
|
+
"weights=None)"
|
|
42
|
+
]
|
|
43
|
+
assert results == expected_results
|
|
@@ -59,12 +59,8 @@ def test_codegen_with_udf(codegen):
|
|
|
59
59
|
|
|
60
60
|
udf_1_body = base64.b64encode(pickle.dumps(f1, protocol=pickle.DEFAULT_PROTOCOL))
|
|
61
61
|
udf_2_body = base64.b64encode(pickle.dumps(f2, protocol=pickle.DEFAULT_PROTOCOL))
|
|
62
|
-
udf_1_value = (
|
|
63
|
-
|
|
64
|
-
)
|
|
65
|
-
udf_2_value = (
|
|
66
|
-
f"pickled_data = cloudpickle.loads(base64.b64decode({udf_2_body}), buffers=[])"
|
|
67
|
-
)
|
|
62
|
+
udf_1_value = f"udf_main_entry = cloudpickle.loads(base64.b64decode({udf_1_body}), buffers=[])"
|
|
63
|
+
udf_2_value = f"udf_main_entry = cloudpickle.loads(base64.b64decode({udf_2_body}), buffers=[])"
|
|
68
64
|
udf_1 = f"user_udf_f1_{hashlib.md5(udf_1_value.encode('utf-8')).hexdigest()}"
|
|
69
65
|
udf_2 = f"user_udf_f2_{hashlib.md5(udf_2_value.encode('utf-8')).hexdigest()}"
|
|
70
66
|
|
|
@@ -74,9 +70,9 @@ def test_codegen_with_udf(codegen):
|
|
|
74
70
|
import base64
|
|
75
71
|
import cloudpickle
|
|
76
72
|
{udf_1_value}
|
|
77
|
-
{udf_1} =
|
|
73
|
+
{udf_1} = udf_main_entry
|
|
78
74
|
{udf_2_value}
|
|
79
|
-
{udf_2} =
|
|
75
|
+
{udf_2} = udf_main_entry
|
|
80
76
|
if not running:
|
|
81
77
|
raise RuntimeError('CANCELLED')
|
|
82
78
|
var_0 = np.random.rand(1, 3)
|
|
@@ -111,9 +107,7 @@ def test_codegen_with_udf_and_args(codegen):
|
|
|
111
107
|
protocol=pickle.DEFAULT_PROTOCOL,
|
|
112
108
|
)
|
|
113
109
|
)
|
|
114
|
-
udf_1_value = (
|
|
115
|
-
f"pickled_data = cloudpickle.loads(base64.b64decode({udf_1_body}), buffers=[])"
|
|
116
|
-
)
|
|
110
|
+
udf_1_value = f"udf_main_entry = cloudpickle.loads(base64.b64decode({udf_1_body}), buffers=[])"
|
|
117
111
|
udf_1 = f"user_udf_f1_{hashlib.md5(udf_1_value.encode('utf-8')).hexdigest()}"
|
|
118
112
|
|
|
119
113
|
expected_contents = f"""
|
|
@@ -122,7 +116,7 @@ def test_codegen_with_udf_and_args(codegen):
|
|
|
122
116
|
import base64
|
|
123
117
|
import cloudpickle
|
|
124
118
|
{udf_1_value}
|
|
125
|
-
{udf_1} =
|
|
119
|
+
{udf_1} = udf_main_entry
|
|
126
120
|
if not running:
|
|
127
121
|
raise RuntimeError('CANCELLED')
|
|
128
122
|
var_0 = np.random.rand(1, 3)
|
maxframe/codegen/spe/utils.py
CHANGED
|
@@ -37,6 +37,8 @@ def build_method_call_adapter(
|
|
|
37
37
|
def generate_code(self, op: OperatorType, context: SPECodeContext) -> List[str]:
|
|
38
38
|
if source_module in _import_aliases:
|
|
39
39
|
context.register_import(_import_aliases[source_module], source_module)
|
|
40
|
+
elif source_module:
|
|
41
|
+
context.register_import(source_module)
|
|
40
42
|
|
|
41
43
|
input_var_name = source_module or context.get_input_tileable_variable(
|
|
42
44
|
op.inputs[0]
|
maxframe/config/config.py
CHANGED
|
@@ -18,7 +18,7 @@ import os
|
|
|
18
18
|
import traceback
|
|
19
19
|
import warnings
|
|
20
20
|
from copy import deepcopy
|
|
21
|
-
from typing import Any, Dict, Optional, Union
|
|
21
|
+
from typing import Any, Callable, Dict, Optional, Union
|
|
22
22
|
|
|
23
23
|
from odps.lib import tzlocal
|
|
24
24
|
|
|
@@ -33,13 +33,17 @@ from ..utils import get_python_tag
|
|
|
33
33
|
from .validators import (
|
|
34
34
|
ValidatorType,
|
|
35
35
|
all_validator,
|
|
36
|
+
dtype_backend_validator,
|
|
36
37
|
is_all_dict_keys_in,
|
|
37
38
|
is_bool,
|
|
38
39
|
is_dict,
|
|
39
40
|
is_float,
|
|
41
|
+
is_great_than,
|
|
40
42
|
is_in,
|
|
41
43
|
is_integer,
|
|
44
|
+
is_less_than_or_equal_to,
|
|
42
45
|
is_non_negative_integer,
|
|
46
|
+
is_notnull,
|
|
43
47
|
is_null,
|
|
44
48
|
is_numeric,
|
|
45
49
|
is_string,
|
|
@@ -59,6 +63,7 @@ _DEFAULT_TASK_START_TIMEOUT = 60
|
|
|
59
63
|
_DEFAULT_TASK_RESTART_TIMEOUT = 300
|
|
60
64
|
_DEFAULT_LOGVIEW_HOURS = 24 * 30
|
|
61
65
|
_DEFAULT_FUNCTION_RUNNING_OPTIONS = {"cpu": 1, "memory": "4GiB", "gpu": 0}
|
|
66
|
+
_DEFAULT_MAX_MEMORY_CPU_RATIO = 12
|
|
62
67
|
|
|
63
68
|
|
|
64
69
|
class OptionError(Exception):
|
|
@@ -66,11 +71,19 @@ class OptionError(Exception):
|
|
|
66
71
|
|
|
67
72
|
|
|
68
73
|
class Redirection:
|
|
69
|
-
def __init__(
|
|
74
|
+
def __init__(
|
|
75
|
+
self,
|
|
76
|
+
item: str,
|
|
77
|
+
warn: Optional[str] = None,
|
|
78
|
+
getter: Callable = None,
|
|
79
|
+
setter: Callable = None,
|
|
80
|
+
):
|
|
70
81
|
self._items = item.split(".")
|
|
71
82
|
self._warn = warn
|
|
72
83
|
self._warned = True
|
|
73
84
|
self._parent = None
|
|
85
|
+
self._getter = getter
|
|
86
|
+
self._setter = setter
|
|
74
87
|
|
|
75
88
|
def bind(self, attr_dict):
|
|
76
89
|
self._parent = attr_dict
|
|
@@ -88,6 +101,8 @@ class Redirection:
|
|
|
88
101
|
conf = self._parent.root
|
|
89
102
|
for it in self._items:
|
|
90
103
|
conf = getattr(conf, it)
|
|
104
|
+
if callable(self._getter):
|
|
105
|
+
conf = self._getter(conf)
|
|
91
106
|
return conf
|
|
92
107
|
|
|
93
108
|
def setvalue(self, value: str, silent: bool = False) -> None:
|
|
@@ -97,6 +112,8 @@ class Redirection:
|
|
|
97
112
|
conf = self._parent.root
|
|
98
113
|
for it in self._items[:-1]:
|
|
99
114
|
conf = getattr(conf, it)
|
|
115
|
+
if callable(self._setter):
|
|
116
|
+
value = self._setter(value)
|
|
100
117
|
setattr(conf, self._items[-1], value)
|
|
101
118
|
|
|
102
119
|
|
|
@@ -251,9 +268,19 @@ class Config:
|
|
|
251
268
|
self._remote_options.add(option)
|
|
252
269
|
|
|
253
270
|
def redirect_option(
|
|
254
|
-
self,
|
|
271
|
+
self,
|
|
272
|
+
option: str,
|
|
273
|
+
target: str,
|
|
274
|
+
warn: str = _DEFAULT_REDIRECT_WARN,
|
|
275
|
+
getter: Callable = None,
|
|
276
|
+
setter: Callable = None,
|
|
255
277
|
) -> None:
|
|
256
|
-
redir = Redirection(
|
|
278
|
+
redir = Redirection(
|
|
279
|
+
target,
|
|
280
|
+
warn=warn.format(source=option, target=target),
|
|
281
|
+
getter=getter,
|
|
282
|
+
setter=setter,
|
|
283
|
+
)
|
|
257
284
|
self.register_option(option, redir)
|
|
258
285
|
|
|
259
286
|
def unregister_option(self, option: str) -> None:
|
|
@@ -315,10 +342,18 @@ class Config:
|
|
|
315
342
|
|
|
316
343
|
|
|
317
344
|
def _get_legal_local_tz_name() -> Optional[str]:
|
|
318
|
-
"""
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
345
|
+
"""
|
|
346
|
+
Sometimes we may get illegal tz name from tzlocal.get_localzone().
|
|
347
|
+
In some environments we can't get any tz name.
|
|
348
|
+
"""
|
|
349
|
+
tz_name = None
|
|
350
|
+
try:
|
|
351
|
+
tz_name = str(tzlocal.get_localzone())
|
|
352
|
+
if tz_name not in available_timezones():
|
|
353
|
+
tz_name = None
|
|
354
|
+
except:
|
|
355
|
+
pass
|
|
356
|
+
|
|
322
357
|
return tz_name
|
|
323
358
|
|
|
324
359
|
|
|
@@ -400,6 +435,12 @@ default_options.register_option(
|
|
|
400
435
|
default_options.register_option(
|
|
401
436
|
"session.quota_name", None, validator=is_null | is_string, remote=True
|
|
402
437
|
)
|
|
438
|
+
default_options.register_option(
|
|
439
|
+
"session.gu_quota_name", None, validator=is_null | is_string, remote=True
|
|
440
|
+
)
|
|
441
|
+
default_options.register_option(
|
|
442
|
+
"session.region_id", None, validator=is_null | is_string, remote=True
|
|
443
|
+
)
|
|
403
444
|
default_options.register_option(
|
|
404
445
|
"session.enable_schema", None, validator=is_null | is_bool, remote=True
|
|
405
446
|
)
|
|
@@ -446,7 +487,15 @@ default_options.register_option(
|
|
|
446
487
|
)
|
|
447
488
|
|
|
448
489
|
default_options.register_option("warn_duplicated_execution", False, validator=is_bool)
|
|
449
|
-
default_options.register_option(
|
|
490
|
+
default_options.register_option(
|
|
491
|
+
"dataframe.dtype_backend", "numpy", validator=dtype_backend_validator
|
|
492
|
+
)
|
|
493
|
+
default_options.redirect_option(
|
|
494
|
+
"dataframe.use_arrow_dtype",
|
|
495
|
+
"dataframe.dtype_backend",
|
|
496
|
+
getter=lambda x: x == "pyarrow",
|
|
497
|
+
setter=lambda x: "pyarrow" if x else "numpy",
|
|
498
|
+
)
|
|
450
499
|
default_options.register_option(
|
|
451
500
|
"dataframe.arrow_array.pandas_only", True, validator=is_bool
|
|
452
501
|
)
|
|
@@ -464,6 +513,15 @@ default_options.register_option(
|
|
|
464
513
|
validator=is_dict | is_all_dict_keys_in("cpu", "memory", "gpu"),
|
|
465
514
|
)
|
|
466
515
|
|
|
516
|
+
default_options.register_option(
|
|
517
|
+
"function.allowed_max_memory_cpu_ratio",
|
|
518
|
+
_DEFAULT_MAX_MEMORY_CPU_RATIO,
|
|
519
|
+
validator=is_integer
|
|
520
|
+
& is_notnull
|
|
521
|
+
& is_less_than_or_equal_to(_DEFAULT_MAX_MEMORY_CPU_RATIO)
|
|
522
|
+
& is_great_than(0),
|
|
523
|
+
)
|
|
524
|
+
|
|
467
525
|
################
|
|
468
526
|
# DPE Settings #
|
|
469
527
|
################
|
|
@@ -505,9 +563,15 @@ default_options.register_option(
|
|
|
505
563
|
assume_finite = os.environ.get("SKLEARN_ASSUME_FINITE")
|
|
506
564
|
if assume_finite is not None:
|
|
507
565
|
assume_finite = bool(assume_finite)
|
|
566
|
+
working_memory = os.environ.get("SKLEARN_WORKING_MEMORY")
|
|
567
|
+
if working_memory is not None:
|
|
568
|
+
working_memory = int(working_memory)
|
|
508
569
|
default_options.register_option(
|
|
509
570
|
"learn.assume_finite", assume_finite, validator=is_null | is_bool
|
|
510
571
|
)
|
|
572
|
+
default_options.register_option(
|
|
573
|
+
"learn.working_memory", working_memory, validator=is_null | is_integer
|
|
574
|
+
)
|
|
511
575
|
|
|
512
576
|
_options_ctx_var = contextvars.ContextVar("_options_ctx_var")
|
|
513
577
|
|
|
@@ -14,7 +14,11 @@
|
|
|
14
14
|
|
|
15
15
|
import pytest
|
|
16
16
|
|
|
17
|
-
from ..validators import
|
|
17
|
+
from ..validators import (
|
|
18
|
+
is_less_than_or_equal_to,
|
|
19
|
+
is_positive_integer,
|
|
20
|
+
simple_yaml_str_validator,
|
|
21
|
+
)
|
|
18
22
|
|
|
19
23
|
|
|
20
24
|
@pytest.mark.parametrize("value", ["a", "http://127.0.0.1:1234", "a-b#", "ab_", "123"])
|
|
@@ -32,3 +36,11 @@ def test_simple_yaml_str_validator_invalid(value):
|
|
|
32
36
|
)
|
|
33
37
|
def test_is_positive_integer_validator(value, valid):
|
|
34
38
|
assert is_positive_integer(value) is valid
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
@pytest.mark.parametrize(
|
|
42
|
+
"value,upper_bound,valid",
|
|
43
|
+
[(3, 5, True), (5, 5, True), (6, 5, False), (None, None, False), (None, 5, False)],
|
|
44
|
+
)
|
|
45
|
+
def test_is_less_than_or_equal_to_validator(value, upper_bound, valid):
|
|
46
|
+
assert is_less_than_or_equal_to(upper_bound)(value) is valid
|
maxframe/config/validators.py
CHANGED
|
@@ -12,9 +12,13 @@
|
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
|
+
import os
|
|
15
16
|
from typing import Callable
|
|
16
17
|
from urllib.parse import urlparse
|
|
17
18
|
|
|
19
|
+
from .. import env
|
|
20
|
+
from ..utils import str_to_bool
|
|
21
|
+
|
|
18
22
|
ValidatorType = Callable[..., bool]
|
|
19
23
|
|
|
20
24
|
|
|
@@ -43,13 +47,22 @@ class Validator:
|
|
|
43
47
|
def __or__(self, other):
|
|
44
48
|
return OrValidator(self, other)
|
|
45
49
|
|
|
50
|
+
def __and__(self, other):
|
|
51
|
+
return AndValidator(self, other)
|
|
52
|
+
|
|
46
53
|
|
|
47
54
|
class OrValidator(Validator):
|
|
48
55
|
def __init__(self, lhs: Validator, rhs: Validator):
|
|
49
56
|
super().__init__(lambda x: lhs(x) or rhs(x))
|
|
50
57
|
|
|
51
58
|
|
|
59
|
+
class AndValidator(Validator):
|
|
60
|
+
def __init__(self, lhs: Validator, rhs: Validator):
|
|
61
|
+
super().__init__(lambda x: lhs(x) and rhs(x))
|
|
62
|
+
|
|
63
|
+
|
|
52
64
|
is_null = Validator(lambda x: x is None)
|
|
65
|
+
is_notnull = Validator(lambda x: x is not None)
|
|
53
66
|
is_bool = Validator(lambda x: isinstance(x, bool))
|
|
54
67
|
is_float = Validator(lambda x: isinstance(x, float))
|
|
55
68
|
is_integer = Validator(lambda x: isinstance(x, int))
|
|
@@ -69,6 +82,30 @@ def is_all_dict_keys_in(*keys):
|
|
|
69
82
|
return Validator(lambda x: x in keys_set)
|
|
70
83
|
|
|
71
84
|
|
|
85
|
+
def is_less_than(upper_bound):
|
|
86
|
+
return Validator(
|
|
87
|
+
lambda x: is_notnull(x) and is_notnull(upper_bound) and x < upper_bound
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def is_less_than_or_equal_to(upper_bound):
|
|
92
|
+
return Validator(
|
|
93
|
+
lambda x: is_notnull(x) and is_notnull(upper_bound) and x <= upper_bound
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def is_great_than(lower_bound):
|
|
98
|
+
return Validator(
|
|
99
|
+
lambda x: is_notnull(x) and is_notnull(lower_bound) and x > lower_bound
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def is_great_than_or_equal_to(lower_bound):
|
|
104
|
+
return Validator(
|
|
105
|
+
lambda x: is_notnull(x) and is_notnull(lower_bound) and x >= lower_bound
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
|
|
72
109
|
def _is_valid_cache_path(path: str) -> bool:
|
|
73
110
|
"""
|
|
74
111
|
path should look like oss://oss_endpoint/oss_bucket/path
|
|
@@ -91,3 +128,15 @@ _invalid_char_in_yaml_str = {'"', "'", "\n", "\\"}
|
|
|
91
128
|
def simple_yaml_str_validator(name: str) -> bool:
|
|
92
129
|
chars = set(name)
|
|
93
130
|
return len(_invalid_char_in_yaml_str & chars) == 0
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
def dtype_backend_validator(name: str) -> bool:
|
|
134
|
+
from ..utils import pd_release_version
|
|
135
|
+
|
|
136
|
+
check_pd_version = not str_to_bool(os.getenv(env.MAXFRAME_INSIDE_TASK))
|
|
137
|
+
name = "pyarrow" if name == "arrow" else name
|
|
138
|
+
if name not in (None, "numpy", "pyarrow"):
|
|
139
|
+
return False
|
|
140
|
+
if check_pd_version and name == "pyarrow" and pd_release_version[:2] < (1, 5):
|
|
141
|
+
raise ValueError("Need pandas>=1.5 to use pyarrow backend")
|
|
142
|
+
return True
|
maxframe/conftest.py
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
|
+
import contextlib
|
|
15
16
|
import faulthandler
|
|
16
17
|
import os
|
|
17
18
|
from configparser import ConfigParser, NoOptionError, NoSectionError
|
|
@@ -60,6 +61,10 @@ def _get_account_env(test_config: ConfigParser, section_name: str) -> ODPS:
|
|
|
60
61
|
tunnel_endpoint = test_config.get("odps", "tunnel_endpoint")
|
|
61
62
|
except NoOptionError:
|
|
62
63
|
tunnel_endpoint = None
|
|
64
|
+
try:
|
|
65
|
+
namespace = test_config.get("odps", "namespace")
|
|
66
|
+
except NoOptionError:
|
|
67
|
+
namespace = None
|
|
63
68
|
return ODPS(
|
|
64
69
|
access_id,
|
|
65
70
|
secret_access_key,
|
|
@@ -67,6 +72,7 @@ def _get_account_env(test_config: ConfigParser, section_name: str) -> ODPS:
|
|
|
67
72
|
endpoint,
|
|
68
73
|
tunnel_endpoint=tunnel_endpoint,
|
|
69
74
|
overwrite_global=False,
|
|
75
|
+
namespace=namespace,
|
|
70
76
|
)
|
|
71
77
|
|
|
72
78
|
|
|
@@ -84,24 +90,30 @@ def _get_bearer_token_env(test_config: ConfigParser, section_name: str) -> ODPS:
|
|
|
84
90
|
project=entry.project,
|
|
85
91
|
endpoint=entry.endpoint,
|
|
86
92
|
tunnel_endpoint=entry.tunnel_endpoint,
|
|
93
|
+
namespace=entry.namespace,
|
|
87
94
|
)
|
|
88
95
|
|
|
89
96
|
|
|
90
|
-
@
|
|
91
|
-
def
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
97
|
+
@contextlib.contextmanager
|
|
98
|
+
def _enter_odps_envs(entry, drop_temp_tables=True):
|
|
99
|
+
stored_envs = {}
|
|
100
|
+
for env_name in (
|
|
101
|
+
"ODPS_BEARER_TOKEN",
|
|
102
|
+
"ODPS_PROJECT_NAME",
|
|
103
|
+
"ODPS_ENDPOINT",
|
|
104
|
+
"RAY_ISOLATION_UT_ENV",
|
|
105
|
+
"ODPS_TUNNEL_ENDPOINT",
|
|
106
|
+
"ODPS_NAMESPACE",
|
|
107
|
+
):
|
|
108
|
+
if env_name in os.environ:
|
|
109
|
+
stored_envs[env_name] = os.environ[env_name]
|
|
110
|
+
del os.environ[env_name]
|
|
101
111
|
|
|
102
112
|
os.environ["ODPS_BEARER_TOKEN"] = entry.account.token
|
|
103
113
|
os.environ["ODPS_PROJECT_NAME"] = entry.project
|
|
104
114
|
os.environ["ODPS_ENDPOINT"] = entry.endpoint
|
|
115
|
+
if entry.namespace:
|
|
116
|
+
os.environ["ODPS_NAMESPACE"] = entry.namespace
|
|
105
117
|
os.environ["RAY_ISOLATION_UT_ENV"] = "UT"
|
|
106
118
|
if entry.tunnel_endpoint:
|
|
107
119
|
os.environ["ODPS_TUNNEL_ENDPOINT"] = entry.tunnel_endpoint
|
|
@@ -112,16 +124,41 @@ def odps_envs(test_config):
|
|
|
112
124
|
os.environ.pop("ODPS_BEARER_TOKEN", None)
|
|
113
125
|
os.environ.pop("ODPS_PROJECT_NAME", None)
|
|
114
126
|
os.environ.pop("ODPS_ENDPOINT", None)
|
|
127
|
+
os.environ.pop("ODPS_NAMESPACE", None)
|
|
115
128
|
os.environ.pop("ODPS_TUNNEL_ENDPOINT", None)
|
|
116
129
|
os.environ.pop("RAY_ISOLATION_UT_ENV", None)
|
|
117
130
|
|
|
118
|
-
|
|
131
|
+
for env_name, val in stored_envs.items():
|
|
132
|
+
os.environ[env_name] = val
|
|
133
|
+
|
|
134
|
+
if drop_temp_tables:
|
|
135
|
+
from .tests.utils import _test_tables_to_drop
|
|
136
|
+
|
|
137
|
+
for table_name in _test_tables_to_drop:
|
|
138
|
+
try:
|
|
139
|
+
entry.delete_table(table_name, wait=False)
|
|
140
|
+
except:
|
|
141
|
+
pass
|
|
119
142
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
143
|
+
|
|
144
|
+
@pytest.fixture
|
|
145
|
+
def odps_with_schema(test_config, request):
|
|
146
|
+
try:
|
|
147
|
+
entry = _get_bearer_token_env(test_config, "odps_with_schema")
|
|
148
|
+
except NoSectionError:
|
|
149
|
+
pytest.skip("Need to specify odps_with_schema section in test.conf")
|
|
150
|
+
raise
|
|
151
|
+
|
|
152
|
+
with _enter_odps_envs(entry, drop_temp_tables=False):
|
|
153
|
+
yield entry
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
@pytest.fixture(scope="session", autouse=True)
|
|
157
|
+
def odps_envs(test_config):
|
|
158
|
+
entry = _get_bearer_token_env(test_config, "odps")
|
|
159
|
+
|
|
160
|
+
with _enter_odps_envs(entry):
|
|
161
|
+
yield
|
|
125
162
|
|
|
126
163
|
|
|
127
164
|
@pytest.fixture(scope="session")
|
maxframe/core/accessor.py
CHANGED
|
@@ -20,13 +20,13 @@ class BaseMaxFrameAccessor:
|
|
|
20
20
|
self.obj = obj
|
|
21
21
|
|
|
22
22
|
@classmethod
|
|
23
|
-
def _register(cls, name, func):
|
|
23
|
+
def _register(cls, name, func, is_property=False):
|
|
24
24
|
@functools.wraps(func)
|
|
25
25
|
def wrapped(self, *args, **kw):
|
|
26
26
|
return func(self.obj, *args, **kw)
|
|
27
27
|
|
|
28
28
|
wrapped.__name__ = name
|
|
29
|
-
setattr(cls, name, wrapped)
|
|
29
|
+
setattr(cls, name, wrapped if not is_property else property(wrapped))
|
|
30
30
|
if hasattr(cls, "_api_count"): # pragma: no branch
|
|
31
31
|
cls._api_count += 1
|
|
32
32
|
|
maxframe/core/base.py
CHANGED
|
@@ -126,12 +126,13 @@ class Base(Serializable):
|
|
|
126
126
|
|
|
127
127
|
def to_kv(
|
|
128
128
|
self,
|
|
129
|
-
exclude_fields: Tuple[str],
|
|
129
|
+
exclude_fields: Tuple[str] = None,
|
|
130
130
|
accept_value_types: Optional[Tuple[Type]] = None,
|
|
131
131
|
):
|
|
132
132
|
fields = self._FIELDS
|
|
133
133
|
kv = {}
|
|
134
134
|
no_value = object()
|
|
135
|
+
exclude_fields = exclude_fields or ()
|
|
135
136
|
for name, field in fields.items():
|
|
136
137
|
if name not in exclude_fields:
|
|
137
138
|
value = getattr(self, name, no_value)
|
maxframe/core/entity/core.py
CHANGED
|
@@ -312,12 +312,14 @@ class HasShapeTileableData(TileableData):
|
|
|
312
312
|
|
|
313
313
|
@property
|
|
314
314
|
def ndim(self):
|
|
315
|
-
return len(self.shape)
|
|
315
|
+
return len(self.shape) if self.shape is not None else np.nan
|
|
316
316
|
|
|
317
317
|
def __len__(self):
|
|
318
318
|
try:
|
|
319
319
|
return int(self.shape[0])
|
|
320
320
|
except (IndexError, ValueError): # pragma: no cover
|
|
321
|
+
if len(self.shape) == 0:
|
|
322
|
+
raise TypeError("len() of unsized object") from None
|
|
321
323
|
return 0
|
|
322
324
|
|
|
323
325
|
@property
|
|
Binary file
|