def test_valid_predict_data_formats(self, mock_open, mock_load_model):
        def _valid_check(data):
            try:
                print("\tChecking data format: {}".format(str(type(data))))
                data = BaseDataLabeler._check_and_return_valid_data_format(
                    data, fit_or_predict='predict')
            except Exception as e:
                self.fail("Exception raised on input of accepted types.")
            return data

        valid_data = [
            CSVData(data=pd.DataFrame([])),
            JSONData(data=pd.DataFrame([])),
            ParquetData(data=pd.DataFrame([])),
            AVROData(data=pd.DataFrame([])),
            pd.DataFrame([]),
            list(),
            np.array([]),
            pd.Series([], dtype=object)
        ]
        print("\nValid Data Predict Checks:")
        for data in valid_data:
            data = _valid_check(data)
            self.assertTrue(
                isinstance(data, np.ndarray) or isinstance(data, pd.Series)
                or isinstance(data, pd.DataFrame))
Example #2
0
    def test_valid_fit_data_formats(self, *mocks):
        def _valid_check(data):
            try:
                print("\tChecking data format: {}".format(str(type(data))))
                data = UnstructuredDataLabeler._check_and_return_valid_data_format(
                    data, fit_or_predict="fit")
            except Exception as e:
                self.fail("Exception raised on input of accepted types.")
            return data

        valid_data = [
            CSVData(data=pd.DataFrame([])),
            JSONData(data=pd.DataFrame([])),
            ParquetData(data=pd.DataFrame([])),
            AVROData(data=pd.DataFrame([])),
            pd.DataFrame([]),
            list(),
            np.array([]),
        ]
        print("\nValid Data Fit Checks:")
        for data in valid_data:
            data = _valid_check(data)
            self.assertIsInstance(data, np.ndarray)