Skip to content

Commit

Permalink
feat(dri-1308): add unitless unit
Browse files Browse the repository at this point in the history
  • Loading branch information
vkeyboardv committed Aug 21, 2024
1 parent bb1fed4 commit 314cbd6
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/corva_unit_converter/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
"volume_concentration": definitions.volume_concentration.rule,
"volume_flow_rate": definitions.volume_flow_rate.rule,
"voltage": definitions.voltage.rule,
"viscosity": definitions.viscosity.rule
"viscosity": definitions.viscosity.rule,
"unitless": definitions.unitless.rule,
}


Expand Down
2 changes: 2 additions & 0 deletions src/corva_unit_converter/definitions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
temperature,
time,
torque,
unitless,
viscosity,
voltage,
volume_concentration,
Expand Down Expand Up @@ -70,6 +71,7 @@
"temperature",
"time",
"torque",
"unitless",
"voltage",
"volume_concentration",
"volume_flow_rate",
Expand Down
30 changes: 30 additions & 0 deletions src/corva_unit_converter/definitions/unitless.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
metric = imperial = {
"unitless": {
"name": {
"singular": "unitless",
"plural": "unitless",
"display": "unitless"
},
"to_anchor": 1,
"aliases": [
"On/Off",
"None",
"EUC"
]
},
}

rule = {
"metric": metric,
"imperial": imperial,
"_anchors": {
"metric": {
"unit": "unitless",
"ratio": 1
},
"imperial": {
"unit": "unitless",
"ratio": 1
}
}
}
2 changes: 1 addition & 1 deletion src/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION = "0.5.0"
VERSION = "0.6.0"
11 changes: 6 additions & 5 deletions tests/test_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ def test_get_measures_returns_correct_keys():
expected_keys = [
"acoustic_slowness", "angle", "angle_per_length", "angular_velocity",
"area", "density", "energy", "force", "gas_concentration",
"gas_volume", "gamma_radiation", "inverse_pressure", "length", "length_per_angle",
"mass", "mass_flow_rate", "mpl", "porosity", "power", "pressure",
"pressure_gradient", "proportion", "revolution_per_volume", "speed",
"strokes_rate", "temperature", "time", "torque",
"volume_concentration", "volume_flow_rate", "viscosity", "voltage"
"gas_volume", "gamma_radiation", "inverse_pressure", "length",
"length_per_angle", "mass", "mass_flow_rate", "mpl", "porosity",
"power", "pressure", "pressure_gradient", "proportion",
"revolution_per_volume", "speed", "strokes_rate", "temperature",
"time", "torque", "volume_concentration", "volume_flow_rate",
"viscosity", "voltage", "unitless"
]

assert sorted(result) == sorted(expected_keys)
Expand Down
11 changes: 11 additions & 0 deletions tests/test_unitless.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from .utils import convert_units

# test cases
cases = [
{"from": "unitless", "amount": 1, "to": "unitless", "expected": 1,
"measure": 'unitless'}
]


def test():
convert_units(cases)

0 comments on commit 314cbd6

Please sign in to comment.