diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2021-08-16 15:16:03 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-16 15:16:03 -0600 |
commit | cde69925a74cafa5c7d3dc3c820f75835c514fb2 (patch) | |
tree | b231291406fd87abc2a0a36d12e09f2ebe57e214 /numpy/lib/npyio.py | |
parent | 9e06c2cc1e83b0ca9869bd1bb0ff5dceb993d12d (diff) | |
parent | ce1188384ad6b2b0e3f2e673e89ff2b84262e038 (diff) | |
download | numpy-cde69925a74cafa5c7d3dc3c820f75835c514fb2.tar.gz |
Merge pull request #19680 from BvB93/fromregex
ENH: Allow `np.fromregex` to accept `os.PathLike` implementations
Diffstat (limited to 'numpy/lib/npyio.py')
-rw-r--r-- | numpy/lib/npyio.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/numpy/lib/npyio.py b/numpy/lib/npyio.py index a593af65e..7a594f25b 100644 --- a/numpy/lib/npyio.py +++ b/numpy/lib/npyio.py @@ -1484,8 +1484,11 @@ def fromregex(file, regexp, dtype, encoding=None): Parameters ---------- - file : str or file + file : path or file Filename or file object to read. + + .. versionchanged:: 1.22.0 + Now accepts `os.PathLike` implementations. regexp : str or regexp Regular expression used to parse the file. Groups in the regular expression correspond to fields in the dtype. @@ -1535,6 +1538,7 @@ def fromregex(file, regexp, dtype, encoding=None): """ own_fh = False if not hasattr(file, "read"): + file = os.fspath(file) file = np.lib._datasource.open(file, 'rt', encoding=encoding) own_fh = True |