You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/Users/enos/temp/venv/lib/python3.10/site-packages/tabulate/__init__.py:107: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison
(len(row) >= 1 and row[0] == SEPARATING_LINE)
-
1
-
The cause is that the line detection function,
def_is_separating_line(row):
row_type=type(row)
is_sl= (row_type==listorrow_type==str) and (
(len(row) >=1androw[0] ==SEPARATING_LINE)
or (len(row) >=2androw[1] ==SEPARATING_LINE)
)
returnis_sl
performs the == operation. This is generally correct, but with numpy (and also other array packages) an == does elementwise comparisons and not object-level. This should still yield the correct answer, just inefficiently and numpy in particular emits that warning.
The fix is simple. Replace the == with is:
(len(row) >=1androw[0] isSEPARATING_LINE)
or (len(row) >=2androw[1] isSEPARATING_LINE)
The is should also be a tiny bit faster, too.
The text was updated successfully, but these errors were encountered:
This code:
```
import numpy as np
from tabulate import tabulate
data = [[np.ones(1)]]
print(tabulate(data))
```
Throws a `FutureWarning` or a `ValueError` due to the comparison with `SEPARATING_LINE`.
Fixesastanin#287
Yields this warning from numpy:
The cause is that the line detection function,
performs the
==
operation. This is generally correct, but with numpy (and also other array packages) an==
does elementwise comparisons and not object-level. This should still yield the correct answer, just inefficiently and numpy in particular emits that warning.The fix is simple. Replace the
==
withis
:The
is
should also be a tiny bit faster, too.The text was updated successfully, but these errors were encountered: