Skip to content

Commit

Permalink
ensure location is cast to int for slicing
Browse files Browse the repository at this point in the history
  • Loading branch information
rhayes777 committed Oct 3, 2022
1 parent cfba98e commit deb0cb3
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
test_autocti/model/files/tracer.json

.idea
.cache
.pytest_cache
Expand Down
2 changes: 1 addition & 1 deletion autocti/dataset_1d/dataset_1d/dataset_1d.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def from_pixel_line_dict(
and noise are embedded in Array1Ds of the same size as the array in
the parallel direction
"""
serial_distance, _ = pixel_line_dict["location"]
serial_distance, _ = map(int, pixel_line_dict["location"])

def make_array(data):
array = np.zeros(size)
Expand Down
72 changes: 72 additions & 0 deletions test_autocti/dataset_1d/test_parse_pixel_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,75 @@ def test_layout(layout, size):
def test_region(layout, pre_cti_data, flux):
region, = layout.region_list
assert pre_cti_data[region.slice] == flux


def test_float_location():
pixel_line_dict = {
"location": [
13.0,
0
],
"date": 2453963.758414352,
"background": 31.30540652532858,
"flux": 992.075,
"data": [
46.933043816970624,
46.3701649771964,
48.711080079945226,
48.11518701894584,
48.14361054867522,
48.00110239950205,
46.16310970820016,
47.16358109918174,
46.49024043290878,
46.863087745614244,
45.796840479854254,
45.55346051503446,
1309.4024294348244,
48.59285309531201,
46.63910977027298,
47.10570908449849,
48.99711399716423,
48.20789077340186,
47.29295786328075,
48.53875401695496,
48.920490584648604,
48.141066131134835,
47.34273778298907,
50.227607541836136,
47.744377164578616
],
"noise": [
0.5256967407012534,
0.4280892624149115,
0.789855949552933,
0.6217203894640145,
0.5786548351791704,
0.5849704312132465,
0.4655796354315316,
0.520450891288638,
0.46729646303852607,
0.5451477925803473,
0.32636264608977256,
0.2349003033720228,
3.0453790917701253,
0.3580557547977746,
0.28042682627171855,
0.44804424425163564,
0.6752575443696331,
0.4971518347953273,
0.4332561468089131,
0.6849637230632679,
0.5805219047418141,
0.5610511215490508,
0.5220946749091355,
0.7818605598254397,
0.558755420934289
]
}
size = 2068

Dataset1D.from_pixel_line_dict(
pixel_line_dict,
size=size,
)

0 comments on commit deb0cb3

Please sign in to comment.