Version 0.5.0. What's new?
Quickly:
- Linting ignores the variables inside save_acquisition
- New AcquisitionLoop which saves on edit
- Possibility to save data with setitem on aqm
- Possibility to precise inside the analysis_cell the name of the expected acquisition
- Parse config files more easily
- Prerun hook, i.e. a function that runs at the beginning of each acquisition or analysis.
Linting ignores the variables inside save_acquisition
The title is explicit, now there is no need to write `noqa` at the end of each line of `save_acquisition`, all variables are ignored automatically.
New AcquisitionLoop which saves on edit
Previously `AcquisitionLoop` did not support saving on edit, or to be more precise, it saved everything every time something changed. This is not normal, so this module has been rewritten and now only saves the part that has been changed.
Usage is the same:
python
aqm['loop'] = loop = AcquisitionLoop()
for i in loop.iter(10):
loop.append(x=i**2)
aqm.save_acquisition()
Or the same thing in the more short way:
python
aqm['loop'] = loop = AcquisitionLoop()
for i in loop(10):
loop(x=i**2)
aqm.save_acquisition()
Note: In case of any bugs, the old AcquisitionLoop is still available using `AcquisitionLoopOld` class. But if there's any problem open an issue, please.
Possibility to save data with setitem on aqm
Now it's possible to save data as:
python
aqm['loop'] = AcquisitionLoop()
Instead of this:
python
aqm.aq['loop'] = AcquisitionLoop()
Note:
- This function is only available **inside `acquisition_cell`** and **not `analysis_cell`**. Inside an analysis_cell use `aqm.d['key']=value` to save something.
- It's only possible to save data and not get it. To get data use `aqm.d['key']` inside `analysis_cell` or `aqm.aq['key']` inside `acquisition_cell`.
Possibility to precise inside the analysis_cell the name of the expected acquisition
Sometimes you have to double-check that you don't start the wrong analysis. Now it's possible to specify inside an analysis_cell which acquisition_cell it should follow.
Suppose an acquisition cell is:
python
aqm.acquisition_cell("measure_1")
...
Then, inside an analysis cell:
python
aqm.analysis_cell(acquisition_name = "measure_1")
...
It's also possible to use regex syntax:
(note: string should start with `^`)
python
aqm.analysis_cell(acquisition_name = r"^measure_\d")
...
Parse config files more easily
From v0.4.0 it was possible to do something like this to output the values:
python
aqm.parse_config_str(["a", "b"]) -> 'a = 123; b = 123000'
But what if you needed to get the actual value? The solution before was:
python
aqm.set_default_config_files(['config1.py', 'config2.py'])
data = aqm.parse_config()
data['x'] -> 123
data.b -> 123
Now you can do:
python
aqm.set_default_config_files(['config1.py', 'config2.py'])
aqm.cfg['x'] -> 123
aqm.cfg.b -> 123000
Note: values inside the config files are calculated once and then cached to make access quicker. Therefore, you should not modify them.
Prerun hook
If you have a default function that should be run before each acquisition or analysis, it's possible to provide it as a hook.
First, define the function:
python
def check_instruments():
...
Then inside the acquisition cell give this function as an argument:
python
aqm.acquisition_cell('measure_1', prerun=check_instruments)
...
It is also possible to pass a default function for all acquisition cells:
python
aqm.set_acquisition_cell_prerun_hook(check_instruments)
Note:
- It's possible to provide a list of functions or do a mix between default functions and locally given ones.
- The same possibility exists for `analysis_cell`. Use `prerun` as a keyword or `set_analysis_cell_prerun_hook` for the global definition.
Minor features
- tight_layout is run by default before saving the figure.
- Almost everything is tested so hope a number of the errors will converge to zero. Coverage report: 96%.