Skip to content

Commit

Permalink
Modified unittest for SourceInjector and ExtendedSourceResponse
Browse files Browse the repository at this point in the history
  • Loading branch information
hiyoneda committed Oct 25, 2024
1 parent b807978 commit 5bdaf39
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 4 additions & 0 deletions tests/response/test_extended_source_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ def test_get_expectation():

hist = resp.get_expectation(allsky_imagemodel)

assert isinstance(hist[:], u.quantity.Quantity) == True

def test_get_expectation_from_astromodel():

resp = ExtendedSourceResponse.open(extended_response_path)
Expand All @@ -47,3 +49,5 @@ def test_get_expectation_from_astromodel():

# Calculate the expectation
hist = resp.get_expectation_from_astromodel(extended_model)

assert isinstance(hist[:], u.quantity.Quantity) == True
12 changes: 10 additions & 2 deletions tests/source_injector/test_source_injector.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,12 @@ def test_inject_point_source():
orientation = ori, source_name = "point_source",
make_spectrum_plot = False, data_save_path = None,
project_axes = None)

results = injected_crab_signal.project("Em").to_dense().contents

assert isinstance(results, u.quantity.Quantity) == True

assert np.allclose(injected_crab_signal.project("Em").to_dense().contents.value,
assert np.allclose(results.value,
[2.18846305e-03, 9.45773119e-03, 1.34892237e-02, 2.78741695e-03, 1.08413769e-02,
6.28299687e-03, 3.63716712e-03, 1.43443841e-03,3.79135752e-04, 2.10058977e-05])

Expand Down Expand Up @@ -72,8 +76,12 @@ def test_inject_point_source_galactic():
source_name = "point_source",
make_spectrum_plot = True, data_save_path = None,
project_axes = None)

results = injected_crab_signal.project("Em").to_dense().contents

assert isinstance(results, u.quantity.Quantity) == True

assert np.allclose(injected_crab_signal.project("Em").to_dense().contents.value,
assert np.allclose(results.value,
[4.02116790e-03, 1.80171140e-02, 2.55344563e-02, 5.45316809e-03, 2.19219388e-02,
1.50895341e-02, 9.97883729e-03, 4.16116828e-03, 1.02528085e-03, 6.26208604e-05])

Expand Down

0 comments on commit 5bdaf39

Please sign in to comment.