MCPcopy Create free account
hub / github.com/datapane/datapane / test_downcast_numbers

Function test_downcast_numbers

python-client/tests/common/test_df_processor.py:108–123  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

106
107
108def test_downcast_numbers():
109 # ints
110 data = pd.DataFrame(
111 [[1, 1, 1, 1, 1, 1, 1, 1], [100, 1000, int(1e6), int(1e12), -100, -1000, int(-1e6), int(-1e12)]],
112 columns=["num1_col", "num2_col", "num3_col", "num4_col", "num5_col", "num6_col", "num7_col", "num8_col"],
113 )
114 downcast_numbers(data)
115 assert [str(x) for x in data.dtypes] == ["uint8", "uint16", "uint32", "uint64", "int8", "int16", "int32", "int64"]
116
117 # floats - currently disabled
118 # data = pd.DataFrame(
119 # [[1.0, 1.0, 1.0, 1.0, 1.0], [1e3, 1e6, 1e12, 1e30, 1e100]],
120 # columns=["num1_col", "num2_col", "num3_col", "num4_col", "num5_col"],
121 # )
122 # downcast_numbers(data)
123 # assert [str(x) for x in data.dtypes] == ["float32", "float32", "float32", "float32", "float64"]
124
125
126def test_timedelta_to_str():

Callers

nothing calls this directly

Calls 1

downcast_numbersFunction · 0.90

Tested by

no test coverage detected