impedance.py icon indicating copy to clipboard operation
impedance.py copied to clipboard

Suggestion: pass in initial_guess as dictionary

Open edmundsj opened this issue 3 years ago • 0 comments

Is your feature request related to a problem? Please describe. Since this package circuit description relies on named elements (R0, R1, C1, etc.) it seems more natural to me (having just read the example) to pass in an initial_guess for values of those elements as a dictionary rather than an array. This would eliminate all ambiguity regarding ordering for elements that have multi-valued parameters.

Describe the solution you'd like

from impedance.models.circuits import CustomCircuit

circuit = 'R0-p(R1,C1)-p(R2-Wo1,C2)'
initial_guess = [.01, .01, 100, .01, .05, 100, 1]

circuit = CustomCircuit(circuit, initial_guess=initial_guess)

would instead be:

from impedance.models.circuits import CustomCircuit

circuit = 'R0-p(R1,C1)-p(R2-Wo1,C2)'
initial_guess = {'R0: .01, 'R1': .01, 'C1': 100, 'R2': .01, 'Wo1': [.05, 100], 'C2': 100]

circuit = CustomCircuit(circuit, initial_guess=initial_guess)

Describe alternatives you've considered While an array is not an unreasonable way to pass in an initial guess, it's prone to errors and mis-typing. You could even leave in the option to pass in an array so as not to break the API and introduce the dict is an additional option, then eventually phase out the array.

Additional context I'm an electrical engineering Ph.D. candidate at UC Berkeley. Thanks for this package :D

edmundsj avatar Jun 02 '22 18:06 edmundsj