8000 [MRG+1] FIX support memmap scalars as CV scores by jnothman · Pull Request #6789 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

[MRG+1] FIX support memmap scalars as CV scores #6789

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

Merged
merged 2 commits into from
Jun 2, 2016

Conversation

jnothman
Copy link
Member

Reference Issue

Fixes #6783

What does this implement/fix? Explain your changes.

The test - which introduces a cross-validation score of type np.memmap - fails without the patch.

scoring=lambda est, X, y: scores)
except Exception:
raise
else:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Souldn't this be a 'finally', rather than an else?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, that's what I mean

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just not thinking straight today.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

@GaelVaroquaux GaelVaroquaux changed the title [MRG] FIX support memmap scalars as CV scores [MRG+1] FIX support memmap scalars as CV scores May 17, 2016
@GaelVaroquaux
Copy link
Member

LGTM. +1 for merge

tf.write('Hello world!!!!!')
tf.close()
scores = np.memmap(tf.name, dtype=float)
score = scores.sum()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I am following correctly your test relies on a sum of memmap to be a memmap 0d array. This is no longer the case in numpy master, see numpy/numpy#7406 for more details.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use

score = np.memmap(tf.name, shape=(), mode=w+, dtype=float)`

which will create a memmap 0d array. This will get rid of the Python 3.5 failure as well (you forgot the b prefix when writing to the file).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, thanks. :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw, I was hoping that was not permanent numpy behaviour, but it is because of that behaviour that this is an issue for us.

@MechCoder MechCoder merged commit 814223c into scikit-learn:master Jun 2, 2016
@MechCoder
Copy link
Member

Thanks!

olologin pushed a commit to olologin/scikit-learn that referenced this pull request Aug 24, 2016
* FIX support memmap scalars as CV scores

* FIX test for Python 3.5 and NumPy 1.12
TomDLT pushed a commit to TomDLT/scikit-learn that referenced this pull request Oct 3, 2016
* FIX support memmap scalars as CV scores

* FIX test for Python 3.5 and NumPy 1.12
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.

"scoring must return a number" error with custom scorer
4 participants
0