コード例 #1
0
class TestTransformer(object):
    def setUp(self):
        self.data_stream = FlagDataStream(IterableDataset([1, 2, 3]))
        self.transformer = Transformer(self.data_stream)

    def test_close(self):
        # Transformer.close should call its wrapped stream's close method
        self.transformer.close()
        assert self.data_stream.close_called

    def test_reset(self):
        # Transformer.reset should call its wrapped stream's reset method
        self.transformer.reset()
        assert self.data_stream.reset_called

    def test_next_epoch(self):
        # Transformer.next_epoch should call its wrapped stream's next_epoch
        # method
        self.transformer.next_epoch()
        assert self.data_stream.next_epoch_called

    def test_get_data_from_example_not_implemented(self):
        self.transformer.batch_input = False
        assert_raises(NotImplementedError, self.transformer.get_data)

    def test_get_data_from_batch_not_implemented(self):
        self.transformer.batch_input = True
        assert_raises(NotImplementedError, self.transformer.get_data)
コード例 #2
0
ファイル: test_transformers.py プロジェクト: DavidDJChen/fuel
class TestTransformer(object):
    def setUp(self):
        self.data_stream = FlagDataStream(IterableDataset([1, 2, 3]))
        self.transformer = Transformer(self.data_stream)

    def test_close(self):
        # Transformer.close should call its wrapped stream's close method
        self.transformer.close()
        assert self.data_stream.close_called

    def test_reset(self):
        # Transformer.reset should call its wrapped stream's reset method
        self.transformer.reset()
        assert self.data_stream.reset_called

    def test_next_epoch(self):
        # Transformer.next_epoch should call its wrapped stream's next_epoch
        # method
        self.transformer.next_epoch()
        assert self.data_stream.next_epoch_called

    def test_get_data_from_example_not_implemented(self):
        self.transformer.batch_input = False
        assert_raises(NotImplementedError, self.transformer.get_data)

    def test_get_data_from_batch_not_implemented(self):
        self.transformer.batch_input = True
        assert_raises(NotImplementedError, self.transformer.get_data)
コード例 #3
0
class TestTransformer(object):
    def setUp(self):
        self.data_stream = FlagDataStream(IterableDataset([1, 2, 3]))
        self.transformer = Transformer(
            self.data_stream, produces_examples=True)

    def test_close(self):
        # Transformer.close should call its wrapped stream's close method
        self.transformer.close()
        assert self.data_stream.close_called

    def test_reset(self):
        # Transformer.reset should call its wrapped stream's reset method
        self.transformer.reset()
        assert self.data_stream.reset_called

    def test_next_epoch(self):
        # Transformer.next_epoch should call its wrapped stream's next_epoch
        # method
        self.transformer.next_epoch()
        assert self.data_stream.next_epoch_called

    def test_value_error_on_request(self):
        assert_raises(ValueError, self.transformer.get_data, [0, 1])

    def test_batch_to_example_and_vice_versa_not_implemented(self):
        self.transformer.produces_examples = False
        self.transformer.get_epoch_iterator()
        assert_raises(NotImplementedError, self.transformer.get_data)

    def test_transform_example_not_implemented_by_default(self):
        assert_raises(
            NotImplementedError, self.transformer.transform_example, None)

    def test_transform_batch_not_implemented_by_default(self):
        assert_raises(
            NotImplementedError, self.transformer.transform_batch, None)
コード例 #4
0
ファイル: test_transformers.py プロジェクト: markusnagel/fuel
class TestTransformer(object):
    def setUp(self):
        self.data_stream = FlagDataStream(IterableDataset([1, 2, 3]))
        self.transformer = Transformer(
            self.data_stream, produces_examples=True)

    def test_close(self):
        # Transformer.close should call its wrapped stream's close method
        self.transformer.close()
        assert self.data_stream.close_called

    def test_reset(self):
        # Transformer.reset should call its wrapped stream's reset method
        self.transformer.reset()
        assert self.data_stream.reset_called

    def test_next_epoch(self):
        # Transformer.next_epoch should call its wrapped stream's next_epoch
        # method
        self.transformer.next_epoch()
        assert self.data_stream.next_epoch_called

    def test_value_error_on_request(self):
        assert_raises(ValueError, self.transformer.get_data, [0, 1])

    def test_batch_to_example_and_vice_versa_not_implemented(self):
        self.transformer.produces_examples = False
        self.transformer.get_epoch_iterator()
        assert_raises(NotImplementedError, self.transformer.get_data)

    def test_transform_example_not_implemented_by_default(self):
        assert_raises(
            NotImplementedError, self.transformer.transform_example, None)

    def test_transform_batch_not_implemented_by_default(self):
        assert_raises(
            NotImplementedError, self.transformer.transform_batch, None)