Skip to content
This repository has been archived by the owner on May 31, 2023. It is now read-only.

Commit

Permalink
report largestSegmentId for uint64 as 2**53-1 (#116)
Browse files Browse the repository at this point in the history
* report largestSegmentId for uint64 as 2**53-1 which is the max safe integer in JS
  • Loading branch information
normanrz authored Aug 31, 2021
1 parent c220def commit 59d9209
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion wkconnect/webknossos/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,12 @@ def __post_init__(self) -> None:
assert self.elementClass in ["uint8", "uint16", "uint24", "uint32", "uint64"]
if self.category == "segmentation":
if self.largestSegmentId is None:
self.largestSegmentId = cast(int, np.iinfo(self.elementClass).max)
if self.elementClass == "uint64":
# See max safe integer in JS
# https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER
self.largestSegmentId = cast(int, 2 ** 53 - 1)
else:
self.largestSegmentId = cast(int, np.iinfo(self.elementClass).max)
self.mappings = []
self.wkwResolutions = [
{"resolution": i, "cubeLength": 1024} for i in self.resolutions
Expand Down

0 comments on commit 59d9209

Please sign in to comment.