Skip to content

Commit

Permalink
test: Remove some to_numpy (#820)
Browse files Browse the repository at this point in the history
  • Loading branch information
luke396 authored Aug 20, 2024
1 parent 95925e1 commit c8e72d2
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 20 deletions.
7 changes: 4 additions & 3 deletions tests/expr_and_series/is_first_distinct_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from typing import Any

import numpy as np
import pytest

import narwhals.stable.v1 as nw
Expand Down Expand Up @@ -28,5 +27,7 @@ def test_is_first_distinct_expr(constructor: Any, request: Any) -> None:
def test_is_first_distinct_series(constructor_eager: Any) -> None:
series = nw.from_native(constructor_eager(data), eager_only=True)["a"]
result = series.is_first_distinct()
expected = np.array([True, False, True, True, False])
assert (result.to_numpy() == expected).all()
expected = {
"a": [True, False, True, True, False],
}
compare_dicts({"a": result}, expected)
7 changes: 4 additions & 3 deletions tests/expr_and_series/is_last_distinct_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from typing import Any

import numpy as np
import pytest

import narwhals.stable.v1 as nw
Expand Down Expand Up @@ -28,5 +27,7 @@ def test_is_last_distinct_expr(constructor: Any, request: Any) -> None:
def test_is_last_distinct_series(constructor_eager: Any) -> None:
series = nw.from_native(constructor_eager(data), eager_only=True)["a"]
result = series.is_last_distinct()
expected = np.array([False, True, False, True, True])
assert (result.to_numpy() == expected).all()
expected = {
"a": [False, True, False, True, True],
}
compare_dicts({"a": result}, expected)
7 changes: 4 additions & 3 deletions tests/expr_and_series/is_unique_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from typing import Any

import numpy as np
import pytest

import narwhals.stable.v1 as nw
Expand Down Expand Up @@ -28,5 +27,7 @@ def test_is_unique_expr(constructor: Any, request: Any) -> None:
def test_is_unique_series(constructor_eager: Any) -> None:
series = nw.from_native(constructor_eager(data), eager_only=True)["a"]
result = series.is_unique()
expected = np.array([False, False, True])
assert (result.to_numpy() == expected).all()
expected = {
"a": [False, False, True],
}
compare_dicts({"a": result}, expected)
5 changes: 2 additions & 3 deletions tests/expr_and_series/unique_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from typing import Any

import numpy as np
import pytest

import narwhals.stable.v1 as nw
Expand All @@ -21,5 +20,5 @@ def test_unique_expr(constructor: Any, request: Any) -> None:
def test_unique_series(constructor_eager: Any) -> None:
series = nw.from_native(constructor_eager(data), eager_only=True)["a"]
result = series.unique()
expected = np.array([1, 2])
assert (result.to_numpy() == expected).all()
expected = {"a": [1, 2]}
compare_dicts({"a": result}, expected)
7 changes: 3 additions & 4 deletions tests/frame/is_duplicated_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@

from typing import Any

import numpy as np

import narwhals.stable.v1 as nw
from tests.utils import compare_dicts


def test_is_duplicated(constructor_eager: Any) -> None:
data = {"a": [1, 3, 2], "b": [4, 4, 6], "z": [7.0, 8, 9]}
df_raw = constructor_eager(data)
df = nw.from_native(df_raw, eager_only=True)
result = nw.concat([df, df.head(1)]).is_duplicated()
expected = np.array([True, False, False, True])
assert (result.to_numpy() == expected).all()
expected = {"is_duplicated": [True, False, False, True]}
compare_dicts({"is_duplicated": result}, expected)
7 changes: 3 additions & 4 deletions tests/frame/is_unique_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@

from typing import Any

import numpy as np

import narwhals.stable.v1 as nw
from tests.utils import compare_dicts


def test_is_unique(constructor_eager: Any) -> None:
data = {"a": [1, 3, 2], "b": [4, 4, 6], "z": [7.0, 8, 9]}
df_raw = constructor_eager(data)
df = nw.from_native(df_raw, eager_only=True)
result = nw.concat([df, df.head(1)]).is_unique()
expected = np.array([False, True, True, False])
assert (result.to_numpy() == expected).all()
expected = {"is_unique": [False, True, True, False]}
compare_dicts({"is_unique": result}, expected)

0 comments on commit c8e72d2

Please sign in to comment.