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

Fixes old call to sort() method #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

orestesmas
Copy link

SPR 'master' fails to load raw ngspice data on python 3.6

>>> from spr import load_raw
>>> data=load_raw('SR-UWB.dat')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/....(entire path isn't relevant).../site-packages/spr/__init__.py", line 65, in load_raw
    ret["vars"].sort(cmp=lambda x, y: int(x["idx"])-int(y["idx"]))
TypeError: 'cmp' is an invalid keyword argument for this function

As stated somewhere on internet:

Technical Detail: If you’re transitioning from Python 2 and are familiar with its function of the same name, you should be aware of a >couple important changes in Python 3:

Python 3’s sorted() does not have a cmp parameter. Instead, only key is used to introduce custom sorting logic.
key and reverse must be passed as keyword arguments, unlike in Python 2, where they could be passed as positional arguments.

If you need to convert a Python 2 cmp function to a key function, then check out functools.cmp_to_key(). This tutorial will not cover any examples using Python 2.

SPR 'master' fails to load raw ngspice data on python 3.6

As stated somewhere on internet:


>Technical Detail: If you’re transitioning from Python 2 and are familiar with its function of the same name, you should be aware of a >couple important changes in Python 3:

>    Python 3’s sorted() does not have a cmp parameter. Instead, only key is used to introduce custom sorting logic.
>    key and reverse must be passed as keyword arguments, unlike in Python 2, where they could be passed as positional arguments.

>If you need to convert a Python 2 cmp function to a key function, then check out functools.cmp_to_key(). This tutorial will not cover any examples using Python 2.


>>> from spr import load_raw
>>> data=load_raw('SR-UWB.dat')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/orestes/Documents/Recerca/SuperReg/NgSpice/ngspice/lib/python3.6/site-packages/spr/__init__.py", line 65, in load_raw
    ret["vars"].sort(cmp=lambda x, y: int(x["idx"])-int(y["idx"]))
TypeError: 'cmp' is an invalid keyword argument for this function
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

Successfully merging this pull request may close these issues.

None yet

1 participant