Skip to content

Commit

Permalink
Merge 6f2b836 into e9507e7
Browse files Browse the repository at this point in the history
  • Loading branch information
coldfix committed Aug 13, 2021
2 parents e9507e7 + 6f2b836 commit bf27bff
Show file tree
Hide file tree
Showing 11 changed files with 1,260 additions and 1,249 deletions.
9 changes: 3 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -211,16 +211,13 @@ jobs:
pip install cpymad -f dist --no-index --no-deps
pip install cpymad
- run: pip install flake8 twine coverage coveralls
- run: pip install flake8 twine coverage coveralls pytest
- run: twine check dist/*
- run: flake8

- run: coverage run --source=cpymad -p test/test_util.py -v
- run: coverage run --source=cpymad -p test/test_madx.py -v
- run: coverage run --source=cpymad -p test/test_regression.py -v

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

- run: coverage combine
- run: coveralls
Expand Down
3 changes: 1 addition & 2 deletions HACKING.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Hacking
~~~~~~~

Try to be consistent with the PEP8_ guidelines. Add `unit tests`_ for all
Try to be consistent with the PEP8_ guidelines. Add tests for all
non-trivial functionality. `Dependency injection`_ is a great pattern to
keep modules testable.

Expand All @@ -10,6 +10,5 @@ titles and also add an explaining commit message unless the modification is
trivial. See also: `A Note About Git Commit Messages`_.

.. _PEP8: http://www.python.org/dev/peps/pep-0008/
.. _`unit tests`: http://docs.python.org/2/library/unittest.html
.. _`Dependency injection`: http://www.youtube.com/watch?v=RlfLCWKxHJ0
.. _`A Note About Git Commit Messages`: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
4 changes: 4 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ doc =
sphinx_automodapi
sphinx_autodoc_typehints
pandas
dev =
cython
flake8
pytest

[flake8]
# codes: https://pycodestyle.readthedocs.io/en/latest/intro.html#error-codes
Expand Down
15 changes: 12 additions & 3 deletions src/cpymad/madx.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,14 @@ class Madx:
"""

def __init__(self, libmadx=None, command_log=None, stdout=None,
history=None, **Popen_args):
history=None, prompt=None, **Popen_args):
"""
Initialize instance variables.
:param libmadx: :mod:`libmadx` compatible object
:param command_log: Log all MAD-X commands issued via cpymad.
:param stdout: file descriptor, file object or callable
:param str prompt: prefix for a new :class:`CommandLog`
:param Popen_args: Additional parameters to ``subprocess.Popen``
If ``libmadx`` is NOT specified, a new MAD-X interpreter will
Expand All @@ -154,9 +155,17 @@ def __init__(self, libmadx=None, command_log=None, stdout=None,
m = Madx(stdout=sys.stdout)
"""
# open history file
if isinstance(command_log, str):
command_log = CommandLog.create(command_log)
# open new history file:
command_log = CommandLog.create(command_log, prompt or '')
elif hasattr(command_log, 'write'):
# assuming stream already opened:
command_log = CommandLog(command_log, prompt or '')
elif prompt is not None:
assert command_log is None, \
"Passing fully constructed `command_log` instances is " \
"incompatible with parameter `prompt`."
command_log = CommandLog(sys.stdout, prompt)
self.reader = NullContext()
# start libmadx subprocess
if libmadx is None:
Expand Down
Loading

0 comments on commit bf27bff

Please sign in to comment.