Skip to content

Commit ce74038

Browse files
authored
Merge pull request #89 from torresramiro350/master
Numpy no longer includes warnings module as attribute as of numpy v1.24.3
2 parents 1c7c9b5 + bdd423b commit ce74038

File tree

1 file changed

+43
-34
lines changed

1 file changed

+43
-34
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import numpy as np
1+
import warnings
2+
23
from healpy import projaxes as PA
3-
import matplotlib.pyplot as plt
44

55

66
def get_gnomonic_projection(figure, hpx_map, **kwargs):
@@ -16,23 +16,23 @@ def get_gnomonic_projection(figure, hpx_map, **kwargs):
1616
:return: the array containing the projection.
1717
"""
1818

19-
defaults = {'coord': 'C',
20-
'rot': None,
21-
'format': '%g',
22-
'flip': 'astro',
23-
'xsize': 200,
24-
'ysize': None,
25-
'reso': 1.5,
26-
'nest': False,
27-
'min': None,
28-
'max': None,
29-
'cmap': None,
30-
'norm': None}
19+
defaults = {
20+
"coord": "C",
21+
"rot": None,
22+
"format": "%g",
23+
"flip": "astro",
24+
"xsize": 200,
25+
"ysize": None,
26+
"reso": 1.5,
27+
"nest": False,
28+
"min": None,
29+
"max": None,
30+
"cmap": None,
31+
"norm": None,
32+
}
3133

3234
for key, default_value in list(defaults.items()):
33-
3435
if key not in kwargs:
35-
3636
kwargs[key] = default_value
3737

3838
## Colas, 2018-07-11: The following fails for really tall figures,
@@ -47,26 +47,35 @@ def get_gnomonic_projection(figure, hpx_map, **kwargs):
4747
# extent[3] - margins[3] - margins[1])
4848
extent = (0.05, 0.05, 0.9, 0.9)
4949

50-
ax = PA.HpxGnomonicAxes(figure, extent,
51-
coord=kwargs['coord'],
52-
rot=kwargs['rot'],
53-
format=kwargs['format'],
54-
flipconv=kwargs['flip'])
50+
ax = PA.HpxGnomonicAxes(
51+
figure,
52+
extent,
53+
coord=kwargs["coord"],
54+
rot=kwargs["rot"],
55+
format=kwargs["format"],
56+
flipconv=kwargs["flip"],
57+
)
5558

5659
# Suppress warnings about nans
57-
with np.warnings.catch_warnings():
58-
59-
np.warnings.filterwarnings('ignore')
60+
# ! numpy does not contain the warnings module as of v1.24.3
61+
# TODO: remove this when numpy is updated
62+
# with np.warnings.catch_warnings():
63+
#
64+
# np.warnings.filterwarnings('ignore')
6065

61-
img = ax.projmap(hpx_map,
62-
nest=kwargs['nest'],
63-
coord=kwargs['coord'],
64-
vmin=kwargs['min'],
65-
vmax=kwargs['max'],
66-
xsize=kwargs['xsize'],
67-
ysize=kwargs['ysize'],
68-
reso=kwargs['reso'],
69-
cmap=kwargs['cmap'],
70-
norm=kwargs['norm'])
66+
with warnings.catch_warnings():
67+
warnings.filterwarnings("ignore")
68+
img = ax.projmap(
69+
hpx_map,
70+
nest=kwargs["nest"],
71+
coord=kwargs["coord"],
72+
vmin=kwargs["min"],
73+
vmax=kwargs["max"],
74+
xsize=kwargs["xsize"],
75+
ysize=kwargs["ysize"],
76+
reso=kwargs["reso"],
77+
cmap=kwargs["cmap"],
78+
norm=kwargs["norm"],
79+
)
7180

7281
return img

0 commit comments

Comments
 (0)