Skip to content
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

Feedback for PR #6. #7

Open
wants to merge 1 commit into
base: feature/example-script-args
from

Conversation

@clemens-tolboom
Copy link
Contributor

commented Sep 15, 2019

pipenv run python example.py --help
usage: example.py [options]
We have some defaults depending on --mode. {'square': {'amplitude': 0.03, 'frequency': 0.1}, 'sine': {'amplitude': 0.3, 'frequency': 0.04}, 'triangle': {'amplitude': 0.05, 'frequency': 1.8}, 'bump': {'amplitude': 0.05, 'frequency': 1.8}}

optional arguments:
  -h, --help            show this help message and exit
  --mode {flat,sine,square,triangle,bump}, -m {flat,sine,square,triangle,bump}
                        Road profile mode: (default: sine)
  --amplitude AMPLITUDE, -a AMPLITUDE
                        Amplitude (in meters) for given '--mode'
  --frequency FREQUENCY, -f FREQUENCY
                        Frequency for given '--mode'
  --time-step TIME_STEP, -t TIME_STEP
                        Simulation time step in seconds (default: 0.0005)
  --interval INTERVAL, -i INTERVAL
                        Draw animation frame every <interval> time steps
                        (default: 100)
  --write, -w           Write resulting animation to a video file
}
}

argparser = argparse.ArgumentParser(usage='%(prog)s [options]\nWe have some defaults depending on --mode. ' + str(mode_defaults))

This comment has been minimized.

Copy link
@clemens-tolboom

clemens-tolboom Sep 15, 2019

Author Contributor
  • Remove [options]
  • How to pretty print mode_defaults instead of str(mode_defaults?

This comment has been minimized.

Copy link
@clemens-tolboom

clemens-tolboom Sep 15, 2019

Author Contributor

Pretty print

pipenv install pyyaml

could do this like so

    argparser = argparse.ArgumentParser(usage='%(prog)s [options]\nWe have some defaults depending on --mode. ' + yaml.dump(mode_defaults, default_flow_style=False))

then it formats like

pipenv run python example.py --help
usage: example.py [options]
We have some defaults depending on --mode. bump:
  amplitude: 0.05
  frequency: 1.8
sine:
  amplitude: 0.3
  frequency: 0.04
square:
  amplitude: 0.03
  frequency: 0.1
triangle:
  amplitude: 0.05
  frequency: 1.8
)
argparser.add_argument("--frequency", "-f", type=float,
help="Frequency for sine, square, triangle, and bump modes"
help="Frequency for given '--mode'"

This comment has been minimized.

Copy link
@clemens-tolboom

clemens-tolboom Sep 15, 2019

Author Contributor

What is the unit?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.