Skip to content

Commit 73c6ee3

Browse files
committed
TEST: made polars optional for tests
narwhals tests depend on polars though
1 parent e903e02 commit 73c6ee3

File tree

1 file changed

+21
-15
lines changed

1 file changed

+21
-15
lines changed

larray_editor/tests/test_api_larray.py

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import qtpy
1313
import larray as la
1414
import pandas as pd
15-
import polars as pl
1615

1716
from larray_editor.api import edit
1817
# from larray_editor.api import view, edit, debug, compare
@@ -344,23 +343,30 @@ def make_test_df(size):
344343
# _big_no_idx.to_parquet('big.parquet')
345344
# _big_no_idx.to_feather('big.feather')
346345

347-
pl_df1 = pl.from_pandas(pd_df1)
348-
pl_df2 = pl.from_pandas(pd_df2)
349-
# test with a datetime column and another column
350-
# the Arrow table has the same problem (e.g. pl_df3.to_arrow())
351-
pl_df3 = pl_df1.select(pl.from_epoch(pl.col('M')).alias('datetime_col'), 'M').limit(5)
352-
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)
354-
pl_lf_parquet = pl.scan_parquet('big.parquet')
355-
pl_lf_feather = pl.scan_ipc('big.feather')
356-
357346
try:
358-
import narwhals as nw
347+
import polars as pl
348+
349+
pl_df1 = pl.from_pandas(pd_df1)
350+
pl_df2 = pl.from_pandas(pd_df2)
351+
# test with a datetime column and another column
352+
# the Arrow table has the same problem (e.g. pl_df3.to_arrow())
353+
pl_df3 = pl_df1.select(pl.from_epoch(pl.col('M')).alias('datetime_col'), 'M').limit(5)
354+
pl_df_big = pl.from_pandas(pd_df_big, include_index=True)
355+
pl_df_mixed = pl.from_pandas(pd_df_mixed, include_index=False)
356+
pl_lf_parquet = pl.scan_parquet('big.parquet')
357+
pl_lf_feather = pl.scan_ipc('big.feather')
358+
359+
try:
360+
import narwhals as nw
361+
362+
nw_df = nw.from_native(pl_df_mixed)
363+
nw_lf = nw.from_native(pl_lf_parquet)
364+
except ImportError:
365+
print("skipping narwhals tests (not installed)")
359366

360-
nw_df = nw.from_native(pl_df_mixed)
361-
nw_lf = nw.from_native(pl_lf_parquet)
362367
except ImportError:
363-
print("skipping narwhals tests (not installed)")
368+
print("skipping polars tests (not installed)")
369+
364370

365371
path_dir = Path('.')
366372
path_py = Path('test_adapter.py')

0 commit comments

Comments
 (0)