PySpice icon indicating copy to clipboard operation
PySpice copied to clipboard

Spice.Parser.SpiceParser fails in "Bad kwarg".

Open aoki-works opened this issue 3 years ago • 0 comments

Environment (OS, Python version, PySpice version, simulator)

OS : Windows 10 Python version : 3.8 PySpice version : 1.5

Expected Behaviour

SpiceParser should parse the following subckt.

.SUBCKT LVMOS 1 2 3
M0 1 22 3 3 smsmosfet
*
.MODEL smsmosfet NMOS
+ L =7.5e-07
+ W =11
+ AD =1.1E-005
+ AS =1.1E-005
+ PD =22
+ PS =22
.ENDS

Actual Behaviour

SpiceParser fails if there is no space after equal, as in the following error message. If put a space after the equal, SpiceParser works fine.

c:\venv\lib\site-packages\PySpice\Spice\Parser.py in get_kwarg(text)
    748                 i += 3
    749             else:
--> 750                 raise ParseError("Bad kwarg: {}".format(text))
    751
    752         return dict_parameters

ParseError: Bad kwarg: L =7.5e-07  W =11  AD =1.1E-005  AS =1.1E-005  PD =22  PS =22

Spice.Parser.SpiceParser.Line.get_kwarg() does not seem to support this notation.
As a workaround, I modified get_kwarg() as follows. I added line 735.
I hope this issue will be officially resolved.

726    @staticmethodkk
727    def get_kwarg(text):
728
729        dict_parameters = {}
730
731        parts = []
732        for part in text.split():
733            if '=' in part and part != '=':
734                left, right = [x for x in part.split('=')]
735                if left:
736                    parts.append(left)
737                parts.append('=')
738                if right:
739                    parts.append(right)
740            else:
741                parts.append(part)

aoki-works avatar May 31 '22 07:05 aoki-works