Skip to content
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
8 changes: 4 additions & 4 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ jobs:
id-token: write

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v3
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install dependencies
Expand All @@ -37,8 +37,8 @@ jobs:
- name: Get MAD Binaries
run: |
mkdir src/pymadng/bin
curl http://madx.web.cern.ch/madx/releases/madng/madng-linux-latest -o src/pymadng/bin/mad_Linux
curl http://madx.web.cern.ch/madx/releases/madng/madng-macos-latest -o src/pymadng/bin/mad_Darwin
curl https://madx.web.cern.ch/madx/releases/madng/0.9/mad-linux-0.9.9 -o src/pymadng/bin/mad_Linux
curl https://madx.web.cern.ch/madx/releases/madng/0.9/mad-macos-0.9.9 -o src/pymadng/bin/mad_Darwin
chmod +x src/pymadng/bin/mad_Linux src/pymadng/bin/mad_Darwin
- name: Build package
run: python -m build
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-20.04, macos-latest]
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }} on ${{ matrix.os }}
uses: actions/setup-python@v3
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
Expand Down
17 changes: 10 additions & 7 deletions .github/workflows/test-pymadng.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,31 @@ on:
jobs:
build:
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }} on ${{ matrix.os }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Get MAD Binaries
run: |
mkdir src/pymadng/bin
curl http://madx.web.cern.ch/madx/releases/madng/madng-linux-latest -o src/pymadng/bin/mad_Linux
curl http://madx.web.cern.ch/madx/releases/madng/madng-macos-latest -o src/pymadng/bin/mad_Darwin
chmod +x src/pymadng/bin/mad_Linux src/pymadng/bin/mad_Darwin
mkdir ./src/pymadng/bin
curl https://madx.web.cern.ch/madx/releases/madng/0.9/mad-linux-0.9.8 -o ./src/pymadng/bin/mad_Linux
curl https://madx.web.cern.ch/madx/releases/madng/0.9/mad-macos-0.9.8 -o ./src/pymadng/bin/mad_Darwin
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install .[tfs]
python -m pip install -e .[tfs]
- name: Test with python
run: |
chmod +x ./src/pymadng/bin/mad_Linux ./src/pymadng/bin/mad_Darwin
python -m unittest tests/*
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
0.5.0 (2024/10/30)

Add `history` method to get the history of communication of strings to MAD-NG. \
Rename a significant amount of the code to be more readable. \
Allow debug mode to be set to a string, which will be the file that the debug information is written to. \
Remove support for Python EOL, now only supporting Python 3.9 and above. \
Change how ctrl-c is handled, now it will raise a KeyboardInterrupt error and delete the MAD process. \

0.4.6 (2024/01/17)

No change, releasing with MAD 0.9.8-1
Expand Down
2 changes: 1 addition & 1 deletion examples/ex-benchmark-and-fork/ex-benchmark-and-fork.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
# METHOD 2
mad["circum", "lcell"] = 60, 20
mad["deferred"] = mad.MAD.typeid.deferred
mad["v"] = mad.deferred(f = "lcell/math.sin(math.pi/4)/4", k = "1/v.f")
mad["v"] = mad.create_deferred_expression(f = "lcell/math.sin(math.pi/4)/4", k = "1/v.f")

mad["qf"] = mad.quadrupole("knl:={0, v.k}", l = 1)
mad["qd"] = mad.quadrupole("knl:={0, -v.k}", l = 1)
Expand Down
6 changes: 3 additions & 3 deletions examples/ex-fodo/ex-fodos.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
mad.load("MADX", "seq")
mad.seq.beam = mad.beam()
mad["mtbl", "mflw"] = mad.twiss(sequence=mad.seq, method=4, implicit=True, nslice=10, save="'atbody'")
cols = mad.py_strs_to_mad_strs(["name", "s", "beta11", "beta22", "mu1", "mu2", "alfa11", "alfa22"])
cols = mad.quote_strings(["name", "s", "beta11", "beta22", "mu1", "mu2", "alfa11", "alfa22"])
mad.mtbl.write("'twiss_py.tfs'", cols)
for x in mad.seq:
print(x.name, x.kind)
Expand All @@ -30,7 +30,7 @@
mad["circum", "lcell"] = 60, 20

mad.load("math", "sin", "pi")
mad["v"] = mad.deferred(k="1/(lcell/sin(pi/4)/4)")
mad["v"] = mad.create_deferred_expression(k="1/(lcell/sin(pi/4)/4)")

mad["qf"] = mad.quadrupole("knl:={0, v.k}", l=1)
mad["qd"] = mad.quadrupole("knl:={0, -v.k}", l=1)
Expand All @@ -44,7 +44,7 @@
""", refer="'entry'", l=mad.circum,)
mad.seq.beam = mad.beam()
mad["mtbl", "mflw"] = mad.twiss(sequence=mad.seq, method=4, implicit=True, nslice=10, save="'atbody'")
cols = mad.py_strs_to_mad_strs(["name", "s", "beta11", "beta22", "mu1", "mu2", "alfa11", "alfa22"])
cols = mad.quote_strings(["name", "s", "beta11", "beta22", "mu1", "mu2", "alfa11", "alfa22"])
mad.mtbl.write("'twiss_py.tfs'", cols)

plt.plot(mad.mtbl.s, mad.mtbl["beta11"])
Expand Down
2 changes: 1 addition & 1 deletion examples/ex-lhc-couplingLocal/lhc-couplingLocal.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"'invalid number of elements %d in LHCB1 (6694 expected)'", "#lhcb1")

mad.lhcb1.beam = mad.beam(particle="'proton'", energy=mad.nrj)
mad.MADX_env_send("""
mad.evaluate_in_madx_environment("""
ktqx1_r2 = -ktqx1_l2 ! remove the link between these 2 vars
kqsx3_l2 = -0.0015
kqsx3_r2 = +0.0015
Expand Down
6 changes: 3 additions & 3 deletions examples/ex-ps-twiss/ps-twiss.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,21 @@
mad["srv", "mflw"] = mad.survey(sequence=mad.ps)

mad.srv.write("'PS_survey_py.tfs'",
mad.py_strs_to_mad_strs(["name", "kind", "s", "l", "angle", "x", "y", "z", "theta"]),
mad.quote_strings(["name", "kind", "s", "l", "angle", "x", "y", "z", "theta"]),
)

mad["mtbl", "mflw"] = mad.twiss(sequence=mad.ps, method=6, nslice=3, chrom=True)

mad.load("MAD.gphys", "melmcol")
#Add element properties as columns
mad.melmcol(mad.mtbl,
mad.py_strs_to_mad_strs(
mad.quote_strings(
["angle", "tilt", "k0l", "k1l", "k2l", "k3l", "k4l", "k5l", "k6l", "k0sl",
"k1sl", "k2sl", "k3sl", "k4sl", "k5sl", "k6sl", "ksl", "hkick", "vkick" ]),
)

mad.mtbl.write("'PS_twiss_py.tfs'",
mad.py_strs_to_mad_strs(
mad.quote_strings(
["name", "kind", "s", "x", "px", "beta11", "alfa11", "beta22", "alfa22","dx",
"dpx", "mu1", "mu2", "l", "angle", "k0l", "k1l", "k2l", "k3l", "hkick", "vkick"]
)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ build-backend = "setuptools.build_meta"
name = "pymadng"
dynamic = ["version"]
authors = [
{ name="Joshua Gray", email="[email protected]" },
{ name="Joshua Gray" },
]
description = "A python interface to MAD-NG running as subprocess"
readme = "README.md"
Expand Down
2 changes: 1 addition & 1 deletion src/pymadng/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from .madp_object import MAD

__title__ = "pymadng"
__version__ = "0.4.6"
__version__ = "0.5.0"

__summary__ = "Python interface to MAD-NG running as subprocess"
__uri__ = "https://github.com/MethodicalAcceleratorDesign/MADpy"
Expand Down
Loading