Skip to content

Commit

Permalink
Alter jvm_scala_object to better handle nested scala classes. (#838)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsleight authored Dec 22, 2022
1 parent 96eaaf9 commit fb43440
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions python/mleap/pyspark/feature/math_binary.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ def __init__(
# if operation is not None, we can proceed to instantiate the scala classes
if operation:
scalaBinaryOperation = jvm_scala_object(
_jvm().ml.combust.mleap.core.feature.BinaryOperation,
operation.name
_jvm().ml.combust.mleap.core.feature,
f"BinaryOperation${operation.name}$"
)

scalaMathBinaryModel = _jvm().ml.combust.mleap.core.feature.MathBinaryModel(
Expand Down
4 changes: 2 additions & 2 deletions python/mleap/pyspark/feature/math_unary.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ def __init__(self, operation=None, inputCol=None, outputCol=None):
# if operation is not None, we can proceed to instantiate the scala classes
if operation:
scalaUnaryOperation = jvm_scala_object(
_jvm().ml.combust.mleap.core.feature.UnaryOperation,
operation.name
_jvm().ml.combust.mleap.core.feature,
f"UnaryOperation${operation.name}$",
)

scalaMathUnaryModel = _jvm().ml.combust.mleap.core.feature.MathUnaryModel(scalaUnaryOperation)
Expand Down
4 changes: 2 additions & 2 deletions python/mleap/pyspark/feature/string_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ def validate_args():
.toMap(_jvm().scala.Predef.conforms())

handle_invalid_jvm = jvm_scala_object(
_jvm().ml.combust.mleap.core.feature.HandleInvalid,
handleInvalid.capitalize(),
_jvm().ml.combust.mleap.core.feature,
f"HandleInvalid${handleInvalid.capitalize()}$",
)

string_map_model = _jvm().ml.combust.mleap.core.feature.StringMapModel(
Expand Down
4 changes: 2 additions & 2 deletions python/mleap/pyspark/py2scala.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def jvm_scala_object(jpkg, obj):
(for reference see file ml.combust.mleap.core.feature.MathUnaryModel)
"""
return getattr(
getattr(jpkg, obj + "$"), # JavaClass
getattr(jpkg, obj), # JavaClass
"MODULE$", # JavaObject
)

Expand All @@ -25,4 +25,4 @@ def Some(value):
return _jvm().scala.Some(value)

def ScalaNone():
return jvm_scala_object(_jvm().scala, "None")
return jvm_scala_object(_jvm().scala, "None$")

0 comments on commit fb43440

Please sign in to comment.