-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enh: nw.dependencies.is_narwhals_dataframe / nw.dependencies.is_narwh…
…als_lazyframe / nw.dependencies.is_narwhals_series (#1550) --------- Co-authored-by: Marco Gorelli <[email protected]>
- Loading branch information
1 parent
d788eec
commit 68bc862
Showing
5 changed files
with
103 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from __future__ import annotations | ||
|
||
from typing import TYPE_CHECKING | ||
|
||
import narwhals as nw | ||
import narwhals.stable.v1 as nws | ||
from narwhals.stable.v1.dependencies import is_narwhals_dataframe | ||
|
||
if TYPE_CHECKING: | ||
from tests.utils import ConstructorEager | ||
|
||
|
||
def test_is_narwhals_dataframe(constructor_eager: ConstructorEager) -> None: | ||
df = constructor_eager({"col1": [1, 2], "col2": [3, 4]}) | ||
|
||
assert is_narwhals_dataframe(nw.from_native(df)) | ||
assert is_narwhals_dataframe(nws.from_native(df)) | ||
assert not is_narwhals_dataframe(df) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from __future__ import annotations | ||
|
||
from typing import TYPE_CHECKING | ||
|
||
import narwhals as nw | ||
import narwhals.stable.v1 as nws | ||
from narwhals.stable.v1.dependencies import is_narwhals_lazyframe | ||
from tests.utils import Constructor | ||
|
||
if TYPE_CHECKING: | ||
from tests.utils import Constructor | ||
|
||
|
||
def test_is_narwhals_lazyframe(constructor: Constructor) -> None: | ||
lf = constructor({"a": [1, 2, 3]}) | ||
|
||
assert is_narwhals_lazyframe(nw.from_native(lf).lazy()) | ||
assert is_narwhals_lazyframe(nws.from_native(lf).lazy()) | ||
assert not is_narwhals_lazyframe(lf) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from __future__ import annotations | ||
|
||
from typing import TYPE_CHECKING | ||
|
||
import narwhals as nw | ||
import narwhals.stable.v1 as nws | ||
from narwhals.stable.v1.dependencies import is_narwhals_series | ||
|
||
if TYPE_CHECKING: | ||
from tests.utils import ConstructorEager | ||
|
||
|
||
def test_is_narwhals_series(constructor_eager: ConstructorEager) -> None: | ||
df = constructor_eager({"col1": [1, 2], "col2": [3, 4]}) | ||
|
||
assert is_narwhals_series(nw.from_native(df, eager_only=True)["col1"]) | ||
assert is_narwhals_series(nws.from_native(df, eager_only=True)["col1"]) | ||
assert not is_narwhals_series(nw.from_native(df, eager_only=True)["col1"].to_native()) |