File tree Expand file tree Collapse file tree 1 file changed +20
-3
lines changed
Expand file tree Collapse file tree 1 file changed +20
-3
lines changed Original file line number Diff line number Diff line change 77
88
99def _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 )
You can’t perform that action at this time.
0 commit comments