PyCUC


NamePyCUC JSON
Version 1.3.0 PyPI version JSON
download
home_pageNone
SummaryPyCUC: A lightweight Python package for creating custom unit conversions.
upload_time2024-09-21 03:06:31
maintainerNone
docs_urlNone
authorSina Gilassi
requires_python>=3.9
licenseMIT
keywords python chemical engineering custom unit conversion pycuc
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
# Python Custom Unit Converter (PyCUC)



![Downloads](https://img.shields.io/pypi/dm/PyCUC) ![PyPI](https://img.shields.io/pypi/v/PyCUC) ![Python Version](https://img.shields.io/pypi/pyversions/PyCUC.svg) ![License](https://img.shields.io/pypi/l/PyCUC) ![Read the Docs](https://img.shields.io/readthedocs/pycuc)



Python Custom Unit Converter (PyCUC) is an open-source package designed to simplify unit conversions in Python. With PyCUC, you can effortlessly create custom conversion factors, convert between units, and streamline calculations in various fields, such as physics, engineering, and scientific computing.



**Key Features:**



* Custom Conversion Factors: Define your own conversion factors for unique units.

* Flexible Unit Conversions: Convert between units with ease, using a simple and intuitive methods.

* Lightweight: Minimal dependencies and optimized for performance.

* Easy to Use: Simple installation and straightforward usage.



## Google Colab



You can use the following code to run `PyCUC` in Google Colab:



[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1AbTCZxz9xH0VxKCh-Qhb66X0GAGo9_0y?usp=sharing)



## Installation



Install PyCUC with pip



```python

import pycuc

# check version

print(pycuc.__version__)

```



## Usage Example 1



* CHECK REFERENCES



```python

print(pycuc.check_reference('pressure'))

```



* CREATE A CUSTOM UNIT CONVERTER



```python

# ! pressure

my_cuc_1 = pycuc.create_cuc(1, 'MPa')

# convert to Pa

print(my_cuc_1.convert('Pa'))

print(my_cuc_1.convert('bar'))

print(my_cuc_1.convert('kPa'))



# ! temperature

my_cuc_2 = pycuc.create_cuc(358, 'K')

# convert to K

print(my_cuc_2.convert('C'))

print(my_cuc_2.convert('F'))

print(my_cuc_2.convert('R'))

```



* CONVERT FROM TO



```python

# ! pressure

print(pycuc.convert_from_to(1, 'MPa', 'Pa'))

# ! temperature

print(pycuc.convert_from_to(358, 'K', 'C'))

print(pycuc.convert_from_to(25, 'C', 'K'))

```



* CONVERT FROM TO (short format)



```python

# ! pressure

print(pycuc.to(125, 'MPa => Pa'))

# ! temperature

print(pycuc.to(360, 'K => C'))

print(pycuc.to(250, 'C => K'))

```



* DEFINE A NEW UNIT



```python

# ! heat capacity unit: J/mol.K

my_cuc_3 = pycuc.create_cuc(25, 'J/mol.K')

# add custom

my_cuc_3.add_custom_unit('J/mol.K', 1)

my_cuc_3.add_custom_unit('kJ/mol.K', 1000)

# conversion

print(my_cuc_3.convert('J/mol.K'))

print(my_cuc_3.convert('kJ/mol.K'))

```



* CHECK REFERENCE



```python

# ! pressure

print(my_cuc_3.check_reference('pressure'))

# ! temperature

print(my_cuc_3.check_reference('temperature'))

# ! custom

print(my_cuc_3.check_reference('custom'))

```



## Usage Examples 2



* LOAD `CUSTOM UNIT` FROM `YML FILES`



```python

# load unit yml file

unit_file = os.path.join(os.getcwd(), 'test', 'custom-unit.yml')

my_cuc = pycuc.go(reference_file=unit_file)

```



* `from_to` METHOD AS:



```python

# ! pressure

print(my_cuc.from_to(1, 'MPa', 'Pa'))

```



* `to` METHOD AS:



```python

# ! pressure

print(my_cuc.to(125, 'MPa => Pa'))

```



* CHECK REFERENCES:



```python

# ! from yml file

print(my_cuc.check_reference('custom::CUSTOM'))

print(my_cuc.check_reference('custom::HEAT-CAPACITY'))

print(my_cuc.check_reference('custom::ENERGY'))

```



## FAQ



For any question, contact me on [LinkedIn](https://www.linkedin.com/in/sina-gilassi/) 





## Authors



- [@sinagilassi](https://www.github.com/sinagilassi)

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "PyCUC",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "python, chemical engineering, custom unit conversion, PyCUC",
    "author": "Sina Gilassi",
    "author_email": "<sina.gilassi@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/11/f3/712a3952e55b9bab61ad0ea433f88e08e40bc4eeb7c0dd4109e3a12c5e97/pycuc-1.3.0.tar.gz",
    "platform": null,
    "description": "\r\n# Python Custom Unit Converter (PyCUC)\r\n\r\n\r\n\r\n![Downloads](https://img.shields.io/pypi/dm/PyCUC) ![PyPI](https://img.shields.io/pypi/v/PyCUC) ![Python Version](https://img.shields.io/pypi/pyversions/PyCUC.svg) ![License](https://img.shields.io/pypi/l/PyCUC) ![Read the Docs](https://img.shields.io/readthedocs/pycuc)\r\n\r\n\r\n\r\nPython Custom Unit Converter (PyCUC) is an open-source package designed to simplify unit conversions in Python. With PyCUC, you can effortlessly create custom conversion factors, convert between units, and streamline calculations in various fields, such as physics, engineering, and scientific computing.\r\n\r\n\r\n\r\n**Key Features:**\r\n\r\n\r\n\r\n* Custom Conversion Factors: Define your own conversion factors for unique units.\r\n\r\n* Flexible Unit Conversions: Convert between units with ease, using a simple and intuitive methods.\r\n\r\n* Lightweight: Minimal dependencies and optimized for performance.\r\n\r\n* Easy to Use: Simple installation and straightforward usage.\r\n\r\n\r\n\r\n## Google Colab\r\n\r\n\r\n\r\nYou can use the following code to run `PyCUC` in Google Colab:\r\n\r\n\r\n\r\n[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1AbTCZxz9xH0VxKCh-Qhb66X0GAGo9_0y?usp=sharing)\r\n\r\n\r\n\r\n## Installation\r\n\r\n\r\n\r\nInstall PyCUC with pip\r\n\r\n\r\n\r\n```python\r\n\r\nimport pycuc\r\n\r\n# check version\r\n\r\nprint(pycuc.__version__)\r\n\r\n```\r\n\r\n\r\n\r\n## Usage Example 1\r\n\r\n\r\n\r\n* CHECK REFERENCES\r\n\r\n\r\n\r\n```python\r\n\r\nprint(pycuc.check_reference('pressure'))\r\n\r\n```\r\n\r\n\r\n\r\n* CREATE A CUSTOM UNIT CONVERTER\r\n\r\n\r\n\r\n```python\r\n\r\n# ! pressure\r\n\r\nmy_cuc_1 = pycuc.create_cuc(1, 'MPa')\r\n\r\n# convert to Pa\r\n\r\nprint(my_cuc_1.convert('Pa'))\r\n\r\nprint(my_cuc_1.convert('bar'))\r\n\r\nprint(my_cuc_1.convert('kPa'))\r\n\r\n\r\n\r\n# ! temperature\r\n\r\nmy_cuc_2 = pycuc.create_cuc(358, 'K')\r\n\r\n# convert to K\r\n\r\nprint(my_cuc_2.convert('C'))\r\n\r\nprint(my_cuc_2.convert('F'))\r\n\r\nprint(my_cuc_2.convert('R'))\r\n\r\n```\r\n\r\n\r\n\r\n* CONVERT FROM TO\r\n\r\n\r\n\r\n```python\r\n\r\n# ! pressure\r\n\r\nprint(pycuc.convert_from_to(1, 'MPa', 'Pa'))\r\n\r\n# ! temperature\r\n\r\nprint(pycuc.convert_from_to(358, 'K', 'C'))\r\n\r\nprint(pycuc.convert_from_to(25, 'C', 'K'))\r\n\r\n```\r\n\r\n\r\n\r\n* CONVERT FROM TO (short format)\r\n\r\n\r\n\r\n```python\r\n\r\n# ! pressure\r\n\r\nprint(pycuc.to(125, 'MPa => Pa'))\r\n\r\n# ! temperature\r\n\r\nprint(pycuc.to(360, 'K => C'))\r\n\r\nprint(pycuc.to(250, 'C => K'))\r\n\r\n```\r\n\r\n\r\n\r\n* DEFINE A NEW UNIT\r\n\r\n\r\n\r\n```python\r\n\r\n# ! heat capacity unit: J/mol.K\r\n\r\nmy_cuc_3 = pycuc.create_cuc(25, 'J/mol.K')\r\n\r\n# add custom\r\n\r\nmy_cuc_3.add_custom_unit('J/mol.K', 1)\r\n\r\nmy_cuc_3.add_custom_unit('kJ/mol.K', 1000)\r\n\r\n# conversion\r\n\r\nprint(my_cuc_3.convert('J/mol.K'))\r\n\r\nprint(my_cuc_3.convert('kJ/mol.K'))\r\n\r\n```\r\n\r\n\r\n\r\n* CHECK REFERENCE\r\n\r\n\r\n\r\n```python\r\n\r\n# ! pressure\r\n\r\nprint(my_cuc_3.check_reference('pressure'))\r\n\r\n# ! temperature\r\n\r\nprint(my_cuc_3.check_reference('temperature'))\r\n\r\n# ! custom\r\n\r\nprint(my_cuc_3.check_reference('custom'))\r\n\r\n```\r\n\r\n\r\n\r\n## Usage Examples 2\r\n\r\n\r\n\r\n* LOAD `CUSTOM UNIT` FROM `YML FILES`\r\n\r\n\r\n\r\n```python\r\n\r\n# load unit yml file\r\n\r\nunit_file = os.path.join(os.getcwd(), 'test', 'custom-unit.yml')\r\n\r\nmy_cuc = pycuc.go(reference_file=unit_file)\r\n\r\n```\r\n\r\n\r\n\r\n* `from_to` METHOD AS:\r\n\r\n\r\n\r\n```python\r\n\r\n# ! pressure\r\n\r\nprint(my_cuc.from_to(1, 'MPa', 'Pa'))\r\n\r\n```\r\n\r\n\r\n\r\n* `to` METHOD AS:\r\n\r\n\r\n\r\n```python\r\n\r\n# ! pressure\r\n\r\nprint(my_cuc.to(125, 'MPa => Pa'))\r\n\r\n```\r\n\r\n\r\n\r\n* CHECK REFERENCES:\r\n\r\n\r\n\r\n```python\r\n\r\n# ! from yml file\r\n\r\nprint(my_cuc.check_reference('custom::CUSTOM'))\r\n\r\nprint(my_cuc.check_reference('custom::HEAT-CAPACITY'))\r\n\r\nprint(my_cuc.check_reference('custom::ENERGY'))\r\n\r\n```\r\n\r\n\r\n\r\n## FAQ\r\n\r\n\r\n\r\nFor any question, contact me on [LinkedIn](https://www.linkedin.com/in/sina-gilassi/) \r\n\r\n\r\n\r\n\r\n\r\n## Authors\r\n\r\n\r\n\r\n- [@sinagilassi](https://www.github.com/sinagilassi)\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "PyCUC: A lightweight Python package for creating custom unit conversions.",
    "version": "1.3.0",
    "project_urls": null,
    "split_keywords": [
        "python",
        " chemical engineering",
        " custom unit conversion",
        " pycuc"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "226c6705d8d0f0d56d4b521378608b6f3c3b617dfb43398366355a42f97de01a",
                "md5": "0e40633b043ad04c856d01f121f25437",
                "sha256": "22a7e4b77bb366b31c606136ef3be0948178ae0f7328d617b5a91af8bda4b104"
            },
            "downloads": -1,
            "filename": "PyCUC-1.3.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "0e40633b043ad04c856d01f121f25437",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 11860,
            "upload_time": "2024-09-21T03:06:30",
            "upload_time_iso_8601": "2024-09-21T03:06:30.570861Z",
            "url": "https://files.pythonhosted.org/packages/22/6c/6705d8d0f0d56d4b521378608b6f3c3b617dfb43398366355a42f97de01a/PyCUC-1.3.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "11f3712a3952e55b9bab61ad0ea433f88e08e40bc4eeb7c0dd4109e3a12c5e97",
                "md5": "2ffdbb9729d21e1d8b54ea44def60c92",
                "sha256": "e8b51054ae127b233a1cdbc57484a9c8212c184dc1c3ddb0455f93c9fd6fb7ca"
            },
            "downloads": -1,
            "filename": "pycuc-1.3.0.tar.gz",
            "has_sig": false,
            "md5_digest": "2ffdbb9729d21e1d8b54ea44def60c92",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 9711,
            "upload_time": "2024-09-21T03:06:31",
            "upload_time_iso_8601": "2024-09-21T03:06:31.828609Z",
            "url": "https://files.pythonhosted.org/packages/11/f3/712a3952e55b9bab61ad0ea433f88e08e40bc4eeb7c0dd4109e3a12c5e97/pycuc-1.3.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-21 03:06:31",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "pycuc"
}
        
Elapsed time: 0.63206s