-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove old import + other style changes
Tidying up: remove import of deprecated `lc_tools`, change some test data, remove extraneous comments, add a couple of docstrings.
- Loading branch information
Showing
11 changed files
with
97 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
meta1,meta2,meta3,std_err | ||
0.180734306909,0.548427238218,0.187956237253,0.00540072367701 | ||
0.196072341892,1.17178931753,0.174802803661,0.00665375480667 | ||
0.558093146298,0.265003093326,0.10984235246,0.00811408738542 | ||
meta1,meta2,meta3,std_err,amplitude | ||
0.180734306909,0.548427238218,0.187956237253,0.00540072367701,0.0 | ||
0.196072341892,1.17178931753,0.174802803661,0.00665375480667,0.0 | ||
0.558093146298,0.265003093326,0.10984235246,0.00811408738542,0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
meta1,meta2,meta3,std_err,f | ||
0.180734306909,0.548427238218,0.187956237253,0.3622,0.3 | ||
0.196072341892,1.17178931753,0.174802803661,0.116672,0.2 | ||
0.558093146298,0.265003093326,0.10984235246,1.3343,1.4 | ||
meta1,meta2,meta3,std_err,amplitude,f | ||
0.180734306909,0.548427238218,0.187956237253,0.3622,0.0,0.3 | ||
0.196072341892,1.17178931753,0.174802803661,0.116672,0.0,0.2 | ||
0.558093146298,0.265003093326,0.10984235246,1.3343,0.0,1.4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
class,meta1,meta2,meta3,std_err | ||
class1,0.180734306909,0.548427238218,0.187956237253,0.00540072367701 | ||
class2,0.196072341892,1.17178931753,0.174802803661,0.00665375480667 | ||
class3,0.558093146298,0.265003093326,0.10984235246,0.00811408738542 | ||
class1,0.180734306909,0.548427238218,0.187956237253 | ||
class2,0.196072341892,1.17178931753,0.174802803661 | ||
class3,0.558093146298,0.265003093326,0.10984235246 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
from mltsp import obs_feature_tools as oft | ||
import itertools | ||
|
||
import numpy as np | ||
import numpy.testing as npt | ||
|
||
|
||
def irregular_random(seed=0, size=50): | ||
"""Generate random test data at irregularly-sampled times.""" | ||
state = np.random.RandomState(seed) | ||
times = np.sort(state.uniform(0, 10, size)) | ||
values = state.normal(1, 1, size) | ||
errors = state.exponential(0.1, size) | ||
return times, values, errors | ||
|
||
|
||
def test_delta_t_hist(): | ||
"""Test histogram of all time lags.""" | ||
times, values, errors = irregular_random() | ||
delta_ts = [pair[1] - pair[0] for pair in itertools.combinations(times, 2)] | ||
nbins = 50 | ||
bins = np.linspace(0, max(times) - min(times), nbins+1) | ||
npt.assert_allclose(oft.delta_t_hist(times, nbins), np.histogram(delta_ts, | ||
bins=bins)[0]) | ||
|
||
|
||
def test_normalize_hist(): | ||
"""Test normalization of histogram.""" | ||
times, values, errors = irregular_random() | ||
delta_ts = [pair[1] - pair[0] for pair in itertools.combinations(times, 2)] | ||
nbins = 50 | ||
bins = np.linspace(0, max(times) - min(times), nbins+1) | ||
nhist = oft.normalize_hist(oft.delta_t_hist(times, nbins), max(times) - | ||
min(times)) | ||
npt.assert_allclose(nhist, np.histogram(delta_ts, | ||
bins=bins, density=True)[0]) | ||
|
||
def test_find_sorted_peaks(): | ||
"""Test peak-finding algorithm.""" | ||
x = np.array([0,5,3,1]) # Single peak | ||
npt.assert_allclose(oft.find_sorted_peaks(x), np.array([[1,5]])) | ||
|
||
x = np.array([0,5,3,6,1]) # Multiple peaks | ||
npt.assert_allclose(oft.find_sorted_peaks(x), np.array([[3,6],[1,5]])) | ||
|
||
x = np.array([3,1,3]) # End-points can be peaks | ||
npt.assert_allclose(oft.find_sorted_peaks(x), np.array([[0,3],[2,3]])) | ||
|
||
x = np.array([0,3,3,3,0]) # In case of ties, peak is left-most point | ||
npt.assert_allclose(oft.find_sorted_peaks(x), np.array([[1,3]])) | ||
|
||
x = np.array([0,3,3,5,0]) # Tie is a peak only if greater than next value | ||
npt.assert_allclose(oft.find_sorted_peaks(x), np.array([[3,5]])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters