Skip to content

[MRG + 2] check_array Error message#9126

Merged
lesteve merged 5 commits intoscikit-learn:masterfrom
massich:is/9047
Jun 26, 2017
Merged

[MRG + 2] check_array Error message#9126
lesteve merged 5 commits intoscikit-learn:masterfrom
massich:is/9047

Conversation

@massich
Copy link
Copy Markdown
Contributor

@massich massich commented Jun 14, 2017

Reference Issue

Fixes #9047, continues #9068 since some comments from @lesteve didn't make it before the merge.

What does this implement/fix? Explain your changes.

Any other comments?

@jnothman can you set it as a milestone (as in #9068)

@jnothman jnothman added this to the 0.19 milestone Jun 15, 2017
@jnothman
Copy link
Copy Markdown
Member

If it's fine by you, @lesteve, please merge.

X_array = check_array([0, 1, 2], ensure_2d=False)
assert_equal(X_array.ndim, 1)
# ensure_2d (True case)
assert_raises(ValueError, check_array, [0, 1, 2], ensure_2d=True)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Check the error message please, e.g. with assert_raises_regex

X_csr = sp.csr_matrix(X)
assert_raises(TypeError, check_array, X_csr)
# ensure_2d
# ensure_2d (False case)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

not really crucial but ensure_2d=False and ensure_2d=True reads better to me.

@lesteve
Copy link
Copy Markdown
Member

lesteve commented Jun 15, 2017

Small additional comment: markdown formatting does not work in PR/issue titles.

@massich massich changed the title [MRG] check_array Error message [MRG] check_array Error message Jun 16, 2017
X_array = check_array([0, 1, 2], ensure_2d=False)
assert_equal(X_array.ndim, 1)
# ensure_2d=True
assert_raises(ValueError, check_array, [0, 1, 2], ensure_2d=True)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Check the error message please, e.g. with assert_raises_regex

My old comment is still valid.

@amueller
Copy link
Copy Markdown
Member

LGTM, though I prefer newlines before the (usually lengthy) array starts.

@amueller amueller changed the title [MRG] check_array Error message [MRG + 1] check_array Error message Jun 19, 2017
@amueller amueller changed the title [MRG + 1] check_array Error message [MRG + 2] check_array Error message Jun 19, 2017
@lesteve
Copy link
Copy Markdown
Member

lesteve commented Jun 26, 2017

I am going to merge this one, thanks @massich!

@lesteve lesteve merged commit 06d0e0d into scikit-learn:master Jun 26, 2017
@massich massich deleted the is/9047 branch June 26, 2017 09:38
dmohns pushed a commit to dmohns/scikit-learn that referenced this pull request Aug 7, 2017
dmohns pushed a commit to dmohns/scikit-learn that referenced this pull request Aug 7, 2017
NelleV pushed a commit to NelleV/scikit-learn that referenced this pull request Aug 11, 2017
paulha pushed a commit to paulha/scikit-learn that referenced this pull request Aug 19, 2017
AishwaryaRK pushed a commit to AishwaryaRK/scikit-learn that referenced this pull request Aug 29, 2017
maskani-moh pushed a commit to maskani-moh/scikit-learn that referenced this pull request Nov 15, 2017
jwjohnson314 pushed a commit to jwjohnson314/scikit-learn that referenced this pull request Dec 18, 2017
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.

Make error messages in check_array and similar not mention variable name

4 participants