Skip to content

Commit e25d10e

Browse files
edit docstrings
1 parent 758b9ed commit e25d10e

File tree

1 file changed

+41
-47
lines changed

1 file changed

+41
-47
lines changed

bittensor/core/subtensor.py

Lines changed: 41 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,7 @@ def query_constant(
281281
Arguments:
282282
module_name: The name of the module containing the constant (e.g., "Balances", "SubtensorModule").
283283
constant_name: The name of the constant to retrieve (e.g., "ExistentialDeposit").
284-
block: The blockchain block number at which to query the constant. Do not specify if using block_hash or
285-
reuse_block.
284+
block: The blockchain block number at which to query the constant.
286285
287286
Returns:
288287
Optional[async_substrate_interface.types.ScaleObj]: The value of the constant if found, ``None`` otherwise.
@@ -413,7 +412,7 @@ def query_runtime_api(
413412
runtime_api: The name of the runtime API to query.
414413
method: The specific method within the runtime API to call.
415414
params: The parameters to pass to the method call.
416-
block: the block number for this query. Do not specify if using block_hash or reuse_block.
415+
block: the block number for this query.
417416
418417
Returns:
419418
The decoded result from the runtime API call, or ``None`` if the call fails.
@@ -441,8 +440,8 @@ def query_subtensor(
441440
Returns:
442441
query_response: An object containing the requested data.
443442
444-
This query function is essential for accessing detailed information about the network and its neurons,
445-
providing valuable insights into the state and dynamics of the Bittensor ecosystem.
443+
This query function is essential for accessing detailed information about the network and its neurons, providing
444+
valuable insights into the state and dynamics of the Bittensor ecosystem.
446445
"""
447446
return self.substrate.query(
448447
module="SubtensorModule",
@@ -465,8 +464,8 @@ def state_call(
465464
Returns:
466465
result (dict[Any, Any]): The result of the rpc call.
467466
468-
The state call function provides a more direct and flexible way of querying blockchain data, useful for
469-
specific use cases where standard queries are insufficient.
467+
The state call function provides a more direct and flexible way of querying blockchain data, useful for specific
468+
use cases where standard queries are insufficient.
470469
"""
471470
block_hash = self.determine_block_hash(block)
472471
return self.substrate.rpc_request(
@@ -485,8 +484,7 @@ def all_subnets(self, block: Optional[int] = None) -> Optional[list["DynamicInfo
485484
and operational status.
486485
487486
Arguments:
488-
block: The block number to query the subnet information from. Do not specify if using block_hash or
489-
reuse_block.
487+
block: The block number to query the subnet information from.
490488
491489
Returns:
492490
Optional[list[DynamicInfo]]: A list of DynamicInfo objects, each containing detailed information about a
@@ -517,7 +515,7 @@ def blocks_since_last_step(
517515
518516
Arguments:
519517
netuid: The unique identifier of the subnetwork.
520-
block: The block number for this query. Do not specify if using block_hash or reuse_block.
518+
block: The block number for this query.
521519
522520
Returns:
523521
The number of blocks since the last step in the subnet, or None if the query fails.
@@ -565,7 +563,7 @@ def bonds(
565563
566564
Arguments:
567565
netuid: The unique identifier of the subnet.
568-
block: The block number for this query. Do not specify if using block_hash or reuse_block.
566+
block: The block number for this query.
569567
570568
Returns:
571569
List of tuples mapping each neuron's UID to its bonds with other neurons.
@@ -642,7 +640,7 @@ def commit_reveal_enabled(
642640
643641
Arguments:
644642
netuid: The unique identifier of the subnet for which to check the commit-reveal mechanism.
645-
block: The block number to query. Do not specify if using block_hash or reuse_block.
643+
block: The block number to query.
646644
647645
Returns:
648646
bool: True if commit-reveal mechanism is enabled, False otherwise.
@@ -672,7 +670,7 @@ def difficulty(self, netuid: int, block: Optional[int] = None) -> Optional[int]:
672670
673671
Arguments:
674672
netuid: The unique identifier of the subnet.
675-
block: The block number for the query. Do not specify if using block_hash or reuse_block.
673+
block: The block number for the query.
676674
677675
Returns:
678676
Optional[int]: The value of the 'Difficulty' hyperparameter if the subnet exists, None otherwise.
@@ -701,7 +699,7 @@ def does_hotkey_exist(self, hotkey_ss58: str, block: Optional[int] = None) -> bo
701699
702700
Arguments:
703701
hotkey_ss58: The SS58 address of the hotkey.
704-
block: The block number for this query. Do not specify if using block_hash or reuse_block.
702+
block: The block number for this query.
705703
706704
Returns:
707705
bool: True if the hotkey is known by the chain and there are accounts, False otherwise.
@@ -937,8 +935,7 @@ def get_hyperparameter(
937935
Arguments:
938936
param_name: The name of the hyperparameter to retrieve (e.g., "Difficulty", "Tempo", "ImmunityPeriod").
939937
netuid: The unique identifier of the subnet.
940-
block: The block number at which to retrieve the hyperparameter. Do not specify if using block_hash or
941-
reuse_block.
938+
block: The block number at which to retrieve the hyperparameter.
942939
943940
Returns:
944941
The value of the specified hyperparameter if the subnet exists, None otherwise.
@@ -949,9 +946,6 @@ def get_hyperparameter(
949946
950947
# Get tempo at a specific block
951948
tempo = subtensor.get_hyperparameter(param_name="Tempo", netuid=1, block=1000000)
952-
953-
# Get immunity period using block hash
954-
immunity = subtensor.get_hyperparameter(param_name="ImmunityPeriod", netuid=1, block_hash="0x1234...")
955949
"""
956950
block_hash = self.determine_block_hash(block)
957951
if not self.subnet_exists(netuid, block=block):
@@ -2230,7 +2224,7 @@ def get_subnet_burn_cost(self, block: Optional[int] = None) -> Optional[Balance]
22302224
amount of Tao that needs to be locked or burned to establish a new subnet.
22312225
22322226
Arguments:
2233-
block (Optional[int]): The blockchain block number for the query.
2227+
block: The blockchain block number for the query.
22342228
22352229
Returns:
22362230
int: The burn cost for subnet registration.
@@ -2255,17 +2249,17 @@ def get_subnet_hyperparameters(
22552249
) -> Optional[Union[list, "SubnetHyperparameters"]]:
22562250
"""
22572251
Retrieves the hyperparameters for a specific subnet within the Bittensor network. These hyperparameters define
2258-
the operational settings and rules governing the subnet's behavior.
2252+
the operational settings and rules governing the subnet's behavior.
22592253
22602254
Arguments:
2261-
netuid (int): The network UID of the subnet to query.
2262-
block (Optional[int]): The blockchain block number for the query.
2255+
netuid: The network UID of the subnet to query.
2256+
block: The blockchain block number for the query.
22632257
22642258
Returns:
2265-
The subnet's hyperparameters, or `None` if not available.
2259+
The subnet's hyperparameters, or ``None`` if not available.
22662260
22672261
Understanding the hyperparameters is crucial for comprehending how subnets are configured and managed, and how
2268-
they interact with the network's consensus and incentive mechanisms.
2262+
they interact with the network's consensus and incentive mechanisms.
22692263
"""
22702264
result = self.query_runtime_api(
22712265
runtime_api="SubnetInfoRuntimeApi",
@@ -2295,13 +2289,13 @@ def get_subnets(self, block: Optional[int] = None) -> list[int]:
22952289
Retrieves the list of all subnet unique identifiers (netuids) currently present in the Bittensor network.
22962290
22972291
Arguments:
2298-
block (Optional[int]): The blockchain block number for the query.
2292+
block: The blockchain block number for the query.
22992293
23002294
Returns:
23012295
A list of subnet netuids.
23022296
2303-
This function provides a comprehensive view of the subnets within the Bittensor network,
2304-
offering insights into its diversity and scale.
2297+
This function provides a comprehensive view of the subnets within the Bittensor network, offering insights into
2298+
its diversity and scale.
23052299
"""
23062300
result = self.substrate.query_map(
23072301
module="SubtensorModule",
@@ -2320,7 +2314,7 @@ def get_total_subnets(self, block: Optional[int] = None) -> Optional[int]:
23202314
Retrieves the total number of subnets within the Bittensor network as of a specific blockchain block.
23212315
23222316
Arguments:
2323-
block (Optional[int]): The blockchain block number for the query.
2317+
block: The blockchain block number for the query.
23242318
23252319
Returns:
23262320
Optional[str]: The total number of subnets in the network.
@@ -2339,22 +2333,22 @@ def get_total_subnets(self, block: Optional[int] = None) -> Optional[int]:
23392333
def get_transfer_fee(self, wallet: "Wallet", dest: str, value: Balance) -> Balance:
23402334
"""
23412335
Calculates the transaction fee for transferring tokens from a wallet to a specified destination address. This
2342-
function simulates the transfer to estimate the associated cost, taking into account the current network
2343-
conditions and transaction complexity.
2336+
function simulates the transfer to estimate the associated cost, taking into account the current network
2337+
conditions and transaction complexity.
23442338
23452339
Arguments:
2346-
wallet (bittensor_wallet.Wallet): The wallet from which the transfer is initiated.
2347-
dest (str): The ``SS58`` address of the destination account.
2348-
value (Union[bittensor.utils.balance.Balance, float, int]): The amount of tokens to be transferred,
2349-
specified as a Balance object, or in Tao (float) or Rao (int) units.
2340+
wallet: The wallet from which the transfer is initiated.
2341+
dest: The ``SS58`` address of the destination account.
2342+
value: The amount of tokens to be transferred, specified as a Balance object, or in Tao (float) or Rao
2343+
(int) units.
23502344
23512345
Returns:
23522346
bittensor.utils.balance.Balance: The estimated transaction fee for the transfer, represented as a Balance
23532347
object.
23542348
2355-
Estimating the transfer fee is essential for planning and executing token transactions, ensuring that the wallet
2356-
has sufficient funds to cover both the transfer amount and the associated costs. This function provides a
2357-
crucial tool for managing financial operations within the Bittensor network.
2349+
Estimating the transfer fee is essential for planning and executing token transactions, ensuring that the
2350+
wallet has sufficient funds to cover both the transfer amount and the associated costs. This function provides
2351+
a crucial tool for managing financial operations within the Bittensor network.
23582352
"""
23592353
value = check_and_convert_to_balance(value)
23602354
call = self.substrate.compose_call(
@@ -2378,17 +2372,17 @@ def get_vote_data(
23782372
) -> Optional["ProposalVoteData"]:
23792373
"""
23802374
Retrieves the voting data for a specific proposal on the Bittensor blockchain. This data includes information
2381-
about how senate members have voted on the proposal.
2375+
about how senate members have voted on the proposal.
23822376
23832377
Arguments:
2384-
proposal_hash (str): The hash of the proposal for which voting data is requested.
2385-
block (Optional[int]): The blockchain block number for the query.
2378+
proposal_hash: The hash of the proposal for which voting data is requested.
2379+
block: The blockchain block number for the query.
23862380
23872381
Returns:
23882382
An object containing the proposal's voting data, or `None` if not found.
23892383
23902384
This function is important for tracking and understanding the decision-making processes within the Bittensor
2391-
network, particularly how proposals are received and acted upon by the governing body.
2385+
network, particularly how proposals are received and acted upon by the governing body.
23922386
"""
23932387
vote_data: dict[str, Any] = self.substrate.query(
23942388
module="Triumvirate",
@@ -2417,7 +2411,7 @@ def get_uid_for_hotkey_on_subnet(
24172411
Optional[int]: The UID of the neuron if it is registered on the subnet, ``None`` otherwise.
24182412
24192413
The UID is a critical identifier within the network, linking the neuron's hotkey to its operational and
2420-
governance activities on a particular subnet.
2414+
governance activities on a particular subnet.
24212415
"""
24222416
result = self.substrate.query(
24232417
module="SubtensorModule",
@@ -2438,10 +2432,10 @@ def filter_netuids_by_registered_hotkeys(
24382432
Filters a given list of all netuids for certain specified netuids and hotkeys
24392433
24402434
Arguments:
2441-
all_netuids (Iterable[int]): A list of netuids to filter.
2442-
filter_for_netuids (Iterable[int]): A subset of all_netuids to filter from the main list.
2443-
all_hotkeys (Iterable[Wallet]): Hotkeys to filter from the main list.
2444-
block (Optional[int]): The blockchain block number for the query.
2435+
all_netuids: A list of netuids to filter.
2436+
filter_for_netuids: A subset of all_netuids to filter from the main list.
2437+
all_hotkeys: Hotkeys to filter from the main list.
2438+
block: The blockchain block number for the query.
24452439
24462440
Returns:
24472441
The filtered list of netuids.

0 commit comments

Comments
 (0)