waves.utilities.validators#

Provides a series of validation functions for commonly used keyword arguments in the Project results methods.

Functions

check_dict_consistency(dict_values, output_name)

Check a dictionary to ensure all values are equal to each other (or None).

validate_by(by)

Checks that the by input is valid.

validate_common_inputs([which])

Validates the standard inputs to many of Project's results methods.

validate_frequency(frequency)

Checks that the frequency input is valid.

validate_per_capacity(per_capacity)

Checks that the per_capacity input is valid.

validate_units(units)

Checks that the units input is valid.

waves.utilities.validators.check_dict_consistency(dict_values, output_name)[source]#

Check a dictionary to ensure all values are equal to each other (or None).

Parameters:
  • dict_values (dict) -- Dictionary containing values to checks.

  • output_name (str) -- Name of the output (for error messages only).

Raises:
  • ValueError -- Raised if none of the items in the dict contain a non-None value.

  • ValueError -- Raised if there is more than one distinct non-None value in the dict.

waves.utilities.validators.validate_frequency(frequency)[source]#

Checks that the frequency input is valid.

Parameters:

frequency (str) -- Date frequency for the timeseries aggregation. Must be one of "project", "annual", or "month-year".

Raises:

ValueError -- Raised if the input to frequency is not one of "project", "annual", or "month-year".

waves.utilities.validators.validate_units(units)[source]#

Checks that the units input is valid.

Parameters:

units (str) -- Power-basis for the energy calculation. Must be one of "gw", "mw", or "kw".

Raises:

ValueError -- Raised if the input to units is not one of "gw", "mw", or "kw".

waves.utilities.validators.validate_per_capacity(per_capacity)[source]#

Checks that the per_capacity input is valid.

Parameters:

per_capacity (str) -- Power-basis for the energy calculation. Must be one of "gw", "mw", "kw", or None.

Raises:

ValueError -- Raised if the input to per_capacity is not one of "gw", "mw", or "kw".

waves.utilities.validators.validate_by(by)[source]#

Checks that the by input is valid.

Parameters:

by (str) -- Wind farm aggregation basis. Must be one of "windfarm" or "turbine".

Raises:

ValueError -- Raised if the input to by is not one of "windfarm" or "turbine".

waves.utilities.validators.validate_common_inputs(which=None)[source]#

Validates the standard inputs to many of Project's results methods. This is a convenience wrapper to writing boilerplate checks for each aggregation method.

Parameters:

which (list[str], optional) -- The names of the method arguments that should be validated. Can only be frequency, units, or by.