Commit 52bcbe68 authored by Tobias Hangleiter's avatar Tobias Hangleiter
Browse files

Merge branch 'wetfridge/master' into 'master'

New input module

See merge request !5
parents 156e55a0 e6fe181b
......@@ -5,11 +5,14 @@ pip install git+https://git.rwth-aachen.de/qutech/qutil.git
```
However, this package profits from everybody's work so please make a development install and contribute your changes. You can do this via
```
git clone git+https://git.rwth-aachen.de/qutech/qutil.git
cd qutil
python setup.py develop
pip install -e git+https://git.rwth-aachen.de/qutech/qutil.git#egg=qutil
```
This will link the files into your environment instead of copying them. If you are on windows you can use [SourceTree](https://www.sourcetreeapp.com/) which is a nice GUI for git.
This will download the source code (i.e. clone the git repository) into a subdirectory of the `./src` argument and link the files into your environment instead of copying them. If you are on windows you can use [SourceTree](https://www.sourcetreeapp.com/) which is a nice GUI for git.
You can specify the source code directory with the `--src` argument (which needs to be BEFORE `-e`):
```
pip install --src some_directory/my_python_source -e git+https://git.rwth-aachen.de/qutech/qutil.git#egg=qutil
```
If you have already downloaded/cloned the package yourself you can use `python setup.py develop`.
## qutil.plotting
`cycle_plots` helps you cycling through many plots with the arrow keys (there are probably much better functions for this out there)
......@@ -42,3 +45,5 @@ This module contains a everything from `itertools`, `more_itertools` and custom
## qutil.caching
Here you find decorators, functions and classes that help you implement caching like `file_cache` and `lru_cache`. This is helpful if you need to call computationally expensive functions with the same arguments repeatedly.
## qutil.io
User input related functions like `query_yes_no`.
from . import const, linalg, matlab, plotting, ui, qi
from . import const, linalg, matlab, plotting, ui, qi, io
__version__ = '0.1'
__all__ = ['const', 'linalg', 'matlab', 'ui', 'plotting', 'qi']
__all__ = ['const', 'linalg', 'matlab', 'ui', 'plotting', 'qi', 'io']
import sys
def query_yes_no(question, default="yes"):
"""Ask a yes/no question via input() and return their answer.
"question" is a string that is presented to the user.
"default" is the presumed answer if the user just hits <Enter>.
It must be "yes" (the default), "no" or None (meaning
an answer is required of the user).
The "answer" return value is True for "yes" or False for "no".
"""
valid = {"yes": True, "y": True, "ye": True,
"no": False, "n": False}
if default is None:
prompt = " [y/n] "
elif default == "yes":
prompt = " [Y/n] "
elif default == "no":
prompt = " [y/N] "
else:
raise ValueError("invalid default answer: '%s'" % default)
while True:
sys.stdout.write(question + prompt)
choice = input().lower()
if default is not None and choice == '':
return valid[default]
elif choice in valid:
return valid[choice]
else:
sys.stdout.write("Please respond with 'yes' or 'no' "
"(or 'y' or 'n').\n")
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment