Skip to content

Commit 7050f6f

Browse files
author
Roman
committed
extend message
1 parent df40f72 commit 7050f6f

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

bittensor/utils/balance.py

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,29 @@
77

88

99
def _check_currencies(self, other):
10-
"""Checks that Balance objects have the same netuids to perform arithmetic operations."""
10+
"""Checks that Balance objects have the same netuids to perform arithmetic operations.
11+
12+
A warning is raised if the netuids differ.
13+
14+
Example:
15+
>>> balance1 = Balance.from_rao(1000).set_unit(12)
16+
>>> balance2 = Balance.from_rao(500).set_unit(12)
17+
>>> balance1 + balance2 # No warning
18+
19+
>>> balance3 = Balance.from_rao(200).set_unit(15)
20+
>>> balance1 + balance3 # Raises DeprecationWarning
21+
22+
In this example:
23+
- `from_rao` creates a Balance instance from the amount in rao (smallest unit).
24+
- `set_unit(12)` sets the unit to correspond to subnet 12 (i.e., Alpha from netuid 12).
25+
"""
1126
if self.netuid != other.netuid:
1227
warnings.simplefilter("default", DeprecationWarning)
1328
warnings.warn(
14-
"Balance objects must have the same netuid (Alpha currency) to perform arithmetic operations. "
15-
f"First balance is `{self}`. Second balance is `{other}`. ",
29+
"Balance objects must have the same netuid (Alpha currency) to perform arithmetic operations.\n"
30+
f"First balance is `{self}`. Second balance is `{other}`.\n\n"
31+
"To create a Balance instance with the correct netuid, use:\n"
32+
"Balance.from_rao(1000).set_unit(12) # 1000 rao in subnet 12",
1633
category=DeprecationWarning,
1734
stacklevel=2,
1835
)

0 commit comments

Comments
 (0)