sys-num 0.0.1__py3-none-any.whl

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.
num_utils/__init__.py ADDED
File without changes
num_utils/num_utils.py ADDED
@@ -0,0 +1,37 @@
1
+ """
2
+ num_utils.py - A custom utility module for clean math operations,
3
+ rounding fixes, and percentage metrics.
4
+ """
5
+
6
+ def clean_round(value: float, decimals: int = 2) -> float:
7
+ """
8
+ Solves floating-point accuracy bugs by rounding safely.
9
+ Example: clean_round(2.675, 2) -> 2.68
10
+ """
11
+ # Adding a tiny epsilon prevents Python's binary floating-point rounding flaws
12
+ epsilon = 1e-9
13
+ if value >= 0:
14
+ return round(value + epsilon, decimals)
15
+ return round(value - epsilon, decimals)
16
+
17
+
18
+ def format_currency(amount: float, symbol: str = "₹") -> str:
19
+ """
20
+ Formats a raw float cleanly into a currency layout.
21
+ Example: format_currency(1250.5) -> "₹1,250.50"
22
+ """
23
+ rounded_amount = clean_round(amount, 2)
24
+ return f"{symbol}{rounded_amount:,.2f}"
25
+
26
+
27
+ def calculate_pb_increase(old_best: float, new_best: float) -> float:
28
+ """
29
+ Calculates the exact percentage improvement between two records.
30
+ Example: Going from 20 push-ups to 26.
31
+ """
32
+ if old_best == 0:
33
+ return 100.0 if new_best > 0 else 0.0
34
+
35
+ increase = new_best - old_best
36
+ percentage = (increase / old_best) * 100
37
+ return clean_round(percentage, 1)
@@ -0,0 +1,12 @@
1
+ Metadata-Version: 2.4
2
+ Name: sys_num
3
+ Version: 0.0.1
4
+ Summary: A clean utility module for math rounding, currency formatting, and PB tracking.
5
+ Author-email: Your Name <sevugganpythoncoder@gmail.com>
6
+ License: MIT
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: Operating System :: OS Independent
9
+ Requires-Python: >=3.7
10
+ Description-Content-Type: text/markdown
11
+ License-File: License.txt
12
+ Dynamic: license-file
@@ -0,0 +1,7 @@
1
+ num_utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ num_utils/num_utils.py,sha256=infi7QmAZOnenpeA-iyz26kpwEzQOjl_5eggWkDBCug,1212
3
+ sys_num-0.0.1.dist-info/licenses/License.txt,sha256=MGCwy1_oqg19naoOZI5AEHGyTp_2E-3phz3OFCefn5c,484
4
+ sys_num-0.0.1.dist-info/METADATA,sha256=tC-YFdw2L9PJohYH6a4B-2--x4_HQ_hoST1y16nfFWg,427
5
+ sys_num-0.0.1.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
6
+ sys_num-0.0.1.dist-info/top_level.txt,sha256=bBeGD7Ap4IYRyVMOPTWzJMzAgGDp2gkcMgIEER2ecMk,10
7
+ sys_num-0.0.1.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (82.0.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,4 @@
1
+ MIT LICENSE:
2
+
3
+ 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.
4
+
@@ -0,0 +1 @@
1
+ num_utils