Skip to content

Commit

Permalink
fixed python 3.9 isinstance bug
Browse files Browse the repository at this point in the history
  • Loading branch information
pauladkisson committed Sep 24, 2024
1 parent 667ebb8 commit ae8d6e6
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/roiextractors/imagingextractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"""

from abc import ABC, abstractmethod
from typing import Union, Optional, Tuple
from typing import Union, Optional, Tuple, get_args
from copy import deepcopy

import numpy as np
Expand Down Expand Up @@ -244,8 +244,8 @@ def frame_slice(self, start_frame: Optional[int] = None, end_frame: Optional[int
assert (
start_frame <= end_frame
), f"'start_frame' ({start_frame}) must be less than or equal to 'end_frame' ({end_frame})"
assert isinstance(start_frame, IntType), "'start_frame' must be an integer"
assert isinstance(end_frame, IntType), "'end_frame' must be an integer"
assert isinstance(start_frame, get_args(IntType)), "'start_frame' must be an integer"
assert isinstance(end_frame, get_args(IntType)), "'end_frame' must be an integer"

return FrameSliceImagingExtractor(parent_imaging=self, start_frame=start_frame, end_frame=end_frame)

Expand Down Expand Up @@ -306,8 +306,9 @@ def get_video(self, start_frame: Optional[int] = None, end_frame: Optional[int]
assert (
start_frame <= end_frame
), f"'start_frame' ({start_frame}) must be less than or equal to 'end_frame' ({end_frame})"
assert isinstance(start_frame, int), "'start_frame' must be an integer"
assert isinstance(end_frame, int), "'end_frame' must be an integer"
# python 3.9 doesn't support get_instance on a Union of types, so we use get_args
assert isinstance(start_frame, get_args(IntType)), "'start_frame' must be an integer"
assert isinstance(end_frame, get_args(IntType)), "'end_frame' must be an integer"

start_frame_shifted = start_frame + self._start_frame
end_frame_shifted = end_frame + self._start_frame
Expand Down

0 comments on commit ae8d6e6

Please sign in to comment.