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

BUG: disallow 'w' mode in pd.read_hdf (#13623) #13858

Merged
merged 1 commit into from
Aug 1, 2016

Conversation

iamsimha
Copy link
Contributor

@@ -303,6 +303,8 @@ def read_hdf(path_or_buf, key=None, **kwargs):

"""

if 'mode' in kwargs and kwargs['mode'] == 'w':
Copy link
Contributor

Choose a reason for hiding this comment

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

use kwargs.get()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@jreback
Copy link
Contributor

jreback commented Jul 31, 2016

needs tests

@codecov-io
Copy link

codecov-io commented Jul 31, 2016

Current coverage is 85.25% (diff: 100%)

Merging #13858 into master will increase coverage by <.01%

@@             master     #13858   diff @@
==========================================
  Files           140        140          
  Lines         50455      50457     +2   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
+ Hits          43014      43017     +3   
+ Misses         7441       7440     -1   
  Partials          0          0          

Powered by Codecov. Last update 59f2557...b03d90b

@iamsimha iamsimha force-pushed the fixing_issue_13623 branch 2 times, most recently from a324cb7 to 785f386 Compare July 31, 2016 20:23
@iamsimha
Copy link
Contributor Author

The existing test cases check for r, r+, a and w modes. I have added a new test case to check read_hdf for default mode (i.e without mode argument given).

@@ -303,6 +303,9 @@ def read_hdf(path_or_buf, key=None, **kwargs):

"""

if kwargs.get('mode') == 'w':
Copy link
Member

Choose a reason for hiding this comment

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

Should raise other invalid mode here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed. Now instead of checking for invalid modes, I check only for valid modes and raise a ValueError if any invalid modes are passed.

@sinhrks sinhrks added Error Reporting Incorrect or improved errors from pandas IO HDF5 read_hdf, HDFStore labels Aug 1, 2016
@sinhrks sinhrks added this to the 0.19.0 milestone Aug 1, 2016
@iamsimha iamsimha force-pushed the fixing_issue_13623 branch from 785f386 to 8359d0b Compare August 1, 2016 06:21
@@ -303,6 +303,9 @@ def read_hdf(path_or_buf, key=None, **kwargs):

"""

if kwargs.get('mode', 'a') not in ['r', 'r+', 'a']:
raise ValueError('mode %s is not allowed while performing a read. '
'Allowed modes are r, r+ and a.' % kwargs.get('mode'))
Copy link
Contributor

Choose a reason for hiding this comment

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

use .format() formatting

@jreback
Copy link
Contributor

jreback commented Aug 1, 2016

@iamsimha minor changes. ping when green.

@iamsimha iamsimha force-pushed the fixing_issue_13623 branch from 8359d0b to b03d90b Compare August 1, 2016 12:47
@iamsimha
Copy link
Contributor Author

iamsimha commented Aug 1, 2016

@jreback I have made the changes.

@jreback jreback merged commit 51e6adb into pandas-dev:master Aug 1, 2016
@jreback
Copy link
Contributor

jreback commented Aug 1, 2016

thanks @iamsimha

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Error Reporting Incorrect or improved errors from pandas IO HDF5 read_hdf, HDFStore
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ERR: disallow read_hdf mode='w'
4 participants