Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SPARK-20862][MLLIB][PYTHON] Avoid passing float to ndarray.reshape in LogisticRegressionModel #18081

Closed
wants to merge 1 commit into from

Conversation

MrBago
Copy link
Contributor

@MrBago MrBago commented May 24, 2017

What changes were proposed in this pull request?

Fixed TypeError with python3 and numpy 1.12.1. Numpy's reshape no longer takes floats as arguments as of 1.12. Also, python3 uses float division for /, we should be using // to ensure that _dataWithBiasSize doesn't get set to a float.

How was this patch tested?

Existing tests run using python3 and numpy 1.12.

@SparkQA
Copy link

SparkQA commented May 24, 2017

Test build #77275 has finished for PR 18081 at commit b536160.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@MrBago MrBago changed the title [SPARK-20862] BugFix - avoid passing float to ndarray.reshape in LogisticRegressionModel [SPARK-20862][MLLIB][PYTHON] BugFix - avoid passing float to ndarray.reshape in LogisticRegressionModel May 24, 2017
@viirya
Copy link
Member

viirya commented May 24, 2017

LGTM

Do we have similar cases in MLlib?

@viirya
Copy link
Member

viirya commented May 24, 2017

To test it in jenkins might need a specified numpy version, but the code change looks ok.

@srowen
Copy link
Member

srowen commented May 24, 2017

Dumb question but this still works in Python 2.6+ right?

@viirya
Copy link
Member

viirya commented May 24, 2017

I think so.

@viirya
Copy link
Member

viirya commented May 24, 2017

Nit: usually we won't specially tag it is a BugFix in the title.

@MrBago MrBago changed the title [SPARK-20862][MLLIB][PYTHON] BugFix - avoid passing float to ndarray.reshape in LogisticRegressionModel [SPARK-20862][MLLIB][PYTHON] Avoid passing float to ndarray.reshape in LogisticRegressionModel May 24, 2017
@MrBago
Copy link
Contributor Author

MrBago commented May 24, 2017

@srowen floor divide has been in python since 2.2, https://www.python.org/download/releases/2.2/.

@MrBago
Copy link
Contributor Author

MrBago commented May 24, 2017

@viirya I was running python tests for pyspark-ml and pyspark-mllib and this was the only place where the python3/numpy interaction caused a test failure. There might be other places where floor int division might be preferable to float division, but if they exist they're not causing any of the tests to fail.

@viirya
Copy link
Member

viirya commented May 24, 2017

@MrBago Yeah, after a quick scan, seems other reshape usage in MLlib are ok.

asfgit pushed a commit that referenced this pull request May 24, 2017
…n LogisticRegressionModel

## What changes were proposed in this pull request?

Fixed TypeError with python3 and numpy 1.12.1. Numpy's `reshape` no longer takes floats as arguments as of 1.12. Also, python3 uses float division for `/`, we should be using `//` to ensure that `_dataWithBiasSize` doesn't get set to a float.

## How was this patch tested?

Existing tests run using python3 and numpy 1.12.

Author: Bago Amirbekian <bago@databricks.com>

Closes #18081 from MrBago/BF-py3floatbug.

(cherry picked from commit bc66a77)
Signed-off-by: Yanbo Liang <ybliang8@gmail.com>
@yanboliang
Copy link
Contributor

yanboliang commented May 24, 2017

LGTM, merged into master/branch-2.2/branch-2.1/branch-2.0. Thanks for all.

asfgit pushed a commit that referenced this pull request May 24, 2017
…n LogisticRegressionModel

## What changes were proposed in this pull request?

Fixed TypeError with python3 and numpy 1.12.1. Numpy's `reshape` no longer takes floats as arguments as of 1.12. Also, python3 uses float division for `/`, we should be using `//` to ensure that `_dataWithBiasSize` doesn't get set to a float.

## How was this patch tested?

Existing tests run using python3 and numpy 1.12.

Author: Bago Amirbekian <bago@databricks.com>

Closes #18081 from MrBago/BF-py3floatbug.

(cherry picked from commit bc66a77)
Signed-off-by: Yanbo Liang <ybliang8@gmail.com>
@asfgit asfgit closed this in bc66a77 May 24, 2017
asfgit pushed a commit that referenced this pull request May 24, 2017
…n LogisticRegressionModel

## What changes were proposed in this pull request?

Fixed TypeError with python3 and numpy 1.12.1. Numpy's `reshape` no longer takes floats as arguments as of 1.12. Also, python3 uses float division for `/`, we should be using `//` to ensure that `_dataWithBiasSize` doesn't get set to a float.

## How was this patch tested?

Existing tests run using python3 and numpy 1.12.

Author: Bago Amirbekian <bago@databricks.com>

Closes #18081 from MrBago/BF-py3floatbug.

(cherry picked from commit bc66a77)
Signed-off-by: Yanbo Liang <ybliang8@gmail.com>
ambauma pushed a commit to ambauma/spark that referenced this pull request Oct 20, 2017
…n LogisticRegressionModel

## What changes were proposed in this pull request?

Fixed TypeError with python3 and numpy 1.12.1. Numpy's `reshape` no longer takes floats as arguments as of 1.12. Also, python3 uses float division for `/`, we should be using `//` to ensure that `_dataWithBiasSize` doesn't get set to a float.

## How was this patch tested?

Existing tests run using python3 and numpy 1.12.

Author: Bago Amirbekian <bago@databricks.com>

Closes apache#18081 from MrBago/BF-py3floatbug.
@MrBago MrBago deleted the BF-py3floatbug branch December 16, 2017 00:30
jzhuge pushed a commit to jzhuge/spark that referenced this pull request Aug 20, 2018
…n LogisticRegressionModel

Fixed TypeError with python3 and numpy 1.12.1. Numpy's `reshape` no longer takes floats as arguments as of 1.12. Also, python3 uses float division for `/`, we should be using `//` to ensure that `_dataWithBiasSize` doesn't get set to a float.

Existing tests run using python3 and numpy 1.12.

Author: Bago Amirbekian <bago@databricks.com>

Closes apache#18081 from MrBago/BF-py3floatbug.

(cherry picked from commit bc66a77)
Signed-off-by: Yanbo Liang <ybliang8@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants