class paramtools.parameters.Parameters(initial_state: Optional[dict] = None, index_rates: Optional[dict] = None, **ops)[source]
adjust(params_or_path: Union[str, Mapping[str, List[NewType.<locals>.new_type]]], ignore_warnings: bool = False, raise_errors: bool = True, extend_adj: bool = True, clobber: bool = True)[source]

Deserialize and validate parameter adjustments. params_or_path can be a file path or a dict that has not been fully deserialized. The adjusted values replace the current values stored in the corresponding parameter attributes.

If clobber is True and extend mode is on, then all future values for a given parameter be replaced by the values in the adjustment. If clobber is False and extend mode is on, then user-defined values will not be replaced by values in this adjustment. Only values that were added automatically via the extend method will be updated.

This simply calls a private method _adjust to do the upate. Creating this layer on top of _adjust makes it easy to subclass Parameters and implement custom adjust methods.


  • params_or_path: Adjustment that is either a dict, file path, or JSON string.

  • ignore_warnings: Whether to raise an error on warnings or ignore them.

  • raise_errors: Either raise errors or simply store the error messages.

  • extend_adj: If in extend mode, this is a flag indicating whether to extend the adjustment values or not.

  • clobber: If in extend mode, this is a flag indicating whether to override all values, including user-defined values, or to only override automatically created values.


  • params: Parsed, validated parameters.


  • marshmallow.exceptions.ValidationError if data is not valid.

  • ParameterUpdateException if label values do not match at least one existing value item’s corresponding label values.


Reset the state of the Parameters instance.

extend(label: Optional[str] = None, label_values: Optional[List[Any]] = None, params: Optional[List[str]] = None, raise_errors: bool = True, ignore_warnings: bool = False)[source]

Extend parameters along label.


  • label: Label to extend values along. By default, label_to_extend is used.

  • label_values: values of label to extend. By default, this is a grid created from the valid values of label_to_extend.

  • params: Parameters to extend. By default, all parameters are extended.

  • raise_errors: Whether adjust should raise or store errors.

  • ignore_warnings: Whether adjust should raise or ignore warnings.


  • InconsistentLabelsException: Value objects do not have consistent labels.

extend_func(param: str, extend_vo: NewType.<locals>.new_type, known_vo: NewType.<locals>.new_type, extend_grid: List, label: str)[source]

Function for applying indexing rates to parameter values as they are extended. Projects may implement their own extend_func by overriding this one. Projects need to write their own indexing_rate method for returning the correct indexing rate for a given parameter and value of label.


  • extend_vo: New ValueObject.

from_array(param, array=None, **labels)[source]

Convert NumPy array to a Value object.


  • param: Name of parameter to convert to a list of value objects.

  • array: Optionally, provide a NumPy array to convert into a list of value objects. If not specified, the value at self.param will be used.

  • labels: Optionally, override instance state.


  • List of ValueObjects


  • InconsistentLabelsException: Value objects do not have consistent labels.


Parse and validate labels.


  • Parsed and validated labels.

read_params(params_or_path: Union[str, pathlib.Path, IO, Dict[str, any]], storage_options: Optional[Dict[str, Any]] = None)[source]

Read JSON data of the form:

  • Python dict.

  • JSON string.

  • Local file path.

  • Any URL readable by fsspec. For example:
    • s3: s3://paramtools-test/defaults.json

    • gcs: gs://paramtools-dev/defaults.json

    • http:

    • github: github://PSLmodels:ParamTools@master/paramtools/tests/defaults.json

Returns - params: Python Dict created from JSON file.


Sets state for the Parameters instance. The _state, label_grid, and parameter attributes are all updated with the new state.

Use the view_state method to inspect the current state of the instance, and use the clear_state method to revert to the default state.


  • ValidationError if the labels kwargs contain labels that are not specified in schema.json or if the label values fail the validator set for the corresponding label in schema.json.

sort_values(data=None, has_meta_data=True)[source]

Sort value objects for all parameters in data according to the order specified in schema.


  • data: Parameter data to be sorted. This should be a dict of parameter names and values. If data is None, the current values will be sorted.

  • has_meta_data: Whether parameter values should be accessed directly or through the “value” attribute.


  • Sorted data.

specification(use_state: bool = True, meta_data: bool = False, include_empty: bool = False, serializable: bool = False, sort_values: bool = False, **labels)[source]

Query value(s) of all parameters along labels specified in labels.


  • use_state: Use the instance’s state for the select operation.

  • meta_data: Include information like the parameter description and title.

  • include_empty: Include parameters that do not meet the label query.

  • serializable: Return data that is compatible with json.dumps.

  • sort_values: Sort values by the label order.


  • dict of parameter names and data.

to_array(param, **labels)[source]

Convert a Value object to an n-labelal array. The list of Value objects must span the specified parameter space. The parameter space is defined by inspecting the label validators in schema.json and the state attribute of the Parameters instance.

  • param: Name of parameter that will be used to create array.

  • labels: Optionally, override instance state.


  • arr: NumPy array created from list of value objects.


  • InconsistentLabelsException: Value objects do not have consistent labels.

  • SparseValueObjectsException: Value object does not span the entire space specified by the Order object.

  • ParamToolsError: Parameter is an array type and has labels. This is not supported by ParamTools when using array_first.


Access the label state of the Parameters instance.