Skip to content

Non-integer oversampling factors cause index error in TLS pipeline #105

@e-gillis

Description

@e-gillis

When the Oversampling factor is set to a float with more than one decimal place, or a float less than 1, TLS fails because of an index error in the running_median function because a non-integer kernel is passed into running_median.

This happens when running_median is called through the spectra function, and can be reproduced by running:

from transitleastsquares import transitleastsquares
import numpy as np

# Random noise timeseries
t = np.linspace(0, 30, num=300)
data = np.random.normal(size=t.shape)*0.1 + 1

model = transitleastsquares(t, data)
# Any oversampling factor with more than two decimal places will cause an error
result = model.power(oversampling_factor=3.14)

Adding something like kernel = int(kernel) to the spectra function to ensure that the median filter kernel is an integer should fix this issue.

After submitting, I'm seeing that this was already discussed in the follow-ups to https://github.com/hippke/tls/issues/88, but it seems the bug is still outstanding.

Install Details:
MacOS, Python 3.10.7, TLS Version 1.0.31

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions