banana.navigator package

banana.navigator.launch_navigator(imports=None, cfg_path=None, skip_cfg=False, pylab=True)[source]

Launch navigator.

Parameters:
  • imports (list(str)) – name of packages/modules to be imported (the whole content is directly imported in the global namespace); if None is considered to be empty (default: None)

  • cfg_path (str or os.PathLike) – path to configuration file or containing folder (if using the conventional name banana.cfg.name); if None or pointing to a non-existing file, automatic detection is attempted (default: None)

  • skip_cfg (bool) – whether to skip configurations loading; useful if this function is invoked by a script, that is pre-loading configurations on its own (default: False)

  • pylab (bool) – whether to load matplotlib.pylab members in the global namespace (default: True)

banana.navigator.register_globals(mod, app)[source]

Submodules

banana.navigator.navigator module

class banana.navigator.navigator.NavigatorApp(cfgpath, external=None)[source]

Bases: ABC

Navigator base class holding all elementry operations.

Parameters:
  • cfgpath (str or os.PathLike) – path to banana configuration

  • external (str) – mode identifier

cache_as_dfd(doc_id)[source]

Load all structure functions in log as DataFrame

Parameters:

doc_id (str or int) – document identifier, see get()

Returns:

log – DataFrames

Return type:

DFdict

change_external(external)[source]

Change mode

Parameters:

mode (string) – mode identifier

compare_external(dfd1, dfd2)[source]

Compare two results in the cache.

It’s taking two results from external benchmarks and compare them in a single table.

Parameters:
  • dfd1 (dict or hash) – if hash the doc_hash of the cache to be loaded

  • dfd2 (dict or hash) – if hash the doc_hash of the cache to be loaded

crashed_log(doc_id)[source]

Check if the log passed the default assertions.

Parameters:

doc_id (str or int) – document identifier, see get()

Returns:

cdfd – log without kinematics

Return type:

dict

get(table, doc_id)[source]

Table getter wrapper.

Parameters:
Returns:

the retrieved document

Return type:

dict

get_all(table)[source]

Get full table.

Parameters:

table (str) – table identifier

Returns:

the full list of documents in the table

Return type:

list(dict)

get_by_log(table, log_id)[source]

Get card related to given log.

Parameters:
  • table (str) – table identifier (of the table from which to get the final card)

  • log_id (int or str) – document identifier of the chosen log, see get()

Returns:

the retrieved document

Return type:

dict

hash_len = 6
abstract static is_valid_physical_object(name)[source]

Identifies physical objects.

Used to test names, in order to distinguish physical quantities from metadata.

Parameters:

name (str) – name to test

Returns:

test response

Return type:

bool

list_all(table, input_data=None, cut_hash=True)[source]

List all elements in a nice table.

Parameters:
  • table (string) – table identifier

  • input_data (list) – data to list

  • cut_hash (bool) – shorten hash if TRUE

Returns:

df – list

Return type:

pandas.DataFrame

list_all_similar_logs(doc_id)[source]

List logs with similar input.

Search logs which are similar to the one given, i.e., same theory and, same observable, and same pdfset.

Parameters:

doc_id (str or int) – document identifier, see get()

Returns:

df – created frame

Return type:

pandas.DataFrame

Note

The external it’s not used to discriminate logs: even different externals should return the same numbers, so it’s relevant to keep all of them.

static load_dfd(dfd, retrieve_method)[source]
log_as_dfd(doc_id)[source]

Load all structure functions in log as DataFrame

Parameters:

doc_id (str or int) – document identifier, see get()

Returns:

log – DataFrames

Return type:

DFdict

myname = 'banana'
remove(table, records)[source]

Remove chosen elements from given table

Parameters:
  • table (str) – table identifier

  • records (list(str or int or dict)) –

    records to remove, specified as:

    • str: partial hash

    • int, >=0: uid

    • int, <0: position from the end of the table

    • dict: the record itself

show_full_logs(t_fields=None, o_fields=None, keep_hashes=False)[source]

Show additional, associated fields in the logs (JOIN).

Parameters:
  • t_fields (list) – theory fields

  • o_fields (list) – ocard fields

  • keep_hashes (boolean) – display hashes?

Returns:

df – data frame

Return type:

pandas.DataFrame

subtract_tables(dfd1, dfd2)[source]

Subtract comparison tables.

Subtract results in the second table from the first one, properly propagate the integration error and recompute the relative error on the subtracted results.

Parameters:
  • dfd1 (dict or hash) – if hash the doc_hash of the log to be loaded

  • dfd2 (dict or hash) – if hash the doc_hash of the log to be loaded

Returns:

diffout – created frames

Return type:

DFdict

table_manager(table)[source]

Get corresponding TableManager

Parameters:

table (str) – table identifier

Returns:

tm – corresponding TableManager

Return type:

yadmark.table_manager.TableManager

table_name(table_abbrev)[source]

Expand a table short cut to its full name

Parameters:

table_abbrev (str) – short cut

Returns:

name – full name

Return type:

str

table_objects = {'c': <class 'banana.data.db.Cache'>, 'l': <class 'banana.data.db.Log'>, 't': <class 'banana.data.db.Theory'>}
truncate(table)[source]

Empty chosen table

Parameters:

table (str) – table identifier

banana.navigator.table_manager module

class banana.navigator.table_manager.TableManager(session, table_object)[source]

Bases: object

Wrapper to a single table

Parameters:
all()[source]

Retrieve all entries

Returns:

the retrieved entries

Return type:

list(dict)

get(hash_or_uid)[source]

Retrieve an entry

Parameters:

hash_or_uid (str or int) –

if str partial hash to match (corresponding to the first len(hash_or_uid) characters of the hash), if int:

  • if positive: the uid of the record to retrieve

  • if negative: position from last

Returns:

the retrieved entry

Return type:

dict

Raises:

sql.RetrieveError – if not a single entry corresponds to the give identifier (so both for no entries and multiple entries)

remove(records)[source]

Remove given elements.

Parameters:

records (list(str or int or dict)) –

records to remove, specified as:

  • str: partial hash

  • int, >=0: uid

  • int, <0: position from the end of the table

  • dict: the record itself

truncate()[source]

Truncate all elements.

update_atime(records)[source]

Update access time for given records.

Parameters:

records (list(dict)) – records to update

banana.navigator.utils module

banana.navigator.utils.compare_dicts(d1, d2, exclude_underscored=False, key_width=20, value_width=30, exclude_keys=None)[source]

Compare similar dictionaries.

Check which entries of the two dictionaries are different, and output the values.

Parameters:
  • d1 (dict) – first dict

  • d2 (dict) – second dict

  • exclude_underscored (bool) – skip keys prefixed with _ (default: False)

  • key_width (int) – print width of key (default: 20)

  • value_width (int) – print width of values (default: 30)

  • exclude_keys (None or list) – if not None, keys contained in this list do not take part in the comparison