Skip to content

Ticket #1793 #123

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

Closed
wants to merge 6 commits into from
Closed

Ticket #1793 #123

wants to merge 6 commits into from

Conversation

pletnes
Copy link
Contributor

@pletnes pletnes commented Jul 28, 2011

This is a quick fix of ticket #1793, exactly as requested. The corresponding test has been rewritten and is now passed.

Another commit simply moves an import statement. I think I made a pull request for that at some earlier stage, apologies for the mess if so...

@rgommers
Copy link
Member

Giving a warning (including file name) that the file is empty may be useful; otherwise this will just lead to errors later on with a less comprehensible error message for users who do not expect their file to be empty.

@pletnes
Copy link
Contributor Author

pletnes commented Jul 28, 2011

Great idea, what's the canonical way of doing this?

@rgommers
Copy link
Member

Use a UserWarning. Something like:

import warnings
warnings.warn("File %s is empty" % filename, UserWarning)

See http://docs.python.org/library/warnings.html

@pletnes
Copy link
Contributor Author

pletnes commented Jul 28, 2011

I think I've got it, looks OK to me at least. UserWarning is the default, it seems.

@rgommers
Copy link
Member

That doesn't include the filename yet - that can be very helpful if you're batch processing files.

@pletnes
Copy link
Contributor Author

pletnes commented Jul 28, 2011

I hope that should do it!

@rgommers
Copy link
Member

Not quite, the .format method was only introduced in Python 2.6. You need the old-fashioned %s instead, we need Python 2.4 compatibility.


test = np.genfromtxt(data)
ctrl = np.array([])
assert_equal(test, ctrl)
Copy link
Contributor

Choose a reason for hiding this comment

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

Could probably shorten this to simply assert_equal(test, [])

…ead. also, removed an unneeded line of code in corresponding unit test.
@pletnes
Copy link
Contributor Author

pletnes commented Jul 29, 2011

I keep living in the future, I forgot about python2.4! stefanv - I did as you suggested.

@rgommers
Copy link
Member

Merged, thanks.

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.

3 participants