".github/git@developer.sourcefind.cn:change/sglang.git" did not exist on "80002562a8158b5c531f2ab81155da313a2a5cd6"
Commit da7925b7 authored by Chris Shallue's avatar Chris Shallue Committed by Christopher Shallue
Browse files

Deal with empty input arrays in kepler_spline.choose_kepler_spline().

PiperOrigin-RevId: 201007094
parent 9546b04c
...@@ -187,7 +187,8 @@ def choose_kepler_spline(all_time, ...@@ -187,7 +187,8 @@ def choose_kepler_spline(all_time,
# model and sigma is the constant standard deviation for all flux values. # model and sigma is the constant standard deviation for all flux values.
# Moreover, we assume that s[i] ~= s[i+1]. Therefore, # Moreover, we assume that s[i] ~= s[i+1]. Therefore,
# (f[i+1] - f[i]) / sqrt(2) ~ N(0, sigma^2). # (f[i+1] - f[i]) / sqrt(2) ~ N(0, sigma^2).
scaled_diffs = np.concatenate([np.diff(f) / np.sqrt(2) for f in all_flux]) scaled_diffs = [np.diff(f) / np.sqrt(2) for f in all_flux]
scaled_diffs = np.concatenate(scaled_diffs) if scaled_diffs else np.array([])
if not scaled_diffs.size: if not scaled_diffs.size:
best_spline = [np.array([np.nan] * len(f)) for f in all_flux] best_spline = [np.array([np.nan] * len(f)) for f in all_flux]
metadata.light_curve_mask = [ metadata.light_curve_mask = [
......
...@@ -79,6 +79,19 @@ class KeplerSplineTest(absltest.TestCase): ...@@ -79,6 +79,19 @@ class KeplerSplineTest(absltest.TestCase):
class ChooseKeplerSplineTest(absltest.TestCase): class ChooseKeplerSplineTest(absltest.TestCase):
def testEmptyInput(self):
# Logarithmically sample candidate break point spacings.
bkspaces = np.logspace(np.log10(0.5), np.log10(5), num=20)
spline, metadata = kepler_spline.choose_kepler_spline(
all_time=[],
all_flux=[],
bkspaces=bkspaces,
penalty_coeff=1.0,
verbose=False)
np.testing.assert_array_equal(spline, [])
np.testing.assert_array_equal(metadata.light_curve_mask, [])
def testNoPoints(self): def testNoPoints(self):
all_time = [np.array([])] all_time = [np.array([])]
all_flux = [np.array([])] all_flux = [np.array([])]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment