-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added more tests for polars and upgraded to v0.19 * Added more tests to polars * day tests for polars
- Loading branch information
Showing
34 changed files
with
1,061 additions
and
50 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
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 |
---|---|---|
|
@@ -45,7 +45,7 @@ duckdb = [ | |
"duckdb==0.8.1" | ||
] | ||
polars = [ | ||
"polars>=0.15.7" | ||
"polars>=0.19.6" | ||
] | ||
iso = [ | ||
"lxml >= 4.9.1" | ||
|
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 |
---|---|---|
@@ -1,11 +1,31 @@ | ||
import pytest | ||
|
||
from cuallee import Check | ||
import polars as pl | ||
import pytest | ||
import numpy as np | ||
|
||
|
||
def test_positive(check): | ||
def test_positive(check: Check): | ||
check.has_correlation("id", "id2", 1.0) | ||
df = pl.DataFrame({"id": [10, 20], "id2": [100, 200]}) | ||
result = check.validate(df).select(pl.col("status")) == "PASS" | ||
assert all(result.to_series().to_list()) | ||
|
||
|
||
def test_negative(check: Check): | ||
check.has_correlation("id", "id2", 1.0) | ||
# result = check.validate(df).select(pl.col('status')) == "PASS" | ||
# assert all(result.to_series().to_list()) | ||
assert True | ||
df = pl.DataFrame({"id": [10, 20, 30, None], "id2": [100, 200, 300, 400]}) | ||
result = check.validate(df).select(pl.col("status")) == "FAIL" | ||
assert all(result.to_series().to_list()) | ||
|
||
|
||
def test_values(check: Check): | ||
check.has_correlation("id", "id2", 1.0) | ||
df = pl.DataFrame({"id": [1, 2, 3], "id2": [1.0, 2.0, 3.0]}) | ||
result = check.validate(df).select(pl.col("status")) == "PASS" | ||
assert all(result.to_series().to_list()) | ||
|
||
|
||
def test_coverage(check: Check): | ||
with pytest.raises(TypeError, match="positional arguments"): | ||
check.has_correlation("id", "id2", 1.0, 0.75) |
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,32 @@ | ||
import polars as pl | ||
from cuallee import Check | ||
import pytest | ||
|
||
|
||
def test_positive(check: Check): | ||
check.has_entropy("id", 1.0) | ||
df = pl.DataFrame({"id": [1, 1, 1, 0, 0, 0]}) | ||
result = check.validate(df).select(pl.col("status")) == "PASS" | ||
assert all(result.to_series().to_list()) | ||
|
||
|
||
def test_negative(check: Check): | ||
check.has_entropy("id", 1.0) | ||
df = pl.DataFrame({"id": [10, 10, 10, 10, 50]}) | ||
result = check.validate(df).select(pl.col("status")) == "FAIL" | ||
assert all(result.to_series().to_list()) | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"values", [[1], [1, 1, 1, 1, 1]], ids=("observation", "classes") | ||
) | ||
def test_parameters(check: Check, values): | ||
check.has_entropy("id", 0.0) | ||
df = pl.DataFrame({"id": values}) | ||
result = check.validate(df).select(pl.col("status")) == "PASS" | ||
assert all(result.to_series().to_list()) | ||
|
||
|
||
def test_coverage(check: Check): | ||
with pytest.raises(TypeError): | ||
check.has_entropy("id", 1.0, pct=0.5) |
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,16 @@ | ||
from cuallee import Check | ||
import polars as pl | ||
|
||
|
||
def test_positive(check: Check): | ||
df = pl.DataFrame({"id": [1, 2, 3, 4, 5]}) | ||
check.has_max("id", 5) | ||
result = check.validate(df).select(pl.col("status")) == "PASS" | ||
assert all(result.to_series().to_list()) | ||
|
||
|
||
def test_negative(check: Check): | ||
df = pl.DataFrame({"id": [1, 2, 3, 4, 5]}) | ||
check.has_max("id", 10) | ||
result = check.validate(df).select(pl.col("status")) == "FAIL" | ||
assert all(result.to_series().to_list()) |
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,34 @@ | ||
import polars as pl | ||
from cuallee import Check | ||
import pytest | ||
|
||
|
||
def test_positive(check: Check): | ||
check.has_max_by("id", "id2", 20) | ||
df = pl.DataFrame({"id": [10, 20], "id2": [300, 500]}) | ||
result = check.validate(df).select(pl.col("status")) == "PASS" | ||
assert all(result.to_series().to_list()) | ||
|
||
|
||
def test_negative(check: Check): | ||
check.has_max_by("id", "id2", 10) | ||
df = pl.DataFrame({"id": [10, 20], "id2": [300, 500]}) | ||
result = check.validate(df).select(pl.col("status")) == "FAIL" | ||
assert all(result.to_series().to_list()) | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"answer, columns", | ||
[(20, [10, 20]), ("herminio", ["antoine", "herminio"])], | ||
ids=("numeric", "string"), | ||
) | ||
def test_values(check: Check, answer, columns): | ||
check.has_max_by("id", "id2", answer) | ||
df = pl.DataFrame({"id": columns, "id2": [300, 500]}) | ||
result = check.validate(df).select(pl.col("status")) == "PASS" | ||
assert all(result.to_series().to_list()) | ||
|
||
|
||
def test_coverage(check: Check): | ||
with pytest.raises(TypeError): | ||
check.has_max_by("id", "id2", 20, 100) |
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,31 @@ | ||
import polars as pl | ||
import numpy as np | ||
from cuallee import Check | ||
import pytest | ||
|
||
|
||
def test_positive(check: Check): | ||
check.has_mean("id", 4.5) | ||
df = pl.DataFrame({"id": np.arange(10)}) | ||
result = check.validate(df).select(pl.col("status")) == "PASS" | ||
assert all(result.to_series().to_list()) | ||
|
||
|
||
def test_negative(check: Check): | ||
check.has_mean("id", 5) | ||
df = pl.DataFrame({"id": np.arange(10)}) | ||
result = check.validate(df).select(pl.col("status")) == "FAIL" | ||
assert all(result.to_series().to_list()) | ||
|
||
|
||
@pytest.mark.parametrize("extra_value", [4, 4.0], ids=("int", "float")) | ||
def test_values(check: Check, extra_value): | ||
check.has_mean("id", extra_value) | ||
df = pl.DataFrame({"id": [0, 1, 2, 3, 14] + [extra_value]}) | ||
result = check.validate(df).select(pl.col("status")) == "PASS" | ||
assert all(result.to_series().to_list()) | ||
|
||
|
||
def test_coverage(check: Check): | ||
with pytest.raises(TypeError): | ||
check.has_mean("id", 5, 0.1) |
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,34 @@ | ||
import polars as pl | ||
from cuallee import Check | ||
import pytest | ||
|
||
|
||
def test_positive(check: Check): | ||
check.has_min_by("id", "id2", 300) | ||
df = pl.DataFrame({"id": [10, 20], "id2": [300, 500]}) | ||
result = check.validate(df).select(pl.col("status")) == "PASS" | ||
assert all(result.to_series().to_list()) | ||
|
||
|
||
def test_negative(check: Check): | ||
check.has_min_by("id", "id2", 50) | ||
df = pl.DataFrame({"id": [10, 20], "id2": [300, 500]}) | ||
result = check.validate(df).select(pl.col("status")) == "FAIL" | ||
assert all(result.to_series().to_list()) | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"answer, columns", | ||
[(10, [10, 20]), ("antoine", ["antoine", "herminio"])], | ||
ids=("numeric", "string"), | ||
) | ||
def test_values(check: Check, answer, columns): | ||
check.has_min_by("id2", "id", answer) | ||
df = pl.DataFrame({"id": columns, "id2": [300, 500]}) | ||
result = check.validate(df).select(pl.col("status")) == "PASS" | ||
assert all(result.to_series().to_list()) | ||
|
||
|
||
def test_coverage(check: Check): | ||
with pytest.raises(TypeError): | ||
check.has_min_by("id2", "id", 20, 100) |
Oops, something went wrong.