{"id":32178345,"url":"https://github.com/pslmodels/paramtools","last_synced_at":"2025-10-21T20:53:51.791Z","repository":{"id":53160663,"uuid":"157580006","full_name":"PSLmodels/ParamTools","owner":"PSLmodels","description":"Library for parameter processing and validation with a focus on computational modeling projects","archived":false,"fork":false,"pushed_at":"2025-05-15T15:11:37.000Z","size":8064,"stargazers_count":19,"open_issues_count":6,"forks_count":14,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-10-21T20:53:43.665Z","etag":null,"topics":["psl-cataloged"],"latest_commit_sha":null,"homepage":"https://paramtools.dev","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PSLmodels.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2018-11-14T16:43:30.000Z","updated_at":"2025-08-27T12:18:27.000Z","dependencies_parsed_at":"2024-11-09T09:21:32.706Z","dependency_job_id":"82a5d8cb-e4a9-4d93-8269-f8a2a7e5222b","html_url":"https://github.com/PSLmodels/ParamTools","commit_stats":{"total_commits":436,"total_committers":4,"mean_commits":109.0,"dds":"0.029816513761467878","last_synced_commit":"8d5ff384b5d50ac4a752757e200019733a44d536"},"previous_names":["hdoupe/paramtools"],"tags_count":45,"template":false,"template_full_name":null,"purl":"pkg:github/PSLmodels/ParamTools","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PSLmodels%2FParamTools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PSLmodels%2FParamTools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PSLmodels%2FParamTools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PSLmodels%2FParamTools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PSLmodels","download_url":"https://codeload.github.com/PSLmodels/ParamTools/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PSLmodels%2FParamTools/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280333496,"owners_count":26312845,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-21T02:00:06.614Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["psl-cataloged"],"created_at":"2025-10-21T20:53:48.455Z","updated_at":"2025-10-21T20:53:51.784Z","avatar_url":"https://github.com/PSLmodels.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ParamTools\n\n**Define, update, and validate your model's parameters.**\n\nInstall using pip:\n\n```\npip install paramtools\n```\n\nInstall using conda:\n\n```\nconda install -c conda-forge paramtools\n```\n\n## Usage\n\nSubclass `paramtools.Parameters` and define your model's [parameters](https://paramtools.dev/parameters):\n\n```python\nimport paramtools\n\n\nclass Params(paramtools.Parameters):\n    defaults = {\n        \"schema\": {\n            \"labels\": {\n                \"date\": {\n                    \"type\": \"date\",\n                    \"validators\": {\n                        \"range\": {\n                            \"min\": \"2020-01-01\",\n                            \"max\": \"2021-01-01\",\n                            \"step\": {\"months\": 1}\n                        }\n                    }\n                }\n            },\n        },\n        \"a\": {\n            \"title\": \"A\",\n            \"type\": \"int\",\n            \"value\": [\n                {\"date\": \"2020-01-01\", \"value\": 2},\n                {\"date\": \"2020-10-01\", \"value\": 8},\n            ],\n            \"validators\": {\n                \"range\" : {\n                    \"min\": 0, \"max\": \"b\"\n                }\n            }\n        },\n        \"b\": {\n            \"title\": \"B\",\n            \"type\": \"float\",\n            \"value\": [{\"date\": \"2020-01-01\", \"value\": 10.5}]\n        }\n    }\n```\n\n### Access parameter values\n\nAccess values using `.sel`:\n\n```python\nparams = Params()\n\nparams.sel[\"a\"]\n```\n\n    Values([\n      {'date': datetime.date(2020, 1, 1), 'value': 2},\n      {'date': datetime.date(2020, 10, 1), 'value': 8},\n    ])\n\nLook up parameter values using a pandas-like api:\n\n```python\nfrom datetime import date\n\nresult = params.sel[\"a\"][\"date\"] == date(2020, 1, 1)\nresult\n```\n\n    QueryResult([\n      {'date': datetime.date(2020, 1, 1), 'value': 2}\n    ])\n\n```python\nresult.isel[0][\"value\"]\n```\n\n    2\n\n### Adjust and validate parameter values\n\nAdd a new value:\n\n```python\nparams.adjust({\"a\": [{\"date\": \"2020-11-01\", \"value\": 22}]})\n\nparams.sel[\"a\"]\n```\n\n    Values([\n      {'date': datetime.date(2020, 1, 1), 'value': 2},\n      {'date': datetime.date(2020, 10, 1), 'value': 8},\n      {'date': datetime.date(2020, 11, 1), 'value': 22},\n    ])\n\nUpdate an existing value:\n\n```python\nparams.adjust({\"a\": [{\"date\": \"2020-01-01\", \"value\": 3}]})\n\nparams.sel[\"a\"]\n```\n\n    Values([\n      {'date': datetime.date(2020, 1, 1), 'value': 3},\n      {'date': datetime.date(2020, 10, 1), 'value': 8},\n      {'date': datetime.date(2020, 11, 1), 'value': 22},\n    ])\n\nUpdate all values:\n\n```python\nparams.adjust({\"a\": 7})\n\nparams.sel[\"a\"]\n```\n\n    Values([\n      {'date': datetime.date(2020, 1, 1), 'value': 7},\n      {'date': datetime.date(2020, 10, 1), 'value': 7},\n      {'date': datetime.date(2020, 11, 1), 'value': 7},\n    ])\n\nErrors on values that are out of range:\n\n```python\nparams.adjust({\"a\": -1})\n```\n\n    ---------------------------------------------------------------------------\n\n    ValidationError                           Traceback (most recent call last)\n\n    \u003cipython-input-8-f8f1b7f6cd9a\u003e in \u003cmodule\u003e\n    ----\u003e 1 params.adjust({\"a\": -1})\n\n\n    ~/Paramtools/paramtools/parameters.py in adjust(self, params_or_path, ignore_warnings, raise_errors, extend_adj, clobber)\n        253             least one existing value item's corresponding label values.\n        254         \"\"\"\n    --\u003e 255         return self._adjust(\n        256             params_or_path,\n        257             ignore_warnings=ignore_warnings,\n\n\n    ~/Paramtools/paramtools/parameters.py in _adjust(self, params_or_path, ignore_warnings, raise_errors, extend_adj, is_deserialized, clobber)\n        371             not ignore_warnings and has_warnings\n        372         ):\n    --\u003e 373             raise self.validation_error\n        374\n        375         # Update attrs for params that were adjusted.\n\n\n    ValidationError: {\n        \"errors\": {\n            \"a\": [\n                \"a -1 \u003c min 0 \"\n            ]\n        }\n    }\n\n```python\nparams = Params()\n\nparams.adjust({\"a\": [{\"date\": \"2020-01-01\", \"value\": 11}]})\n```\n\n    ---------------------------------------------------------------------------\n\n    ValidationError                           Traceback (most recent call last)\n\n    \u003cipython-input-9-cc8a21f044d8\u003e in \u003cmodule\u003e\n          1 params = Params()\n          2\n    ----\u003e 3 params.adjust({\"a\": [{\"date\": \"2020-01-01\", \"value\": 11}]})\n\n\n    ~/Paramtools/paramtools/parameters.py in adjust(self, params_or_path, ignore_warnings, raise_errors, extend_adj, clobber)\n        253             least one existing value item's corresponding label values.\n        254         \"\"\"\n    --\u003e 255         return self._adjust(\n        256             params_or_path,\n        257             ignore_warnings=ignore_warnings,\n\n\n    ~/Paramtools/paramtools/parameters.py in _adjust(self, params_or_path, ignore_warnings, raise_errors, extend_adj, is_deserialized, clobber)\n        371             not ignore_warnings and has_warnings\n        372         ):\n    --\u003e 373             raise self.validation_error\n        374\n        375         # Update attrs for params that were adjusted.\n\n\n    ValidationError: {\n        \"errors\": {\n            \"a\": [\n                \"a[date=2020-01-01] 11 \u003e max 10.5 b[date=2020-01-01]\"\n            ]\n        }\n    }\n\nErrors on invalid values:\n\n```python\nparams = Params()\n\nparams.adjust({\"b\": \"abc\"})\n```\n\n    ---------------------------------------------------------------------------\n\n    ValidationError                           Traceback (most recent call last)\n\n    \u003cipython-input-10-8373a2715e38\u003e in \u003cmodule\u003e\n          1 params = Params()\n          2\n    ----\u003e 3 params.adjust({\"b\": \"abc\"})\n\n\n    ~/Paramtools/paramtools/parameters.py in adjust(self, params_or_path, ignore_warnings, raise_errors, extend_adj, clobber)\n        253             least one existing value item's corresponding label values.\n        254         \"\"\"\n    --\u003e 255         return self._adjust(\n        256             params_or_path,\n        257             ignore_warnings=ignore_warnings,\n\n\n    ~/Paramtools/paramtools/parameters.py in _adjust(self, params_or_path, ignore_warnings, raise_errors, extend_adj, is_deserialized, clobber)\n        371             not ignore_warnings and has_warnings\n        372         ):\n    --\u003e 373             raise self.validation_error\n        374\n        375         # Update attrs for params that were adjusted.\n\n\n    ValidationError: {\n        \"errors\": {\n            \"b\": [\n                \"Not a valid number: abc.\"\n            ]\n        }\n    }\n\n### Extend parameter values using label definitions\n\nExtend values using `label_to_extend`:\n\n```python\nparams = Params(label_to_extend=\"date\")\n```\n\n```python\nparams.sel[\"a\"]\n```\n\n    Values([\n      {'date': datetime.date(2020, 1, 1), 'value': 2},\n      {'date': datetime.date(2020, 2, 1), 'value': 2, '_auto': True},\n      {'date': datetime.date(2020, 3, 1), 'value': 2, '_auto': True},\n      {'date': datetime.date(2020, 4, 1), 'value': 2, '_auto': True},\n      {'date': datetime.date(2020, 5, 1), 'value': 2, '_auto': True},\n      {'date': datetime.date(2020, 6, 1), 'value': 2, '_auto': True},\n      {'date': datetime.date(2020, 7, 1), 'value': 2, '_auto': True},\n      {'date': datetime.date(2020, 8, 1), 'value': 2, '_auto': True},\n      {'date': datetime.date(2020, 9, 1), 'value': 2, '_auto': True},\n      {'date': datetime.date(2020, 10, 1), 'value': 8},\n      {'date': datetime.date(2020, 11, 1), 'value': 8, '_auto': True},\n      {'date': datetime.date(2020, 12, 1), 'value': 8, '_auto': True},\n      {'date': datetime.date(2021, 1, 1), 'value': 8, '_auto': True},\n    ])\n\nUpdates to values are carried through to future dates:\n\n```python\nparams.adjust({\"a\": [{\"date\": \"2020-4-01\", \"value\": 9}]})\n\nparams.sel[\"a\"]\n```\n\n    Values([\n      {'date': datetime.date(2020, 1, 1), 'value': 2},\n      {'date': datetime.date(2020, 2, 1), 'value': 2, '_auto': True},\n      {'date': datetime.date(2020, 3, 1), 'value': 2, '_auto': True},\n      {'date': datetime.date(2020, 4, 1), 'value': 9},\n      {'date': datetime.date(2020, 5, 1), 'value': 9, '_auto': True},\n      {'date': datetime.date(2020, 6, 1), 'value': 9, '_auto': True},\n      {'date': datetime.date(2020, 7, 1), 'value': 9, '_auto': True},\n      {'date': datetime.date(2020, 8, 1), 'value': 9, '_auto': True},\n      {'date': datetime.date(2020, 9, 1), 'value': 9, '_auto': True},\n      {'date': datetime.date(2020, 10, 1), 'value': 9, '_auto': True},\n      {'date': datetime.date(2020, 11, 1), 'value': 9, '_auto': True},\n      {'date': datetime.date(2020, 12, 1), 'value': 9, '_auto': True},\n      {'date': datetime.date(2021, 1, 1), 'value': 9, '_auto': True},\n    ])\n\nUse `clobber` to only update values that were set automatically:\n\n```python\nparams = Params(label_to_extend=\"date\")\nparams.adjust(\n    {\"a\": [{\"date\": \"2020-4-01\", \"value\": 9}]},\n    clobber=False,\n)\n\n# Sort parameter values by date for nicer output\nparams.sort_values()\nparams.sel[\"a\"]\n```\n\n    Values([\n      {'date': datetime.date(2020, 1, 1), 'value': 2},\n      {'date': datetime.date(2020, 2, 1), 'value': 2, '_auto': True},\n      {'date': datetime.date(2020, 3, 1), 'value': 2, '_auto': True},\n      {'date': datetime.date(2020, 4, 1), 'value': 9},\n      {'date': datetime.date(2020, 5, 1), 'value': 9, '_auto': True},\n      {'date': datetime.date(2020, 6, 1), 'value': 9, '_auto': True},\n      {'date': datetime.date(2020, 7, 1), 'value': 9, '_auto': True},\n      {'date': datetime.date(2020, 8, 1), 'value': 9, '_auto': True},\n      {'date': datetime.date(2020, 9, 1), 'value': 9, '_auto': True},\n      {'date': datetime.date(2020, 10, 1), 'value': 8},\n      {'date': datetime.date(2020, 11, 1), 'value': 8, '_auto': True},\n      {'date': datetime.date(2020, 12, 1), 'value': 8, '_auto': True},\n      {'date': datetime.date(2021, 1, 1), 'value': 8, '_auto': True},\n    ])\n\n### NumPy integration\n\nAccess values as NumPy arrays with `array_first`:\n\n```python\nparams = Params(label_to_extend=\"date\", array_first=True)\n\nparams.a\n```\n\n    array([2, 2, 2, 2, 2, 2, 2, 2, 2, 8, 8, 8, 8])\n\n```python\nparams.a * params.b\n```\n\n    array([21., 21., 21., 21., 21., 21., 21., 21., 21., 84., 84., 84., 84.])\n\nOnly get the values that you want:\n\n```python\narr = params.to_array(\"a\", date=[\"2020-01-01\", \"2020-11-01\"])\narr\n```\n\n    array([2, 8])\n\nGo back to a list of dictionaries:\n\n```python\nparams.from_array(\"a\", arr, date=[\"2020-01-01\", \"2020-11-01\"])\n```\n\n    [{'date': datetime.date(2020, 1, 1), 'value': 2},\n     {'date': datetime.date(2020, 11, 1), 'value': 8}]\n\n## Documentation\n\nFull documentation available at [paramtools.dev](https://paramtools.dev).\n\n## Contributing\n\nContributions are welcome! Checkout [CONTRIBUTING.md][3] to get started.\n\n## Credits\n\nParamTools is built on top of the excellent [marshmallow][1] JSON schema and validation framework. I encourage everyone to check out their repo and documentation. ParamTools was modeled off of [Tax-Calculator's][2] parameter processing and validation engine due to its maturity and sophisticated capabilities.\n\n[1]: https://github.com/marshmallow-code/marshmallow\n[2]: https://github.com/PSLmodels/Tax-Calculator\n[3]: https://github.com/PSLmodels/ParamTools/blob/master/CONTRIBUTING.md\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpslmodels%2Fparamtools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpslmodels%2Fparamtools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpslmodels%2Fparamtools/lists"}