huaxingao commented on a change in pull request #25908:
[SPARK-29143][PYTHON][ML] Pyspark feature models support column setters/getters
URL: https://github.com/apache/spark/pull/25908#discussion_r329192597
##########
File path: python/pyspark/ml/tests/test_param.py
##########
@@ -353,7 +353,7 @@ def test_java_params(self):
for name, cls in inspect.getmembers(module, inspect.isclass):
if not name.endswith('Model') and not name.endswith('Params') \
and issubclass(cls, JavaParams) and not
inspect.isabstract(cls) \
- and not name.startswith('Java'):
+ and not name.startswith('Java') and name != 'LSH':
Review comment:
The original code doesn't have python class ```LSH```
```
class LSH(JavaEstimator, _LSHParams, JavaMLReadable, JavaMLWritable):
"""
Mixin for Locality Sensitive Hashing (LSH).
"""
def setNumHashTables(self, value):
"""
Sets the value of :py:attr:`numHashTables`.
"""
return self._set(numHashTables=value)
```
I add this class so I can have a place for ```setNumHashTables```. I don't
have a ```__init__``` in ```LSH``` because scala ```LSH``` is an abstract class
and no constructor. Since no ```__init__```, this ```self._java_obj``` is never
set and ```test_param``` will throw Exception for ```LSH```
```
Traceback (most recent call last):
File
"/Users/hgao/spark092119/spark/python/pyspark/ml/tests/test_param.py", line
358, in test_java_params
check_params(self, cls(), check_params_exist=False)
File "/Users/hgao/spark092119/spark/python/pyspark/testing/mlutils.py",
line 40, in check_params
java_stage = py_stage._to_java()
File "/Users/hgao/spark092119/spark/python/pyspark/ml/wrapper.py", line
222, in _to_java
self._transfer_params_to_java()
File "/Users/hgao/spark092119/spark/python/pyspark/ml/wrapper.py", line
145, in _transfer_params_to_java
pair = self._make_java_param_pair(param, self._defaultParamMap[param])
File "/Users/hgao/spark092119/spark/python/pyspark/ml/wrapper.py", line
131, in _make_java_param_pair
java_param = self._java_obj.getParam(param.name)
AttributeError: 'NoneType' object has no attribute 'getParam'
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]