Skip to content

Commit

Permalink
the shape of you the shape of me
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-jkew committed Oct 24, 2024
1 parent c3cf7c6 commit f832d52
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/snowflake/snowpark/modin/plugin/utils/numpy_to_pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,13 @@ def full_like_mapper(
if dtype is not None:
return NotImplemented

result_shape = shape or a.shape
result_shape = shape
if isinstance(result_shape, tuple) and len(result_shape) == 0:
result_shape = (1,)
if isinstance(result_shape, int):
result_shape = (result_shape,)
if result_shape is None:
result_shape = a.shape
if len(result_shape) == 2:
height, width = result_shape # type: ignore
return pd.DataFrame(fill_value, index=range(height), columns=range(width))
Expand Down
11 changes: 11 additions & 0 deletions tests/integ/modin/test_numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,17 @@ def test_full_like():
pandas_result = np.full_like(pandas_df, "numpy is the best")
assert_array_equal(np.array(snow_result), np.array(pandas_result))

with SqlCounter(query_count=1):
pandas_result = np.full_like(pandas_df, fill_value=4, shape=())
# breakpoint()
snow_result = np.full_like(snow_df, fill_value=4, shape=())
assert_array_equal(np.array(snow_result), np.array(pandas_result))

with SqlCounter(query_count=1):
snow_result = np.full_like(snow_df, fill_value=4, shape=(4))
pandas_result = np.full_like(pandas_df, fill_value=4, shape=(4))
assert_array_equal(np.array(snow_result), np.array(pandas_result))

with pytest.raises(TypeError):
np.full_like(snow_df, 1234, subok=False)

Expand Down

0 comments on commit f832d52

Please sign in to comment.