ucon 0.6.3__py3-none-any.whl → 0.6.5__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.
ucon/mcp/server.py CHANGED
@@ -91,16 +91,11 @@ def convert(value: float, from_unit: str, to_unit: str) -> ConversionResult:
91
91
  num = Number(quantity=value, unit=src)
92
92
  result = num.to(dst)
93
93
 
94
- unit_str = None
95
- dim_name = "none"
96
-
97
- if result.unit:
98
- if isinstance(result.unit, UnitProduct):
99
- unit_str = result.unit.shorthand
100
- dim_name = result.unit.dimension.name
101
- elif isinstance(result.unit, Unit):
102
- unit_str = result.unit.shorthand
103
- dim_name = result.unit.dimension.name
94
+ # Use the target unit string as output (what the user asked for).
95
+ # This handles cases like mg/kg → µg/kg where internal representation
96
+ # may lose unit info due to dimension cancellation.
97
+ unit_str = to_unit
98
+ dim_name = dst.dimension.name if hasattr(dst, 'dimension') else "none"
104
99
 
105
100
  return ConversionResult(
106
101
  quantity=result.quantity,
ucon/units.py CHANGED
@@ -267,6 +267,7 @@ def _build_registry() -> None:
267
267
 
268
268
  # Register priority scaled aliases (medical conventions)
269
269
  _PRIORITY_SCALED_ALIASES['mcg'] = (gram, Scale.micro) # microgram
270
+ _PRIORITY_SCALED_ALIASES['cc'] = (liter, Scale.milli) # cubic centimeter = 1 mL
270
271
 
271
272
 
272
273
  def _parse_exponent(s: str) -> Tuple[str, float]:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ucon
3
- Version: 0.6.3
3
+ Version: 0.6.5
4
4
  Summary: A tool for dimensional analysis: a 'Unit CONverter'
5
5
  Home-page: https://github.com/withtwoemms/ucon
6
6
  Author: Emmanuel I. Obi
@@ -5,13 +5,13 @@ ucon/graph.py,sha256=vBIKwppYCAu5sw6R_3zTBlnOk2WmYMClIb6j5kDvJHI,21342
5
5
  ucon/maps.py,sha256=-rPMOHylcQYUn62R9IU23bXdCRCRNBhdH3UD4G5IUEk,9123
6
6
  ucon/pydantic.py,sha256=64ZR1EYFRnBGHj3VIF5pc3swdAiR2ZlYrgcntdbKN4k,5189
7
7
  ucon/quantity.py,sha256=GBxZ_96nocx-8F-usNWGbPvWHRhRgdZzqfH9Sx69iC4,465
8
- ucon/units.py,sha256=vKHGf5UX-g9t8dKy2IXgutHZD7W9frYdXSef_aPgZgo,17329
8
+ ucon/units.py,sha256=T410Haid7PBLKQgxEfUGKheOAj61E3gRCau4aw0NNJM,17414
9
9
  ucon/mcp/__init__.py,sha256=WoFOQ7JeDIzbjjkFIJ0Uv53VVLu-4lrjzG5vpVGGfT4,123
10
- ucon/mcp/server.py,sha256=uUrdevEaR65Qjh9xn8Q-_IusNjPGxdkLF9iQmiSTs0g,7016
11
- ucon-0.6.3.dist-info/licenses/LICENSE,sha256=LtimSYBSw1L_X6n1-VEdZRdwuROzPumrMUNX21asFuI,11356
12
- ucon-0.6.3.dist-info/licenses/NOTICE,sha256=bh4fBOItio3kM4hSNYhqfFpcaAvOoixjD7Du8im-sYA,1079
13
- ucon-0.6.3.dist-info/METADATA,sha256=8GNTOLltkPWCt68V7-dauFzK_e-XngBhCNlVXpBz_rw,17397
14
- ucon-0.6.3.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
15
- ucon-0.6.3.dist-info/entry_points.txt,sha256=jbfLf0FbOulgGa0nM_sRiTNfiCAkJcHnSSK_oj3g0cQ,50
16
- ucon-0.6.3.dist-info/top_level.txt,sha256=Vv3KDuZ86fmH5yOYLbYap9DbBblK1YUkmlThffF71jA,5
17
- ucon-0.6.3.dist-info/RECORD,,
10
+ ucon/mcp/server.py,sha256=RDKFvr_NtLNd8UBQp1wCDUpgnF0OYucn6woMi3JP8E0,6971
11
+ ucon-0.6.5.dist-info/licenses/LICENSE,sha256=LtimSYBSw1L_X6n1-VEdZRdwuROzPumrMUNX21asFuI,11356
12
+ ucon-0.6.5.dist-info/licenses/NOTICE,sha256=bh4fBOItio3kM4hSNYhqfFpcaAvOoixjD7Du8im-sYA,1079
13
+ ucon-0.6.5.dist-info/METADATA,sha256=lfPdyNwcs_zVQO7_0zTchbkfLZy63NzmwKld4JD1heY,17397
14
+ ucon-0.6.5.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
15
+ ucon-0.6.5.dist-info/entry_points.txt,sha256=jbfLf0FbOulgGa0nM_sRiTNfiCAkJcHnSSK_oj3g0cQ,50
16
+ ucon-0.6.5.dist-info/top_level.txt,sha256=Vv3KDuZ86fmH5yOYLbYap9DbBblK1YUkmlThffF71jA,5
17
+ ucon-0.6.5.dist-info/RECORD,,
File without changes