Skip to content

Commit

Permalink
DEP,MAINT: Remove keywords "skiprows" and "missing" from genfromtxt.
Browse files Browse the repository at this point in the history
Deprecated in NumPy 1.5. If this causes problems in the 1.10 release
cycle the change can be reverted.
  • Loading branch information
charris committed Jun 21, 2015
1 parent e3b2bc0 commit ec4e91b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 32 deletions.
1 change: 1 addition & 0 deletions doc/release/1.10.0-notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Dropped Support:
* try_run and get_output have been removed from
numpy/distutils/command/config.py
* The a._format attribute is no longer supported for array printing.
* Keywords ``skiprows`` and ``missing`` removed from genfromtxt.

Future Changes:

Expand Down
41 changes: 9 additions & 32 deletions numpy/lib/npyio.py
Original file line number Diff line number Diff line change
Expand Up @@ -1301,13 +1301,12 @@ def fromregex(file, regexp, dtype):


def genfromtxt(fname, dtype=float, comments='#', delimiter=None,
skiprows=0, skip_header=0, skip_footer=0, converters=None,
missing='', missing_values=None, filling_values=None,
usecols=None, names=None,
excludelist=None, deletechars=None, replace_space='_',
autostrip=False, case_sensitive=True, defaultfmt="f%i",
unpack=None, usemask=False, loose=True, invalid_raise=True,
max_rows=None):
skip_header=0, skip_footer=0, converters=None,
missing_values=None, filling_values=None, usecols=None,
names=None, excludelist=None, deletechars=None,
replace_space='_', autostrip=False, case_sensitive=True,
defaultfmt="f%i", unpack=None, usemask=False, loose=True,
invalid_raise=True, max_rows=None):
"""
Load data from a text file, with missing values handled as specified.
Expand All @@ -1332,8 +1331,7 @@ def genfromtxt(fname, dtype=float, comments='#', delimiter=None,
whitespaces act as delimiter. An integer or sequence of integers
can also be provided as width(s) of each field.
skiprows : int, optional
`skiprows` was deprecated in numpy 1.5, and will be removed in
numpy 2.0. Please use `skip_header` instead.
`skiprows` was removed in numpy 1.10. Please use `skip_header` instead.
skip_header : int, optional
The number of lines to skip at the beginning of the file.
skip_footer : int, optional
Expand All @@ -1343,8 +1341,8 @@ def genfromtxt(fname, dtype=float, comments='#', delimiter=None,
The converters can also be used to provide a default value
for missing data: ``converters = {3: lambda s: float(s or 0)}``.
missing : variable, optional
`missing` was deprecated in numpy 1.5, and will be removed in
numpy 2.0. Please use `missing_values` instead.
`missing` was removed in numpy 1.10. Please use `missing_values`
instead.
missing_values : variable, optional
The set of strings corresponding to missing data.
filling_values : variable, optional
Expand Down Expand Up @@ -1475,8 +1473,6 @@ def genfromtxt(fname, dtype=float, comments='#', delimiter=None,
comments = asbytes(comments)
if isinstance(delimiter, unicode):
delimiter = asbytes(delimiter)
if isinstance(missing, unicode):
missing = asbytes(missing)
if isinstance(missing_values, (unicode, list, tuple)):
missing_values = asbytes_nested(missing_values)

Expand Down Expand Up @@ -1513,14 +1509,6 @@ def genfromtxt(fname, dtype=float, comments='#', delimiter=None,
case_sensitive=case_sensitive,
replace_space=replace_space)

# Get the first valid lines after the first skiprows ones ..
if skiprows:
# 2011-03-06 Cannot remove is keyword.
warnings.warn(
"The use of `skiprows` is deprecated, it will be removed in "
"numpy 2.0.\nPlease use `skip_header` instead.",
DeprecationWarning)
skip_header = skiprows
# Skip the first `skip_header` rows
for i in range(skip_header):
next(fhd)
Expand Down Expand Up @@ -1649,17 +1637,6 @@ def genfromtxt(fname, dtype=float, comments='#', delimiter=None,
for entry in missing_values:
entry.extend([str(user_missing_values)])

# Process the deprecated `missing`
if missing != asbytes(''):
# 2011-03-06 Cannot remove, is keyword.
warnings.warn(
"The use of `missing` is deprecated, it will be removed in "
"Numpy 2.0.\nPlease use `missing_values` instead.",
DeprecationWarning)
values = [str(_) for _ in missing.split(asbytes(","))]
for entry in missing_values:
entry.extend(values)

# Process the filling_values ...............................
# Rename the input for convenience
user_filling_values = filling_values
Expand Down

0 comments on commit ec4e91b

Please sign in to comment.