Commit 0c6be646 authored by Mitar's avatar Mitar
Browse files

Convert to a regular List type.

parent 1ccab6d0
Pipeline #23117201 failed with stage
in 2 minutes and 27 seconds
......@@ -11,8 +11,8 @@ __all__ = ('MonomialPrimitive',)
# It is useful to define these names, so that you can reuse it both
# for class type arguments and method signatures.
Inputs = container.List[float]
Outputs = container.List[float]
Inputs = container.List
Outputs = container.List
class Params(params.Params):
......@@ -90,7 +90,7 @@ class MonomialPrimitive(supervised_learning.SupervisedLearnerPrimitiveBase[Input
result = (self._a * input + self.hyperparams['bias'] for input in inputs)
# We convert a regular list to container list which supports metadata attribute.
outputs: container.List[float] = container.List[float](result)
outputs: container.List = container.List(result)
# Even if the structure of outputs is the same as inputs, conceptually, outputs
# are different, they are new data. So we do not reuse metadata from inputs but create
......
......@@ -84,7 +84,7 @@ class RandomPrimitive(generator.GeneratorPrimitiveBase[Outputs, None, Hyperparam
self._random_state = numpy.random.RandomState(self.random_seed)
def produce(self, *, inputs: container.List[None], timeout: float = None, iterations: int = None) -> base.CallResult[Outputs]:
def produce(self, *, inputs: container.List, timeout: float = None, iterations: int = None) -> base.CallResult[Outputs]:
result = self._random_state.normal(self.hyperparams['mu'], self.hyperparams['sigma'], len(inputs))
# We convert a regular ndarray to a container DataFrame which supports metadata attribute.
......
......@@ -20,10 +20,10 @@ DOCKER_KEY = 'summing'
# for class type arguments and method signatures.
# This is just an example of how to define a more complicated input type,
# which is in fact more restrictive than what the primitive can really handle.
# One could probably just use "typing.Container" in this case, if accepting
# One could probably just use "typing.Union[typing.Container]" in this case, if accepting
# a wide range of input types.
Inputs = typing.Union[container.ndarray, container.DataFrame, container.List[float], container.List[container.List[float]]]
Outputs = container.List[float]
Inputs = typing.Union[container.ndarray, container.DataFrame, container.List]
Outputs = container.List
class Hyperparams(hyperparams.Hyperparams):
......@@ -143,7 +143,7 @@ class SumPrimitive(transformer.TransformerPrimitiveBase[Inputs, Outputs, Hyperpa
result = float(response.read())
outputs = container.List[float]((result,))
outputs = container.List((result,))
# Outputs are different from inputs, so we do not reuse metadata from inputs but create
# new metadata. We do this by clearing old metadata which keeps history and link the
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment