Tools

In this module, several functions, used in the rest of the code, are available to create dictionaries, modify parameters, or convert prices, among other aspects.

CPR.tools.get_params(file, numerical_key=False)

Function to create a dictionary from a .csv file.

Parameters
  • file (_io.TextIOWrapper) – csv file

  • numerical_key (bool, optional) – numerical key, by default False

Returns

Dictionary of parameters.

Return type

dict

CPR.tools.add_params_as_attr(inst, file)

Function to add parameters to a class instance.

Parameters
  • inst (object) – class instance

  • file (_io.TextIOWrapper) – csv file

CPR.tools.change_params(inst, extra_params)

Function to update the value of some parameters in inst with values from extra_params.

Parameters
  • inst (dict) – parameters

  • extra_params (dict) – parameters to be updated and their new values

CPR.tools.create_nom_real(year, prices)

Creation of a function to convert prices from real to nominal and from nominal to real, with base year 2018.

Parameters
  • year (int) – year

  • prices (Prices) – instance of the class Prices

Returns

  • function – Function converting nominal to real.

  • function – Function converting real to nominal.

CPR.tools.create_nom(year, prices)

Creation of a function that converts prices from real to nominal, with base year 2018. Used for some specific purposes elsewhere in the code.

Parameters
  • year (int) – year

  • prices (Prices) – instance of the class Prices

Returns

Function converting real to nominal.

Return type

function

CPR.tools.create_real(year, prices)

Creation of a function that converts prices from nominal to real, with base year 2018.

Parameters
  • year (int) – year

  • prices (Prices) – instance of the class Prices

Returns

function converting nominal to real

Return type

function