Skip to content

Commit

Permalink
Fix Set encoding
Browse files Browse the repository at this point in the history
- The bits were in the wrong order before.
  • Loading branch information
gburca committed Aug 6, 2024
1 parent 67f3e66 commit ff7f827
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion sbe/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,8 @@ class Set:

def encode(self, vals: Iterable[str]) -> int:
vals = set(vals)
return bitstring.BitArray(v.name in vals for i, v in enumerate(self.choices)).uint
assert vals.issubset({c.name for c in self.choices}), f"{vals} is not a subset of {self.choices}"
return bitstring.BitArray(v.name in vals for v in reversed(self.choices)).uint

def decode(self, val: int) -> List[str]:
if isinstance(self.encodingType, SetEncodingType):
Expand Down

0 comments on commit ff7f827

Please sign in to comment.