-
Notifications
You must be signed in to change notification settings - Fork 74
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
TypeError: Unhashable type: 'list' #58
Comments
I'm using test tube with pytorch lightning and experienced the same issue. Any thoughts? |
Can you use a Tuple instead? |
I ran into this problem and ended up creating a function to convert strings to tuples so when These are the methods I used (since in my case I needed lists of strings and integers):
And then using the example in the OP, I called
Ultimately, however, I ended up not using the |
The problem is that you can't use a list as the key in a dict, since dict keys need to be immutable. This means that when you try to hash an unhashable object it will result an error. For ex. when you use a list as a key in the dictionary , this cannot be done because lists can't be hashed. The standard way to solve this issue is to cast a list to a tuple . TypeError: unhashable type: 'list' usually means that you are trying to use a list as an hash argument. The standard way to solve this issue is to cast a list to tuple. Though tuples may seem similar to lists, they are often used in different situations and for different purposes. Tuples can be used as keys if they contain only strings, numbers, or tuples; if a tuple contains any mutable object either directly or indirectly, it cannot be used as a key. You can’t use lists as key. |
I am trying to extend my existing argparse with the
HyperOptArgumentParser
class. In my current argparse I have two options which arenargs
list.When I do the following,
I get this error:
How can I fix this?
The text was updated successfully, but these errors were encountered: