Skip to content

Commit

Permalink
fixed errors & warning messages with tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jarathomas committed Apr 2, 2024
1 parent 736926a commit 9673aa9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
10 changes: 8 additions & 2 deletions tests/test_compare_r.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,19 @@
r_check = get_conversion().rpy2py(r_df)
r_data = get_conversion().rpy2py(randomva5)

r_data.replace({"y": 1, "n": 0, ".": nan}, inplace=True)
for col in r_data:
if not (col == "ID"):
r_data[col] = r_data[col].cat.rename_categories({"y": 1, "n": 0, ".": 3})
r_data[col] = r_data[col].astype("float64")
r_data[col] = r_data[col].replace(3, nan)


pb = get_probbase()
py_check = r_data.replace(".", nan).apply(
lambda x: datacheck5(x, x.ID, probbase=pb)['output'],
axis=1)
py_check
r_check.set_axis(list(py_check), axis=1, inplace=True)
r_check = r_check.set_axis(list(py_check), axis=1)
r_check["ID"] = py_check["ID"].copy()


Expand Down
8 changes: 4 additions & 4 deletions tests/test_datacheck5.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,17 @@ def test_invalid_arg_type(single_record):
with pytest.raises(exceptions.VAInputException):
datacheck5(single_record.to_list(), probbase=pb, va_id="d1")
with pytest.raises(exceptions.VAIDException):
single_record[0] = ""
single_record.iloc[0] = ""
datacheck5(single_record, probbase=pb, va_id="")
with pytest.raises(exceptions.VAInputException):
single_record[0] = 3
single_record[2] = 3
single_record.iloc[0] = 3
single_record.iloc[2] = 3
datacheck5(single_record, probbase=pb, va_id=3)


def test_invalid_va_input_data_value(single_record):
bad_record = single_record
bad_record[2] = 33
bad_record.iloc[2] = 33
with pytest.raises(exceptions.VAInputException):
datacheck5(bad_record, probbase=pb, va_id="d1")

Expand Down

0 comments on commit 9673aa9

Please sign in to comment.