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 ...@@ -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 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 pip install -e git+https://git.rwth-aachen.de/qutech/qutil.git#egg=qutil
cd qutil
python setup.py develop
``` ```
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 ## qutil.plotting
`cycle_plots` helps you cycling through many plots with the arrow keys (there are probably much better functions for this out there) `cycle_plots` helps you cycling through many plots with the arrow keys (there are probably much better functions for this out there)
...@@ -22,7 +25,7 @@ In this module there are functions that are helpful for reading `.mat` files, es ...@@ -22,7 +25,7 @@ In this module there are functions that are helpful for reading `.mat` files, es
This module defines all the constants you could wish for as well as functions to convert temperatures (`convert_temperature`) or between wavelengths and frequencies (`lambda2nu`, `nu2lambda`). For an overview, see the module docstring. This module defines all the constants you could wish for as well as functions to convert temperatures (`convert_temperature`) or between wavelengths and frequencies (`lambda2nu`, `nu2lambda`). For an overview, see the module docstring.
## qutil.linalg ## qutil.linalg
This module provides several handy linear algebra functions. While some are implemented elsewhere, the implementation here is typically speedier for large arrays. For example, `pauli_expm` exploits the fact that a matrix exponential of Pauli matrices can be written as a cosine times the identity matrix plus a sine times the Paulis to speed up the calculation. This module provides several handy linear algebra functions. While some are implemented elsewhere, the implementation here is typically speedier for large arrays. For example, `pauli_expm` exploits the fact that a matrix exponential of Pauli matrices can be written as a cosine times the identity matrix plus a sine times the Paulis to speed up the calculation.
For an overview of the included functions, see the module docstring. For an overview of the included functions, see the module docstring.
...@@ -42,3 +45,5 @@ This module contains a everything from `itertools`, `more_itertools` and custom ...@@ -42,3 +45,5 @@ This module contains a everything from `itertools`, `more_itertools` and custom
## qutil.caching ## 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. 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' __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