Skip to content

Version 0.4.0. What's new?

Quickly:

  • Linting error inside analysis_cell!
  • Function to parse your config files
  • New class AttrDict. Classical dictionary accessible by attr

Parse config files

aqm.set_default_config_files(['config1.py', 'config2.py'])

aqm.parse_config_str(["a", "b"]) # ->  'a = 123; b = 123000'

Units and format

It's possible to provide a unit and a format to parse config function. Use the such structure for the string key__unit__format.

Examples:

# from config: k = 123.54321

aqm.parse_config_str(["k__ms__2f"]) # -> 'k = 123.54 (ms)'

aqm.parse_config_str(["k__ms"]) # -> 'a = 123.54321 (ms)'

aqm.parse_config_str(["k__2f"]) # -> 'a = 123.54'

aqm.parse_config_str(["k__2e"]) # -> 'a = 1.23e+02'

Warning when analyzing old data

Now when you're analyzing old files using aqm.analysis_cell inside the Jupyter notebook you will see a warning.

Linting!

Now analysis cell is parsed in the search for a classical error.

It happens a lot that you use by mistake global variables inside analysis_cell, now you can prevent it.

How to setup

You can set explicitly which external variables you are allowed to use inside analysis_cell

aqm.linting(allowed_variables=['aqm', 'plt'])

Or you can parse the init_analyse file. (Normally this is a file which is run before running the analysis cell so you are allowed to use any variables from it)

aqm.linting(init_file="files/init_analyse.py")

Note that this function will not look inside if you use import of type from module import *

How to use

After running aqm.linting there is nothing more to do, just run the usual aqm.analysis_cell and see if there are any warnings.

If some usage of global variables should be ignored add # noqa at the end of the line.

AttrDict

Now there is a new class available: AttrDict. It's a classical dictionary but allows to access it by attributes.

Simple example:

data = AttrDict({'a': 123})
print(data.a) # -> 123

Recursive example:

data = AttrDict({'a':{'b': 456}})
print(data.a.b) # -> 456

Feature: Now parsed data from the config files are returned as an instance of AttrDict, so it can be easily accessed.

Minor features

  • SyncData.asdict() -> dict
  • more tests