Skip to content

Commit

Permalink
Fix tests (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
juanep97 authored Dec 14, 2023
1 parent 8e71d44 commit aa4b5d1
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 14 deletions.
10 changes: 10 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
comment: false

coverage:
status:
project:
default:
target: 80%
patch:
default:
target: 50%
2 changes: 0 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- name: create and activate env
uses: conda-incubator/setup-miniconda@v3
with:
Expand Down Expand Up @@ -64,7 +63,6 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- name: create and activate env
uses: conda-incubator/setup-miniconda@v3
with:
Expand Down
4 changes: 2 additions & 2 deletions mutis/lib/signal.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ def lc_gen_psd_nft(times, values):
compute the power spectral density and to reconstruct the
randomised signal."""

k = np.arange(-times.size // 2, times.size / 2)
n = k.size
k = np.arange(-times.size / 2, times.size / 2)
n = 2* (k.size//2)

nft = nfft.nfft_adjoint(
(times - (times.max() + times.min()) / 2) / np.ptp(times), values, n, use_fft=True
Expand Down
9 changes: 0 additions & 9 deletions mutis/signal.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,6 @@ class Signal:

def __init__(self, times, values, dvalues=None, fgen=None):

if times.dtype is not np.float64:
log.warning('times.dtype not float64, which may cause erros when using numba, casting automatically.')

if values.dtype is not np.float64:
log.warning('values.dtype not float64, which It may cause erros when using numba, casting automatically.')

if dvalues.dtype is not np.float64:
log.warning('dvalues.dtype not float64, which may cause erros when using numba, casting automatically.')

self.times = np.array(times, dtype=np.float64)
self.values = np.array(values, dtype=np.float64)
self.fgen = fgen
Expand Down
14 changes: 13 additions & 1 deletion mutis/tests/test_bayblocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,25 @@
from mutis import Signal

def test_bayblocks():

# test the bayblock algorithm with a signal that corresponds to 3 gaussian pulses in a row

t = np.linspace(0, 6, 50)
y = np.exp(-(t-1)**2/0.1) + np.exp(-(t-3)**2/0.1) + np.exp(-(t-5)**2/0.1)
dy = 0.1 * np.abs(y)

signal = Signal(t, y, dy)
bayblocks = BayesianBlocks(signal, p=1e-1)

bayblocks.get_flares()

# test that the signal and the bayblocks can be plotted
bayblocks.signal.plot()
bayblocks.plot()
assert len(bayblocks.get_flare_list()) == 3

assert len(bayblocks.get_flare_list()) == 3

## test that the flares can be plotted too

for flare in bayblocks.get_flare_list():
flare.plot()

0 comments on commit aa4b5d1

Please sign in to comment.