Thanks to visit codestin.com
Credit goes to github.com

Skip to content

MAINT (API?): organize npyio.recfromcsv defaults #3830

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 4 commits into from
Mar 29, 2014

Conversation

jarondl
Copy link
Contributor

@jarondl jarondl commented Sep 29, 2013

Organizes the default kwargs in recfromcsv. Changes two undocumented
kwargs behaviors:

@hpaulj
Copy link

hpaulj commented Nov 24, 2013

You might want to add a test to test_io.py, such as:

    #
    data = TextIO('A,B\n0,1\n2,3')
    dtype = [('a', np.int), ('b', np.float)]
    test = np.recfromcsv(data, missing_values='N/A', dtype=dtype)
    control = np.array([(0, 1), (2, 3)],
                       dtype=dtype)
    self.assertTrue(isinstance(test, np.recarray))
    assert_equal(test, control)

The existing tests all use dtype=None, which works even if it mistakenly tries to get that value from update.

@@ -1867,16 +1867,18 @@ def recfromcsv(fname, **kwargs):
numpy.genfromtxt : generic function to load ASCII data.

Copy link

Choose a reason for hiding this comment

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

Add:
Notes
-----
By default, dtype is None, which means that the data-type of the output
array will be determined from the data.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi.

I think we should consider the state of the io documentation as a whole. The four functions ndfromtxt,
mafromtxt, recfromtxt and recfromcsv exist online only as remarks in the user guide : http://docs.scipy.org/doc/numpy/user/basics.io.genfromtxt.html . They are not mentioned in http://docs.scipy.org/doc/numpy/reference/routines.io.html and therefore have no sphinx docs in the reference. Of-course they do appear in the python help() system.

Not only dtype is given a default, but also case_sensitive, names and delimiter,
so they should be addressed together. Any ideas on how to do that?

Thanks,
Yaron

Copy link
Member

Choose a reason for hiding this comment

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

Sounds like it would be a good idea to add them. The appropriate spot looks to be doc/source/reference/routines.io.rst. You can open a new PR for that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I'll open another PR for that.

@charris
Copy link
Member

charris commented Feb 17, 2014

Travis error looks bogus, restarted tests.

@charris
Copy link
Member

charris commented Feb 17, 2014

LGTM. Can you add a note to doc/release/1.9.0-notes.rst? You should probably mention the change in behavior of the update keyword.

case_sensitive=case_sensitive)
usemask = kwargs.get("usemask", False)
# Set default kwargs as relevant to csv import.
# These seem to be undocumented. (case_sensitive is mentioned in basics.io)
Copy link
Member

Choose a reason for hiding this comment

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

These are all keywords in genfromtxt.

Copy link
Member

Choose a reason for hiding this comment

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

Should mention that these are keywords used by genfromtxt.

@charris
Copy link
Member

charris commented Feb 27, 2014

Needs a rebase.

Yaron de Leeuw added 3 commits February 28, 2014 09:18
Organizes the default kwargs in recfromcsv. Changes two undocumented
kwargs behaviors:

*  previously, if a user set `names=None`, it was ignored and replaced
   with `names=True`
*  the `dtype` kwarg was ignored. If `update` was given, it was used as
   `dtype`, and if not, None was used. We can retain the `update` behavior
 by using `kwargs.setdefault("dtype",kwargs.get('update', None))`.
  This Closes numpy#311 .
Added a note to recfromcsv about the `dtype` keyword,
as suggested by @hpaulj. Also added a note to the release notes,
about the change in the `update` keyword, as suggested by @charris.
@jarondl
Copy link
Contributor Author

jarondl commented Feb 28, 2014

It needed a rebase because of the release notes. I've rebased.

@jarondl
Copy link
Contributor Author

jarondl commented Mar 11, 2014

Hi @charris, any news?

# Set default kwargs as relevant to csv import.
# These seem to be undocumented. (case_sensitive is mentioned in basics.io)
kwargs.setdefault("case_sensitive", "lower")
# previously, names were set to True if they were not set or if they
Copy link
Member

Choose a reason for hiding this comment

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

These two comment lines can be removed.

@charris
Copy link
Member

charris commented Mar 11, 2014

LGTM modulo a few nitpicks.

Removed two irrelevant comments about code history.

P.S. my first try with Github's online editor.
@jarondl
Copy link
Contributor Author

jarondl commented Mar 12, 2014

The travis error is about fetching from sphinx or something. Anyway, the only changes in the commit are in comments.

@jarondl
Copy link
Contributor Author

jarondl commented Mar 25, 2014

Hi @charris or any other dev, could you please try to rebuild the travis run?

charris added a commit that referenced this pull request Mar 29, 2014
MAINT (API?): organize npyio.recfromcsv defaults
@charris charris merged commit bce5bfb into numpy:master Mar 29, 2014
@charris
Copy link
Member

charris commented Mar 29, 2014

Thanks @jarondl.

@jarondl jarondl deleted the recfromcsv branch March 30, 2014 05:46
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.

npyio.py --> recfromcsv seems to have a bug that ignores any dtypes provided
3 participants