Skip to content
Snippets Groups Projects
Commit 4a77d168 authored by Arin Wongprommoon's avatar Arin Wongprommoon
Browse files

fix!(abc): Take multiple DataFrames as inputs

WHY IS THIS CHANGE NEEDED?:
- Function implementations of processes (i.e. process.as_function(...))
  are not able to take muliple DataFrames as inputs.
- This affects processes under multisignal.

HOW DOES THE CHANGE SOLVE THE PROBLEM?:
- PostProcessABC.as_function() assumed that there is only one input in
  the `data` argument.
- Change treats additional input DataFrames as arguments (*extra_data)
  after `data`.  This preserves behaviour for `core` processes that take
  one DataFrame as an input but also allows multiple DataFrame inputs to
  be processed.
- Change treats parameters as keyword arguments (**kwargs).
- *args renamed as *extra_data for readability.

WHAT SIDE EFFECTS DOES THIS CHANGE HAVE?:
- User needs to specify the keyword argument names and can't rely on
  position alone.  Otherwise, an KeyError will be raised.
- I do not add error handling in this case because I think if the error
  is raised, the solution is obvious enough, i.e.:

    output = multisignal_process.as_function(
        input1, input2, parameter1)

  will raise an error.  Change this to:

    output = multisignal_process.as_function(
        input1, input2, parameter1=parameter1)

EVIDENCE THAT COMMIT WORKS:
- I ran a script that uses both `multisignal` and `core` processes as
  functions in the format of the example above.  No errors returned.
- Tests pending.

REFERENCES:
- Issue #28
parent 56d61883
No related branches found
No related tags found
No related merge requests found
......@@ -15,10 +15,10 @@ class PostProcessABC(ProcessABC):
super().__init__(*args, **kwargs)
@classmethod
def as_function(cls, data, *args, **kwargs):
def as_function(cls, data, *extra_data, **kwargs):
# Find the parameter's default
parameters = cls.default_parameters(*args, **kwargs)
return cls(parameters=parameters).run(data)
parameters = cls.default_parameters(**kwargs)
return cls(parameters=parameters).run(data, *extra_data)
@classmethod
def default_parameters(cls, *args, **kwargs):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment