This Hashable package defines a class, Hashable, for types that can be converted to a hash value. This class exists for the benefit of hashing-based data structures. The package provides instances for basic types and a way to combine hash values.
Questions tagged [hashable]
161 questions
0
votes
0 answers
Swift - What is the difference between implementing Hashable and Equatable and NSObject hash and isEqual overrides
I'm trying to wrap my head around the new DiffableDataSource way of handling data in tableviews/collectionviews and during testing I came across a strange crash.
I would expect that the two implementations below would work exactly the…

L3M0L
- 429
- 8
- 23
0
votes
0 answers
Type Error - Unhashable Type List - Before Method Call
So, I'm working on programming problem website where you submit answers to programming problems using a class called solution. You submit your code with a specially named method that the website uses to see if you are able to answer the question.
I…

Campbell Hutcheson
- 549
- 2
- 4
- 12
0
votes
1 answer
Pandas Multi–Column Pie Plot with "TypeError: Int64Index.name must be a hashable type"
I am quite new to coding, and this seems to be some fundamental aspect of Python/Pandas/Matplotlib that I am not understanding. I am happy with general answers, but, for reference, here is my specific context:
top_100.index = top_100.Company
top_100…

Renzzy
- 25
- 1
- 8
0
votes
1 answer
How to natively hash a struct without randomization?
Is it possible to hash a struct without randomization natively in Swift?
struct Kiwi: Hashable {
let userId: String
let selections: Set
init(userId: String, selections: Set) {
self.userId = userId
…

lurning too koad
- 2,698
- 1
- 17
- 47
0
votes
1 answer
Error interpreting categorical data: all items must be hashable [statsmodel]
I'm trying to use linear mixed-effects model from statsmodel. And I get an error message:
Error interpreting categorical data: all items must be hashable
fc ~ group * session
^^
Where "fc" is a column in my data frame which contains a 1D…

stasia_l
- 47
- 6
0
votes
1 answer
How can I cast a an array of protocol X to `Hashable` if the class conform to X is Hashable?
I have a protocol my TableView cell controllers conform too:
protocol TableViewCellController {
func view(in tableView: UITableView) -> UITableViewCell
func cancelLoad()
func prefetch()
}
extension TableViewCellController {
func prefetch()…

Teddy K
- 820
- 1
- 6
- 17
0
votes
0 answers
Does Python itself break inheritance foundations with Hashable class?
from collections import Hashable
issubclass(list, object) # True
issubclass(object, Hashable) # True
issubclass(list, Hashable) # False
I thought that inheritance was a transitive relationship. So if "A inherits from B" and "B inherits…
user3479249
0
votes
2 answers
ForEach view for collection of lists. What is the identifiable for list? Cannot convert value of type 'Text' to closure result type '_'
I have state data which is a collection of lists with key: values from json. I want to use ForEach View to show each list items in one list view but I'm getting Error. So I read that ForEach requires unique identifier, is there a hashable protocol…

ilaunchpad
- 1,283
- 3
- 16
- 32
0
votes
0 answers
AnyHashable dictionary conversion, changes a key value(is also a Dictionary) of the result dictionary into a String instead of Dictionary
This is the result dictionary getting when I converted the Dictionary to Dictionary,
{
…

Harsha
- 760
- 1
- 7
- 21
0
votes
1 answer
Swift Protocols: can I restrict associated types?
I have set of protocols:
protocol SpaceInterpolatorProtocol {
associatedtype Axis: SpaceAxisProtocol
associatedtype Spot: SpaceAxisSpotProtocol
associatedtype Vertex: SpaceVertexProtocol
....
}
protocol SpaceAxisProtocol: Equatable &…

Łukasz
- 773
- 5
- 23
0
votes
0 answers
Why mutable Type in Python also having a Hash Method when we do dir(mutable_obj)
I was reading about hashable in Python and got the idea that in python a hashable obj must have hash and eq method defined. That makes sense to me as of now and I am learning more about it.
But in between, one thing going in my mind is when I did…

Prashant Pathak
- 173
- 1
- 2
- 12
0
votes
2 answers
How to implement hash(into hasher: inout Hasher) for a struct
I have a struct, Student that conforms to Hashable protocol but I am getting an error for the hash(into:) method.
struct Student: Hashable{
let studentID: Int
let name: String
init(studentID id:Int, andName name: String){
…

Natasha
- 6,651
- 3
- 36
- 58
0
votes
1 answer
Python : 'Series' objects are mutable, thus they cannot be hashed
I have a DataFrame df with text as below :
|---------------------|-----------------------------------|
| File_name | Content |
…

Lorenna Van Munnecom
- 117
- 2
- 10
0
votes
2 answers
how to iterate using iterrows() and check for a subset
I would find the rows in a dataframe which contains all of the elements of a tuple and then set a value in a specific column for the corrisponding index of the row
for ix, row in df.iterrows():
if set(tuple).issubset(row):
df.loc[ix,…

Guido Cei
- 5
- 4
0
votes
1 answer
App Crashing with error: generic parameter 'T' could not be inferred
I'm trying to get custom object which is hashable from UserDefault.
My custom model is defined below:
class WorkerProfileResponse: Mappable, Hashable{
static func == (lhs: WorkerProfileResponse, rhs: WorkerProfileResponse) -> Bool {
…

Faraz Ahmed Khan
- 71
- 2
- 12