Skip to content

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

Closed
MrBago wants to merge 1 commit into
apache:masterfrom
MrBago:BF-py3floatbug
Closed

[SPARK-20862][MLLIB][PYTHON] Avoid passing float to ndarray.reshape in LogisticRegressionModel#18081
MrBago wants to merge 1 commit into
apache:masterfrom
MrBago:BF-py3floatbug

Conversation

@MrBago

@MrBago MrBago commented May 24, 2017

Copy link
Copy Markdown
Contributor

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

SparkQA commented May 24, 2017

Copy link
Copy Markdown

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

viirya commented May 24, 2017

Copy link
Copy Markdown
Member

LGTM

Do we have similar cases in MLlib?

@viirya

viirya commented May 24, 2017

Copy link
Copy Markdown
Member

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

@srowen

srowen commented May 24, 2017

Copy link
Copy Markdown
Member

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

@viirya

viirya commented May 24, 2017

Copy link
Copy Markdown
Member

I think so.

@viirya

viirya commented May 24, 2017

Copy link
Copy Markdown
Member

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

MrBago commented May 24, 2017

Copy link
Copy Markdown
Contributor Author

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

@MrBago

MrBago commented May 24, 2017

Copy link
Copy Markdown
Contributor Author

@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

viirya commented May 24, 2017

Copy link
Copy Markdown
Member

@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

yanboliang commented May 24, 2017

Copy link
Copy Markdown
Contributor

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

Development

Successfully merging this pull request may close these issues.

5 participants