Skip to content

Commit 4e34e5a

Browse files
Fix serialization errors.
1 parent 5d48636 commit 4e34e5a

File tree

4 files changed

+7
-5
lines changed

4 files changed

+7
-5
lines changed

diplomat/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
A tool providing multi-animal tracking capabilities on top of other Deep learning based tracking software.
33
"""
44

5-
__version__ = "0.3.1"
5+
__version__ = "0.3.2"
66
# Can be used by functions to determine if diplomat was invoked through it's CLI interface.
77
CLI_RUN = False
88

diplomat/predictors/fpe/frame_passes/optimize_std.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def run_pass(
5151
result = super().run_pass(fb_data, prog_bar, in_place, reset_bar)
5252

5353
approx_std = (self._histogram.get_quantile(0.5)[2] / self.MAGIC_CONST) * self.config.std_multiplier
54-
result.metadata.optimal_std = (*self._histogram.get_bin_for_value(approx_std)[:2], approx_std)
54+
result.metadata.optimal_std = (*self._histogram.get_bin_for_value(approx_std)[:2], float(approx_std))
5555

5656
if(self.config.DEBUG):
5757
print(f"Optimal STD: {result.metadata.optimal_std}")

diplomat/predictors/fpe/skeleton_structures.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ def add(self, value: float, weight: int = 1):
302302
def get_bin_for_value(self, value: float) -> Tuple[float, int, float]:
303303
val_bin = int((value - self._bin_offset) / self._bin_size)
304304
freq, avg = self._bins.get(val_bin, (0, value))
305-
return (val_bin * self._bin_size + self._bin_offset, freq, avg)
305+
return (float(val_bin * self._bin_size + self._bin_offset), int(freq), float(avg))
306306

307307
def __iter__(self) -> Iterable[float]:
308308
return (b * self._bin_size + self._bin_offset for b in self._bins)

diplomat/predictors/sfpe/file_io.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -366,8 +366,10 @@ def _is_fully_covered_no_overlap(self):
366366
def _encode_meta_chunk(self, data: dict = None) -> bytes:
367367
if(data is None):
368368
data = {}
369-
370-
return zlib.compress(json.dumps(data, cls=FPEMetadataEncoder).encode(), self._compression_level)
369+
try:
370+
return zlib.compress(json.dumps(data, cls=FPEMetadataEncoder).encode(), self._compression_level)
371+
except TypeError as e:
372+
raise ValueError(f"Bad metadata object: {data}") from e
371373

372374
def _decode_meta_chunk(self, data: bytes) -> dict:
373375
if(len(data) == 0):

0 commit comments

Comments
 (0)