-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into new_parameters
- Loading branch information
Showing
7 changed files
with
116 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# CountESS 0.0.64 | ||
# CountESS 0.0.65 | ||
|
||
This is CountESS, a modular, Python 3 reimplementation of Enrich2. | ||
|
||
|
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,3 +1,3 @@ | ||
"""CountESS Project""" | ||
|
||
VERSION = "0.0.64" | ||
VERSION = "0.0.65" |
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
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,55 @@ | ||
import logging | ||
import numpy as np | ||
import pandas as pd | ||
import pytest | ||
|
||
from countess.plugins.python import PythonPlugin | ||
|
||
dfi = pd.DataFrame( | ||
[[1, 1, 2, 7, 11], [2, 2, 3, 8, 1], [3, 3, 4, 9, 3], [4, 4, 5, 10, 4], [5, 5, 6, 12, 7]], | ||
columns=["a", "b", "c", "d", "e"], | ||
) | ||
|
||
def test_python_builtins(): | ||
plugin = PythonPlugin() | ||
plugin.set_parameter( | ||
"code", | ||
""" | ||
x = mean(a,b,c,d,e) | ||
y = std(a,b,c,d,e) | ||
z = sqrt(pow(a,2) + pow(b,2)) | ||
v = var(a,b,c,d,e) | ||
""", | ||
) | ||
|
||
plugin.prepare(["test"], None) | ||
dfo = plugin.process_dataframe(dfi) | ||
output = dfo.to_records() | ||
|
||
assert output[0]["x"] == 4.4 | ||
assert 2.48 < output[1]["y"] < 2.49 | ||
assert 4.24 < output[2]["z"] < 4.25 | ||
assert 5.43 < output[3]["v"] < 5.45 | ||
|
||
|
||
def test_python_dropna(): | ||
plugin = PythonPlugin() | ||
plugin.set_parameter( | ||
"code", | ||
""" | ||
a = None | ||
n = None | ||
if d >= 10: d = None | ||
""", | ||
) | ||
plugin.set_parameter("dropna", True) | ||
|
||
plugin.prepare(["test"], None) | ||
dfo = plugin.process_dataframe(dfi) | ||
|
||
assert "a" not in dfo.columns | ||
assert "n" not in dfo.columns | ||
assert "d" in dfo.columns | ||
|
||
assert any(np.isnan(dfo["d"])) | ||
assert not any(np.isnan(dfo["b"])) |