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

Pbc feature location fix #350

Merged
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
version: 2
formats: all
build:
os: ubuntu-22.04
tools:
python: "3.9"
python:
version: 3
install:
- requirements: doc/requirements.txt
- requirements: doc/requirements.txt
1 change: 1 addition & 0 deletions doc/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
ipykernel
nbsphinx
numpy
sphinx_rtd_theme
11 changes: 8 additions & 3 deletions tobac/segmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,13 @@ def add_markers(
marker_arr = marker_arr[np.newaxis, :, :]

if seed_3D_flag == "column":
for index, row in features.iterrows():
marker_arr[level, int(row["hdim_1"]), int(row["hdim_2"])] = row["feature"]
for _, row in features.iterrows():
# Offset marker locations by 0.5 to find nearest pixel
marker_arr[
level,
int(row["hdim_1"] + 0.5) % h1_len,
int(row["hdim_2"] + 0.5) % h2_len,
] = row["feature"]

elif seed_3D_flag == "box":
# Get the size of the seed box from the input parameter
Expand All @@ -123,7 +128,7 @@ def add_markers(
seed_h1 = seed_3D_size
seed_h2 = seed_3D_size

for index, row in features.iterrows():
for _, row in features.iterrows():
if is_3D:
# If we have a 3D input and we need to do box seeding
# we need to have 3D features.
Expand Down
5 changes: 4 additions & 1 deletion tobac/utils/periodic_boundaries.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,10 @@
angle_average = np.arctan2(sin_average, cos_average) % (2 * np.pi)
rescaled_average = (angle_average * scaling_factor) + low
# Round return value to try and supress rounding errors
return np.round(rescaled_average, 12)
rescaled_average = np.round(rescaled_average, 12)
if rescaled_average == high:
rescaled_average = low

Check warning on line 302 in tobac/utils/periodic_boundaries.py

View check run for this annotation

Codecov / codecov/patch

tobac/utils/periodic_boundaries.py#L302

Added line #L302 was not covered by tests
return rescaled_average


def transfm_pbc_point(in_dim, dim_min, dim_max):
Expand Down
Loading