Skip to content
This repository has been archived by the owner on Jul 10, 2021. It is now read-only.

Commit

Permalink
Fix for Python3.4 build, requiring a __hash__ to work.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexjc committed May 8, 2015
1 parent e2f50e8 commit 9d88196
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions sknn/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,26 @@ class FastVectorSpace(VectorSpace):

@functools.wraps(VectorSpace._validate)
def _validate(self, is_numeric, batch):
"""
Short-circuit the entire validation if the user has specified it's not necessary.
"""
pass

def __eq__(self, other):
"""
Equality should work between Fast and slow VectorSpace instances.
"""
return (type(other) in (FastVectorSpace, VectorSpace)
and self.dim == other.dim
and self.sparse == other.sparse
and self.dtype == other.dtype)

def __hash__(self):
"""
Override necessary for Python 3.x.
"""
return hash((type(VectorSpace), self.dim, self.sparse, self.dtype))


class SparseDesignMatrix(Dataset):
"""
Expand Down

0 comments on commit 9d88196

Please sign in to comment.