Skip to content

Commit

Permalink
Fix: update np.loadtxt with old default encoding argument (#33) (close
Browse files Browse the repository at this point in the history
…#29)

* fix: update np.loadtxt with old default encoding argument

* update Changelog

---------

Co-authored-by: Eoghan O'Connell <[email protected]>
  • Loading branch information
PinkShnack and Eoghan O'Connell authored Jan 15, 2025
1 parent caae826 commit 6f4a048
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
0.18.4
- fix: update np.loadtxt with old default encoding argument (#29)
0.18.3
- ci: fix readthedocs.yml
0.18.2
Expand Down
5 changes: 3 additions & 2 deletions afmformats/formats/fmt_ntmdt_txt.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ def detect_txt(path):
"""File should be plain text"""
valid = False
try:
rawdata = np.loadtxt(path, converters=converters, max_rows=10)
rawdata = np.loadtxt(path, converters=converters, max_rows=10,
encoding="bytes")
except (ValueError, IndexError):
pass
else:
Expand Down Expand Up @@ -85,7 +86,7 @@ def load_txt(path, callback=None, meta_override=None):
mis_metadata,
f"Please specify {' and '.join(mis_metadata)}!")

rawdata = np.loadtxt(path, converters=converters)
rawdata = np.loadtxt(path, converters=converters, encoding="bytes")

if rawdata.shape[1] != 3:
raise errors.InvalidFileFormatError(
Expand Down
3 changes: 2 additions & 1 deletion afmformats/formats/fmt_workshop/ws_single.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ def load_csv(path, callback=None, meta_override=None, mode="single"):
"Unknown file format: {}".format(path))

# load data
rawdata = np.loadtxt(path, skiprows=header_index+1, delimiter=",")
rawdata = np.loadtxt(path, skiprows=header_index+1, delimiter=",",
encoding="bytes")
segsize = rawdata.shape[0]
data = {"height (measured)": np.zeros(2*segsize, dtype=float)*np.nan,
"force": np.zeros(2*segsize, dtype=float)*np.nan,
Expand Down

0 comments on commit 6f4a048

Please sign in to comment.