diff --git a/lumen/tests/sources/test_base.py b/lumen/tests/sources/test_base.py index aa532082..ccc10fe7 100644 --- a/lumen/tests/sources/test_base.py +++ b/lumen/tests/sources/test_base.py @@ -17,6 +17,9 @@ except ImportError: fastparquet = None +from ..utils import assert_frame_equal_no_dtype_check + + @pytest.fixture def source(make_filesource): root = os.path.dirname(__file__) @@ -95,7 +98,7 @@ def test_file_source_filter(source, column_value_type, dask, expected_df): column, value, _ = column_value_type kwargs = {column: value, '__dask': dask} filtered = source.get('test', **kwargs) - pd.testing.assert_frame_equal(filtered, expected_df) + assert_frame_equal_no_dtype_check(filtered, expected_df) @pytest.mark.parametrize( @@ -123,7 +126,7 @@ def test_file_source_get_query_cache(source, column_value_type, dask, expected_d cached_df = source._cache[cache_key] if dask: cached_df = cached_df.compute() - pd.testing.assert_frame_equal(cached_df, expected_df) + assert_frame_equal_no_dtype_check(cached_df, expected_df) cache_key = source._get_key('test', **kwargs) assert cache_key in source._cache @@ -160,7 +163,7 @@ def test_file_source_get_query_cache_to_file(make_filesource, cachedir): # Patch index names due to https://github.com/dask/fastparquet/issues/732 df.index.names = [None] - pd.testing.assert_frame_equal( + assert_frame_equal_no_dtype_check( df, makeMixedDataFrame().iloc[1:3] ) @@ -177,7 +180,7 @@ def test_file_source_variable(make_variable_filesource, mixed_df): state.variables.tables = {'test': 'test2.csv'} df = source.get('test') expected = mixed_df.iloc[::-1].reset_index(drop=True) - pd.testing.assert_frame_equal(df, expected) + assert_frame_equal_no_dtype_check(df, expected) def test_extension_of_comlicated_url(source): diff --git a/lumen/tests/sources/test_derived.py b/lumen/tests/sources/test_derived.py index 1cfdbfbf..60228da1 100644 --- a/lumen/tests/sources/test_derived.py +++ b/lumen/tests/sources/test_derived.py @@ -1,10 +1,11 @@ import os -import pandas as pd import pytest from lumen.sources.base import DerivedSource, Source +from ..utils import assert_frame_equal_no_dtype_check + @pytest.fixture def original(make_filesource): @@ -60,7 +61,7 @@ def test_derived_mirror_source(original, mirror_mode_spec): assert derived.get_tables() == original.get_tables() assert derived.get_schema() == original.get_schema() for table in original.get_tables(): - pd.testing.assert_frame_equal(derived.get(table), original.get(table)) + assert_frame_equal_no_dtype_check(derived.get(table), original.get(table)) @pytest.mark.parametrize("additional_spec", [ @@ -75,13 +76,13 @@ def test_derived_mirror_source_apply( derived = Source.from_spec(mirror_mode_spec) assert derived.get_tables() == original.get_tables() assert derived.get_schema('test') == expected_schema - pd.testing.assert_frame_equal(derived.get('test'), expected_table) + assert_frame_equal_no_dtype_check(derived.get('test'), expected_table) def test_derived_tables_source(original, tables_mode_spec, mixed_df): derived = Source.from_spec(tables_mode_spec) assert derived.get_tables() == ['derived'] - pd.testing.assert_frame_equal(derived.get('derived'), mixed_df) + assert_frame_equal_no_dtype_check(derived.get('derived'), mixed_df) assert original.get_schema('test') == derived.get_schema('derived') @@ -96,7 +97,7 @@ def test_derived_tables_source_apply( tables_mode_spec['tables']['derived'][spec_key] = spec_value derived = Source.from_spec(tables_mode_spec) assert derived.get_tables() == ['derived'] - pd.testing.assert_frame_equal(derived.get('derived'), expected_table) + assert_frame_equal_no_dtype_check(derived.get('derived'), expected_table) assert derived.get_schema('derived') == expected_schema @@ -106,7 +107,7 @@ def test_derived_get_query_cache(original, mirror_mode_spec): cache_key = derived._get_key('test') assert cache_key in derived._cache cached_df = derived._cache[cache_key] - pd.testing.assert_frame_equal(cached_df, df) + assert_frame_equal_no_dtype_check(cached_df, df) def test_derived_clear_cache(original, mirror_mode_spec): diff --git a/lumen/tests/sources/test_duckdb.py b/lumen/tests/sources/test_duckdb.py index 1514f2ed..ba11e112 100644 --- a/lumen/tests/sources/test_duckdb.py +++ b/lumen/tests/sources/test_duckdb.py @@ -1,7 +1,6 @@ import datetime as dt import os -import pandas as pd import pytest from lumen.transforms.sql import SQLGroupBy @@ -12,6 +11,7 @@ except ImportError: pytestmark = pytest.mark.skip(reason="Duckdb is not installed") +from ..utils import assert_frame_equal_no_dtype_check @pytest.fixture @@ -49,7 +49,7 @@ def test_duckdb_get_tables(duckdb_source, source_tables): tables = duckdb_source.get_tables() assert not len(set(tables) - set(source_tables.keys())) for table in tables: - pd.testing.assert_frame_equal( + assert_frame_equal_no_dtype_check( duckdb_source.get(table), source_tables[table], ) @@ -119,7 +119,7 @@ def test_duckdb_filter(duckdb_source, table_column_value_type, dask, expected_fi table, column, value, _ = table_column_value_type kwargs = {column: value} filtered = duckdb_source.get(table, __dask=dask, **kwargs) - pd.testing.assert_frame_equal(filtered, expected_filtered_df.reset_index(drop=True)) + assert_frame_equal_no_dtype_check(filtered, expected_filtered_df.reset_index(drop=True)) @pytest.mark.flaky(reruns=3) @@ -128,7 +128,7 @@ def test_duckdb_transforms(duckdb_source, source_tables): transforms = [SQLGroupBy(by=['B'], aggregates={'SUM': 'A'})] transformed = duckdb_source.get('test_sql', sql_transforms=transforms) expected = df_test_sql.groupby('B')['A'].sum().reset_index() - pd.testing.assert_frame_equal(transformed, expected) + assert_frame_equal_no_dtype_check(transformed, expected) @pytest.mark.flaky(reruns=3) @@ -141,7 +141,7 @@ def test_duckdb_transforms_cache(duckdb_source, source_tables): assert cache_key in duckdb_source._cache expected = df_test_sql.groupby('B')['A'].sum().reset_index() - pd.testing.assert_frame_equal(duckdb_source._cache[cache_key], expected) + assert_frame_equal_no_dtype_check(duckdb_source._cache[cache_key], expected) cache_key = duckdb_source._get_key('test_sql', sql_transforms=transforms) assert cache_key in duckdb_source._cache @@ -166,4 +166,4 @@ def test_duckdb_source_ephemeral_roundtrips(duckdb_memory_source, mixed_df): def test_duckdb_source_mirrors_source(duckdb_source): mirrored = DuckDBSource(uri=':memory:', mirrors={'mixed': (duckdb_source, 'test_sql')}) - pd.testing.assert_frame_equal(duckdb_source.get('test_sql'), mirrored.get('mixed')) + assert_frame_equal_no_dtype_check(duckdb_source.get('test_sql'), mirrored.get('mixed')) diff --git a/lumen/tests/sources/test_intake.py b/lumen/tests/sources/test_intake.py index b59d9e5e..7c4702ed 100644 --- a/lumen/tests/sources/test_intake.py +++ b/lumen/tests/sources/test_intake.py @@ -1,12 +1,13 @@ import datetime as dt import os -import pandas as pd import pytest import yaml from lumen.sources.intake import IntakeSource +from ..utils import assert_frame_equal_no_dtype_check + @pytest.fixture def source(): @@ -36,7 +37,7 @@ def test_intake_resolve_module_type(): def test_intake_source_from_file(source, mixed_df): - pd.testing.assert_frame_equal(source.get('test'), mixed_df) + assert_frame_equal_no_dtype_check(source.get('test'), mixed_df) def test_intake_source_from_dict(mixed_df): @@ -44,7 +45,7 @@ def test_intake_source_from_dict(mixed_df): with open(os.path.join(root, 'catalog.yml')) as f: catalog = yaml.load(f, Loader=yaml.Loader) source = IntakeSource(catalog=catalog, root=root) - pd.testing.assert_frame_equal(source.get('test'), mixed_df) + assert_frame_equal_no_dtype_check(source.get('test'), mixed_df) @pytest.mark.parametrize( @@ -65,4 +66,4 @@ def test_intake_filter(source, table_column_value_type, dask, expected_filtered_ table, column, value, _ = table_column_value_type kwargs = {column: value} filtered = source.get(table, __dask=dask, **kwargs) - pd.testing.assert_frame_equal(filtered, expected_filtered_df) + assert_frame_equal_no_dtype_check(filtered, expected_filtered_df) diff --git a/lumen/tests/sources/test_intake_sql.py b/lumen/tests/sources/test_intake_sql.py index b6620031..f99b7ea8 100644 --- a/lumen/tests/sources/test_intake_sql.py +++ b/lumen/tests/sources/test_intake_sql.py @@ -1,7 +1,6 @@ import datetime as dt import os -import pandas as pd import pytest try: @@ -12,6 +11,8 @@ from lumen.sources.intake_sql import IntakeSQLSource from lumen.transforms.sql import SQLGroupBy +from ..utils import assert_frame_equal_no_dtype_check + @pytest.fixture def source(): @@ -31,7 +32,7 @@ def test_intake_sql_get_tables(source, source_tables): tables = source.get_tables() assert tables == list(source_tables.keys()) for table in tables: - pd.testing.assert_frame_equal(source.get(table), source_tables[table]) + assert_frame_equal_no_dtype_check(source.get(table), source_tables[table]) def test_intake_sql_get_schema(source): @@ -99,7 +100,7 @@ def test_intake_sql_filter(source, table_column_value_type, dask, expected_filte table, column, value, _ = table_column_value_type kwargs = {column: value} filtered = source.get(table, __dask=dask, **kwargs) - pd.testing.assert_frame_equal(filtered, expected_filtered_df.reset_index(drop=True)) + assert_frame_equal_no_dtype_check(filtered, expected_filtered_df.reset_index(drop=True)) def test_intake_sql_transforms(source, source_tables): @@ -107,7 +108,7 @@ def test_intake_sql_transforms(source, source_tables): transforms = [SQLGroupBy(by=['B'], aggregates={'SUM': 'A'})] transformed = source.get('test_sql', sql_transforms=transforms) expected = df_test_sql.groupby('B')['A'].sum().reset_index() - pd.testing.assert_frame_equal(transformed, expected) + assert_frame_equal_no_dtype_check(transformed, expected) def test_intake_sql_transforms_cache(source, source_tables): @@ -119,7 +120,7 @@ def test_intake_sql_transforms_cache(source, source_tables): assert cache_key in source._cache expected = df_test_sql.groupby('B')['A'].sum().reset_index() - pd.testing.assert_frame_equal(source._cache[cache_key], expected) + assert_frame_equal_no_dtype_check(source._cache[cache_key], expected) cache_key = source._get_key('test_sql', sql_transforms=transforms) assert cache_key in source._cache diff --git a/lumen/tests/test_dashboard.py b/lumen/tests/test_dashboard.py index 319783bf..d27a13aa 100644 --- a/lumen/tests/test_dashboard.py +++ b/lumen/tests/test_dashboard.py @@ -1,6 +1,5 @@ import pathlib -import pandas as pd import panel as pn import pytest @@ -10,6 +9,7 @@ from lumen.validation import ValidationError from .test_pipeline import sql_available +from .utils import assert_frame_equal_no_dtype_check def test_dashboard_with_local_view(set_root): @@ -131,11 +131,11 @@ def test_dashboard_with_sql_source_and_transforms(set_root, document, mixed_df_o layout.update() table = layout._cards[0]._card[0][0] - pd.testing.assert_frame_equal(table.value, mixed_df_object_type) + assert_frame_equal_no_dtype_check(table.value, mixed_df_object_type) dashboard._sidebar[0][0][0]._widgets['limit'].value = 2 - pd.testing.assert_frame_equal(table.value, mixed_df_object_type.iloc[:2]) + assert_frame_equal_no_dtype_check(table.value, mixed_df_object_type.iloc[:2]) def test_dashboard_with_transform_variable(set_root, document, mixed_df): root = pathlib.Path(__file__).parent / 'sample_dashboard' @@ -146,11 +146,11 @@ def test_dashboard_with_transform_variable(set_root, document, mixed_df): layout.update() table = layout._cards[0]._card[0][0] - pd.testing.assert_frame_equal(table.value, mixed_df) + assert_frame_equal_no_dtype_check(table.value, mixed_df) state.variables.length = 2 - pd.testing.assert_frame_equal(table.value, mixed_df.iloc[:2]) + assert_frame_equal_no_dtype_check(table.value, mixed_df.iloc[:2]) def test_dashboard_with_source_variable(set_root, document, mixed_df): root = pathlib.Path(__file__).parent / 'sample_dashboard' @@ -161,11 +161,11 @@ def test_dashboard_with_source_variable(set_root, document, mixed_df): layout.update() table = layout._cards[0]._card[0][0] - pd.testing.assert_frame_equal(table.value, mixed_df) + assert_frame_equal_no_dtype_check(table.value, mixed_df) state.variables.tables = {'test': '../sources/test2.csv'} - pd.testing.assert_frame_equal(table.value, mixed_df.iloc[::-1].reset_index(drop=True)) + assert_frame_equal_no_dtype_check(table.value, mixed_df.iloc[::-1].reset_index(drop=True)) def test_dashboard_with_nested_source_variable(set_root, document, mixed_df): root = pathlib.Path(__file__).parent / 'sample_dashboard' @@ -176,11 +176,11 @@ def test_dashboard_with_nested_source_variable(set_root, document, mixed_df): layout.update() table = layout._cards[0]._card[0][0] - pd.testing.assert_frame_equal(table.value, mixed_df) + assert_frame_equal_no_dtype_check(table.value, mixed_df) state.variables.ticker = '../sources/test2.csv' - pd.testing.assert_frame_equal(table.value, mixed_df.iloc[::-1].reset_index(drop=True)) + assert_frame_equal_no_dtype_check(table.value, mixed_df.iloc[::-1].reset_index(drop=True)) def test_dashboard_with_view_variable(set_root, document): root = pathlib.Path(__file__).parent / 'sample_dashboard' diff --git a/lumen/tests/test_pipeline.py b/lumen/tests/test_pipeline.py index 649302fa..ffb5c8d8 100644 --- a/lumen/tests/test_pipeline.py +++ b/lumen/tests/test_pipeline.py @@ -1,6 +1,5 @@ import pathlib -import pandas as pd import pytest try: @@ -24,18 +23,19 @@ from lumen.transforms.base import Columns from lumen.transforms.sql import SQLColumns, SQLGroupBy -sql_available = pytest.mark.skipif(intake_sql is None or duckdb is None, reason="intake-sql is not installed") +from .utils import assert_frame_equal_no_dtype_check +sql_available = pytest.mark.skipif(intake_sql is None or duckdb is None, reason="intake-sql is not installed") def test_pipeline_source_only(make_filesource, mixed_df): root = pathlib.Path(__file__).parent / 'sources' source = make_filesource(str(root)) pipeline = Pipeline(source=source, table='test') - pd.testing.assert_frame_equal(pipeline.data, mixed_df) + assert_frame_equal_no_dtype_check(pipeline.data, mixed_df) source.tables = {'test': 'test2.csv'} - pd.testing.assert_frame_equal(pipeline.data, mixed_df[::-1].reset_index(drop=True)) + assert_frame_equal_no_dtype_check(pipeline.data, mixed_df[::-1].reset_index(drop=True)) def test_pipeline_change_table(make_filesource, mixed_df): root = pathlib.Path(__file__).parent / 'sources' @@ -43,10 +43,10 @@ def test_pipeline_change_table(make_filesource, mixed_df): source.tables = {'test': 'test.csv', 'test2': 'test2.csv'} pipeline = Pipeline(source=source, table='test') - pd.testing.assert_frame_equal(pipeline.data, mixed_df) + assert_frame_equal_no_dtype_check(pipeline.data, mixed_df) pipeline.table = 'test2' - pd.testing.assert_frame_equal(pipeline.data, mixed_df[::-1].reset_index(drop=True)) + assert_frame_equal_no_dtype_check(pipeline.data, mixed_df[::-1].reset_index(drop=True)) def test_pipeline_with_filter(make_filesource, mixed_df): root = pathlib.Path(__file__).parent / 'sources' @@ -55,12 +55,12 @@ def test_pipeline_with_filter(make_filesource, mixed_df): pipeline = Pipeline(source=source, filters=[cfilter], table='test') expected = mixed_df.iloc[1:3] - pd.testing.assert_frame_equal(pipeline.data, expected) + assert_frame_equal_no_dtype_check(pipeline.data, expected) # Update cfilter.value = (0, 2) expected = mixed_df.iloc[0:3] - pd.testing.assert_frame_equal(pipeline.data, expected) + assert_frame_equal_no_dtype_check(pipeline.data, expected) def test_pipeline_manual_with_filter(make_filesource, mixed_df): root = pathlib.Path(__file__).parent / 'sources' @@ -69,16 +69,16 @@ def test_pipeline_manual_with_filter(make_filesource, mixed_df): pipeline = Pipeline(source=source, filters=[cfilter], table='test', auto_update=False) expected = mixed_df.iloc[1:3] - pd.testing.assert_frame_equal(pipeline.data, expected) + assert_frame_equal_no_dtype_check(pipeline.data, expected) # Update filter cfilter.value = (0, 2) - pd.testing.assert_frame_equal(pipeline.data, expected) + assert_frame_equal_no_dtype_check(pipeline.data, expected) # Trigger pipeline update pipeline.param.trigger('update') expected = mixed_df.iloc[0:3] - pd.testing.assert_frame_equal(pipeline.data, expected) + assert_frame_equal_no_dtype_check(pipeline.data, expected) def test_pipeline_with_transform(make_filesource, mixed_df): root = pathlib.Path(__file__).parent / 'sources' @@ -88,12 +88,12 @@ def test_pipeline_with_transform(make_filesource, mixed_df): pipeline = Pipeline(source=source, transforms=[transform], table='test') expected = mixed_df[['A', 'B']] - pd.testing.assert_frame_equal(pipeline.data, expected) + assert_frame_equal_no_dtype_check(pipeline.data, expected) # Update transform.columns = ['B', 'C'] expected = mixed_df[['B', 'C']] - pd.testing.assert_frame_equal(pipeline.data, expected) + assert_frame_equal_no_dtype_check(pipeline.data, expected) def test_pipeline_manual_with_transform(make_filesource, mixed_df): root = pathlib.Path(__file__).parent / 'sources' @@ -103,16 +103,16 @@ def test_pipeline_manual_with_transform(make_filesource, mixed_df): pipeline = Pipeline(source=source, transforms=[transform], table='test', auto_update=False) expected = mixed_df[['A', 'B']] - pd.testing.assert_frame_equal(pipeline.data, expected) + assert_frame_equal_no_dtype_check(pipeline.data, expected) # Update transform transform.columns = ['B', 'C'] - pd.testing.assert_frame_equal(pipeline.data, expected) + assert_frame_equal_no_dtype_check(pipeline.data, expected) # Trigger update pipeline.param.trigger('update') expected = mixed_df[['B', 'C']] - pd.testing.assert_frame_equal(pipeline.data, expected) + assert_frame_equal_no_dtype_check(pipeline.data, expected) @sql_available def test_pipeline_with_sql_transform(mixed_df_object_type): @@ -125,12 +125,12 @@ def test_pipeline_with_sql_transform(mixed_df_object_type): pipeline = Pipeline(source=source, table='test_sql', sql_transforms=[transform]) df = mixed_df_object_type[['A', 'B']] - pd.testing.assert_frame_equal(pipeline.data, df) + assert_frame_equal_no_dtype_check(pipeline.data, df) # Update transform.columns = ['B', 'C'] df = mixed_df_object_type[['B', 'C']] - pd.testing.assert_frame_equal(pipeline.data, df) + assert_frame_equal_no_dtype_check(pipeline.data, df) def test_pipeline_chained_with_filter(make_filesource, mixed_df): root = pathlib.Path(__file__).parent / 'sources' @@ -142,16 +142,16 @@ def test_pipeline_chained_with_filter(make_filesource, mixed_df): pipeline2 = pipeline1.chain(filters=[cfilter2]) expected = mixed_df.iloc[[1, 3]] - pd.testing.assert_frame_equal(pipeline2.data, expected) + assert_frame_equal_no_dtype_check(pipeline2.data, expected) # Update cfilter1.value = (2, 3) expected = mixed_df.iloc[[3]] - pd.testing.assert_frame_equal(pipeline2.data, expected) + assert_frame_equal_no_dtype_check(pipeline2.data, expected) cfilter2.value = 0.0 expected = mixed_df.iloc[[2]] - pd.testing.assert_frame_equal(pipeline2.data, expected) + assert_frame_equal_no_dtype_check(pipeline2.data, expected) def test_pipeline_manual_chained_with_filter(make_filesource, mixed_df): root = pathlib.Path(__file__).parent / 'sources' @@ -163,25 +163,25 @@ def test_pipeline_manual_chained_with_filter(make_filesource, mixed_df): pipeline2 = pipeline1.chain(filters=[cfilter2], _chain_update=True) expected = mixed_df.iloc[[1, 3]] - pd.testing.assert_frame_equal(pipeline2.data, expected) + assert_frame_equal_no_dtype_check(pipeline2.data, expected) # Update filter cfilter1.value = (2, 3) - pd.testing.assert_frame_equal(pipeline2.data, expected) + assert_frame_equal_no_dtype_check(pipeline2.data, expected) # Trigger update pipeline1.param.trigger('update') expected = mixed_df.iloc[[3]] - pd.testing.assert_frame_equal(pipeline2.data, expected) + assert_frame_equal_no_dtype_check(pipeline2.data, expected) # Update chained filter cfilter2.value = 0.0 - pd.testing.assert_frame_equal(pipeline2.data, expected) + assert_frame_equal_no_dtype_check(pipeline2.data, expected) # Trigger update pipeline2.param.trigger('update') expected = mixed_df.iloc[[2]] - pd.testing.assert_frame_equal(pipeline2.data, expected) + assert_frame_equal_no_dtype_check(pipeline2.data, expected) def test_pipeline_chained_with_transform(make_filesource, mixed_df): root = pathlib.Path(__file__).parent / 'sources' @@ -193,16 +193,16 @@ def test_pipeline_chained_with_transform(make_filesource, mixed_df): pipeline2 = pipeline1.chain(transforms=[transform]) expected = mixed_df.iloc[1:3][['A', 'B']] - pd.testing.assert_frame_equal(pipeline2.data, expected) + assert_frame_equal_no_dtype_check(pipeline2.data, expected) # Update cfilter.value = (2, 3) expected = mixed_df.iloc[2:4][['A', 'B']] - pd.testing.assert_frame_equal(pipeline2.data, expected) + assert_frame_equal_no_dtype_check(pipeline2.data, expected) transform.columns = ['B', 'C'] expected = mixed_df.iloc[2:4][['B', 'C']] - pd.testing.assert_frame_equal(pipeline2.data, expected) + assert_frame_equal_no_dtype_check(pipeline2.data, expected) @sql_available def test_pipeline_chained_with_sql_transform(mixed_df_object_type): @@ -220,17 +220,17 @@ def test_pipeline_chained_with_sql_transform(mixed_df_object_type): assert isinstance(pipeline2.source, DuckDBSource) expected = mixed_df_object_type.iloc[1:3][['A', 'B']].reset_index(drop=True) - pd.testing.assert_frame_equal(pipeline2.data, expected) + assert_frame_equal_no_dtype_check(pipeline2.data, expected) # Update cfilter.value = (2, 3) expected = mixed_df_object_type.iloc[2:4][['A', 'B']].reset_index(drop=True) - pd.testing.assert_frame_equal(pipeline2.data, expected) + assert_frame_equal_no_dtype_check(pipeline2.data, expected) transform.columns = ['B', 'C'] expected = mixed_df_object_type.iloc[2:4][['B', 'C']].reset_index(drop=True) - pd.testing.assert_frame_equal(pipeline2.data, expected) + assert_frame_equal_no_dtype_check(pipeline2.data, expected) @sql_available def test_pipeline_chained_sql_transform_with_regular_transforms(mixed_df_object_type): @@ -247,16 +247,16 @@ def test_pipeline_chained_sql_transform_with_regular_transforms(mixed_df_object_ pipeline3 = pipeline2.chain(filters=[cfilter2]) expected = mixed_df_object_type.iloc[1:3][['A', 'B']] - pd.testing.assert_frame_equal(pipeline3.data, expected) + assert_frame_equal_no_dtype_check(pipeline3.data, expected) # Update cfilter1.value = (1, 3) expected = mixed_df_object_type.iloc[1:4][['A', 'B']] - pd.testing.assert_frame_equal(pipeline3.data, expected) + assert_frame_equal_no_dtype_check(pipeline3.data, expected) transform1.columns = ['B', 'C'] expected = mixed_df_object_type[['B', 'C']] - pd.testing.assert_frame_equal(pipeline2.data, expected) + assert_frame_equal_no_dtype_check(pipeline2.data, expected) @sql_available def test_pipeline_chained_manual_update_with_sql_transform(mixed_df_object_type): @@ -276,26 +276,26 @@ def test_pipeline_chained_manual_update_with_sql_transform(mixed_df_object_type) pipeline3 = pipeline2.chain(filters=[cfilter2], auto_update=False, name='Pipeline 3') expected = mixed_df_object_type.iloc[1:3][['A', 'B']] - pd.testing.assert_frame_equal(pipeline3.data, expected) + assert_frame_equal_no_dtype_check(pipeline3.data, expected) # Update cfilter1.value = (1, 3) - pd.testing.assert_frame_equal(pipeline3.data, expected) + assert_frame_equal_no_dtype_check(pipeline3.data, expected) pipeline3.param.trigger('update') expected = mixed_df_object_type.iloc[1:4][['A', 'B']] - pd.testing.assert_frame_equal(pipeline3.data, expected) + assert_frame_equal_no_dtype_check(pipeline3.data, expected) transform1.columns = ['B', 'C'] - pd.testing.assert_frame_equal(pipeline3.data, expected) + assert_frame_equal_no_dtype_check(pipeline3.data, expected) pipeline3.param.trigger('update') expected = mixed_df_object_type[['B', 'C']] - pd.testing.assert_frame_equal(pipeline3.data, expected) + assert_frame_equal_no_dtype_check(pipeline3.data, expected) cfilter2.value = (0, 0) - pd.testing.assert_frame_equal(pipeline3.data, expected) + assert_frame_equal_no_dtype_check(pipeline3.data, expected) pipeline3.param.trigger('update') expected = mixed_df_object_type.iloc[::2][['B', 'C']] - pd.testing.assert_frame_equal(pipeline3.data, expected) + assert_frame_equal_no_dtype_check(pipeline3.data, expected) def test_not_removing_type(penguins_file): spec = { @@ -349,9 +349,9 @@ def test_pipeline_with_sql_transform_nested_widget_vars(mixed_df_object_type): pipeline = Pipeline(source=source, table='test_sql', sql_transforms=[transform]) df = mixed_df_object_type[['C', 'A']] - pd.testing.assert_frame_equal(pipeline.data, df) + assert_frame_equal_no_dtype_check(pipeline.data, df) # Update sel.value = 'B' df = mixed_df_object_type[['C', 'B']] - pd.testing.assert_frame_equal(pipeline.data, df) + assert_frame_equal_no_dtype_check(pipeline.data, df) diff --git a/lumen/tests/transforms/test_base.py b/lumen/tests/transforms/test_base.py index c4ea5bdc..93a3209c 100644 --- a/lumen/tests/transforms/test_base.py +++ b/lumen/tests/transforms/test_base.py @@ -1,13 +1,14 @@ import os import pathlib -import pandas as pd import param # type: ignore from lumen.transforms.base import ( Count, DropNA, Eval, Sum, Transform, ) +from ..utils import assert_frame_equal_no_dtype_check + class CustomTransform(Transform): @@ -51,7 +52,7 @@ def test_transform_control_options_by_reference(make_filesource): def test_count_transform(mixed_df): count_df = Count.apply_to(mixed_df) - pd.testing.assert_frame_equal(count_df, mixed_df.count().to_frame().T) + assert_frame_equal_no_dtype_check(count_df, mixed_df.count().to_frame().T) def test_sum_transform(mixed_df): @@ -59,7 +60,7 @@ def test_sum_transform(mixed_df): sum_df = Sum.apply_to(df) - pd.testing.assert_frame_equal(sum_df, df.sum().to_frame().T) + assert_frame_equal_no_dtype_check(sum_df, df.sum().to_frame().T) def test_eval_transform(mixed_df): @@ -70,7 +71,7 @@ def test_eval_transform(mixed_df): df2 = df.copy() df2['B'] = df.A * 2 - pd.testing.assert_frame_equal(eval_df, df2) + assert_frame_equal_no_dtype_check(eval_df, df2) def test_dropna_transform(mixed_df): diff --git a/lumen/tests/utils.py b/lumen/tests/utils.py new file mode 100644 index 00000000..deb8518a --- /dev/null +++ b/lumen/tests/utils.py @@ -0,0 +1,5 @@ +import pandas as pd + + +def assert_frame_equal_no_dtype_check(left, right, **kwargs): + return pd.testing.assert_frame_equal(left, right, check_dtype=False, **kwargs)