Skip to content

Commit

Permalink
fix: correct return value for coincidence_collect
Browse files Browse the repository at this point in the history
coincidence_collect can now return "None" when there are no coincidences

build: build system can now detect if running locally or on CI
  • Loading branch information
Peter-Barrow committed Sep 12, 2024
1 parent d09b872 commit 4f1aafd
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 84 deletions.
75 changes: 0 additions & 75 deletions .ipynb_checkpoints/setup-checkpoint.py

This file was deleted.

8 changes: 1 addition & 7 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,7 @@
from Cython.Build import cythonize
from setuptools import setup, Extension


local = True
print("CIBUILDWHEEL ", os.environ.get("CIBUILDWHEEL", '0'))
if os.environ.get("CIBUILDWHEEL", '0') == 1:
local = False
local = False

local = os.path.isdir("./local_testing/")
cython_dir = os.path.join("tangy_src")

extensions = []
Expand Down
9 changes: 7 additions & 2 deletions tangy_src/_tangy.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import cython
from cython.cimports import _tangy as _tangy
import warnings

import mmap
from os import dup, listdir, remove, makedirs
Expand Down Expand Up @@ -974,7 +975,7 @@ def coincidence_count(self, read_time: float, window: float,
@cython.ccall
def coincidence_collect(self, read_time: float, window: float,
channels: List[int],
delays: Optional[List[float]] = None) -> Records:
delays: Optional[List[float]] = None) -> Optional[Records]:
""" Collect coincident timetags
Collects the timetags in coincdience for the chosen channels over the
Expand Down Expand Up @@ -1021,6 +1022,10 @@ def coincidence_collect(self, read_time: float, window: float,
read_time,
cython.address(self._buf.records))

if count == 0:
warnings.warn("No coincidences found")
return None

slice: _tangy.tangy_field_ptrs
n_records: u64n = count * _n_channels

Expand Down Expand Up @@ -1731,7 +1736,7 @@ def __init__(self, file_path: str, name: str, length: int = 1000):
name, 1e-12, 1, 8, length, TangyBufferType.Standard)

self._timetag_offset = _tangy.srb_read_header_qutools(
self._buffer._ptr_rb, self._c_file_handle)
self._buffer._ptr_rb, self._c_file_handle)
return

def __del__(self):
Expand Down

0 comments on commit 4f1aafd

Please sign in to comment.