Name | streamlit-quantity-text-input JSON |
Version |
0.1.0a0
JSON |
| download |
home_page | None |
Summary | Streamlit input field that uses the pint library for parsing quantities |
upload_time | 2024-04-29 09:38:10 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.7 |
license | Copyright (c) 2018 The Python Packaging Authority Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
keywords |
streamlit
pint
quantity
input
conversion
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# streamlit_quantity_text_input
This Python module gives you a Streamlit text input field (like `st.text_input`) for entering and processing concentrations, volumes, amounts ect. in free-text, yet in an input-safe manner.
The *quantity_text_input* field uses the **pint** library to parse the user's input as a quantity (volume, speed, concentration etc.).
### Features
* The input field can be configured to **accept only inputs of a given dimensionality** (e.g. volume) and will accept inputs in a wide range of relevant units.
* The input field can be configured to **return the input value in your preferred unit** (such as milliliters, barrels, in³ etc.).
* In case of user input error, the input field displays a **helpful error message to the user** immediately below the field.
* Developers can specify a callable for **pre-processing the user's input** before it is handed over to the input field's parsing algorithm.
* The return value, a pint.Quantity instance, can be used downstream for **unit-aware calculations**.
## Getting started
$ `pip install streamlit-quantity-text-input`
from streamlit_quantity_text_input import quantity_text_input
vol = quantity_text_input(
"Please input a volume:",
mandatory_dimension="volume",
output_unit="ml",
lower_limit="0 l")
print(f"You input volume is: {vol if vol else 'pending'}")
Check out the accompanying `demo.py` for a more detailed example and documentation.
## Roadmap
Wanted but not yet planned:
* **Test cases:** Unit tests, perhaps via the doctest module.
* **Flag:** `relaxed_time_input`. Implement a flag to allow a much broader range of types of time inputs to be parsed correctly, consistently (e.g. `1h45`, `1hrs3minutes`, `2wks60'45"` etc.). Bonus points for offering a solution that also addresses Danish spellings (perhaps as a pre-parser).
* **Fool-profing the math parser:** The pint library treats scalars and units equally, which can lead to some unexpected parsing when mixing scalars and units (`1 m / 2 s` parses into `1*m/2*s`=`½ m*s`, not `½ m/s`). Presumably, this can be fixed by tokenizing the input string and 'gluing' scalars and their abutting unit(s) together with parenthesis (`((1*m)/(2*s))`). However, writing the tokenizer could be non-trivial.
## License
See LICENSE.txt
## Project status
New as of April 2024.
Raw data
{
"_id": null,
"home_page": null,
"name": "streamlit-quantity-text-input",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": "\"NN dept. 244\" <244AKA@novonordisk.com>",
"keywords": "streamlit, pint, quantity, input, conversion",
"author": null,
"author_email": "Holger D\u00f8ssing <hldn@novonordisk.com>",
"download_url": "https://files.pythonhosted.org/packages/03/22/c697ace1a5b53dcd2ebf4719f5db0df71ef6e9e1bcac13f2f09de02a2308/streamlit_quantity_text_input-0.1.0a0.tar.gz",
"platform": null,
"description": "# streamlit_quantity_text_input\r\n\r\nThis Python module gives you a Streamlit text input field (like `st.text_input`) for entering and processing concentrations, volumes, amounts ect. in free-text, yet in an input-safe manner.\r\n\r\nThe *quantity_text_input* field uses the **pint** library to parse the user's input as a quantity (volume, speed, concentration etc.).\r\n\r\n### Features\r\n* The input field can be configured to **accept only inputs of a given dimensionality** (e.g. volume) and will accept inputs in a wide range of relevant units.\r\n* The input field can be configured to **return the input value in your preferred unit** (such as milliliters, barrels, in\u00b3 etc.). \r\n* In case of user input error, the input field displays a **helpful error message to the user** immediately below the field.\r\n* Developers can specify a callable for **pre-processing the user's input** before it is handed over to the input field's parsing algorithm.\r\n* The return value, a pint.Quantity instance, can be used downstream for **unit-aware calculations**.\r\n\r\n\r\n## Getting started\r\n\r\n$ `pip install streamlit-quantity-text-input`\r\n\r\n from streamlit_quantity_text_input import quantity_text_input\r\n \r\n vol = quantity_text_input(\r\n \"Please input a volume:\",\r\n mandatory_dimension=\"volume\",\r\n output_unit=\"ml\",\r\n lower_limit=\"0 l\")\r\n \r\n print(f\"You input volume is: {vol if vol else 'pending'}\")\r\n\r\nCheck out the accompanying `demo.py` for a more detailed example and documentation.\r\n\r\n\r\n## Roadmap\r\n\r\nWanted but not yet planned:\r\n\r\n* **Test cases:** Unit tests, perhaps via the doctest module.\r\n\r\n* **Flag:** `relaxed_time_input`. Implement a flag to allow a much broader range of types of time inputs to be parsed correctly, consistently (e.g. `1h45`, `1hrs3minutes`, `2wks60'45\"` etc.). Bonus points for offering a solution that also addresses Danish spellings (perhaps as a pre-parser).\r\n\r\n* **Fool-profing the math parser:** The pint library treats scalars and units equally, which can lead to some unexpected parsing when mixing scalars and units (`1 m / 2 s` parses into `1*m/2*s`=`\u00bd m*s`, not `\u00bd m/s`). Presumably, this can be fixed by tokenizing the input string and 'gluing' scalars and their abutting unit(s) together with parenthesis (`((1*m)/(2*s))`). However, writing the tokenizer could be non-trivial.\r\n\r\n## License\r\n\r\nSee LICENSE.txt\r\n\r\n## Project status\r\n\r\nNew as of April 2024.\r\n",
"bugtrack_url": null,
"license": "Copyright (c) 2018 The Python Packaging Authority Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
"summary": "Streamlit input field that uses the pint library for parsing quantities",
"version": "0.1.0a0",
"project_urls": {
"Bug Reports": "https://sc216.corp.novocorp.net/rba244/quantity_text_input/issues",
"Homepage": "https://sc216.corp.novocorp.net/rba244/quantity_text_input"
},
"split_keywords": [
"streamlit",
" pint",
" quantity",
" input",
" conversion"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "cde299b4f57bb22cc3c596c09b5892ea5b259c48bc39ae4a7b2a3a88cd4e9cf5",
"md5": "62fe6eb14304844e28c0164c93961947",
"sha256": "518f0c869409a8497814e17057e67307bc5b243a10756f77d80467a82d7c5ee1"
},
"downloads": -1,
"filename": "streamlit_quantity_text_input-0.1.0a0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "62fe6eb14304844e28c0164c93961947",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 11142,
"upload_time": "2024-04-29T09:38:08",
"upload_time_iso_8601": "2024-04-29T09:38:08.903811Z",
"url": "https://files.pythonhosted.org/packages/cd/e2/99b4f57bb22cc3c596c09b5892ea5b259c48bc39ae4a7b2a3a88cd4e9cf5/streamlit_quantity_text_input-0.1.0a0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "0322c697ace1a5b53dcd2ebf4719f5db0df71ef6e9e1bcac13f2f09de02a2308",
"md5": "9582ef78e434995c153694d792a20251",
"sha256": "6ac780e2110a94291b43a370d84ec77890113e8d591e326500361aaba43fb91a"
},
"downloads": -1,
"filename": "streamlit_quantity_text_input-0.1.0a0.tar.gz",
"has_sig": false,
"md5_digest": "9582ef78e434995c153694d792a20251",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 13805,
"upload_time": "2024-04-29T09:38:10",
"upload_time_iso_8601": "2024-04-29T09:38:10.171390Z",
"url": "https://files.pythonhosted.org/packages/03/22/c697ace1a5b53dcd2ebf4719f5db0df71ef6e9e1bcac13f2f09de02a2308/streamlit_quantity_text_input-0.1.0a0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-04-29 09:38:10",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "streamlit-quantity-text-input"
}