{"id":14989276,"url":"https://github.com/zceemja/si-base","last_synced_at":"2026-02-12T23:02:44.442Z","repository":{"id":57467010,"uuid":"424179385","full_name":"zceemja/si-base","owner":"zceemja","description":"A basic python package that converts numerical strings with units to base units","archived":false,"fork":false,"pushed_at":"2022-08-04T14:40:35.000Z","size":29,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-24T22:48:41.461Z","etag":null,"topics":["conversion","jax","numpy","python","scientific","scipy"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/sibase/","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/zceemja.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-11-03T10:27:25.000Z","updated_at":"2024-12-05T21:11:21.000Z","dependencies_parsed_at":"2022-09-10T02:01:22.601Z","dependency_job_id":null,"html_url":"https://github.com/zceemja/si-base","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/zceemja/si-base","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zceemja%2Fsi-base","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zceemja%2Fsi-base/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zceemja%2Fsi-base/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zceemja%2Fsi-base/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zceemja","download_url":"https://codeload.github.com/zceemja/si-base/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zceemja%2Fsi-base/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29385018,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-12T22:07:52.078Z","status":"ssl_error","status_checked_at":"2026-02-12T22:07:49.026Z","response_time":55,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["conversion","jax","numpy","python","scientific","scipy"],"created_at":"2024-09-24T14:17:58.633Z","updated_at":"2026-02-12T23:02:44.414Z","avatar_url":"https://github.com/zceemja.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SI-Base python package\n\nA basic python package that converts numerical strings with units to base units.\nThere are two main classes:\n* `Unit` which holds information about units, for instance that string `km/s` has unit **m** with *10 power of 3* and unit **s** with *10 power of -1* \n* `Value` is a float which also holds Unit and some numerical value that is always in **SI Base**. \n\n### Examples:\n\n```python\nfrom sibase import Value, Unit\n\nvalue = Value('3e5 nm/ps')  # 3e+08 m/s\n# value is instance of float with value if 3e8\nfloat_value = value.to('km/s')  # 300000.0\n# shorthand method:\nfloat_value = value @ 'km/s' \n\n# Converting with units:\nfloat_value = Unit('km/s').convert(3e8)\n# shorthand methods:\nfloat_value = 3e8 @ Unit('km/s')\nfloat_value = Unit('km/s') @ 3e8\n\n# Operations\n# Note that this only compares numerical values, not units\nValue('50 km') \u003e '1e6 mm'  # True\nValue('50 km') \u003c '1e8 mm'  # True\nValue('50 /km') == '50 km^-1'  # True\n\nValue('50 km') + '50 km'  # 1e5 m (returns Value object, keeps units from LHS)\nValue('50 km') - '1e4 m'  # 4e4 m (returns Value object, keeps units from LHS)\nValue('50 km') * '100 m'  # 5e6 m^2 (returns Value object, unit updated)\nValue('1 km') / '50 m'  # 20 (returns Value object, this case unitless)\nValue('1 km') / '50 s'  # 20 m/s (returns Value object, units updated)\n\n# Invert operation returns string with original units\n~Value('50 km')  # 50 km\nValue('50 km').original()  # 50 km\n# Reduces same unit and prefix values, useful for multiply/divide operations \nValue('17 ps/nm/km/km').original(simplify=True)  # 17 ps/nm/km^2\n```\n\nSuperscripts are enabled by default\n\n```python\nfrom sibase import Value, Unit\nUnit.USE_SUBSCRIPTS = False  # Disable superscripts for units\nValue('300mm^2/ps')  # 3e+08 m²s⁻¹\n```\n\nSupports converting units with powers such as:\n\n```python\nfrom sibase import Value\n\nValue('-21 ps^2/km')  #  -2.1e-26 s^2/m\nValue('17 ps/nm/km')  #  1.7e-05 s/m^2\n\n# dB, dBm and Np (Nepers) are special units\nValue('20 dB/km')  # 0.1 /m \nValue('2.3 km/Np')  # ~10.05 m \nValue('-20 dB') @ 'dBm'  # 10.0\nValue('0.2 dB/km') @ 'Np/m'  # -3.43\n\n# More special units can be added\nfrom sibase import set_special_unit\n\nset_special_unit(\n    'log',  # name of unit \n    lambda x, _math: _math.log(x),  # function to convert to SI base  \n    lambda x, _math: _math.exp(x)   # inverse of above\n)\n# Note: _math will depend on instance of x, it could be python's math module or numpy or jax.numpy\nValue('10 log') # 2.30258509 \nValue('2.3') @ 'log' # ~10 \nValue('1π')  # 3.14159265 ( π treated as special unit )\n\n```\n\nNumpy, probably could also applied for other libraries\n\n```python\nfrom sibase import to_base, Unit\nimport numpy as np\n\nnp_array = np.array([...])\n# Convert from nonstandard:\nsi_array = to_base(np_array, 'km/s')\n\n# Convert to other units\nnot_base_array = Unit('km/s').convert(si_array)\n# shorthand method (will not work other way around for numpy arrays):\nnot_base_array = Unit('km/s') @ si_array\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzceemja%2Fsi-base","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzceemja%2Fsi-base","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzceemja%2Fsi-base/lists"}