Skip to content

Commit 3e66fd8

Browse files
authored
Tweaks (#84)
1 parent cc1d93d commit 3e66fd8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+40
-63551
lines changed

docs/release.rst

+7-1

pyhdtoolkit/cpymadtools/plotters.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -222,10 +222,10 @@ def plot_envelope(
222222
twiss_hr["dispersive_envelope_x"] = twiss_hr.dx * beam_params.deltap_p
223223
twiss_hr["dispersive_envelope_y"] = twiss_hr.dy * beam_params.deltap_p
224224
twiss_hr["envelope_x"] = np.sqrt(
225-
twiss_hr.betatronic_envelope_x ** 2 + (twiss_hr.dx * beam_params.deltap_p) ** 2
225+
twiss_hr.betatronic_envelope_x**2 + (twiss_hr.dx * beam_params.deltap_p) ** 2
226226
)
227227
twiss_hr["envelope_y"] = np.sqrt(
228-
twiss_hr.betatronic_envelope_y ** 2 + (twiss_hr.dy * beam_params.deltap_p) ** 2
228+
twiss_hr.betatronic_envelope_y**2 + (twiss_hr.dy * beam_params.deltap_p) ** 2
229229
)
230230
machine = twiss_hr[twiss_hr.apertype == "ellipse"]
231231

@@ -1226,7 +1226,6 @@ def plot_machine_layout(
12261226
height=dipole.k1l,
12271227
v_offset=dipole.k1l / 2,
12281228
color="r",
1229-
alpha=0.3,
12301229
**kwargs,
12311230
)
12321231
plotted_elements += 1

tests/conftest.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111
BASE_LATTICE = LatticeGenerator.generate_base_cas_lattice()
1212
CURRENT_DIR = pathlib.Path(__file__).parent
1313
INPUTS_DIR = CURRENT_DIR / "inputs"
14-
LHC_SEQUENCE = INPUTS_DIR / "lhc_as-built.seq"
15-
LHC_OPTICS = INPUTS_DIR / "opticsfile.22"
16-
LHC_INJ_OPTICS = INPUTS_DIR / "opticsfile.1"
17-
LHC_B1_APERTURE = INPUTS_DIR / "aperture.b1.madx"
18-
LHC_B1_APERTOL = INPUTS_DIR / "aper_tol.b1.madx"
14+
LHC_SEQUENCE = INPUTS_DIR / "madx" / "lhc_as-built.seq"
15+
LHC_OPTICS = INPUTS_DIR / "madx" / "opticsfile.22"
16+
LHC_INJ_OPTICS = INPUTS_DIR / "madx" / "opticsfile.1"
17+
LHC_B1_APERTURE = INPUTS_DIR / "madx" / "aperture.b1.madx"
18+
LHC_B1_APERTOL = INPUTS_DIR / "madx" / "aper_tol.b1.madx"
1919

2020
# ----- Fixtures for cpymadtools tests ----- #
2121

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

tests/inputs/tfstools_latwiss.tfs

-2,164
This file was deleted.

tests/inputs/twiss_for_ampdet.tfs

-61,352
This file was deleted.
File renamed without changes.

tests/test_cpymadtools/test_lhc.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -345,14 +345,14 @@ def test_get_bpms_coupling_rdts(self, _non_matched_lhc_madx, _reference_twiss_rd
345345

346346
@pytest.fixture()
347347
def _magnets_fields_path() -> pathlib.Path:
348-
return INPUTS_DIR / "magnets_fields.tfs"
348+
return INPUTS_DIR / "cpymadtools" / "magnets_fields.tfs"
349349

350350

351351
@pytest.fixture()
352352
def _correct_bpms_list() -> pathlib.Path:
353-
return INPUTS_DIR / "correct_bpms_list.pkl"
353+
return INPUTS_DIR / "cpymadtools" / "correct_bpms_list.pkl"
354354

355355

356356
@pytest.fixture()
357357
def _reference_twiss_rdts() -> pathlib.Path:
358-
return INPUTS_DIR / "twiss_with_rdts.tfs"
358+
return INPUTS_DIR / "cpymadtools" / "twiss_with_rdts.tfs"

tests/test_cpymadtools/test_plotters.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
CURRENT_DIR = pathlib.Path(__file__).parent
3030
INPUTS_DIR = CURRENT_DIR.parent / "inputs"
31-
GUIDO_LATTICE = INPUTS_DIR / "guido_lattice.madx"
31+
GUIDO_LATTICE = INPUTS_DIR / "cpymadtools" / "guido_lattice.madx"
3232
BASE_LATTICE = LatticeGenerator.generate_base_cas_lattice()
3333

3434

tests/test_cpymadtools/test_ptc.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,14 @@ def test_single_particle_ptc_track_with_onepass(self, _matched_base_lattice):
9393

9494
@pytest.fixture()
9595
def _ampdet_tfs_path() -> pathlib.Path:
96-
return INPUTS_DIR / "ampdet.tfs"
96+
return INPUTS_DIR / "cpymadtools" / "ampdet.tfs"
9797

9898

9999
@pytest.fixture()
100100
def _rdts_tfs_path() -> pathlib.Path:
101-
return INPUTS_DIR / "rdts.tfs"
101+
return INPUTS_DIR / "cpymadtools" / "rdts.tfs"
102102

103103

104104
@pytest.fixture()
105105
def _ptc_twiss_tfs_path() -> pathlib.Path:
106-
return INPUTS_DIR / "ptc_twiss.tfs"
106+
return INPUTS_DIR / "cpymadtools" / "ptc_twiss.tfs"

tests/test_cpymadtools/test_tune.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,9 @@ def test_get_footprint_patches_raises_wrong_shape(self, _dynap_tfs_path, caplog)
105105

106106
@pytest.fixture()
107107
def _plottable_footprint_path() -> pathlib.Path:
108-
return INPUTS_DIR / "plottable_footprint.npz"
108+
return INPUTS_DIR / "cpymadtools" / "plottable_footprint.npz"
109109

110110

111111
@pytest.fixture()
112112
def _dynap_tfs_path() -> pathlib.Path:
113-
return INPUTS_DIR / "dynap.tfs"
113+
return INPUTS_DIR / "cpymadtools" / "dynap.tfs"

tests/test_cpymadtools/test_twiss.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def test_get_ips_twiss(self, _ips_twiss_path, _matched_lhc_madx):
3232
def test_get_irs_twiss(self, ir, _matched_lhc_madx):
3333
madx = _matched_lhc_madx
3434

35-
reference_df = tfs.read(INPUTS_DIR / f"ir{ir:d}_twiss.tfs")
35+
reference_df = tfs.read(INPUTS_DIR / "cpymadtools" / f"ir{ir:d}_twiss.tfs")
3636
ir_df = get_ir_twiss(madx, ir=ir)
3737
# assert_dict_equal(reference_df.headers, ir_df.headers) # bugged at the moment
3838
assert_frame_equal(reference_df.set_index("name"), ir_df.set_index("name"))
@@ -47,9 +47,9 @@ def test_get_irs_twiss(self, ir, _matched_lhc_madx):
4747

4848
@pytest.fixture()
4949
def _ips_twiss_path() -> pathlib.Path:
50-
return INPUTS_DIR / "ips_twiss.tfs"
50+
return INPUTS_DIR / "cpymadtools" / "ips_twiss.tfs"
5151

5252

5353
@pytest.fixture()
5454
def _twiss_export() -> pathlib.Path:
55-
return INPUTS_DIR / "twiss_export.tfs"
55+
return INPUTS_DIR / "cpymadtools" / "twiss_export.tfs"

tests/test_maths.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -211,14 +211,14 @@ def _create_2d_gaussian_noise(mean: float, stdev: float, shape: tuple) -> np.nda
211211

212212
@pytest.fixture()
213213
def _to_scale() -> np.ndarray:
214-
return np.load(INPUTS_DIR / "to_scale.npy")
214+
return np.load(INPUTS_DIR / "maths" / "to_scale.npy")
215215

216216

217217
@pytest.fixture()
218218
def _scaled() -> np.ndarray:
219-
return np.load(INPUTS_DIR / "scaled.npy")
219+
return np.load(INPUTS_DIR / "maths" / "scaled.npy")
220220

221221

222222
@pytest.fixture()
223223
def _force_scaled() -> np.ndarray:
224-
return np.load(INPUTS_DIR / "force_scaled.npy")
224+
return np.load(INPUTS_DIR / "maths" / "force_scaled.npy")

tests/test_optics.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010
CURRENT_DIR = pathlib.Path(__file__).parent
1111
INPUTS_DIR = CURRENT_DIR / "inputs"
1212
INPUT_PATHS = {
13-
"alpha_beta": INPUTS_DIR / "alpha_beta.npy",
14-
"u_vector": INPUTS_DIR / "u_vector.npy",
15-
"u_bar": INPUTS_DIR / "u_bar.npy",
16-
"beta11": INPUTS_DIR / "beta11.npy",
17-
"beta21": INPUTS_DIR / "beta21.npy",
18-
"lebedev": INPUTS_DIR / "lebedev_size.npy",
13+
"alpha_beta": INPUTS_DIR / "optics" / "alpha_beta.npy",
14+
"u_vector": INPUTS_DIR / "optics" / "u_vector.npy",
15+
"u_bar": INPUTS_DIR / "optics" / "u_bar.npy",
16+
"beta11": INPUTS_DIR / "optics" / "beta11.npy",
17+
"beta21": INPUTS_DIR / "optics" / "beta21.npy",
18+
"lebedev": INPUTS_DIR / "optics" / "lebedev_size.npy",
1919
}
2020

2121

tests/test_utils.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939

4040
def _square(integer: int) -> int:
41-
return integer ** 2
41+
return integer**2
4242

4343

4444
def _to_str(integer: int) -> str:
@@ -416,7 +416,7 @@ class TestMultiProcessorExecutor:
416416
"function, inputs, results",
417417
[
418418
(_square, list(range(6)), [0, 1, 4, 9, 16, 25]),
419-
(_square, [10 * i for i in range(10)], [e ** 2 for e in [10 * i for i in range(10)]]),
419+
(_square, [10 * i for i in range(10)], [e**2 for e in [10 * i for i in range(10)]]),
420420
(_to_str, list(range(6)), [str(e) for e in range(6)]),
421421
(_to_str, [10 * i for i in range(10)], [str(e) for e in [10 * i for i in range(10)]]),
422422
],
@@ -435,7 +435,7 @@ class TestMultiThreaderExecutor:
435435
"function, inputs, results",
436436
[
437437
(_square, list(range(6)), [0, 1, 4, 9, 16, 25]),
438-
(_square, [10 * i for i in range(10)], [e ** 2 for e in [10 * i for i in range(10)]]),
438+
(_square, [10 * i for i in range(10)], [e**2 for e in [10 * i for i in range(10)]]),
439439
(_to_str, list(range(6)), [str(e) for e in range(6)]),
440440
(_to_str, [10 * i for i in range(10)], [str(e) for e in [10 * i for i in range(10)]]),
441441
],
@@ -674,13 +674,13 @@ def _taskless_condor_q_output() -> str:
674674

675675
@pytest.fixture()
676676
def _correct_user_tasks() -> List[HTCTaskSummary]:
677-
pickle_file_path = INPUTS_DIR / "correct_user_tasks.pkl"
677+
pickle_file_path = INPUTS_DIR / "utils" / "correct_user_tasks.pkl"
678678
with pickle_file_path.open("rb") as file:
679679
return pickle.load(file)
680680

681681

682682
@pytest.fixture()
683683
def _correct_cluster_summary() -> ClusterSummary:
684-
pickle_file_path = INPUTS_DIR / "correct_cluster_summary.pkl"
684+
pickle_file_path = INPUTS_DIR / "utils" / "correct_cluster_summary.pkl"
685685
with pickle_file_path.open("rb") as file:
686686
return pickle.load(file)

0 commit comments

Comments
 (0)