예제 #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)
예제 #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)
예제 #3
0
    def test_incorrect_input_names(self, example_dataframe_loaded):

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

        assert load_data_for_simulation(example_dataframe_loaded)[3] == 2
예제 #5
0
    def test_dataframe_n_runs(self, example_dataframe_loaded):

        assert load_data_for_simulation(example_dataframe_loaded)[2] == 2
예제 #6
0
    def test_dataframe_has_rows(self, example_dataframe_loaded):

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

        assert load_data_for_simulation(np.ones((3, 4)))[2] == 4
예제 #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]})])
예제 #9
0
    def test_infs_in_outcomes(self):

        with pytest.raises(ValueError):
            load_data_for_simulation(np.array([0, 1, np.inf]))
예제 #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)
예제 #11
0
    def test_more_than_2d_array(self):

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

        with pytest.raises(AttributeError):
            load_data_for_simulation(np.array([1]))
예제 #13
0
    def test_array_with_model_inputs(self):

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

        with pytest.raises(TypeError):
            load_data_for_simulation(example_dataframe_loaded, [1])
예제 #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)
예제 #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)
예제 #17
0
    def test_correct_number_of_outputs(self):

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