PoliUniLu / cora

This repository contains all files for the CORA software package.
GNU General Public License v3.0
5 stars 2 forks source link

Some of unit tests fail #17

Closed Naeemkh closed 1 year ago

Naeemkh commented 1 year ago

I am following these steps to run the unit tests (using Windows 11):

I get two failed tests:

================================================= test session starts =================================================
platform win32 -- Python 3.9.16, pytest-7.2.2, pluggy-1.0.0
rootdir: D:\All_Windows_Files\Document_file\My_reviews\software_package\JOSS_CORA\cora_from_github\cora
collected 18 items

tests\test_data_miming.py ..                                                                                     [ 11%]
tests\test_implicants.py .........                                                                               [ 61%]
tests\test_multi_value_output.py F.                                                                              [ 72%]
tests\test_on_dc_alg.py .F..                                                                                     [ 94%]
tests\test_petric.py .                                                                                           [100%]

====================================================== FAILURES =======================================================
_______________________________________________ TestOutputs.test_output _______________________________________________

self = <tests.test_multi_value_output.TestOutputs testMethod=test_output>

    def test_output(self):
        df = pd.DataFrame(
            [[1, 0, 1, 1], [0, 1, 1, 1], [0, 1, 0, 0], [1, 0, 1, 2]],
            columns=['a', 'b', 'c', 'o'])
        context1 = cora.OptimizationContext(df, ['o{1}'])
        df_test1 = pd.DataFrame(
            [[0, 1, 0, 0], [0, 1, 1, 1],[1, 0, 1, 0]],
            columns=['a', 'b', 'c', 'o'])
>       assert_frame_equal(df_test1, context1.get_preprocessed_data())
E       AssertionError: Attributes of DataFrame.iloc[:, 3] (column name="o") are different
E
E       Attribute "dtype" are different
E       [left]:  int64
E       [right]: int32

tests\test_multi_value_output.py:22: AssertionError
___________________________________ OptimizationContext_tests.test_inclusion_scores ___________________________________

self = <tests.test_on_dc_alg.OptimizationContext_tests testMethod=test_inclusion_scores>

    def test_inclusion_scores(self):
        opt_context = OptimizationContext(pd.DataFrame(data=[["1", 1, 0, 1, 0],
                                                             ["2", 1, 1, 1, 0],
                                                             ["3", 0, 1, 0, 1],
                                                             ["4", 1 ,1, 1, 1],
                                                             ["5", 1, 0, 1, 1]],
                                                       columns=["ID", "A", "B",
                                                                "C","O"]),
                                          ["O"],
                                          case_col="ID",
                                          inc_score1=0.5)
        opt_context.preprocess_data()
        result = opt_context.preprocessed_data_raw
        expected_cols = {
            "A": [0, 1, 1],
            "B": [1, 0, 1],
            "C": [0, 1, 1],
            "n": [1, 2, 2],
            "Cases": ["3", "1,5", "2,4"],
            "Inc_O": [1.0, 0.5, 0.5],
            "O": [1, 1, 1]
        }
        expected_result = pd.DataFrame.from_dict(expected_cols)
>       pd.testing.assert_frame_equal(result, expected_result)
E       AssertionError: Attributes of DataFrame.iloc[:, 6] (column name="O") are different
E
E       Attribute "dtype" are different
E       [left]:  int32
E       [right]: int64

tests\test_on_dc_alg.py:37: AssertionError
=============================================== short test summary info ===============================================
FAILED tests/test_multi_value_output.py::TestOutputs::test_output - AssertionError: Attributes of DataFrame.iloc[:, 3] (column name="o") are different
FAILED tests/test_on_dc_alg.py::OptimizationContext_tests::test_inclusion_scores - AssertionError: Attributes of DataFrame.iloc[:, 6] (column name="O") are different
============================================ 2 failed, 16 passed in 16.93s ============================================

This issue is related to this submission: https://github.com/openjournals/joss-reviews/issues/5019