Skip to content

Commit 01c2c74

Browse files
Copilotllucax
authored andcommitted
Add Installation and Quick Start sections to README.md
Signed-off-by: Leandro Lucarella <[email protected]> Co-authored-by: copilot-swe-agent[bot] <[email protected]>
1 parent 9568583 commit 01c2c74

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

README.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,53 @@ converting one of them.
1717
Quantities store the value in a base unit, and then provide methods to get that
1818
quantity as a particular unit.
1919

20+
## Installation
21+
22+
### Using `pip`
23+
24+
```bash
25+
python3 -m pip install frequenz-quantities
26+
```
27+
28+
### Using `pyproject.toml`
29+
30+
Add this to your `pyproject.toml` file:
31+
32+
```toml
33+
[project]
34+
dependencies = [
35+
"frequenz-quantities >= 1.0.0, < 2"
36+
]
37+
```
38+
39+
> [!NOTE]
40+
> We recommend pinning the dependency to the latest version for programs,
41+
> like `"frequenz-quantities == 1.0.0"`, and specifying a version range
42+
> spanning one major version for libraries, like `"frequenz-quantities >= 1.0.0, < 2"`.
43+
> We follow [semver](https://semver.org/).
44+
45+
## Quick Start
46+
47+
```python
48+
from frequenz.quantities import Power, Current, Voltage
49+
50+
# Create quantities using unit-specific constructors
51+
power = Power.from_watts(1500.0)
52+
current = Current.from_amperes(10.0)
53+
voltage = Voltage.from_volts(230.0)
54+
55+
# Perform operations between quantities
56+
total_power = power + Power.from_kilowatts(2.0)
57+
print(f"Total power: {total_power}") # Total power: 3500 W
58+
59+
# Convert to different units
60+
print(f"Power in kW: {total_power.as_kilowatts()}") # Power in kW: 3.5
61+
62+
# Type safety prevents invalid operations
63+
# This would raise a TypeError:
64+
# invalid = power + current # Can't add power and current!
65+
```
66+
2067
## Documentation
2168

2269
For more information on how to use this library and examples, please check the

0 commit comments

Comments
 (0)