Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_lambdifygenerated() missing 20 required positional arguments: #4

Closed
n1c0l492 opened this issue May 27, 2020 · 3 comments
Closed

_lambdifygenerated() missing 20 required positional arguments: #4

n1c0l492 opened this issue May 27, 2020 · 3 comments

Comments

@n1c0l492
Copy link

Error while running the multiLCAAlgebraic function.
The LCA model and parameters definition are the same used in version 0.0.8.

l = newFloatParam(  
    'l', #float parameter for deep well lenght
    default=2273, min=586, max=4727,  # Average lenght
    unit='m',
    description="float parameter for  well lenght, uniform distribution, centre on median value")

After update to 0.0.9, it is not working anymore.
Here the error outputted


TypeError                                 Traceback (most recent call last)
<ipython-input-23-b16c25db248f> in <module>
----> 1 multiLCAAlgebric(life_cycle, impact_list)

~\...\lca_algebraic\lca.py in multiLCAAlgebric(models, methods, **params)
    272 
    273         # Filter on required parameters
--> 274         df = postMultiLCAAlgebric(methods, lambdas, alpha=alpha, **params)
    275 
    276         model_name = _actName(model)

~\...\lca_algebraic\lca.py in postMultiLCAAlgebric(methods, lambdas, alpha, **params)
    201     # Use multithread for that
    202     with concurrent.futures.ThreadPoolExecutor() as exec:
--> 203         for imethod, value in exec.map(process, enumerate(lambdas)):
    204             res[imethod, :] = value
    205 

~\anaconda3\envs\bw\lib\concurrent\futures\_base.py in result_iterator()
    584                     # Careful not to keep a reference to the popped future
    585                     if timeout is None:
--> 586                         yield fs.pop().result()
    587                     else:
    588                         yield fs.pop().result(end_time - time.monotonic())

~\anaconda3\envs\bw\lib\concurrent\futures\_base.py in result(self, timeout)
    423                 raise CancelledError()
    424             elif self._state == FINISHED:
--> 425                 return self.__get_result()
    426 
    427             self._condition.wait(timeout)

~\anaconda3\envs\bw\lib\concurrent\futures\_base.py in __get_result(self)
    382     def __get_result(self):
    383         if self._exception:
--> 384             raise self._exception
    385         else:
    386             return self._result

~\anaconda3\envs\bw\lib\concurrent\futures\thread.py in run(self)
     54 
     55         try:
---> 56             result = self.fn(*self.args, **self.kwargs)
     57         except BaseException as exc:
     58             self.future.set_exception(exc)

~\...\lca_algebraic\lca.py in process(args)
    196         imethod = args[0]
    197         lambd_with_params : LambdaWithParamNames = args[1]
--> 198         value = alpha * lambd_with_params.compute(**params)
    199         return (imethod, value)
    200 

~\...\lca_algebraic\lca.py in compute(self, **params)
    138         # Filter on required parameters
    139         params = {key : val for key, val in params.items() if key in self.expanded_params}
--> 140         return self.lambd(**params)
    141 
    142 def preMultiLCAAlgebric(model: ActivityExtended, methods):

TypeError: _lambdifygenerated() missing 20 required positional arguments: 'OperatingHours', 'l', 'fNH3', 'HgAbatementRatio', 'AVGLoad', 'fCH4', 'fHg', 'AMISOutOfServiceHours', 'LifeTime', 'AuxNeed', 'FlowRate', 'MaintenancePeriod', 'ElecCapacity', 'fCO2', 'CO2AbatementRatio', 'fCO', 'fH2S', 'H2SAbatementRatio', 'MakeUpWellsRatio', and 'fNCG'
@raphaeljolivet
Copy link
Contributor

I cannot reproduce this issue.
I don't understand why you provided an example of deifinition of parameter, unrelated to this issue.
Could you maybe share minimalist notebook for reproducing the error ?

@n1c0l492
Copy link
Author

n1c0l492 commented May 27, 2020

Here a minimalist notebook.
Since the error seems to be related to the parameter, I shared with you the way I defined it.

Thank you

Issue #4 _lambdifygenerated() missing 20 required positional arguments.zip

EDIT:FIXED parameter do not create the issue

@n1c0l492
Copy link
Author

I tried to debug.
Using a local copy of the script in a new environment, I added this:

    def compute(self, **params):
        """Compute result value based of input parameters """
        # Filter on required parameters
        print(params) #NEW LINE
        params = {key : val for key, val in params.items() if key in self.expanded_params}
        return self.lambd(**params)

The output of multiLCAAlgebric(well_drilling, impact_list) is:

{}{}

{}
{}{}

{}
{}

and no computation is performed.
While passing a value: multiLCAAlgebric(well_drilling, impact_list, l=1):

{'l': array([1.])}{'l': array([1.])}

{'l': array([1.])}
{'l': array([1.])}
{'l': array([1.])}
{'l': array([1.])}
{'l': array([1.])}

And the LCA computation is performed.
So, it seems that no float to the lambdified function is passed since the dictionary is empty.
Do you have a suggestion?
Thank you

raphaeljolivet added a commit that referenced this issue May 28, 2020
@n1c0l492 n1c0l492 closed this as completed Jun 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants