Skip to content

Commit 2e2a7c0

Browse files
committed
Duplicated '_midpoint' function from 'murfey.client.contexts.tomo' to preserve client-server independence
1 parent 19f2f31 commit 2e2a7c0

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/murfey/server/__init__.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
import murfey.server.prometheus as prom
4949
import murfey.server.websocket
5050
import murfey.util.db as db
51-
from murfey.client.contexts.tomo import _midpoint
5251
from murfey.server.murfey_db import url # murfey_db
5352
from murfey.util import LogFilter
5453
from murfey.util.config import (
@@ -165,6 +164,24 @@ def _mc_path(mov_path: Path) -> str:
165164
return [_mc_path(Path(r.movie_path)) for r in results]
166165

167166

167+
def _midpoint(angles: List[float]) -> int:
168+
"""
169+
Duplicate of the function in 'murfey.client.contexts.tomo', so as to preserve
170+
client-server independence.
171+
"""
172+
if not angles:
173+
return 0
174+
if len(angles) <= 2:
175+
return round(angles[0])
176+
sorted_angles = sorted(angles)
177+
return round(
178+
sorted_angles[len(sorted_angles) // 2]
179+
if sorted_angles[len(sorted_angles) // 2]
180+
and sorted_angles[len(sorted_angles) // 2 + 1]
181+
else 0
182+
)
183+
184+
168185
def get_job_ids(tilt_series_id: int, appid: int) -> JobIDs:
169186
results = murfey_db.exec(
170187
select(

0 commit comments

Comments
 (0)