Esempio n. 1
0
    def test_dataframe_nans(self, example_dataframe_loaded):

        df = example_dataframe_loaded
        df.Run[0] = np.nan

        with pytest.raises(ValueError):
            load_data_for_simulation(df)
Esempio n. 2
0
    def test_dataframe_has_outcome_column(self, example_dataframe_loaded):

        df = example_dataframe_loaded
        df.columns = [i.replace('Outcome', 'abc') for i in df.columns]

        with pytest.raises(AttributeError):
            load_data_for_simulation(df)
Esempio n. 3
0
    def test_incorrect_input_names(self, example_dataframe_loaded):

        with pytest.raises(AttributeError):
            load_data_for_simulation(example_dataframe_loaded, ['Input2'])
Esempio n. 4
0
    def test_dataframe_n_subjects(self, example_dataframe_loaded):

        assert load_data_for_simulation(example_dataframe_loaded)[3] == 2
Esempio n. 5
0
    def test_dataframe_n_runs(self, example_dataframe_loaded):

        assert load_data_for_simulation(example_dataframe_loaded)[2] == 2
Esempio n. 6
0
    def test_dataframe_has_rows(self, example_dataframe_loaded):

        with pytest.raises(AttributeError):
            load_data_for_simulation(example_dataframe_loaded.iloc[:1, :])
Esempio n. 7
0
    def test_numpy_array_n_runs(self):

        assert load_data_for_simulation(np.ones((3, 4)))[2] == 4
Esempio n. 8
0
    def test_convert_to_numpy_array(self):
        """ Try providing a list of pandas dataframes, this should fail as it can't be converted to an array"""

        with pytest.raises(TypeError):
            load_data_for_simulation([pd.DataFrame({'a': [1, 2]})])
Esempio n. 9
0
    def test_infs_in_outcomes(self):

        with pytest.raises(ValueError):
            load_data_for_simulation(np.array([0, 1, np.inf]))
Esempio n. 10
0
    def test_numpy_array_outcome_shape_1D(self):
        """Tests whether a 1D array has been successfully converted to shape (n_trials, 1)"""

        assert load_data_for_simulation(np.ones(3))[0].shape == (3, 1)
Esempio n. 11
0
    def test_more_than_2d_array(self):

        with pytest.raises(AttributeError):
            load_data_for_simulation(np.ones((2, 3, 4)))
Esempio n. 12
0
    def test_one_length_array(self):

        with pytest.raises(AttributeError):
            load_data_for_simulation(np.array([1]))
Esempio n. 13
0
    def test_array_with_model_inputs(self):

        with pytest.raises(ValueError):
            load_data_for_simulation(np.array([1, 2, 3]), ['a'])
Esempio n. 14
0
    def test_inputs_not_strings(self, example_dataframe_loaded):

        with pytest.raises(TypeError):
            load_data_for_simulation(example_dataframe_loaded, [1])
Esempio n. 15
0
    def test_dataframe_load_from_string(self):
        """ Check that loading from path produces a numpy array"""

        assert isinstance(
            load_data_for_simulation('example_outcome_df.csv')[0], np.ndarray)
Esempio n. 16
0
    def test_model_input_returns_list_of_arrays(self,
                                                example_dataframe_loaded):

        assert isinstance(
            load_data_for_simulation(example_dataframe_loaded,
                                     ['Input1'])[1][0], np.ndarray)
Esempio n. 17
0
    def test_correct_number_of_outputs(self):

        assert len(load_data_for_simulation(np.ones(3))) == 5