pycuc 2.1.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pycuc-2.1.1/LICENSE +21 -0
- pycuc-2.1.1/PKG-INFO +189 -0
- pycuc-2.1.1/PyCUC.egg-info/PKG-INFO +189 -0
- pycuc-2.1.1/PyCUC.egg-info/SOURCES.txt +28 -0
- pycuc-2.1.1/PyCUC.egg-info/dependency_links.txt +1 -0
- pycuc-2.1.1/PyCUC.egg-info/requires.txt +5 -0
- pycuc-2.1.1/PyCUC.egg-info/top_level.txt +7 -0
- pycuc-2.1.1/README.md +161 -0
- pycuc-2.1.1/pycuc/__init__.py +6 -0
- pycuc-2.1.1/pycuc/app.py +266 -0
- pycuc-2.1.1/pycuc/config/__init__.py +3 -0
- pycuc-2.1.1/pycuc/config/setting.py +8 -0
- pycuc-2.1.1/pycuc/docs/__init__.py +5 -0
- pycuc-2.1.1/pycuc/docs/cuc.py +549 -0
- pycuc-2.1.1/pycuc/docs/cucx.py +414 -0
- pycuc-2.1.1/pycuc/docs/refs.py +259 -0
- pycuc-2.1.1/pycuc/docs/utils.py +79 -0
- pycuc-2.1.1/pyproject.toml +88 -0
- pycuc-2.1.1/setup.cfg +4 -0
- pycuc-2.1.1/setup.py +43 -0
- pycuc-2.1.1/test/test1.py +76 -0
- pycuc-2.1.1/test/test2.py +63 -0
- pycuc-2.1.1/test/test3.py +51 -0
- pycuc-2.1.1/test/test4.py +26 -0
- pycuc-2.1.1/test/test5.py +45 -0
pycuc-2.1.1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 SiGi
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
pycuc-2.1.1/PKG-INFO
ADDED
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pycuc
|
|
3
|
+
Version: 2.1.1
|
|
4
|
+
Summary: PyCUC: A lightweight Python package for creating custom unit conversions. Easily define and convert between units with simplicity and flexibility.
|
|
5
|
+
Author: Sina Gilassi
|
|
6
|
+
Author-email: Sina Gilassi <sina.gilassi@gmail.com>
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
Project-URL: Homepage, https://github.com/sinagilassi/pycuc
|
|
9
|
+
Project-URL: Source, https://github.com/sinagilassi/pycuc
|
|
10
|
+
Project-URL: Tracker, https://github.com/sinagilassi/pycuc/issues
|
|
11
|
+
Keywords: chemical-engineering,custom unit conversion,engineering unit conversion,unit conversion tool,lightweight unit conversion,density conversion,temperature conversion,pressure conversion,mass conversion,volume conversion,heat-capacity conversion,enthalpy conversion,gibbs-free-energy conversion
|
|
12
|
+
Classifier: Development Status :: 1 - Planning
|
|
13
|
+
Classifier: Intended Audience :: Education
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Classifier: Operating System :: Unix
|
|
16
|
+
Classifier: Operating System :: MacOS :: MacOS X
|
|
17
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
18
|
+
Requires-Python: >=3.10
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
License-File: LICENSE
|
|
21
|
+
Requires-Dist: pandas>=2.3.3
|
|
22
|
+
Requires-Dist: pyyaml>=6.0.3
|
|
23
|
+
Provides-Extra: dev
|
|
24
|
+
Requires-Dist: rich>=14.2.0; extra == "dev"
|
|
25
|
+
Dynamic: author
|
|
26
|
+
Dynamic: license-file
|
|
27
|
+
Dynamic: requires-python
|
|
28
|
+
|
|
29
|
+
# 🔄 Python Custom Unit Converter (PyCUC)
|
|
30
|
+
|
|
31
|
+

|
|
32
|
+
|
|
33
|
+
    
|
|
34
|
+
|
|
35
|
+
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.
|
|
36
|
+
|
|
37
|
+
## ✨ Key Features
|
|
38
|
+
|
|
39
|
+
* 📐 **Custom Conversion Factors**: Define your own conversion factors for unique units
|
|
40
|
+
* 🔄 **Flexible Unit Conversions**: Convert between units with ease, using simple and intuitive methods
|
|
41
|
+
* 🪶 **Lightweight**: Minimal dependencies and optimized for performance
|
|
42
|
+
* 🚀 **Easy to Use**: Simple installation and straightforward usage
|
|
43
|
+
|
|
44
|
+
## References
|
|
45
|
+
|
|
46
|
+
PyCUC supports a wide range of unit conversions. Below are the updated references you can use for conversions:
|
|
47
|
+
|
|
48
|
+
- **Density**: Convert between units like kg/m³, g/cm³, lb/ft³, etc.
|
|
49
|
+
- **Energy**: Convert between units like J, kJ, cal, BTU, etc.
|
|
50
|
+
- **Heat Capacity**: Convert between units like J/mol·K, kJ/mol·K, cal/mol·K, etc.
|
|
51
|
+
- **Volume**: Convert between units like m³, L, mL, ft³, etc.
|
|
52
|
+
- **Mass**: Convert between units like kg, g, lb, oz, etc.
|
|
53
|
+
- **Power**: Convert between units like W, kW, HP, etc.
|
|
54
|
+
- **Length**: Convert between units like m, cm, mm, in, ft, etc.
|
|
55
|
+
- **Force**: Convert between units like N, kN, lbf, etc.
|
|
56
|
+
|
|
57
|
+
## 📊 Google Colab
|
|
58
|
+
|
|
59
|
+
You can use the following code to run `PyCUC` in Google Colab:
|
|
60
|
+
|
|
61
|
+
[](https://colab.research.google.com/drive/1AbTCZxz9xH0VxKCh-Qhb66X0GAGo9_0y?usp=sharing)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
## 📥 Installation
|
|
65
|
+
|
|
66
|
+
Install PyCUC with pip:
|
|
67
|
+
|
|
68
|
+
```python
|
|
69
|
+
import pycuc
|
|
70
|
+
# check version
|
|
71
|
+
print(pycuc.__version__)
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
## 🔍 Usage Examples
|
|
76
|
+
|
|
77
|
+
### 📋 Example 1: Basic Operations
|
|
78
|
+
|
|
79
|
+
#### 🔍 Check References
|
|
80
|
+
|
|
81
|
+
```python
|
|
82
|
+
print(pycuc.check_reference('pressure'))
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
#### 🛠️ Create a Custom Unit Converter
|
|
86
|
+
|
|
87
|
+
```python
|
|
88
|
+
# ! pressure
|
|
89
|
+
my_cuc_1 = pycuc.create_cuc(1, 'MPa')
|
|
90
|
+
# convert to Pa
|
|
91
|
+
print(my_cuc_1.convert('Pa'))
|
|
92
|
+
print(my_cuc_1.convert('bar'))
|
|
93
|
+
print(my_cuc_1.convert('kPa'))
|
|
94
|
+
|
|
95
|
+
# ! temperature
|
|
96
|
+
my_cuc_2 = pycuc.create_cuc(358, 'K')
|
|
97
|
+
# convert to K
|
|
98
|
+
print(my_cuc_2.convert('C'))
|
|
99
|
+
print(my_cuc_2.convert('F'))
|
|
100
|
+
print(my_cuc_2.convert('R'))
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
#### ↔️ Convert From/To
|
|
104
|
+
|
|
105
|
+
```python
|
|
106
|
+
# ! pressure
|
|
107
|
+
print(pycuc.convert_from_to(1, 'MPa', 'Pa'))
|
|
108
|
+
# ! temperature
|
|
109
|
+
print(pycuc.convert_from_to(358, 'K', 'C'))
|
|
110
|
+
print(pycuc.convert_from_to(25, 'C', 'K'))
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
#### 🔄 Convert From/To (Short Format)
|
|
114
|
+
|
|
115
|
+
```python
|
|
116
|
+
# ! pressure
|
|
117
|
+
print(pycuc.to(125, 'MPa => Pa'))
|
|
118
|
+
# ! temperature
|
|
119
|
+
print(pycuc.to(360, 'K => C'))
|
|
120
|
+
print(pycuc.to(250, 'C => K'))
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
#### ✏️ Define a New Unit
|
|
125
|
+
|
|
126
|
+
```python
|
|
127
|
+
# ! heat capacity unit: J/mol.K
|
|
128
|
+
my_cuc_3 = pycuc.create_cuc(25, 'J/mol.K')
|
|
129
|
+
# add custom
|
|
130
|
+
my_cuc_3.add_custom_unit('J/mol.K', 1)
|
|
131
|
+
my_cuc_3.add_custom_unit('kJ/mol.K', 1000)
|
|
132
|
+
# conversion
|
|
133
|
+
print(my_cuc_3.convert('J/mol.K'))
|
|
134
|
+
print(my_cuc_3.convert('kJ/mol.K'))
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
#### 📚 Check Reference
|
|
138
|
+
|
|
139
|
+
```python
|
|
140
|
+
# ! pressure
|
|
141
|
+
print(my_cuc_3.check_reference('pressure'))
|
|
142
|
+
# ! temperature
|
|
143
|
+
print(my_cuc_3.check_reference('temperature'))
|
|
144
|
+
# ! custom
|
|
145
|
+
print(my_cuc_3.check_reference('custom'))
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
### 📋 Example 2: Advanced Usage
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
#### 📂 Load Custom Units from YML Files
|
|
153
|
+
|
|
154
|
+
```python
|
|
155
|
+
# load unit yml file
|
|
156
|
+
unit_file = os.path.join(os.getcwd(), 'test', 'custom-unit.yml')
|
|
157
|
+
my_cuc = pycuc.go(reference_file=unit_file)
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
#### 🔀 Using from_to Method
|
|
161
|
+
|
|
162
|
+
```python
|
|
163
|
+
# ! pressure
|
|
164
|
+
print(my_cuc.from_to(1, 'MPa', 'Pa'))
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
#### 🚀 Using to Method
|
|
168
|
+
|
|
169
|
+
```python
|
|
170
|
+
# ! pressure
|
|
171
|
+
print(my_cuc.to(125, 'MPa => Pa'))
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
#### 📋 Check References
|
|
175
|
+
|
|
176
|
+
```python
|
|
177
|
+
# ! from yml file
|
|
178
|
+
print(my_cuc.check_reference('custom::CUSTOM'))
|
|
179
|
+
print(my_cuc.check_reference('custom::HEAT-CAPACITY'))
|
|
180
|
+
print(my_cuc.check_reference('custom::ENERGY'))
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
## ❓ FAQ
|
|
184
|
+
|
|
185
|
+
For any questions, contact me on [LinkedIn](https://www.linkedin.com/in/sina-gilassi/)
|
|
186
|
+
|
|
187
|
+
## 👨💻 Authors
|
|
188
|
+
|
|
189
|
+
* [@sinagilassi](https://www.github.com/sinagilassi)
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pycuc
|
|
3
|
+
Version: 2.1.1
|
|
4
|
+
Summary: PyCUC: A lightweight Python package for creating custom unit conversions. Easily define and convert between units with simplicity and flexibility.
|
|
5
|
+
Author: Sina Gilassi
|
|
6
|
+
Author-email: Sina Gilassi <sina.gilassi@gmail.com>
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
Project-URL: Homepage, https://github.com/sinagilassi/pycuc
|
|
9
|
+
Project-URL: Source, https://github.com/sinagilassi/pycuc
|
|
10
|
+
Project-URL: Tracker, https://github.com/sinagilassi/pycuc/issues
|
|
11
|
+
Keywords: chemical-engineering,custom unit conversion,engineering unit conversion,unit conversion tool,lightweight unit conversion,density conversion,temperature conversion,pressure conversion,mass conversion,volume conversion,heat-capacity conversion,enthalpy conversion,gibbs-free-energy conversion
|
|
12
|
+
Classifier: Development Status :: 1 - Planning
|
|
13
|
+
Classifier: Intended Audience :: Education
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Classifier: Operating System :: Unix
|
|
16
|
+
Classifier: Operating System :: MacOS :: MacOS X
|
|
17
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
18
|
+
Requires-Python: >=3.10
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
License-File: LICENSE
|
|
21
|
+
Requires-Dist: pandas>=2.3.3
|
|
22
|
+
Requires-Dist: pyyaml>=6.0.3
|
|
23
|
+
Provides-Extra: dev
|
|
24
|
+
Requires-Dist: rich>=14.2.0; extra == "dev"
|
|
25
|
+
Dynamic: author
|
|
26
|
+
Dynamic: license-file
|
|
27
|
+
Dynamic: requires-python
|
|
28
|
+
|
|
29
|
+
# 🔄 Python Custom Unit Converter (PyCUC)
|
|
30
|
+
|
|
31
|
+

|
|
32
|
+
|
|
33
|
+
    
|
|
34
|
+
|
|
35
|
+
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.
|
|
36
|
+
|
|
37
|
+
## ✨ Key Features
|
|
38
|
+
|
|
39
|
+
* 📐 **Custom Conversion Factors**: Define your own conversion factors for unique units
|
|
40
|
+
* 🔄 **Flexible Unit Conversions**: Convert between units with ease, using simple and intuitive methods
|
|
41
|
+
* 🪶 **Lightweight**: Minimal dependencies and optimized for performance
|
|
42
|
+
* 🚀 **Easy to Use**: Simple installation and straightforward usage
|
|
43
|
+
|
|
44
|
+
## References
|
|
45
|
+
|
|
46
|
+
PyCUC supports a wide range of unit conversions. Below are the updated references you can use for conversions:
|
|
47
|
+
|
|
48
|
+
- **Density**: Convert between units like kg/m³, g/cm³, lb/ft³, etc.
|
|
49
|
+
- **Energy**: Convert between units like J, kJ, cal, BTU, etc.
|
|
50
|
+
- **Heat Capacity**: Convert between units like J/mol·K, kJ/mol·K, cal/mol·K, etc.
|
|
51
|
+
- **Volume**: Convert between units like m³, L, mL, ft³, etc.
|
|
52
|
+
- **Mass**: Convert between units like kg, g, lb, oz, etc.
|
|
53
|
+
- **Power**: Convert between units like W, kW, HP, etc.
|
|
54
|
+
- **Length**: Convert between units like m, cm, mm, in, ft, etc.
|
|
55
|
+
- **Force**: Convert between units like N, kN, lbf, etc.
|
|
56
|
+
|
|
57
|
+
## 📊 Google Colab
|
|
58
|
+
|
|
59
|
+
You can use the following code to run `PyCUC` in Google Colab:
|
|
60
|
+
|
|
61
|
+
[](https://colab.research.google.com/drive/1AbTCZxz9xH0VxKCh-Qhb66X0GAGo9_0y?usp=sharing)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
## 📥 Installation
|
|
65
|
+
|
|
66
|
+
Install PyCUC with pip:
|
|
67
|
+
|
|
68
|
+
```python
|
|
69
|
+
import pycuc
|
|
70
|
+
# check version
|
|
71
|
+
print(pycuc.__version__)
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
## 🔍 Usage Examples
|
|
76
|
+
|
|
77
|
+
### 📋 Example 1: Basic Operations
|
|
78
|
+
|
|
79
|
+
#### 🔍 Check References
|
|
80
|
+
|
|
81
|
+
```python
|
|
82
|
+
print(pycuc.check_reference('pressure'))
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
#### 🛠️ Create a Custom Unit Converter
|
|
86
|
+
|
|
87
|
+
```python
|
|
88
|
+
# ! pressure
|
|
89
|
+
my_cuc_1 = pycuc.create_cuc(1, 'MPa')
|
|
90
|
+
# convert to Pa
|
|
91
|
+
print(my_cuc_1.convert('Pa'))
|
|
92
|
+
print(my_cuc_1.convert('bar'))
|
|
93
|
+
print(my_cuc_1.convert('kPa'))
|
|
94
|
+
|
|
95
|
+
# ! temperature
|
|
96
|
+
my_cuc_2 = pycuc.create_cuc(358, 'K')
|
|
97
|
+
# convert to K
|
|
98
|
+
print(my_cuc_2.convert('C'))
|
|
99
|
+
print(my_cuc_2.convert('F'))
|
|
100
|
+
print(my_cuc_2.convert('R'))
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
#### ↔️ Convert From/To
|
|
104
|
+
|
|
105
|
+
```python
|
|
106
|
+
# ! pressure
|
|
107
|
+
print(pycuc.convert_from_to(1, 'MPa', 'Pa'))
|
|
108
|
+
# ! temperature
|
|
109
|
+
print(pycuc.convert_from_to(358, 'K', 'C'))
|
|
110
|
+
print(pycuc.convert_from_to(25, 'C', 'K'))
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
#### 🔄 Convert From/To (Short Format)
|
|
114
|
+
|
|
115
|
+
```python
|
|
116
|
+
# ! pressure
|
|
117
|
+
print(pycuc.to(125, 'MPa => Pa'))
|
|
118
|
+
# ! temperature
|
|
119
|
+
print(pycuc.to(360, 'K => C'))
|
|
120
|
+
print(pycuc.to(250, 'C => K'))
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
#### ✏️ Define a New Unit
|
|
125
|
+
|
|
126
|
+
```python
|
|
127
|
+
# ! heat capacity unit: J/mol.K
|
|
128
|
+
my_cuc_3 = pycuc.create_cuc(25, 'J/mol.K')
|
|
129
|
+
# add custom
|
|
130
|
+
my_cuc_3.add_custom_unit('J/mol.K', 1)
|
|
131
|
+
my_cuc_3.add_custom_unit('kJ/mol.K', 1000)
|
|
132
|
+
# conversion
|
|
133
|
+
print(my_cuc_3.convert('J/mol.K'))
|
|
134
|
+
print(my_cuc_3.convert('kJ/mol.K'))
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
#### 📚 Check Reference
|
|
138
|
+
|
|
139
|
+
```python
|
|
140
|
+
# ! pressure
|
|
141
|
+
print(my_cuc_3.check_reference('pressure'))
|
|
142
|
+
# ! temperature
|
|
143
|
+
print(my_cuc_3.check_reference('temperature'))
|
|
144
|
+
# ! custom
|
|
145
|
+
print(my_cuc_3.check_reference('custom'))
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
### 📋 Example 2: Advanced Usage
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
#### 📂 Load Custom Units from YML Files
|
|
153
|
+
|
|
154
|
+
```python
|
|
155
|
+
# load unit yml file
|
|
156
|
+
unit_file = os.path.join(os.getcwd(), 'test', 'custom-unit.yml')
|
|
157
|
+
my_cuc = pycuc.go(reference_file=unit_file)
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
#### 🔀 Using from_to Method
|
|
161
|
+
|
|
162
|
+
```python
|
|
163
|
+
# ! pressure
|
|
164
|
+
print(my_cuc.from_to(1, 'MPa', 'Pa'))
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
#### 🚀 Using to Method
|
|
168
|
+
|
|
169
|
+
```python
|
|
170
|
+
# ! pressure
|
|
171
|
+
print(my_cuc.to(125, 'MPa => Pa'))
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
#### 📋 Check References
|
|
175
|
+
|
|
176
|
+
```python
|
|
177
|
+
# ! from yml file
|
|
178
|
+
print(my_cuc.check_reference('custom::CUSTOM'))
|
|
179
|
+
print(my_cuc.check_reference('custom::HEAT-CAPACITY'))
|
|
180
|
+
print(my_cuc.check_reference('custom::ENERGY'))
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
## ❓ FAQ
|
|
184
|
+
|
|
185
|
+
For any questions, contact me on [LinkedIn](https://www.linkedin.com/in/sina-gilassi/)
|
|
186
|
+
|
|
187
|
+
## 👨💻 Authors
|
|
188
|
+
|
|
189
|
+
* [@sinagilassi](https://www.github.com/sinagilassi)
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
setup.py
|
|
5
|
+
PyCUC.egg-info/PKG-INFO
|
|
6
|
+
PyCUC.egg-info/SOURCES.txt
|
|
7
|
+
PyCUC.egg-info/dependency_links.txt
|
|
8
|
+
PyCUC.egg-info/requires.txt
|
|
9
|
+
PyCUC.egg-info/top_level.txt
|
|
10
|
+
pycuc/__init__.py
|
|
11
|
+
pycuc/app.py
|
|
12
|
+
pycuc.egg-info/PKG-INFO
|
|
13
|
+
pycuc.egg-info/SOURCES.txt
|
|
14
|
+
pycuc.egg-info/dependency_links.txt
|
|
15
|
+
pycuc.egg-info/requires.txt
|
|
16
|
+
pycuc.egg-info/top_level.txt
|
|
17
|
+
pycuc/config/__init__.py
|
|
18
|
+
pycuc/config/setting.py
|
|
19
|
+
pycuc/docs/__init__.py
|
|
20
|
+
pycuc/docs/cuc.py
|
|
21
|
+
pycuc/docs/cucx.py
|
|
22
|
+
pycuc/docs/refs.py
|
|
23
|
+
pycuc/docs/utils.py
|
|
24
|
+
test/test1.py
|
|
25
|
+
test/test2.py
|
|
26
|
+
test/test3.py
|
|
27
|
+
test/test4.py
|
|
28
|
+
test/test5.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
pycuc-2.1.1/README.md
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
# 🔄 Python Custom Unit Converter (PyCUC)
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
    
|
|
6
|
+
|
|
7
|
+
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.
|
|
8
|
+
|
|
9
|
+
## ✨ Key Features
|
|
10
|
+
|
|
11
|
+
* 📐 **Custom Conversion Factors**: Define your own conversion factors for unique units
|
|
12
|
+
* 🔄 **Flexible Unit Conversions**: Convert between units with ease, using simple and intuitive methods
|
|
13
|
+
* 🪶 **Lightweight**: Minimal dependencies and optimized for performance
|
|
14
|
+
* 🚀 **Easy to Use**: Simple installation and straightforward usage
|
|
15
|
+
|
|
16
|
+
## References
|
|
17
|
+
|
|
18
|
+
PyCUC supports a wide range of unit conversions. Below are the updated references you can use for conversions:
|
|
19
|
+
|
|
20
|
+
- **Density**: Convert between units like kg/m³, g/cm³, lb/ft³, etc.
|
|
21
|
+
- **Energy**: Convert between units like J, kJ, cal, BTU, etc.
|
|
22
|
+
- **Heat Capacity**: Convert between units like J/mol·K, kJ/mol·K, cal/mol·K, etc.
|
|
23
|
+
- **Volume**: Convert between units like m³, L, mL, ft³, etc.
|
|
24
|
+
- **Mass**: Convert between units like kg, g, lb, oz, etc.
|
|
25
|
+
- **Power**: Convert between units like W, kW, HP, etc.
|
|
26
|
+
- **Length**: Convert between units like m, cm, mm, in, ft, etc.
|
|
27
|
+
- **Force**: Convert between units like N, kN, lbf, etc.
|
|
28
|
+
|
|
29
|
+
## 📊 Google Colab
|
|
30
|
+
|
|
31
|
+
You can use the following code to run `PyCUC` in Google Colab:
|
|
32
|
+
|
|
33
|
+
[](https://colab.research.google.com/drive/1AbTCZxz9xH0VxKCh-Qhb66X0GAGo9_0y?usp=sharing)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
## 📥 Installation
|
|
37
|
+
|
|
38
|
+
Install PyCUC with pip:
|
|
39
|
+
|
|
40
|
+
```python
|
|
41
|
+
import pycuc
|
|
42
|
+
# check version
|
|
43
|
+
print(pycuc.__version__)
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
## 🔍 Usage Examples
|
|
48
|
+
|
|
49
|
+
### 📋 Example 1: Basic Operations
|
|
50
|
+
|
|
51
|
+
#### 🔍 Check References
|
|
52
|
+
|
|
53
|
+
```python
|
|
54
|
+
print(pycuc.check_reference('pressure'))
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
#### 🛠️ Create a Custom Unit Converter
|
|
58
|
+
|
|
59
|
+
```python
|
|
60
|
+
# ! pressure
|
|
61
|
+
my_cuc_1 = pycuc.create_cuc(1, 'MPa')
|
|
62
|
+
# convert to Pa
|
|
63
|
+
print(my_cuc_1.convert('Pa'))
|
|
64
|
+
print(my_cuc_1.convert('bar'))
|
|
65
|
+
print(my_cuc_1.convert('kPa'))
|
|
66
|
+
|
|
67
|
+
# ! temperature
|
|
68
|
+
my_cuc_2 = pycuc.create_cuc(358, 'K')
|
|
69
|
+
# convert to K
|
|
70
|
+
print(my_cuc_2.convert('C'))
|
|
71
|
+
print(my_cuc_2.convert('F'))
|
|
72
|
+
print(my_cuc_2.convert('R'))
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
#### ↔️ Convert From/To
|
|
76
|
+
|
|
77
|
+
```python
|
|
78
|
+
# ! pressure
|
|
79
|
+
print(pycuc.convert_from_to(1, 'MPa', 'Pa'))
|
|
80
|
+
# ! temperature
|
|
81
|
+
print(pycuc.convert_from_to(358, 'K', 'C'))
|
|
82
|
+
print(pycuc.convert_from_to(25, 'C', 'K'))
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
#### 🔄 Convert From/To (Short Format)
|
|
86
|
+
|
|
87
|
+
```python
|
|
88
|
+
# ! pressure
|
|
89
|
+
print(pycuc.to(125, 'MPa => Pa'))
|
|
90
|
+
# ! temperature
|
|
91
|
+
print(pycuc.to(360, 'K => C'))
|
|
92
|
+
print(pycuc.to(250, 'C => K'))
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
#### ✏️ Define a New Unit
|
|
97
|
+
|
|
98
|
+
```python
|
|
99
|
+
# ! heat capacity unit: J/mol.K
|
|
100
|
+
my_cuc_3 = pycuc.create_cuc(25, 'J/mol.K')
|
|
101
|
+
# add custom
|
|
102
|
+
my_cuc_3.add_custom_unit('J/mol.K', 1)
|
|
103
|
+
my_cuc_3.add_custom_unit('kJ/mol.K', 1000)
|
|
104
|
+
# conversion
|
|
105
|
+
print(my_cuc_3.convert('J/mol.K'))
|
|
106
|
+
print(my_cuc_3.convert('kJ/mol.K'))
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
#### 📚 Check Reference
|
|
110
|
+
|
|
111
|
+
```python
|
|
112
|
+
# ! pressure
|
|
113
|
+
print(my_cuc_3.check_reference('pressure'))
|
|
114
|
+
# ! temperature
|
|
115
|
+
print(my_cuc_3.check_reference('temperature'))
|
|
116
|
+
# ! custom
|
|
117
|
+
print(my_cuc_3.check_reference('custom'))
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
### 📋 Example 2: Advanced Usage
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
#### 📂 Load Custom Units from YML Files
|
|
125
|
+
|
|
126
|
+
```python
|
|
127
|
+
# load unit yml file
|
|
128
|
+
unit_file = os.path.join(os.getcwd(), 'test', 'custom-unit.yml')
|
|
129
|
+
my_cuc = pycuc.go(reference_file=unit_file)
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
#### 🔀 Using from_to Method
|
|
133
|
+
|
|
134
|
+
```python
|
|
135
|
+
# ! pressure
|
|
136
|
+
print(my_cuc.from_to(1, 'MPa', 'Pa'))
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
#### 🚀 Using to Method
|
|
140
|
+
|
|
141
|
+
```python
|
|
142
|
+
# ! pressure
|
|
143
|
+
print(my_cuc.to(125, 'MPa => Pa'))
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
#### 📋 Check References
|
|
147
|
+
|
|
148
|
+
```python
|
|
149
|
+
# ! from yml file
|
|
150
|
+
print(my_cuc.check_reference('custom::CUSTOM'))
|
|
151
|
+
print(my_cuc.check_reference('custom::HEAT-CAPACITY'))
|
|
152
|
+
print(my_cuc.check_reference('custom::ENERGY'))
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
## ❓ FAQ
|
|
156
|
+
|
|
157
|
+
For any questions, contact me on [LinkedIn](https://www.linkedin.com/in/sina-gilassi/)
|
|
158
|
+
|
|
159
|
+
## 👨💻 Authors
|
|
160
|
+
|
|
161
|
+
* [@sinagilassi](https://www.github.com/sinagilassi)
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
from .app import create_cuc, convert_from_to, check_version, to, check_reference, go
|
|
2
|
+
from .config import __author__, __version__, __description__, __email__
|
|
3
|
+
|
|
4
|
+
__all__ = ['create_cuc', 'convert_from_to',
|
|
5
|
+
'check_version', '__author__', '__version__', 'to',
|
|
6
|
+
'check_reference', 'go', '__description__', '__email__']
|