Skip to content

Commit 09e5ea1

Browse files
author
David Turner
committed
Made some stylistic changes to __init__.py of tests and added use of the TYPE_CHECKING flag to sourcetools/misc.py to avoid circular import errors from including BaseSource etc. as type hints.
1 parent 2d41610 commit 09e5ea1

2 files changed

Lines changed: 35 additions & 15 deletions

File tree

tests/__init__.py

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717

1818
# This is the main source for running the tests on
1919
SRC_INFO = {'ra': 226.0318, 'dec': -2.8046, 'z': 0.2093, 'name': "1eRASS_J150407.6-024816"}
20-
expected_xmm_obs = set(['0401040101', '0840580201', '0840580101'])
21-
expected_ero_obs = set(['227093', '227090', '224093'])
20+
expected_xmm_obs = {'0401040101', '0840580201', '0840580101'}
21+
expected_ero_obs = {'227093', '227090', '224093'}
2222

2323
# This is another cluster that we can use to test ClusterSample objects
2424
SUPP_SRC_INFO = {'ra': 55.7164, 'dec': -53.6292, 'z': 0.0587, 'name': 'A3158'}
@@ -31,16 +31,30 @@
3131
CLUSTER_SMP = pd.DataFrame(data=cluster_data, columns=column_names)
3232
CLUSTER_SMP[['ra', 'dec', 'z', 'r500']] = CLUSTER_SMP[['ra', 'dec', 'z', 'r500']].astype(float)
3333

34-
SRC_ALL_TELS = GalaxyCluster(SRC_INFO['ra'], SRC_INFO['dec'], SRC_INFO['z'], r500=Quantity(500, 'kpc'),
35-
name=SRC_INFO['name'], use_peak=False,
36-
search_distance={'erosita': Quantity(3.6, 'deg')},
37-
load_profiles=False)
34+
SRC_ALL_TELS = GalaxyCluster(SRC_INFO['ra'],
35+
SRC_INFO['dec'],
36+
SRC_INFO['z'],
37+
r500=Quantity(500, 'kpc'),
38+
name=SRC_INFO['name'],
39+
use_peak=False,
40+
search_distance={'erosita': Quantity(3.6, 'deg')},
41+
load_profiles=False)
3842

39-
SRC_XMM = GalaxyCluster(SRC_INFO['ra'], SRC_INFO['dec'], SRC_INFO['z'], r500=Quantity(500, 'kpc'),
40-
name=SRC_INFO['name'], use_peak=False,
41-
telescope='xmm', load_profiles=False)
42-
SRC_ERO = GalaxyCluster(SRC_INFO['ra'], SRC_INFO['dec'], SRC_INFO['z'], r500=Quantity(500, 'kpc'),
43-
name=SRC_INFO['name'], use_peak=False,
44-
telescope='erosita',
45-
search_distance={'erosita': Quantity(3.6, 'deg')},
46-
load_profiles=False)
43+
SRC_XMM = GalaxyCluster(SRC_INFO['ra'],
44+
SRC_INFO['dec'],
45+
SRC_INFO['z'],
46+
r500=Quantity(500, 'kpc'),
47+
name=SRC_INFO['name'],
48+
use_peak=False,
49+
telescope='xmm',
50+
load_profiles=False)
51+
52+
SRC_ERO = GalaxyCluster(SRC_INFO['ra'],
53+
SRC_INFO['dec'],
54+
SRC_INFO['z'],
55+
r500=Quantity(500, 'kpc'),
56+
name=SRC_INFO['name'],
57+
use_peak=False,
58+
telescope='erosita',
59+
search_distance={'erosita': Quantity(3.6, 'deg')},
60+
load_profiles=False)

xga/sourcetools/misc.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
# This code is a part of X-ray: Generate and Analyse (XGA), a module designed for the XMM Cluster Survey (XCS).
22
# Last modified by David J Turner (turne540@msu.edu) 16/01/2024, 14:56. Copyright (c) The Contributors
33

4+
from __future__ import annotations
5+
46
import warnings
57
from copy import deepcopy
68
from subprocess import Popen, PIPE
7-
from typing import Union, List
9+
from typing import Union, List, TYPE_CHECKING
810

911
from astropy.coordinates import SkyCoord
1012
from astropy.cosmology import Cosmology
@@ -15,6 +17,10 @@
1517
from ..exceptions import HeasoftError
1618
from ..models import BaseModel1D
1719

20+
if TYPE_CHECKING:
21+
from ..sources.base import BaseSource
22+
from ..samples.base import BaseSample
23+
1824

1925
def nh_lookup(coord_pair: Quantity) -> Quantity:
2026
"""

0 commit comments

Comments
 (0)