Skip to content

Commit 39ebec0

Browse files
authored
Merge pull request #132 from fact-project/fix_reuse_add_test
Fix reuse add test
2 parents 1a9e3b3 + 3757394 commit 39ebec0

File tree

4 files changed

+16
-5
lines changed

4 files changed

+16
-5
lines changed

fact/VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.25.1
1+
0.25.2

fact/io.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import astropy.units as u
1111
import tempfile
1212
import warnings
13-
from time import perf_counter
1413

1514

1615
__all__ = [
@@ -559,7 +558,7 @@ def read_simulated_spectrum(corsika_headers_path):
559558
if 'n_reuse' in runs.columns:
560559
# if reuse is not the same for all runs, multply n_showers
561560
# and set reuse to 1
562-
unique = runs['reuse'].unique()
561+
unique = runs['n_reuse'].unique()
563562
if len(unique) > 1:
564563
summary['n_showers'] = (n_showers * runs['n_reuse']).sum()
565564
summary['n_reuse'] = 1
536 KB
Binary file not shown.

tests/test_io.py

+14-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
import tables.filters
21
import pandas as pd
32
import tempfile
43
import numpy as np
54
import h5py
65
import pytest
7-
from pandas.util.testing import assert_frame_equal
6+
87

98

109
def test_to_h5py():
@@ -335,3 +334,16 @@ def test_compression():
335334
assert all(df.dtypes == df2.dtypes)
336335
assert all(df['x'] == df2['x'])
337336
assert all(df['N'] == df2['N'])
337+
338+
339+
def test_read_simulated_spectrum():
340+
from fact.io import read_simulated_spectrum
341+
import astropy.units as u
342+
343+
s = read_simulated_spectrum('tests/resources/proton_header_test.hdf5')
344+
345+
assert s['n_showers'] == 20000
346+
assert s['n_reuse'] == 20
347+
assert s['energy_min'] == 100 * u.GeV
348+
assert s['energy_max'] == 200 * u.TeV
349+
assert s['energy_spectrum_slope'] == -2.0

0 commit comments

Comments
 (0)