Skip to content

Commit ee34256

Browse files
committed
TESTS: cleaner way to define test dataframes and added test for large mixed type Polars DF
1 parent dd22185 commit ee34256

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

larray_editor/tests/test_api_larray.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -323,13 +323,15 @@ def test_run_editor_on_exception(local_arr):
323323
# run_editor_on_exception(usercode_traceback=False, usercode_frame=False)
324324

325325
# test_run_editor_on_exception(arr2)
326-
_df_size = 100_000
327-
pd_df_mixed = pd.DataFrame({
328-
'name': la.sequence(_df_size).apply(lambda i: f'name{i}').to_series(),
329-
'age': la.random.randint(0, 105, axes=_df_size).to_series(),
330-
'male': (la.random.randint(0, 2, axes=_df_size) == 1).to_series(),
331-
'height': la.random.normal(1.75, 0.07, axes=_df_size).to_series()
332-
})
326+
def make_test_df(size):
327+
return pd.DataFrame({
328+
'name': la.sequence(size).apply(lambda i: f'name{i}').to_series(),
329+
'age': la.random.randint(0, 105, axes=size).to_series(),
330+
'male': (la.random.randint(0, 2, axes=size) == 1).to_series(),
331+
'height': la.random.normal(1.75, 0.07, axes=size).to_series()
332+
})
333+
334+
pd_df_mixed = make_test_df(100_000)
333335
pd_df1 = la_int_2d.df
334336
pd_df2 = la_float_4d_many_digits.df
335337
pd_df3 = pd_df2.T
@@ -346,8 +348,9 @@ def test_run_editor_on_exception(local_arr):
346348
pl_df2 = pl.from_pandas(pd_df2)
347349
# test with a datetime column and another column
348350
# the Arrow table has the same problem (e.g. pl_df3.to_arrow())
349-
pl_df3 = pl_df1.select(pl.from_epoch(pl.col('M')).alias('Datetime Column'), 'M').limit(5)
351+
pl_df3 = pl_df1.select(pl.from_epoch(pl.col('M')).alias('datetime_col'), 'M').limit(5)
350352
pl_df_big = pl.from_pandas(pd_df_big, include_index=True)
353+
pl_df_mixed = pl.from_pandas(pd_df_mixed, include_index=False)
351354
pl_lf1 = pl.scan_parquet('big.parquet')
352355
pl_lf2 = pl.scan_ipc('big.feather')
353356

0 commit comments

Comments
 (0)