Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tickets/DM-34158 #26

Merged
merged 1 commit into from
Apr 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 26 additions & 0 deletions scarlet/bbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,32 @@ def grow(self, radius):
shape = tuple([self.shape[d]+2*radius[d] for d in range(self.D)])
return Box(shape, origin=origin)

def shift(self, shift):
"""Shift this box in-place

Parameters
----------
shift: tuple of `int`
A tuple the same shape as `origin` to shift this box along each axis.
"""
self.origin = tuple(o + shift[i] for i, o in enumerate(self.origin))

def shifted_by(self, shift):
"""Generate a shifted copy of this box

Parameters
----------
shift: tuple of `int`
The amount to shift each axis to create the new box

Returns
-------
result: `Box`
The resulting bounding box.
"""
origin = tuple(o + shift[i] for i, o in enumerate(self.origin))
return Box(self.shape, origin=origin)

def __or__(self, other):
"""Union of two bounding boxes

Expand Down
2 changes: 2 additions & 0 deletions scarlet/lite/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from .component import *
from .frame import *
from .initialization import *
from .models import *
from .parameters import *
Expand Down