Skip to content

Commit faf1a21

Browse files
JoschDfsoubelet
andauthored
Patch numpy ComplexWarning (#443)
* explicitely import complexwarning as its not part of namespace * patch version * Update CHANGELOG.md --------- Co-authored-by: Felix Soubelet <[email protected]>
1 parent 33b16a2 commit faf1a21

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# OMC3 Changelog
22

3+
#### 2024-08-14 - v0.15.2 - _fesoubel_, _jdilly_
4+
5+
- Fixed:
6+
- Numpy's `ComplexWarning` was not part of main namespace in v2.0, so we import it directly
7+
38
#### 2024-08-14 - v0.15.1 - _fesoubel_
49

510
- Fixed:

omc3/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
__title__ = "omc3"
1212
__description__ = "An accelerator physics tools package for the OMC team at CERN."
1313
__url__ = "https://github.com/pylhc/omc3"
14-
__version__ = "0.15.1"
14+
__version__ = "0.15.2"
1515
__author__ = "pylhc"
1616
__author_email__ = "[email protected]"
1717
__license__ = "MIT"

omc3/correction/response_madx.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,12 @@
2121
import zipfile
2222
import pandas as pd
2323
import tfs
24+
from numpy.exceptions import ComplexWarning
2425
from optics_functions.coupling import coupling_via_cmatrix
2526

2627
import omc3.madx_wrapper as madx_wrapper
2728
from omc3.optics_measurements.constants import (BETA, DISPERSION, F1001, F1010,
28-
NORM_DISPERSION, PHASE_ADV, TUNE)
29+
NORM_DISPERSION, PHASE_ADV, TUNE)
2930
from omc3.correction.constants import INCR
3031
from omc3.model.accelerators.accelerator import Accelerator, AccElementTypes
3132
from omc3.utils import logging_tools
@@ -154,7 +155,7 @@ def _clean_up(temp_dir: Path, num_proc: int) -> None:
154155

155156
def _load_madx_results(
156157
variables: List[str],
157-
process_pool: multiprocessing.Pool,
158+
process_pool,
158159
incr_dict: dict,
159160
temp_dir: Path
160161
) -> Dict[str, tfs.TfsDataFrame]:
@@ -213,7 +214,7 @@ def _create_fullresponse_from_dict(var_to_twiss: Dict[str, tfs.TfsDataFrame]) ->
213214
resp = np.divide(resp,resp[columns.index(f"{INCR}")])
214215
Q_arr = np.column_stack((resp[columns.index(f"{TUNE}1"), 0, :], resp[columns.index(f"{TUNE}2"), 0, :])).T
215216

216-
with suppress_warnings(np.ComplexWarning): # raised as everything is complex-type now
217+
with suppress_warnings(ComplexWarning): # raised as everything is complex-type now
217218
return {
218219
f"{PHASE_ADV}X": pd.DataFrame(data=resp[columns.index(f"{PHASE_ADV}X")], index=bpms, columns=keys).astype(np.float64),
219220
f"{PHASE_ADV}Y": pd.DataFrame(data=resp[columns.index(f"{PHASE_ADV}Y")], index=bpms, columns=keys).astype(np.float64),

0 commit comments

Comments
 (0)