Skip to content

Commit

Permalink
Added type hint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nvoxland committed Sep 7, 2023
1 parent 8a4809a commit 7707ef8
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions deeplake/core/chunk_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -1739,7 +1739,8 @@ def read_bytes_for_sample(self, global_sample_index: int) -> bytes:
buffer = chunk.memoryview_data
if not buffer:
return b""
if self.is_sequence and self.sequence_encoder is not None:
if self.is_sequence:
assert self.sequence_encoder is not None
start_idx, end_idx = self.sequence_encoder[global_sample_index]
end_idx -= 1
start_idx, end_idx = map(
Expand Down Expand Up @@ -2242,7 +2243,8 @@ def pop(
sample_id: Optional[int] = None,
):
if global_sample_index is None:
if self.is_sequence and self.sequence_encoder is not None:
if self.is_sequence:
assert self.sequence_encoder is not None

Check warning on line 2247 in deeplake/core/chunk_engine.py

View check run for this annotation

Codecov / codecov/patch

deeplake/core/chunk_engine.py#L2247

Added line #L2247 was not covered by tests
global_sample_index = self.sequence_encoder.num_samples - 1
else:
global_sample_index = self.num_samples - 1
Expand All @@ -2263,7 +2265,8 @@ def pop(
link_callback(global_sample_index)

self.commit_diff.pop(global_sample_index, sample_id)
if self.is_sequence and self.sequence_encoder is not None:
if self.is_sequence:
assert self.sequence_encoder is not None
# pop in reverse order else indices get shifted
for idx in reversed(range(*self.sequence_encoder[global_sample_index])):
self.pop_item(idx)
Expand Down

0 comments on commit 7707ef8

Please sign in to comment.