Github user yanboliang commented on a diff in the pull request:

    https://github.com/apache/spark/pull/6992#discussion_r33420166
  
    --- Diff: python/pyspark/mllib/clustering.py ---
    @@ -466,7 +557,8 @@ def predictOnValues(self, dstream):
     
     def _test():
         import doctest
    -    globs = globals().copy()
    +    import pyspark.mllib.clustering
    +    globs = pyspark.mllib.clustering.__dict__.copy()
    --- End diff --
    
    Yes, the original code will raise "Py4JError: Trying to call a package" at 
https://github.com/apache/spark/pull/6992/files#diff-21c55b407050d37f67a2919470e047ebR324
 .
    I took a glance over related code and found in 
https://github.com/apache/spark/blob/master/python/pyspark/mllib/recommendation.py#L209
 it use __dict__copy(), so I try the same method here and it works well.
    Then I investigate the difference between the two ways.
    Running the following code:
    ```python
    globs1 = globals().copy()
    globs2 = pyspark.mllib.clustering.__dict__.copy()
    
    print [k for k in glob1 if k not in glob2]
    print [k for k in glob2 if k not in glob1] 
    ``` 
    and the output is:
    ```
    ['__loader__']
    []
    ```
    It means that globs1(can't pass test) has one elements called 
```__loader__``` more than globs2(can pass). I have no idea of what cause this.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to