From b88b2c0c19851810d4ee07f03a7734b6e19dbdaa Mon Sep 17 00:00:00 2001 From: Ross Barnowski Date: Wed, 18 Nov 2020 22:56:16 -0800 Subject: MAINT: Minor touchups in npyio (#17796) * Simplify logic for encoding kwarg in _decode_line. * Remove unnecessary else branch from split_line. * MAINT: rm else branch from loadtxt. * MAINT: re-nest encoding parsing. Co-Authored-By: mattip * condense return statement. Co-authored-by: mattip --- numpy/lib/npyio.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'numpy/lib/npyio.py') diff --git a/numpy/lib/npyio.py b/numpy/lib/npyio.py index 805e59bc1..3b2de3e61 100644 --- a/numpy/lib/npyio.py +++ b/numpy/lib/npyio.py @@ -965,10 +965,7 @@ def loadtxt(fname, dtype=float, comments='#', delimiter=None, if comments is not None: line = regex_comments.split(line, maxsplit=1)[0] line = line.strip('\r\n') - if line: - return line.split(delimiter) - else: - return [] + return line.split(delimiter) if line else [] def read_data(chunk_size): """Parse each line, including the first. @@ -1030,11 +1027,10 @@ def loadtxt(fname, dtype=float, comments='#', delimiter=None, user_converters = converters + byte_converters = False if encoding == 'bytes': encoding = None byte_converters = True - else: - byte_converters = False if usecols is not None: # Allow usecols to be a single int or a sequence of ints -- cgit v1.2.1