Skip to content

Commit c2875b1

Browse files
FIX-quantopian#26: Ignore UserWarnings from spreadsheet package (quantopian#30)
1 parent 59554c4 commit c2875b1

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

modin_spreadsheet/grid.py

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import pandas
44
import numpy as np
55
import json
6+
import warnings
67

78
from types import FunctionType
89
from IPython.display import display
@@ -969,9 +970,11 @@ def should_be_stringified(col_series):
969970
else:
970971
self._row_styles = {}
971972

972-
df_json = df.to_json(
973-
None, orient="table", date_format="iso", double_precision=self.precision
974-
)
973+
with warnings.catch_warnings():
974+
warnings.simplefilter("ignore", category=UserWarning)
975+
df_json = df.to_json(
976+
None, orient="table", date_format="iso", double_precision=self.precision
977+
)
975978

976979
if update_columns:
977980
self._interval_columns = []
@@ -1046,9 +1049,14 @@ def should_be_stringified(col_series):
10461049
# and then call 'to_json' again to get a new version of the table
10471050
# json that has interval columns replaced with text columns
10481051
if len(self._interval_columns) > 0 or len(self._period_columns) > 0:
1049-
df_json = df.to_json(
1050-
None, orient="table", date_format="iso", double_precision=self.precision
1051-
)
1052+
with warnings.catch_warnings():
1053+
warnings.simplefilter("ignore", category=UserWarning)
1054+
df_json = df.to_json(
1055+
None,
1056+
orient="table",
1057+
date_format="iso",
1058+
double_precision=self.precision,
1059+
)
10521060

10531061
self._df_json = df_json
10541062

@@ -1490,7 +1498,10 @@ def _handle_change_filter(self, content):
14901498

14911499
def _handle_view_msg(self, widget, content, buffers=None):
14921500
try:
1493-
self._handle_view_msg_helper(content)
1501+
# Ignore UserWarnings in spreadsheet widget
1502+
with warnings.catch_warnings():
1503+
warnings.simplefilter("ignore", category=UserWarning)
1504+
self._handle_view_msg_helper(content)
14941505
except Exception as e:
14951506
self.log.error(e)
14961507
self.log.exception("Unhandled exception while handling msg")

0 commit comments

Comments
 (0)