iodutil

buzz.iodutil

Functions

changedictnamespace(dict, namespace[, append])

Change the namespace of a dictionary.

combineiod(input_dict, output_dict)

combines the input and output dictionaries into a single dictionary

connectDicts(d1, d2[, inlist, outlist])

Combine input and output dictionaries

getNamespace(sys)

Get the namespace of a system

iskeyinput(key)

returns True if the key is an input to the control system and False if it is an output

listinputs(iod[, values])

returns a list of the inputs to the control system either their names or their values

listoutputs(iod[, values])

returns a list of the outputs to the control system either their names or their values

removeIodIndices(iod, inputs_to_remove, ...)

Take an iod and remove the inputs and outputs specified by the indices and or names provided in the inputs_to_remove and outputs_to_remove lists

squareDict(d)

Square the dictionary by removing any holes in the indices and moving down those with higher indices to fill the holes

Details

changedictnamespace(dict, namespace, append=False)[source]

Change the namespace of a dictionary.

Parameters:
  • dict (dict) – The dictionary to change the namespace of.

  • namespace (str) – The new namespace.

  • append (bool) – wheather to just append the new name space to the old one ‘A.in’ becomes ‘EA.in’

Returns:

The dictionary with the new namespace.

Return type:

dict

combineiod(input_dict, output_dict)[source]

combines the input and output dictionaries into a single dictionary

Parameters:
  • i (dict) – dictionary of the input names and values

  • o (dict) – dictionary of the output names and values

Returns:

dictionary of the input and output names and values

Return type:

dict

connectDicts(d1, d2, inlist=None, outlist=None)[source]

Combine input and output dictionaries

Parameters:
  • d1 (dict) – first dictionary

  • d2 (dict) – second dictionary

  • inlist (list, optional) – list of inputs to connect. Defaults to None.

  • outlist (list, optional) – list of outputs to connect. Defaults to None.

Returns:

combined dictionary

Return type:

dict

getNamespace(sys)[source]

Get the namespace of a system

Parameters:

sys (dict or Bunch) – State space model or bunch system with mod as attribute

Returns:

Namespace

Return type:

dict

iskeyinput(key: str)[source]

returns True if the key is an input to the control system and False if it is an output

Parameters:

key (str) – string of the input or output name

Returns:

is the name an input or output name. true if input, false if output, none if not a valid name

Return type:

boolean

listinputs(iod, values=False)[source]

returns a list of the inputs to the control system either their names or their values

Parameters:
  • iod (dict) – dictionary of the input and output names and indices or wield.control.mimo iod object

  • values (bool, optional) – if True, return the values of the inputs. Defaults to False.

Returns:

list of the input names or values if values is True

Return type:

list

listoutputs(iod, values=False)[source]

returns a list of the outputs to the control system either their names or their values

Parameters:
  • iod (dict) – dictionary of the input and output names and indices or wield.control.mimo iod object

  • values (bool, optional) – if True, return the values of the outputs. Defaults to False.

Returns:

list of the output names or values if values is True

Return type:

list

removeIodIndices(iod, inputs_to_remove, outputs_to_remove)[source]

Take an iod and remove the inputs and outputs specified by the indices and or names provided in the inputs_to_remove and outputs_to_remove lists

Parameters:
  • iod (dict or Bunch) – input/output dictionary or bunch system with iod as attribute

  • inputs_to_remove (list) – List of indices or names of inputs to remove

  • outputs_to_remove (list) – List of indices or names of outputs to remove

Returns:

Input/output dictionary with the removed inputs and outputs

Return type:

dict

squareDict(d)[source]

Square the dictionary by removing any holes in the indices and moving down those with higher indices to fill the holes

Parameters:

d (dict) – dictionary to square

Returns:

squared dictionary

Return type:

dict