update sources tests to accomodate new pos attribute

This commit is contained in:
Pim Nelissen
2026-02-09 15:36:23 +01:00
parent 016ea6b783
commit a1acf95004

View File

@ -1,27 +1,36 @@
import numpy as np import numpy as np
import pytest import pytest
from pg_rad.sources import PointSource from pg_rad.objects import PointSource
from pg_rad.isotopes import Isotope
@pytest.fixture @pytest.fixture
def test_sources(): def test_sources():
iso = Isotope("test", E=662, b=0)
pos_a = np.random.rand(3) pos_a = np.random.rand(3)
pos_b = np.random.rand(3) pos_b = np.random.rand(3)
a = PointSource(*tuple(pos_a), strength = None) a = PointSource(pos_a, activity=None, isotope=iso)
b = PointSource(*tuple(pos_b), strength = None) b = PointSource(pos_b, activity=None, isotope=iso)
return pos_a, pos_b, a, b return pos_a, pos_b, a, b
def test_if_distances_equal(test_sources): def test_if_distances_equal(test_sources):
"""Verify whether from PointSource A to PointSource B is the same as B to A.""" """
Verify whether distance from PointSource A to B is the same as B to A.
"""
_, _, a, b = test_sources _, _, a, b = test_sources
assert a.distance_to(b) == b.distance_to(a) assert a.distance_to(b) == b.distance_to(a)
def test_distance_calculation(test_sources): def test_distance_calculation(test_sources):
"""Verify whether distance between two PointSources is calculated correctly.""" """
Verify whether distance between PointSources is calculated correctly.
"""
pos_a, pos_b, a, b = test_sources pos_a, pos_b, a, b = test_sources