-
Notifications
You must be signed in to change notification settings - Fork 18
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
Checking of Madx commands #9
Comments
Hello |
Hey, welcome to github! Two beginner tips first:
Did you consider to just leave these commands in a If you really do need python code to input these commands: Most MAD-X commands can be converted to python syntax pretty straight forward, e.g.: # (assuming your Madx instance is called `madx`:)
madx.command.select(flag="error", clear=True)
# note the trailing underscore in 'class_' is needed because class is a python keyword:
madx.command.select(flag="error", class_="quadrupole")
# Now this command is a bit non-standard and currently cpymad does a bad job getting it right.
# But you can still generate your command string manually and input it to cpymad:
madx.input('efcomp, order:=0, radius:=0.013, dknr={tgauss(2)*1e-4,tgauss(2)*1e-3};')
madx.command.esave(file="efield.tab0") I agree that many of this should be simplified and made more straight forward, but this is not on the top of my priority list right now;) |
Hi. |
Concerning the original issue: implemented in the branch merged in 24717d2. |
- command/element etc: * retrieve information about commands from MAD-X ``defined_commands`` and store in ``Command`` instances. * use ``Command`` to improve command string generation and type-checks in ``util.mad_command`` (#9) * quote filename parameters when composing command string * use deferred expressions (``:=``) whenever passing strings to non-string parameters (#11) * subclass elements, beam from ``Command`` * support attribute access for table/mappings/commands/elements/beams etc * allow case-insensitive access * overload index-access in tables to retrieve rows * implement ``Element.__delitem__`` by setting value to default * return name for global elements too * add ``Madx.base_types`` data variable that yields the base elements * add ``Element.parent``/``base_type`` attributes * more concise string representations * strip -Proxy suffix from class names * apply user defined row/column selections even when no output file is specified - installation: * automatically use ``-lquadmath`` * add ``--static`` flag for setup script, use ``--shared`` by default * no more need to link against PTC shared object separately * finally provide some binary wheels for py 3.5 and 3.6 (#32) - raise cython language_level to 3
Currently, commands are checked only rudimentary. By defining a list of allowed parameters (+types) it should be easy to check any Madx command before execution.
EDIT: This information is already available in
mad_dict.c
, i.e. in theconst_command_def
variable, or just using thedefined_commands
...So scratch the following:
I have something like this in mind:The text was updated successfully, but these errors were encountered: