Пример #1
0
def test_default_kwargs():
    class A(object):
        def __init__(self, a, b=2):
            self.a = a
            self.b = b

        def get_values(self):
            return self.a, self.b

    assert default_kwargs(A) == {"b": 2}

    def fn(a, b=2):
        return a, b

    assert default_kwargs(fn) == {"b": 2}

    def fn(b=2):
        return b

    assert default_kwargs(fn) == {"b": 2}

    def fn(b):
        return b

    assert default_kwargs(fn) == {}
Пример #2
0
    def get_output_schema(cls):
        """Get the output schema. Overrides the default `cls.output_schema`
        """
        output_schema = deepcopy(cls.output_schema)

        # get the default kwargs
        kwargs = default_kwargs(cls)

        # figure out the input shape
        mock_input_transform = ReorderedOneHot(
            alphabet=kwargs['alphabet'],
            dtype=kwargs['dtype'],
            alphabet_axis=kwargs['alphabet_axis'],
            dummy_axis=kwargs['dummy_axis'])
        input_shape = mock_input_transform.get_output_shape(
            kwargs['auto_resize_len'])

        # modify it
        output_schema.inputs.shape = input_shape

        # (optionally) get rid of the target shape
        if kwargs['ignore_targets']:
            output_schema.targets = None

        return output_schema
Пример #3
0
 def get_output_schema(cls):
     output_schema = deepcopy(cls.output_schema)
     kwargs = default_kwargs(cls)
     ignore_targets = kwargs['ignore_targets']
     if ignore_targets:
         output_schema.targets = None
     return output_schema