I am wondering if there is any idea to remove ' ' from tuple items in the passed and get the needed as below :
passed = (('XCl', 'XNa', 'Xwater'), 'WwaterNaCl', 'UwaterNaCl', 'VwaterNaCl', 'BNaCl')
needed = ((XCl, XNa, Xwater), WwaterNaCl, UwaterNaCl, VwaterNaCl, BNaCl)
what I 'm getting in my code are two lists:
vars = ['XCl', 'XNa', 'Xwater']
params = ['WwaterNaCl', 'UwaterNaCl', 'VwaterNaCl', 'BNaCl']
then the following are made:
[['XCl', 'XNa', 'Xwater'], 'WwaterNaCl', 'UwaterNaCl', 'VwaterNaCl', 'BNaCl']
turning to,
lam_pars = ((XCl, XNa, Xwater), BNaCl, WwaterNaCl, UwaterNaCl,
VwaterNaCl)
and should be passed in lambdify as following:
s_p = sp.lambdify(lam_pars, lnfca(), modules=["sympy"])
CodePudding user response:
To whom may find it useful, in the following way we can remove the quote and change string type to list or tuple:
vars = ['XCl', 'XNa', 'Xwater']
params = ['WwaterNaCl', 'UwaterNaCl', 'VwaterNaCl', 'BNaCl']
_symreg_1 = []
_symreg_2 = []
for i in vars:
_symreg_1 = sym.symbols(i ',')
print('_symreg_1:', type(_symreg_1), _symreg_1)
for i in params:
_symreg_2 = sym.symbols(i ',')
print('_symreg_2:', type(_symreg_2), _symreg_2)
_symreg_2.insert(0, _symreg_1)
print(_symreg_2)
>> _symreg_1: <class 'list'> [XCl, XNa, Xwater]
_symreg_2: <class 'list'> [WwaterNaCl, UwaterNaCl, VwaterNaCl, BNaCl]
[[XCl, XNa, Xwater], WwaterNaCl, UwaterNaCl, VwaterNaCl, BNaCl]
this way as list or tuple it can be passed to lambdify