Skip to content

Commit

Permalink
branch error messages on pandas version
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-joshi committed Oct 9, 2024
1 parent 5c84f56 commit 2a85e96
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
12 changes: 9 additions & 3 deletions tests/integ/modin/frame/test_apply_axis_0.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
#

import datetime
import re

import modin.pandas as pd
import numpy as np
import pandas as native_pd
import pytest
from packaging.version import Version
from pytest import param

import snowflake.snowpark.modin.plugin # noqa: F401
Expand Down Expand Up @@ -220,9 +222,13 @@ def test_axis_0_return_dataframe_not_supported():

# Note that pands returns failure "ValueError: If using all scalar values, you must pass an index" which
# doesn't explain this isn't supported. We go with the default returned by pandas in this case.
with pytest.raises(
SnowparkSQLException, match="The truth value of a DataFrame is ambiguous."
):
if Version(native_pd.__version__) > Version("2.2.1"):
expected_message = re.escape(
"Data must be 1-dimensional, got ndarray of shape (2, 1) instead"
)
else:
expected_message = "The truth value of a DataFrame is ambiguous."
with pytest.raises(SnowparkSQLException, match=expected_message):
# return value
snow_df.apply(lambda x: native_pd.DataFrame([1, 2]), axis=0).to_pandas()

Expand Down
14 changes: 9 additions & 5 deletions tests/integ/modin/index/test_df_series_creation_with_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import numpy as np
import pandas as native_pd
import pytest
from packaging.version import Version

import snowflake.snowpark.modin.plugin # noqa: F401
from tests.integ.modin.utils import assert_frame_equal, assert_series_equal
Expand Down Expand Up @@ -1316,13 +1317,16 @@ def test_create_series_with_df_index_negative():

@sql_count_checker(query_count=0)
def test_create_series_with_df_data_negative():
with pytest.raises(
ValueError,
match=re.escape(
if Version(native_pd.__version__) > Version("2.2.1"):
expected_message = re.escape(
"Data must be 1-dimensional, got ndarray of shape (3, 2) instead"
)
else:
expected_message = re.escape(
"The truth value of a DataFrame is ambiguous. Use a.empty, a.bool()"
", a.item(), a.any() or a.all()."
),
):
)
with pytest.raises(ValueError, match=expected_message):
native_pd.Series(native_pd.DataFrame([[1, 2], [3, 4], [5, 6]]))
with pytest.raises(ValueError, match="Data cannot be a DataFrame"):
pd.Series(pd.DataFrame([[1, 2], [3, 4], [5, 6]]))
Expand Down

0 comments on commit 2a85e96

Please sign in to comment.