Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch complexwarning #443

Merged
merged 3 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# OMC3 Changelog

#### 2024-08-14 - v0.15.2 - _fesoubel_, _jdilly_

- Fixed:
- Numpy's `ComplexWarning` was not part of main namespace in v2.0, so we import it directly

#### 2024-08-14 - v0.15.1 - _fesoubel_

- Fixed:
Expand Down
2 changes: 1 addition & 1 deletion omc3/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
__title__ = "omc3"
__description__ = "An accelerator physics tools package for the OMC team at CERN."
__url__ = "https://github.com/pylhc/omc3"
__version__ = "0.15.1"
__version__ = "0.15.2"
__author__ = "pylhc"
__author_email__ = "[email protected]"
__license__ = "MIT"
Expand Down
7 changes: 4 additions & 3 deletions omc3/correction/response_madx.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@
import zipfile
import pandas as pd
import tfs
from numpy.exceptions import ComplexWarning
from optics_functions.coupling import coupling_via_cmatrix

import omc3.madx_wrapper as madx_wrapper
from omc3.optics_measurements.constants import (BETA, DISPERSION, F1001, F1010,
NORM_DISPERSION, PHASE_ADV, TUNE)
NORM_DISPERSION, PHASE_ADV, TUNE)
from omc3.correction.constants import INCR
from omc3.model.accelerators.accelerator import Accelerator, AccElementTypes
from omc3.utils import logging_tools
Expand Down Expand Up @@ -154,7 +155,7 @@ def _clean_up(temp_dir: Path, num_proc: int) -> None:

def _load_madx_results(
variables: List[str],
process_pool: multiprocessing.Pool,
process_pool,
incr_dict: dict,
temp_dir: Path
) -> Dict[str, tfs.TfsDataFrame]:
Expand Down Expand Up @@ -213,7 +214,7 @@ def _create_fullresponse_from_dict(var_to_twiss: Dict[str, tfs.TfsDataFrame]) ->
resp = np.divide(resp,resp[columns.index(f"{INCR}")])
Q_arr = np.column_stack((resp[columns.index(f"{TUNE}1"), 0, :], resp[columns.index(f"{TUNE}2"), 0, :])).T

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