Skip to content

Commit

Permalink
Fix OFF for new numpy errors
Browse files Browse the repository at this point in the history
Summary: Error messages have changed around numpy version 2, making existing code fail.

Reviewed By: MichaelRamamonjisoa

Differential Revision: D65280674

fbshipit-source-id: b3ae613ea8f0f4ae20fb6e5e816314b8c10e6c65
  • Loading branch information
bottler authored and facebook-github-bot committed Nov 6, 2024
1 parent 9563ef7 commit dd2a11b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pytorch3d/io/off_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def _read_faces_lump(
)
data = np.loadtxt(file, dtype=np.float32, ndmin=2, max_rows=n_faces)
except ValueError as e:
if n_faces > 1 and "Wrong number of columns" in e.args[0]:
if n_faces > 1 and "number of columns" in e.args[0]:
file.seek(old_offset)
return None
raise ValueError("Not enough face data.") from None
Expand Down
8 changes: 4 additions & 4 deletions tests/test_io_off.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,15 +286,15 @@ def load(lines):

lines2 = lines.copy()
lines2[0] = "6 2 0"
with self.assertRaisesRegex(ValueError, "Wrong number of columns at line 5"):
with self.assertRaisesRegex(ValueError, "number of columns"):
load(lines2)

lines2[0] = "5 1 0"
with self.assertRaisesRegex(ValueError, "Wrong number of columns at line 5"):
with self.assertRaisesRegex(ValueError, "number of columns"):
load(lines2)

lines2[0] = "16 2 0"
with self.assertRaisesRegex(ValueError, "Wrong number of columns at line 5"):
with self.assertRaisesRegex(ValueError, "number of columns"):
load(lines2)

lines2[0] = "3 3 0"
Expand All @@ -312,7 +312,7 @@ def load(lines):

lines2 = lines.copy()
lines2[2] = "7.3 4.2 8.3 932"
with self.assertRaisesRegex(ValueError, "Wrong number of columns at line 2"):
with self.assertRaisesRegex(ValueError, "number of columns"):
load(lines2)

lines2[1] = "7.3 4.2 8.3 932"
Expand Down

0 comments on commit dd2a11b

Please sign in to comment.