Skip to content

Commit

Permalink
BUG: fix to_dict() for nested selections
Browse files Browse the repository at this point in the history
  • Loading branch information
jakevdp committed Apr 29, 2020
1 parent 8f942ed commit 1854ef0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 6 additions & 2 deletions altair/vegalite/v3/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,14 @@ def __repr__(self):
return "Selection({0!r}, {1})".format(self.name, self.selection)

def ref(self):
return {"selection": self.name}
return self.to_dict()

def to_dict(self):
return {"selection": self.name}
return {
"selection": self.name
if isinstance(self.name, str)
else self.name.to_dict()
}

def __invert__(self):
return Selection(core.SelectionNot(**{"not": self.name}), self.selection)
Expand Down
8 changes: 6 additions & 2 deletions altair/vegalite/v4/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,14 @@ def __repr__(self):
return "Selection({0!r}, {1})".format(self.name, self.selection)

def ref(self):
return {"selection": self.name}
return self.to_dict()

def to_dict(self):
return {"selection": self.name}
return {
"selection": self.name
if isinstance(self.name, str)
else self.name.to_dict()
}

def __invert__(self):
return Selection(core.SelectionNot(**{"not": self.name}), self.selection)
Expand Down

0 comments on commit 1854ef0

Please sign in to comment.