Coverage for pyspark/ml/common.py : 83%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. #
# Hack for support float('inf') in Py4j
'nan': 'NaN', 'inf': 'Infinity', '-inf': '-Infinity', }
s = str(obj) return _float_str_mapping.get(s, s)
'SparseVector', 'DenseVector', 'SparseMatrix', 'DenseMatrix', ]
# this will call the ML version of pythonToJava() """ Return an JavaRDD of Object by unpickling
It will convert each Python object into Java object by Pyrolite, whenever the RDD is serialized in batch or not. """ rdd = rdd._reserialize(AutoBatchedSerializer(PickleSerializer())) return rdd.ctx._jvm.org.apache.spark.ml.python.MLSerDe.pythonToJava(rdd._jrdd, True)
""" Convert Python object into Java """ obj = _to_java_object_rdd(obj) obj = obj._jsc else:
# convert RDD into JavaRDD r = r.toJavaRDD() clsName = 'JavaRDD'
jrdd = sc._jvm.org.apache.spark.ml.python.MLSerDe.javaToPython(r) return RDD(jrdd, sc)
""" Call Java Function """ args = [_py2java(sc, a) for a in args] return _java2py(sc, func(*args))
""" A decorator that makes a class inherit documentation from its parents. """ # only inherit docstring for public functions |