Skip to content

Commit

Permalink
Merge test_pandas.py into test_madx.py again
Browse files Browse the repository at this point in the history
  • Loading branch information
coldfix committed Aug 13, 2021
1 parent ebb1997 commit 23d2d26
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 53 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -216,12 +216,12 @@ jobs:
- run: flake8

- run: coverage run --source=cpymad -p -m pytest test/test_util.py -v
- run: coverage run --source=cpymad -p -m pytest test/test_madx.py -v
- run: coverage run --source=cpymad -p -m pytest test/test_madx.py -v -k "not dframe"
- run: coverage run --source=cpymad -p -m pytest test/test_regression.py -v
- run: coverage run --source=cpymad -p -m pytest test/test_transfer_map.py -v

- run: pip install pandas
- run: coverage run --source=cpymad -p -m pytest test/test_pandas.py -v
- run: coverage run --source=cpymad -p -m pytest test/test_madx.py -v -k "dframe"

- run: coverage combine
- run: coveralls
Expand Down
39 changes: 39 additions & 0 deletions test/test_madx.py
Original file line number Diff line number Diff line change
Expand Up @@ -843,6 +843,45 @@ def test_errors(mad):
assert_allclose(al.dy, -4e-3)


def test_dframe_after_use(mad):
mad.input("""
mqf.k1 = 0.3037241107;
mqd.k1 = -0.3037241107;
fodo: sequence, l=10, refer=entry;
mqf: quadrupole, at=0, l=1, k1:=mqf.k1;
dff: drift, at=1, l=4;
mqd: quadrupole, at=5, l=1, k1:=mqd.k1;
dfd: drift, at=6, l=4;
endsequence;
beam;
use, sequence=fodo;
twiss, sequence=fodo, x=0.1;
""")
index = ['#s', 'mqf', 'dff', 'mqd', 'dfd', '#e']
names = ['fodo$start', 'mqf', 'dff', 'mqd', 'dfd', 'fodo$end']

twiss = mad.table.twiss
assert index == twiss.row_names()
assert index == twiss.dframe().index.tolist()
assert names == twiss.dframe(index='name').index.tolist()

mad.use(sequence='fodo')

twiss = mad.table.twiss

# Should still work:
assert names == twiss.dframe(index='name').index.tolist()

# The following assert demonstrates the current behaviour and is
# meant to detect if the MAD-X implementation changes. It may lead
# to crashes or change in the future. In that case, please remove
# this line. It does not represent desired behaviour!
assert mad.table.twiss.row_names() == \
['#s', '#e', 'dfd', 'mqd', 'dff', 'mqf']


def _get_elems(mad, seq_name):
elems = mad.sequence[seq_name].elements
elem_idx = dict((el.node_name, i) for i, el in enumerate(elems))
Expand Down
51 changes: 0 additions & 51 deletions test/test_pandas.py

This file was deleted.

0 comments on commit 23d2d26

Please sign in to comment.