Skip to content

Commit

Permalink
fix pickling issue
Browse files Browse the repository at this point in the history
  • Loading branch information
j-luo93 committed Sep 23, 2019
1 parent 901c5cb commit 0ea0324
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 0 additions & 1 deletion nd/dataset/vocab.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ def build_vocabs(path, lost_lang, known_lang, max_size=0):

@dataclass(frozen=True, order=True)
class Word:
__slots__ = ['lang', 'form', 'idx']
lang: str
form: str
idx: int
Expand Down
7 changes: 6 additions & 1 deletion nd/magic_tensor/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,12 @@ def __getattribute__(self, attr):
try:
return super().__getattribute__(attr)
except AttributeError:
orig = getattr(self.tensor, attr)
try:
tensor = super().__getattribute__('_tensor')
except AttributeError:
raise

orig = getattr(tensor, attr)
if attr in _SAFE_METHODS:
setattr(self, attr, orig)
elif attr in _SAFE_METHODS_WITH_WRAPPER:
Expand Down

0 comments on commit 0ea0324

Please sign in to comment.