body stringlengths 26 98.2k | body_hash int64 -9,222,864,604,528,158,000 9,221,803,474B | docstring stringlengths 1 16.8k | path stringlengths 5 230 | name stringlengths 1 96 | repository_name stringlengths 7 89 | lang stringclasses 1
value | body_without_docstring stringlengths 20 98.2k |
|---|---|---|---|---|---|---|---|
def refresh_data(self, force_refresh=False, data_refresh_time_seconds=None):
' Read and stores crea blockchain parameters\n If the last data refresh is older than data_refresh_time_seconds, data will be refreshed\n\n :param bool force_refresh: if True, a refresh of the data is enforced\n ... | 7,819,743,639,589,063,000 | Read and stores crea blockchain parameters
If the last data refresh is older than data_refresh_time_seconds, data will be refreshed
:param bool force_refresh: if True, a refresh of the data is enforced
:param float data_refresh_time_seconds: set a new minimal refresh time in seconds | crea/crea.py | refresh_data | creativechain/crea-python-lib | python | def refresh_data(self, force_refresh=False, data_refresh_time_seconds=None):
' Read and stores crea blockchain parameters\n If the last data refresh is older than data_refresh_time_seconds, data will be refreshed\n\n :param bool force_refresh: if True, a refresh of the data is enforced\n ... |
def get_dynamic_global_properties(self, use_stored_data=True):
' This call returns the *dynamic global properties*\n\n :param bool use_stored_data: if True, stored data will be returned. If stored data are\n empty or old, refresh_data() is used.\n\n '
if use_stored_data:
... | -3,508,538,338,149,902,000 | This call returns the *dynamic global properties*
:param bool use_stored_data: if True, stored data will be returned. If stored data are
empty or old, refresh_data() is used. | crea/crea.py | get_dynamic_global_properties | creativechain/crea-python-lib | python | def get_dynamic_global_properties(self, use_stored_data=True):
' This call returns the *dynamic global properties*\n\n :param bool use_stored_data: if True, stored data will be returned. If stored data are\n empty or old, refresh_data() is used.\n\n '
if use_stored_data:
... |
def get_reserve_ratio(self):
' This call returns the *reserve ratio*\n '
if (self.rpc is None):
return None
self.rpc.set_next_node_on_empty_reply(True)
if self.rpc.get_use_appbase():
return self.rpc.get_reserve_ratio(api='witness')
else:
props = self.get_dynamic_global... | 5,242,808,978,048,539,000 | This call returns the *reserve ratio* | crea/crea.py | get_reserve_ratio | creativechain/crea-python-lib | python | def get_reserve_ratio(self):
' \n '
if (self.rpc is None):
return None
self.rpc.set_next_node_on_empty_reply(True)
if self.rpc.get_use_appbase():
return self.rpc.get_reserve_ratio(api='witness')
else:
props = self.get_dynamic_global_properties()
reserve_ratio =... |
def get_feed_history(self, use_stored_data=True):
' Returns the feed_history\n\n :param bool use_stored_data: if True, stored data will be returned. If stored data are\n empty or old, refresh_data() is used.\n\n '
if use_stored_data:
self.refresh_data()
return se... | 206,164,912,570,837,760 | Returns the feed_history
:param bool use_stored_data: if True, stored data will be returned. If stored data are
empty or old, refresh_data() is used. | crea/crea.py | get_feed_history | creativechain/crea-python-lib | python | def get_feed_history(self, use_stored_data=True):
' Returns the feed_history\n\n :param bool use_stored_data: if True, stored data will be returned. If stored data are\n empty or old, refresh_data() is used.\n\n '
if use_stored_data:
self.refresh_data()
return se... |
def get_reward_funds(self, use_stored_data=True):
' Get details for a reward fund.\n\n :param bool use_stored_data: if True, stored data will be returned. If stored data are\n empty or old, refresh_data() is used.\n\n '
if use_stored_data:
self.refresh_data()
ret... | -760,045,488,233,925,500 | Get details for a reward fund.
:param bool use_stored_data: if True, stored data will be returned. If stored data are
empty or old, refresh_data() is used. | crea/crea.py | get_reward_funds | creativechain/crea-python-lib | python | def get_reward_funds(self, use_stored_data=True):
' Get details for a reward fund.\n\n :param bool use_stored_data: if True, stored data will be returned. If stored data are\n empty or old, refresh_data() is used.\n\n '
if use_stored_data:
self.refresh_data()
ret... |
def get_current_median_history(self, use_stored_data=True):
' Returns the current median price\n\n :param bool use_stored_data: if True, stored data will be returned. If stored data are\n empty or old, refresh_data() is used.\n '
if use_stored_data:
... | 283,038,694,342,067,040 | Returns the current median price
:param bool use_stored_data: if True, stored data will be returned. If stored data are
empty or old, refresh_data() is used. | crea/crea.py | get_current_median_history | creativechain/crea-python-lib | python | def get_current_median_history(self, use_stored_data=True):
' Returns the current median price\n\n :param bool use_stored_data: if True, stored data will be returned. If stored data are\n empty or old, refresh_data() is used.\n '
if use_stored_data:
... |
def get_hardfork_properties(self, use_stored_data=True):
' Returns Hardfork and live_time of the hardfork\n\n :param bool use_stored_data: if True, stored data will be returned. If stored data are\n empty or old, refresh_data() is used.\n '
if use_stored... | 3,865,267,989,304,429,000 | Returns Hardfork and live_time of the hardfork
:param bool use_stored_data: if True, stored data will be returned. If stored data are
empty or old, refresh_data() is used. | crea/crea.py | get_hardfork_properties | creativechain/crea-python-lib | python | def get_hardfork_properties(self, use_stored_data=True):
' Returns Hardfork and live_time of the hardfork\n\n :param bool use_stored_data: if True, stored data will be returned. If stored data are\n empty or old, refresh_data() is used.\n '
if use_stored... |
def get_network(self, use_stored_data=True):
' Identify the network\n\n :param bool use_stored_data: if True, stored data will be returned. If stored data are\n empty or old, refresh_data() is used.\n\n :returns: Network parameters\n :rtype: d... | 5,438,952,769,049,470,000 | Identify the network
:param bool use_stored_data: if True, stored data will be returned. If stored data are
empty or old, refresh_data() is used.
:returns: Network parameters
:rtype: dictionary | crea/crea.py | get_network | creativechain/crea-python-lib | python | def get_network(self, use_stored_data=True):
' Identify the network\n\n :param bool use_stored_data: if True, stored data will be returned. If stored data are\n empty or old, refresh_data() is used.\n\n :returns: Network parameters\n :rtype: d... |
def get_median_price(self, use_stored_data=True):
' Returns the current median history price as Price\n '
median_price = self.get_current_median_history(use_stored_data=use_stored_data)
if (median_price is None):
return None
a = Price(None, base=Amount(median_price['base'], crea_instance=... | 7,293,544,818,523,480,000 | Returns the current median history price as Price | crea/crea.py | get_median_price | creativechain/crea-python-lib | python | def get_median_price(self, use_stored_data=True):
' \n '
median_price = self.get_current_median_history(use_stored_data=use_stored_data)
if (median_price is None):
return None
a = Price(None, base=Amount(median_price['base'], crea_instance=self), quote=Amount(median_price['quote'], crea_i... |
def get_block_interval(self, use_stored_data=True):
'Returns the block interval in seconds'
props = self.get_config(use_stored_data=use_stored_data)
block_interval = 3
if (props is None):
return block_interval
for key in props:
if (key[(- 14):] == 'BLOCK_INTERVAL'):
block... | 4,398,964,587,922,790,000 | Returns the block interval in seconds | crea/crea.py | get_block_interval | creativechain/crea-python-lib | python | def get_block_interval(self, use_stored_data=True):
props = self.get_config(use_stored_data=use_stored_data)
block_interval = 3
if (props is None):
return block_interval
for key in props:
if (key[(- 14):] == 'BLOCK_INTERVAL'):
block_interval = props[key]
return block... |
def get_blockchain_version(self, use_stored_data=True):
'Returns the blockchain version'
props = self.get_config(use_stored_data=use_stored_data)
blockchain_version = '0.0.0'
if (props is None):
return blockchain_version
for key in props:
if (key[(- 18):] == 'BLOCKCHAIN_VERSION'):
... | 6,491,688,609,673,718,000 | Returns the blockchain version | crea/crea.py | get_blockchain_version | creativechain/crea-python-lib | python | def get_blockchain_version(self, use_stored_data=True):
props = self.get_config(use_stored_data=use_stored_data)
blockchain_version = '0.0.0'
if (props is None):
return blockchain_version
for key in props:
if (key[(- 18):] == 'BLOCKCHAIN_VERSION'):
blockchain_version = p... |
def get_dust_threshold(self, use_stored_data=True):
'Returns the vote dust threshold'
props = self.get_config(use_stored_data=use_stored_data)
dust_threshold = 0
if (props is None):
return dust_threshold
for key in props:
if (key[(- 20):] == 'VOTE_DUST_THRESHOLD'):
dust_t... | -8,331,495,759,918,413,000 | Returns the vote dust threshold | crea/crea.py | get_dust_threshold | creativechain/crea-python-lib | python | def get_dust_threshold(self, use_stored_data=True):
props = self.get_config(use_stored_data=use_stored_data)
dust_threshold = 0
if (props is None):
return dust_threshold
for key in props:
if (key[(- 20):] == 'VOTE_DUST_THRESHOLD'):
dust_threshold = props[key]
return ... |
def get_resource_params(self):
'Returns the resource parameter'
return self.rpc.get_resource_params(api='rc')['resource_params'] | 5,245,043,488,725,302,000 | Returns the resource parameter | crea/crea.py | get_resource_params | creativechain/crea-python-lib | python | def get_resource_params(self):
return self.rpc.get_resource_params(api='rc')['resource_params'] |
def get_resource_pool(self):
'Returns the resource pool'
return self.rpc.get_resource_pool(api='rc')['resource_pool'] | 9,023,864,460,098,035,000 | Returns the resource pool | crea/crea.py | get_resource_pool | creativechain/crea-python-lib | python | def get_resource_pool(self):
return self.rpc.get_resource_pool(api='rc')['resource_pool'] |
def get_rc_cost(self, resource_count):
'Returns the RC costs based on the resource_count'
pools = self.get_resource_pool()
params = self.get_resource_params()
config = self.get_config()
dyn_param = self.get_dynamic_global_properties()
rc_regen = (int(Amount(dyn_param['total_vesting_shares'], cre... | 1,370,687,015,575,499,300 | Returns the RC costs based on the resource_count | crea/crea.py | get_rc_cost | creativechain/crea-python-lib | python | def get_rc_cost(self, resource_count):
pools = self.get_resource_pool()
params = self.get_resource_params()
config = self.get_config()
dyn_param = self.get_dynamic_global_properties()
rc_regen = (int(Amount(dyn_param['total_vesting_shares'], crea_instance=self)) / (CREA_RC_REGEN_TIME / config['... |
def _compute_rc_cost(self, curve_params, current_pool, resource_count, rc_regen):
'Helper function for computing the RC costs'
num = int(rc_regen)
num *= int(curve_params['coeff_a'])
num = (int(num) >> int(curve_params['shift']))
num += 1
num *= int(resource_count)
denom = int(curve_params['... | 4,214,059,006,486,920,700 | Helper function for computing the RC costs | crea/crea.py | _compute_rc_cost | creativechain/crea-python-lib | python | def _compute_rc_cost(self, curve_params, current_pool, resource_count, rc_regen):
num = int(rc_regen)
num *= int(curve_params['coeff_a'])
num = (int(num) >> int(curve_params['shift']))
num += 1
num *= int(resource_count)
denom = int(curve_params['coeff_b'])
if (int(current_pool) > 0):
... |
def rshares_to_sbd(self, rshares, not_broadcasted_vote=False, use_stored_data=True):
' Calculates the current CBD value of a vote\n '
payout = (float(rshares) * self.get_sbd_per_rshares(use_stored_data=use_stored_data, not_broadcasted_vote_rshares=(rshares if not_broadcasted_vote else 0)))
return pay... | -4,718,203,261,994,518,000 | Calculates the current CBD value of a vote | crea/crea.py | rshares_to_sbd | creativechain/crea-python-lib | python | def rshares_to_sbd(self, rshares, not_broadcasted_vote=False, use_stored_data=True):
' \n '
payout = (float(rshares) * self.get_sbd_per_rshares(use_stored_data=use_stored_data, not_broadcasted_vote_rshares=(rshares if not_broadcasted_vote else 0)))
return payout |
def get_sbd_per_rshares(self, not_broadcasted_vote_rshares=0, use_stored_data=True):
' Returns the current rshares to CBD ratio\n '
reward_fund = self.get_reward_funds(use_stored_data=use_stored_data)
reward_balance = Amount(reward_fund['reward_balance'], crea_instance=self).amount
recent_claims ... | 1,823,671,415,033,162,200 | Returns the current rshares to CBD ratio | crea/crea.py | get_sbd_per_rshares | creativechain/crea-python-lib | python | def get_sbd_per_rshares(self, not_broadcasted_vote_rshares=0, use_stored_data=True):
' \n '
reward_fund = self.get_reward_funds(use_stored_data=use_stored_data)
reward_balance = Amount(reward_fund['reward_balance'], crea_instance=self).amount
recent_claims = (float(reward_fund['recent_claims']) +... |
def get_crea_per_mvest(self, time_stamp=None, use_stored_data=True):
' Returns the MVEST to CREA ratio\n\n :param int time_stamp: (optional) if set, return an estimated\n CREA per MVEST ratio for the given time stamp. If unset the\n current ratio is returned (default). (can ... | -4,148,933,468,931,298,300 | Returns the MVEST to CREA ratio
:param int time_stamp: (optional) if set, return an estimated
CREA per MVEST ratio for the given time stamp. If unset the
current ratio is returned (default). (can also be a datetime object) | crea/crea.py | get_crea_per_mvest | creativechain/crea-python-lib | python | def get_crea_per_mvest(self, time_stamp=None, use_stored_data=True):
' Returns the MVEST to CREA ratio\n\n :param int time_stamp: (optional) if set, return an estimated\n CREA per MVEST ratio for the given time stamp. If unset the\n current ratio is returned (default). (can ... |
def vests_to_sp(self, vests, timestamp=None, use_stored_data=True):
' Converts vests to SP\n\n :param amount.Amount vests/float vests: Vests to convert\n :param int timestamp: (Optional) Can be used to calculate\n the conversion rate from the past\n\n '
if isinstance(... | -2,568,794,267,450,538,500 | Converts vests to SP
:param amount.Amount vests/float vests: Vests to convert
:param int timestamp: (Optional) Can be used to calculate
the conversion rate from the past | crea/crea.py | vests_to_sp | creativechain/crea-python-lib | python | def vests_to_sp(self, vests, timestamp=None, use_stored_data=True):
' Converts vests to SP\n\n :param amount.Amount vests/float vests: Vests to convert\n :param int timestamp: (Optional) Can be used to calculate\n the conversion rate from the past\n\n '
if isinstance(... |
def sp_to_vests(self, sp, timestamp=None, use_stored_data=True):
' Converts SP to vests\n\n :param float sp: Crea power to convert\n :param datetime timestamp: (Optional) Can be used to calculate\n the conversion rate from the past\n '
return ((sp * 1000000.0) / self.... | -4,849,199,026,127,953,000 | Converts SP to vests
:param float sp: Crea power to convert
:param datetime timestamp: (Optional) Can be used to calculate
the conversion rate from the past | crea/crea.py | sp_to_vests | creativechain/crea-python-lib | python | def sp_to_vests(self, sp, timestamp=None, use_stored_data=True):
' Converts SP to vests\n\n :param float sp: Crea power to convert\n :param datetime timestamp: (Optional) Can be used to calculate\n the conversion rate from the past\n '
return ((sp * 1000000.0) / self.... |
def sp_to_sbd(self, sp, voting_power=CREA_100_PERCENT, vote_pct=CREA_100_PERCENT, not_broadcasted_vote=True, use_stored_data=True):
' Obtain the resulting CBD vote value from Crea power\n\n :param number crea_power: Crea Power\n :param int voting_power: voting power (100% = 10000)\n ... | 5,978,847,911,755,759,000 | Obtain the resulting CBD vote value from Crea power
:param number crea_power: Crea Power
:param int voting_power: voting power (100% = 10000)
:param int vote_pct: voting percentage (100% = 10000)
:param bool not_broadcasted_vote: not_broadcasted or already broadcasted vote (True = not_broadcasted vote).
Only impactfu... | crea/crea.py | sp_to_sbd | creativechain/crea-python-lib | python | def sp_to_sbd(self, sp, voting_power=CREA_100_PERCENT, vote_pct=CREA_100_PERCENT, not_broadcasted_vote=True, use_stored_data=True):
' Obtain the resulting CBD vote value from Crea power\n\n :param number crea_power: Crea Power\n :param int voting_power: voting power (100% = 10000)\n ... |
def vests_to_sbd(self, vests, voting_power=CREA_100_PERCENT, vote_pct=CREA_100_PERCENT, not_broadcasted_vote=True, use_stored_data=True):
' Obtain the resulting CBD vote value from vests\n\n :param number vests: vesting shares\n :param int voting_power: voting power (100% = 10000)\n ... | -7,475,987,706,363,184,000 | Obtain the resulting CBD vote value from vests
:param number vests: vesting shares
:param int voting_power: voting power (100% = 10000)
:param int vote_pct: voting percentage (100% = 10000)
:param bool not_broadcasted_vote: not_broadcasted or already broadcasted vote (True = not_broadcasted vote).
Only impactful for ... | crea/crea.py | vests_to_sbd | creativechain/crea-python-lib | python | def vests_to_sbd(self, vests, voting_power=CREA_100_PERCENT, vote_pct=CREA_100_PERCENT, not_broadcasted_vote=True, use_stored_data=True):
' Obtain the resulting CBD vote value from vests\n\n :param number vests: vesting shares\n :param int voting_power: voting power (100% = 10000)\n ... |
def sp_to_rshares(self, crea_power, voting_power=CREA_100_PERCENT, vote_pct=CREA_100_PERCENT, use_stored_data=True):
' Obtain the r-shares from Crea power\n\n :param number crea_power: Crea Power\n :param int voting_power: voting power (100% = 10000)\n :param int vote_pct: voting pe... | -7,830,901,295,728,305,000 | Obtain the r-shares from Crea power
:param number crea_power: Crea Power
:param int voting_power: voting power (100% = 10000)
:param int vote_pct: voting percentage (100% = 10000) | crea/crea.py | sp_to_rshares | creativechain/crea-python-lib | python | def sp_to_rshares(self, crea_power, voting_power=CREA_100_PERCENT, vote_pct=CREA_100_PERCENT, use_stored_data=True):
' Obtain the r-shares from Crea power\n\n :param number crea_power: Crea Power\n :param int voting_power: voting power (100% = 10000)\n :param int vote_pct: voting pe... |
def vests_to_rshares(self, vests, voting_power=CREA_100_PERCENT, vote_pct=CREA_100_PERCENT, subtract_dust_threshold=True, use_stored_data=True):
' Obtain the r-shares from vests\n\n :param number vests: vesting shares\n :param int voting_power: voting power (100% = 10000)\n :param i... | 8,090,407,536,710,920,000 | Obtain the r-shares from vests
:param number vests: vesting shares
:param int voting_power: voting power (100% = 10000)
:param int vote_pct: voting percentage (100% = 10000) | crea/crea.py | vests_to_rshares | creativechain/crea-python-lib | python | def vests_to_rshares(self, vests, voting_power=CREA_100_PERCENT, vote_pct=CREA_100_PERCENT, subtract_dust_threshold=True, use_stored_data=True):
' Obtain the r-shares from vests\n\n :param number vests: vesting shares\n :param int voting_power: voting power (100% = 10000)\n :param i... |
def sbd_to_rshares(self, sbd, not_broadcasted_vote=False, use_stored_data=True):
' Obtain the r-shares from CBD\n\n :param sbd: CBD\n :type sbd: str, int, amount.Amount\n :param bool not_broadcasted_vote: not_broadcasted or already broadcasted vote (True = not_broadcasted vote).\n Only ... | -82,920,561,340,008,460 | Obtain the r-shares from CBD
:param sbd: CBD
:type sbd: str, int, amount.Amount
:param bool not_broadcasted_vote: not_broadcasted or already broadcasted vote (True = not_broadcasted vote).
Only impactful for very high amounts of CBD. Slight modification to the value calculation, as the not_broadcasted
vote rshares d... | crea/crea.py | sbd_to_rshares | creativechain/crea-python-lib | python | def sbd_to_rshares(self, sbd, not_broadcasted_vote=False, use_stored_data=True):
' Obtain the r-shares from CBD\n\n :param sbd: CBD\n :type sbd: str, int, amount.Amount\n :param bool not_broadcasted_vote: not_broadcasted or already broadcasted vote (True = not_broadcasted vote).\n Only ... |
def rshares_to_vote_pct(self, rshares, crea_power=None, vests=None, voting_power=CREA_100_PERCENT, use_stored_data=True):
' Obtain the voting percentage for a desired rshares value\n for a given Crea Power or vesting shares and voting_power\n Give either crea_power or vests, not both.\n ... | -4,879,210,701,771,130,000 | Obtain the voting percentage for a desired rshares value
for a given Crea Power or vesting shares and voting_power
Give either crea_power or vests, not both.
When the output is greater than 10000 or less than -10000,
the given absolute rshares are too high
Returns the required voting percentage (100% = 10000)
:param ... | crea/crea.py | rshares_to_vote_pct | creativechain/crea-python-lib | python | def rshares_to_vote_pct(self, rshares, crea_power=None, vests=None, voting_power=CREA_100_PERCENT, use_stored_data=True):
' Obtain the voting percentage for a desired rshares value\n for a given Crea Power or vesting shares and voting_power\n Give either crea_power or vests, not both.\n ... |
def sbd_to_vote_pct(self, sbd, crea_power=None, vests=None, voting_power=CREA_100_PERCENT, not_broadcasted_vote=True, use_stored_data=True):
' Obtain the voting percentage for a desired CBD value\n for a given Crea Power or vesting shares and voting power\n Give either Crea Power or vests, not... | 1,368,237,473,710,176,000 | Obtain the voting percentage for a desired CBD value
for a given Crea Power or vesting shares and voting power
Give either Crea Power or vests, not both.
When the output is greater than 10000 or smaller than -10000,
the CBD value is too high.
Returns the required voting percentage (100% = 10000)
:param sbd: desired C... | crea/crea.py | sbd_to_vote_pct | creativechain/crea-python-lib | python | def sbd_to_vote_pct(self, sbd, crea_power=None, vests=None, voting_power=CREA_100_PERCENT, not_broadcasted_vote=True, use_stored_data=True):
' Obtain the voting percentage for a desired CBD value\n for a given Crea Power or vesting shares and voting power\n Give either Crea Power or vests, not... |
def get_chain_properties(self, use_stored_data=True):
" Return witness elected chain properties\n\n Properties:::\n\n {\n 'account_creation_fee': '30.000 CREA',\n 'maximum_block_size': 65536,\n 'sbd_interest_rate': 250\n ... | 900,415,650,330,882,200 | Return witness elected chain properties
Properties:::
{
'account_creation_fee': '30.000 CREA',
'maximum_block_size': 65536,
'sbd_interest_rate': 250
} | crea/crea.py | get_chain_properties | creativechain/crea-python-lib | python | def get_chain_properties(self, use_stored_data=True):
" Return witness elected chain properties\n\n Properties:::\n\n {\n 'account_creation_fee': '30.000 CREA',\n 'maximum_block_size': 65536,\n 'sbd_interest_rate': 250\n ... |
def get_witness_schedule(self, use_stored_data=True):
' Return witness elected chain properties\n\n '
if use_stored_data:
self.refresh_data()
return self.data['witness_schedule']
if (self.rpc is None):
return None
self.rpc.set_next_node_on_empty_reply(True)
return self... | -4,272,107,932,345,133,600 | Return witness elected chain properties | crea/crea.py | get_witness_schedule | creativechain/crea-python-lib | python | def get_witness_schedule(self, use_stored_data=True):
' \n\n '
if use_stored_data:
self.refresh_data()
return self.data['witness_schedule']
if (self.rpc is None):
return None
self.rpc.set_next_node_on_empty_reply(True)
return self.rpc.get_witness_schedule(api='database... |
def get_config(self, use_stored_data=True):
' Returns internal chain configuration.\n\n :param bool use_stored_data: If True, the cached value is returned\n '
if use_stored_data:
self.refresh_data()
config = self.data['config']
else:
if (self.rpc is None):
... | 7,234,055,566,862,977,000 | Returns internal chain configuration.
:param bool use_stored_data: If True, the cached value is returned | crea/crea.py | get_config | creativechain/crea-python-lib | python | def get_config(self, use_stored_data=True):
' Returns internal chain configuration.\n\n :param bool use_stored_data: If True, the cached value is returned\n '
if use_stored_data:
self.refresh_data()
config = self.data['config']
else:
if (self.rpc is None):
... |
def set_default_account(self, account):
' Set the default account to be used\n '
Account(account, crea_instance=self)
config['default_account'] = account | 2,919,257,918,958,075,400 | Set the default account to be used | crea/crea.py | set_default_account | creativechain/crea-python-lib | python | def set_default_account(self, account):
' \n '
Account(account, crea_instance=self)
config['default_account'] = account |
def set_password_storage(self, password_storage):
' Set the password storage mode.\n\n When set to "no", the password has to be provided each time.\n When set to "environment" the password is taken from the\n UNLOCK variable\n\n When set to "keyring" the password is taken... | -388,675,954,485,607,360 | Set the password storage mode.
When set to "no", the password has to be provided each time.
When set to "environment" the password is taken from the
UNLOCK variable
When set to "keyring" the password is taken from the
python keyring module. A wallet password can be stored with
python -m keyring set crea wallet passwo... | crea/crea.py | set_password_storage | creativechain/crea-python-lib | python | def set_password_storage(self, password_storage):
' Set the password storage mode.\n\n When set to "no", the password has to be provided each time.\n When set to "environment" the password is taken from the\n UNLOCK variable\n\n When set to "keyring" the password is taken... |
def set_default_nodes(self, nodes):
' Set the default nodes to be used\n '
if bool(nodes):
if isinstance(nodes, list):
nodes = str(nodes)
config['node'] = nodes
else:
config.delete('node') | -685,676,945,500,974,800 | Set the default nodes to be used | crea/crea.py | set_default_nodes | creativechain/crea-python-lib | python | def set_default_nodes(self, nodes):
' \n '
if bool(nodes):
if isinstance(nodes, list):
nodes = str(nodes)
config['node'] = nodes
else:
config.delete('node') |
def get_default_nodes(self):
'Returns the default nodes'
if ('node' in config):
nodes = config['node']
elif ('nodes' in config):
nodes = config['nodes']
elif (('default_nodes' in config) and bool(config['default_nodes'])):
nodes = config['default_nodes']
else:
nodes =... | -1,576,660,519,120,907,800 | Returns the default nodes | crea/crea.py | get_default_nodes | creativechain/crea-python-lib | python | def get_default_nodes(self):
if ('node' in config):
nodes = config['node']
elif ('nodes' in config):
nodes = config['nodes']
elif (('default_nodes' in config) and bool(config['default_nodes'])):
nodes = config['default_nodes']
else:
nodes = []
if (isinstance(node... |
def move_current_node_to_front(self):
'Returns the default node list, until the first entry\n is equal to the current working node url\n '
node = self.get_default_nodes()
if (len(node) < 2):
return
offline = self.offline
while ((not offline) and (node[0] != self.rpc.url) an... | -5,797,824,108,166,384,000 | Returns the default node list, until the first entry
is equal to the current working node url | crea/crea.py | move_current_node_to_front | creativechain/crea-python-lib | python | def move_current_node_to_front(self):
'Returns the default node list, until the first entry\n is equal to the current working node url\n '
node = self.get_default_nodes()
if (len(node) < 2):
return
offline = self.offline
while ((not offline) and (node[0] != self.rpc.url) an... |
def set_default_vote_weight(self, vote_weight):
' Set the default vote weight to be used\n '
config['default_vote_weight'] = vote_weight | -6,378,185,273,434,452,000 | Set the default vote weight to be used | crea/crea.py | set_default_vote_weight | creativechain/crea-python-lib | python | def set_default_vote_weight(self, vote_weight):
' \n '
config['default_vote_weight'] = vote_weight |
def finalizeOp(self, ops, account, permission, **kwargs):
' This method obtains the required private keys if present in\n the wallet, finalizes the transaction, signs it and\n broadacasts it\n\n :param ops: The operation (or list of operations) to\n broadcast\n ... | -6,611,208,480,797,089,000 | This method obtains the required private keys if present in
the wallet, finalizes the transaction, signs it and
broadacasts it
:param ops: The operation (or list of operations) to
broadcast
:type ops: list, GrapheneObject
:param Account account: The account that authorizes the
operation
:param string permissio... | crea/crea.py | finalizeOp | creativechain/crea-python-lib | python | def finalizeOp(self, ops, account, permission, **kwargs):
' This method obtains the required private keys if present in\n the wallet, finalizes the transaction, signs it and\n broadacasts it\n\n :param ops: The operation (or list of operations) to\n broadcast\n ... |
def sign(self, tx=None, wifs=[], reconstruct_tx=True):
' Sign a provided transaction with the provided key(s)\n\n :param dict tx: The transaction to be signed and returned\n :param string wifs: One or many wif keys to use for signing\n a transaction. If not present, the keys wil... | 8,778,294,486,211,037,000 | Sign a provided transaction with the provided key(s)
:param dict tx: The transaction to be signed and returned
:param string wifs: One or many wif keys to use for signing
a transaction. If not present, the keys will be loaded
from the wallet as defined in "missing_signatures" key
of the transactions.
:para... | crea/crea.py | sign | creativechain/crea-python-lib | python | def sign(self, tx=None, wifs=[], reconstruct_tx=True):
' Sign a provided transaction with the provided key(s)\n\n :param dict tx: The transaction to be signed and returned\n :param string wifs: One or many wif keys to use for signing\n a transaction. If not present, the keys wil... |
def broadcast(self, tx=None):
' Broadcast a transaction to the Crea network\n\n :param tx tx: Signed transaction to broadcast\n\n '
if tx:
return TransactionBuilder(tx, crea_instance=self).broadcast()
else:
return self.txbuffer.broadcast() | -6,851,223,572,119,729,000 | Broadcast a transaction to the Crea network
:param tx tx: Signed transaction to broadcast | crea/crea.py | broadcast | creativechain/crea-python-lib | python | def broadcast(self, tx=None):
' Broadcast a transaction to the Crea network\n\n :param tx tx: Signed transaction to broadcast\n\n '
if tx:
return TransactionBuilder(tx, crea_instance=self).broadcast()
else:
return self.txbuffer.broadcast() |
def info(self, use_stored_data=True):
' Returns the global properties\n '
return self.get_dynamic_global_properties(use_stored_data=use_stored_data) | -818,533,252,388,624,900 | Returns the global properties | crea/crea.py | info | creativechain/crea-python-lib | python | def info(self, use_stored_data=True):
' \n '
return self.get_dynamic_global_properties(use_stored_data=use_stored_data) |
def newWallet(self, pwd):
' Create a new wallet. This method is basically only calls\n :func:`crea.wallet.Wallet.create`.\n\n :param str pwd: Password to use for the new wallet\n\n :raises WalletExists: if there is already a\n wallet created\n\n '
return se... | 3,670,030,472,949,375,000 | Create a new wallet. This method is basically only calls
:func:`crea.wallet.Wallet.create`.
:param str pwd: Password to use for the new wallet
:raises WalletExists: if there is already a
wallet created | crea/crea.py | newWallet | creativechain/crea-python-lib | python | def newWallet(self, pwd):
' Create a new wallet. This method is basically only calls\n :func:`crea.wallet.Wallet.create`.\n\n :param str pwd: Password to use for the new wallet\n\n :raises WalletExists: if there is already a\n wallet created\n\n '
return se... |
def unlock(self, *args, **kwargs):
' Unlock the internal wallet\n '
return self.wallet.unlock(*args, **kwargs) | -8,737,820,938,272,326,000 | Unlock the internal wallet | crea/crea.py | unlock | creativechain/crea-python-lib | python | def unlock(self, *args, **kwargs):
' \n '
return self.wallet.unlock(*args, **kwargs) |
@property
def txbuffer(self):
' Returns the currently active tx buffer\n '
return self.tx() | 3,077,081,393,798,707,700 | Returns the currently active tx buffer | crea/crea.py | txbuffer | creativechain/crea-python-lib | python | @property
def txbuffer(self):
' \n '
return self.tx() |
def tx(self):
' Returns the default transaction buffer\n '
return self._txbuffers[0] | 5,966,482,822,398,606,000 | Returns the default transaction buffer | crea/crea.py | tx | creativechain/crea-python-lib | python | def tx(self):
' \n '
return self._txbuffers[0] |
def new_tx(self, *args, **kwargs):
" Let's obtain a new txbuffer\n\n :returns: id of the new txbuffer\n :rtype: int\n "
builder = TransactionBuilder(*args, crea_instance=self, **kwargs)
self._txbuffers.append(builder)
return builder | -812,935,130,183,155,200 | Let's obtain a new txbuffer
:returns: id of the new txbuffer
:rtype: int | crea/crea.py | new_tx | creativechain/crea-python-lib | python | def new_tx(self, *args, **kwargs):
" Let's obtain a new txbuffer\n\n :returns: id of the new txbuffer\n :rtype: int\n "
builder = TransactionBuilder(*args, crea_instance=self, **kwargs)
self._txbuffers.append(builder)
return builder |
def claim_account(self, creator, fee=None, **kwargs):
' Claim account for claimed account creation.\n\n When fee is 0 CREA a subsidized account is claimed and can be created\n later with create_claimed_account.\n The number of subsidized account is limited.\n\n :param str... | 4,870,016,310,296,848,000 | Claim account for claimed account creation.
When fee is 0 CREA a subsidized account is claimed and can be created
later with create_claimed_account.
The number of subsidized account is limited.
:param str creator: which account should pay the registration fee (RC or CREA)
(defaults to ``default_account``)
:pa... | crea/crea.py | claim_account | creativechain/crea-python-lib | python | def claim_account(self, creator, fee=None, **kwargs):
' Claim account for claimed account creation.\n\n When fee is 0 CREA a subsidized account is claimed and can be created\n later with create_claimed_account.\n The number of subsidized account is limited.\n\n :param str... |
def create_claimed_account(self, account_name, creator=None, owner_key=None, active_key=None, memo_key=None, posting_key=None, password=None, additional_owner_keys=[], additional_active_keys=[], additional_posting_keys=[], additional_owner_accounts=[], additional_active_accounts=[], additional_posting_accounts=[], stor... | 1,773,387,453,791,773,400 | Create new claimed account on Crea
The brainkey/password can be used to recover all generated keys
(see :class:`creagraphenebase.account` for more details.
By default, this call will use ``default_account`` to
register a new name ``account_name`` with all keys being
derived from a new brain key that will be returned.... | crea/crea.py | create_claimed_account | creativechain/crea-python-lib | python | def create_claimed_account(self, account_name, creator=None, owner_key=None, active_key=None, memo_key=None, posting_key=None, password=None, additional_owner_keys=[], additional_active_keys=[], additional_posting_keys=[], additional_owner_accounts=[], additional_active_accounts=[], additional_posting_accounts=[], stor... |
def create_account(self, account_name, creator=None, owner_key=None, active_key=None, memo_key=None, posting_key=None, password=None, additional_owner_keys=[], additional_active_keys=[], additional_posting_keys=[], additional_owner_accounts=[], additional_active_accounts=[], additional_posting_accounts=[], storekeys=Tr... | 7,496,495,228,049,349,000 | Create new account on Crea
The brainkey/password can be used to recover all generated keys
(see :class:`creagraphenebase.account` for more details.
By default, this call will use ``default_account`` to
register a new name ``account_name`` with all keys being
derived from a new brain key that will be returned. The
cor... | crea/crea.py | create_account | creativechain/crea-python-lib | python | def create_account(self, account_name, creator=None, owner_key=None, active_key=None, memo_key=None, posting_key=None, password=None, additional_owner_keys=[], additional_active_keys=[], additional_posting_keys=[], additional_owner_accounts=[], additional_active_accounts=[], additional_posting_accounts=[], storekeys=Tr... |
def witness_set_properties(self, wif, owner, props, use_condenser_api=True):
' Set witness properties\n\n :param str wif: Private signing key\n :param dict props: Properties\n :param str owner: witness account name\n\n Properties:::\n\n {\n ... | -335,836,913,302,357,600 | Set witness properties
:param str wif: Private signing key
:param dict props: Properties
:param str owner: witness account name
Properties:::
{
"account_creation_fee": x,
"account_subsidy_budget": x,
"account_subsidy_decay": x,
"maximum_block_size": x,
"url": x,
"s... | crea/crea.py | witness_set_properties | creativechain/crea-python-lib | python | def witness_set_properties(self, wif, owner, props, use_condenser_api=True):
' Set witness properties\n\n :param str wif: Private signing key\n :param dict props: Properties\n :param str owner: witness account name\n\n Properties:::\n\n {\n ... |
def witness_update(self, signing_key, url, props, account=None, **kwargs):
' Creates/updates a witness\n\n :param str signing_key: Public signing key\n :param str url: URL\n :param dict props: Properties\n :param str account: (optional) witness account name\n\n ... | 7,657,583,815,086,333,000 | Creates/updates a witness
:param str signing_key: Public signing key
:param str url: URL
:param dict props: Properties
:param str account: (optional) witness account name
Properties:::
{
"account_creation_fee": "3.000 CREA",
"maximum_block_size": 65536,
"sbd_interest_rate": 0,
} | crea/crea.py | witness_update | creativechain/crea-python-lib | python | def witness_update(self, signing_key, url, props, account=None, **kwargs):
' Creates/updates a witness\n\n :param str signing_key: Public signing key\n :param str url: URL\n :param dict props: Properties\n :param str account: (optional) witness account name\n\n ... |
def _test_weights_treshold(self, authority):
' This method raises an error if the threshold of an authority cannot\n be reached by the weights.\n\n :param dict authority: An authority of an account\n :raises ValueError: if the threshold is set too high\n '
weights = 0
... | 3,737,531,144,419,280,400 | This method raises an error if the threshold of an authority cannot
be reached by the weights.
:param dict authority: An authority of an account
:raises ValueError: if the threshold is set too high | crea/crea.py | _test_weights_treshold | creativechain/crea-python-lib | python | def _test_weights_treshold(self, authority):
' This method raises an error if the threshold of an authority cannot\n be reached by the weights.\n\n :param dict authority: An authority of an account\n :raises ValueError: if the threshold is set too high\n '
weights = 0
... |
def custom_json(self, id, json_data, required_auths=[], required_posting_auths=[], **kwargs):
' Create a custom json operation\n\n :param str id: identifier for the custom json (max length 32 bytes)\n :param json json_data: the json data to put into the custom_json\n operation\n... | -7,896,908,938,538,909,000 | Create a custom json operation
:param str id: identifier for the custom json (max length 32 bytes)
:param json json_data: the json data to put into the custom_json
operation
:param list required_auths: (optional) required auths
:param list required_posting_auths: (optional) posting auths
.. note:: While reqired a... | crea/crea.py | custom_json | creativechain/crea-python-lib | python | def custom_json(self, id, json_data, required_auths=[], required_posting_auths=[], **kwargs):
' Create a custom json operation\n\n :param str id: identifier for the custom json (max length 32 bytes)\n :param json json_data: the json data to put into the custom_json\n operation\n... |
def post(self, title, body, author=None, permlink=None, reply_identifier=None, json_metadata=None, comment_options=None, community=None, app=None, tags=None, beneficiaries=None, self_vote=False, parse_body=False, **kwargs):
" Create a new post.\n If this post is intended as a reply/comment, `reply_identifier... | -7,500,273,544,721,181,000 | Create a new post.
If this post is intended as a reply/comment, `reply_identifier` needs
to be set with the identifier of the parent post/comment (eg.
`@author/permlink`).
Optionally you can also set json_metadata, comment_options and upvote
the newly created post as an author.
Setting category, tags or community will ... | crea/crea.py | post | creativechain/crea-python-lib | python | def post(self, title, body, author=None, permlink=None, reply_identifier=None, json_metadata=None, comment_options=None, community=None, app=None, tags=None, beneficiaries=None, self_vote=False, parse_body=False, **kwargs):
" Create a new post.\n If this post is intended as a reply/comment, `reply_identifier... |
def comment_options(self, options, identifier, beneficiaries=[], account=None, **kwargs):
' Set the comment options\n\n :param dict options: The options to define.\n :param str identifier: Post identifier\n :param list beneficiaries: (optional) list of beneficiaries\n :pa... | -6,666,822,546,965,145,000 | Set the comment options
:param dict options: The options to define.
:param str identifier: Post identifier
:param list beneficiaries: (optional) list of beneficiaries
:param str account: (optional) the account to allow access
to (defaults to ``default_account``)
For the options, you have these defaults:::
{
... | crea/crea.py | comment_options | creativechain/crea-python-lib | python | def comment_options(self, options, identifier, beneficiaries=[], account=None, **kwargs):
' Set the comment options\n\n :param dict options: The options to define.\n :param str identifier: Post identifier\n :param list beneficiaries: (optional) list of beneficiaries\n :pa... |
def get_api_methods(self):
'Returns all supported api methods'
return self.rpc.get_methods(api='jsonrpc') | -1,289,893,449,848,988,200 | Returns all supported api methods | crea/crea.py | get_api_methods | creativechain/crea-python-lib | python | def get_api_methods(self):
return self.rpc.get_methods(api='jsonrpc') |
def get_apis(self):
'Returns all enabled apis'
api_methods = self.get_api_methods()
api_list = []
for a in api_methods:
api = a.split('.')[0]
if (api not in api_list):
api_list.append(api)
return api_list | -5,086,419,132,837,562,000 | Returns all enabled apis | crea/crea.py | get_apis | creativechain/crea-python-lib | python | def get_apis(self):
api_methods = self.get_api_methods()
api_list = []
for a in api_methods:
api = a.split('.')[0]
if (api not in api_list):
api_list.append(api)
return api_list |
def _get_asset_symbol(self, asset_id):
' get the asset symbol from an asset id\n\n :@param int asset_id: 0 -> CBD, 1 -> CREA, 2 -> VESTS\n\n '
for asset in self.chain_params['chain_assets']:
if (asset['id'] == asset_id):
return asset['symbol']
raise KeyError('asset ID n... | -2,621,830,467,201,586,700 | get the asset symbol from an asset id
:@param int asset_id: 0 -> CBD, 1 -> CREA, 2 -> VESTS | crea/crea.py | _get_asset_symbol | creativechain/crea-python-lib | python | def _get_asset_symbol(self, asset_id):
' get the asset symbol from an asset id\n\n :@param int asset_id: 0 -> CBD, 1 -> CREA, 2 -> VESTS\n\n '
for asset in self.chain_params['chain_assets']:
if (asset['id'] == asset_id):
return asset['symbol']
raise KeyError('asset ID n... |
@property
def sbd_symbol(self):
' get the current chains symbol for CBD (e.g. "TBD" on testnet) '
try:
symbol = self._get_asset_symbol(0)
except KeyError:
symbol = self._get_asset_symbol(1)
return symbol | 258,778,943,592,325,400 | get the current chains symbol for CBD (e.g. "TBD" on testnet) | crea/crea.py | sbd_symbol | creativechain/crea-python-lib | python | @property
def sbd_symbol(self):
' '
try:
symbol = self._get_asset_symbol(0)
except KeyError:
symbol = self._get_asset_symbol(1)
return symbol |
@property
def crea_symbol(self):
' get the current chains symbol for CREA (e.g. "TESTS" on testnet) '
return self._get_asset_symbol(1) | 7,066,429,717,625,459,000 | get the current chains symbol for CREA (e.g. "TESTS" on testnet) | crea/crea.py | crea_symbol | creativechain/crea-python-lib | python | @property
def crea_symbol(self):
' '
return self._get_asset_symbol(1) |
@property
def vests_symbol(self):
' get the current chains symbol for VESTS '
return self._get_asset_symbol(2) | -7,246,487,139,812,229,000 | get the current chains symbol for VESTS | crea/crea.py | vests_symbol | creativechain/crea-python-lib | python | @property
def vests_symbol(self):
' '
return self._get_asset_symbol(2) |
def edge_1_to_2(in_string):
'A Test function for an edge for a Graph'
return in_string.splitlines() | -869,047,839,222,694,000 | A Test function for an edge for a Graph | Code/DataHandlers/GraphModels.py | edge_1_to_2 | aricsanders/pyMez3 | python | def edge_1_to_2(in_string):
return in_string.splitlines() |
def edge_2_to_1(string_list):
'A test function for an edge in a Graph'
return string_list_collapse(string_list) | 4,905,795,175,625,708,000 | A test function for an edge in a Graph | Code/DataHandlers/GraphModels.py | edge_2_to_1 | aricsanders/pyMez3 | python | def edge_2_to_1(string_list):
return string_list_collapse(string_list) |
def visit_all_nodes(graph):
'Visit all nodes visits each node on a graph'
nodes = graph.node_names
for node in nodes:
graph.move_to_node(node) | -8,874,546,696,860,967,000 | Visit all nodes visits each node on a graph | Code/DataHandlers/GraphModels.py | visit_all_nodes | aricsanders/pyMez3 | python | def visit_all_nodes(graph):
nodes = graph.node_names
for node in nodes:
graph.move_to_node(node) |
def visit_and_print_all_nodes(graph):
'Visits all the nodes in graph and prints graph.data after each move'
nodes = graph.node_names
for node in nodes:
graph.move_to_node(node)
print(graph.data) | 5,210,747,465,776,017,000 | Visits all the nodes in graph and prints graph.data after each move | Code/DataHandlers/GraphModels.py | visit_and_print_all_nodes | aricsanders/pyMez3 | python | def visit_and_print_all_nodes(graph):
nodes = graph.node_names
for node in nodes:
graph.move_to_node(node)
print(graph.data) |
def to_node_name(node_data):
'Creates a node name given an input object, does a bit of silly type selecting and name rearranging. This matches for 75%\n of the cases. There are a lot of user defined nodes without a clear path to generate a name. For instance the DataTableGraph\n node HpFile, does not save wit... | 3,272,076,638,068,714,000 | Creates a node name given an input object, does a bit of silly type selecting and name rearranging. This matches for 75%
of the cases. There are a lot of user defined nodes without a clear path to generate a name. For instance the DataTableGraph
node HpFile, does not save with a .hp extension so it would be auto named ... | Code/DataHandlers/GraphModels.py | to_node_name | aricsanders/pyMez3 | python | def to_node_name(node_data):
'Creates a node name given an input object, does a bit of silly type selecting and name rearranging. This matches for 75%\n of the cases. There are a lot of user defined nodes without a clear path to generate a name. For instance the DataTableGraph\n node HpFile, does not save wit... |
def TableGraph_to_Links(table_graph, **options):
'Converts a table graph to a set of download links with embedded data in them'
defaults = {'base_name': None, 'nodes': ['XmlFile', 'CsvFile', 'ExcelFile', 'OdsFile', 'MatFile', 'HtmlFile', 'JsonFile'], 'extensions': ['xml', 'csv', 'xlsx', 'ods', 'mat', 'html', 'j... | 7,363,370,345,560,202,000 | Converts a table graph to a set of download links with embedded data in them | Code/DataHandlers/GraphModels.py | TableGraph_to_Links | aricsanders/pyMez3 | python | def TableGraph_to_Links(table_graph, **options):
defaults = {'base_name': None, 'nodes': ['XmlFile', 'CsvFile', 'ExcelFile', 'OdsFile', 'MatFile', 'HtmlFile', 'JsonFile'], 'extensions': ['xml', 'csv', 'xlsx', 'ods', 'mat', 'html', 'json'], 'mime_types': ['application/xml', 'text/plain', 'application/vnd.openxm... |
def remove_circular_paths(path):
'Removes pieces of the path that just end on the same node'
edge_pattern = re.compile('edge_(?P<begin_node>\\w+)_(?P<end_node>\\w+)_(?P<iterator>\\w+)')
past_locations = []
for (index, edge) in enumerate(path):
match = re.match(edge_pattern, edge)
begin_n... | -6,199,381,688,604,721,000 | Removes pieces of the path that just end on the same node | Code/DataHandlers/GraphModels.py | remove_circular_paths | aricsanders/pyMez3 | python | def remove_circular_paths(path):
edge_pattern = re.compile('edge_(?P<begin_node>\\w+)_(?P<end_node>\\w+)_(?P<iterator>\\w+)')
past_locations = []
for (index, edge) in enumerate(path):
match = re.match(edge_pattern, edge)
begin_node = match.groupdict()['begin_node']
end_node = ma... |
def __init__(self, **options):
'Initializes the graph. The first 2 nodes and two edges forming a bijection between them are required'
defaults = {'graph_name': 'Graph', 'node_names': ['n1', 'n2'], 'node_descriptions': ['A plain string', 'A list of strings with no \\n, created with string.splitlines()'], 'curren... | 680,835,897,459,036,800 | Initializes the graph. The first 2 nodes and two edges forming a bijection between them are required | Code/DataHandlers/GraphModels.py | __init__ | aricsanders/pyMez3 | python | def __init__(self, **options):
defaults = {'graph_name': 'Graph', 'node_names': ['n1', 'n2'], 'node_descriptions': ['A plain string', 'A list of strings with no \\n, created with string.splitlines()'], 'current_node': 'n1', 'state': [1, 0], 'data': 'This is a test string\n it has to have multiple lines \n and ... |
def get_description_dictionary(self):
'returns a dictionary of the form {NodeName:Node Description for all of the current nodes'
dictionary = {node_name: self.node_descriptions[index] for (index, node_name) in enumerate(self.node_names)}
return dictionary | 2,856,175,162,624,585,000 | returns a dictionary of the form {NodeName:Node Description for all of the current nodes | Code/DataHandlers/GraphModels.py | get_description_dictionary | aricsanders/pyMez3 | python | def get_description_dictionary(self):
dictionary = {node_name: self.node_descriptions[index] for (index, node_name) in enumerate(self.node_names)}
return dictionary |
def set_state(self, node_name, node_data):
'Sets the graph state to be the state specified by node_name, and node_data'
try:
current_node_state_position = self.node_names.index(node_name)
self.current_node = node_name
self.data = node_data
self.state = [0 for i in range(len(self.... | -2,547,455,262,427,283,500 | Sets the graph state to be the state specified by node_name, and node_data | Code/DataHandlers/GraphModels.py | set_state | aricsanders/pyMez3 | python | def set_state(self, node_name, node_data):
try:
current_node_state_position = self.node_names.index(node_name)
self.current_node = node_name
self.data = node_data
self.state = [0 for i in range(len(self.node_names))]
self.state[current_node_state_position] = 1
se... |
def add_edge(self, begin_node=None, end_node=None, edge_function=None):
"Adds an edge mapping one node to another, required input is begin_node (it's name)\n end_node, and the edge function"
edge_match = re.compile('edge_{0}_{1}'.format(begin_node, end_node))
keys = list(self.__dict__.keys())
ite... | -377,289,024,457,575,600 | Adds an edge mapping one node to another, required input is begin_node (it's name)
end_node, and the edge function | Code/DataHandlers/GraphModels.py | add_edge | aricsanders/pyMez3 | python | def add_edge(self, begin_node=None, end_node=None, edge_function=None):
"Adds an edge mapping one node to another, required input is begin_node (it's name)\n end_node, and the edge function"
edge_match = re.compile('edge_{0}_{1}'.format(begin_node, end_node))
keys = list(self.__dict__.keys())
ite... |
def add_jump(self, begin_node=None, end_node=None, jump_function=None):
"Adds a jump mapping one internal node to an external node, required input is begin_node (it's name)\n end_node, and the edge function"
jump_match = re.compile('jump_{0}_{1}'.format(begin_node, end_node))
keys = list(self.__dict_... | 9,149,446,158,159,192,000 | Adds a jump mapping one internal node to an external node, required input is begin_node (it's name)
end_node, and the edge function | Code/DataHandlers/GraphModels.py | add_jump | aricsanders/pyMez3 | python | def add_jump(self, begin_node=None, end_node=None, jump_function=None):
"Adds a jump mapping one internal node to an external node, required input is begin_node (it's name)\n end_node, and the edge function"
jump_match = re.compile('jump_{0}_{1}'.format(begin_node, end_node))
keys = list(self.__dict_... |
def move_to(self, path, **options):
'Changes the state of the graph by moving along the path specified'
defaults = {'debug': False, 'verbose': False}
move_options = {}
for (key, value) in defaults.items():
move_options[key] = value
for (key, value) in options.items():
move_options[ke... | 1,822,351,231,675,839,500 | Changes the state of the graph by moving along the path specified | Code/DataHandlers/GraphModels.py | move_to | aricsanders/pyMez3 | python | def move_to(self, path, **options):
defaults = {'debug': False, 'verbose': False}
move_options = {}
for (key, value) in defaults.items():
move_options[key] = value
for (key, value) in options.items():
move_options[key] = value
if move_options['debug']:
print(path)
fo... |
def virtual_move_to(self, path):
'virtual_move_to simulates moving but does not change the state of the graph'
temp_state = self.state
temp_data = self.data
temp_current_node = self.current_node
temp_node_names = self.node_names
for (index, edge) in enumerate(path):
edge_pattern = 'edge_... | -7,026,627,548,040,439,000 | virtual_move_to simulates moving but does not change the state of the graph | Code/DataHandlers/GraphModels.py | virtual_move_to | aricsanders/pyMez3 | python | def virtual_move_to(self, path):
temp_state = self.state
temp_data = self.data
temp_current_node = self.current_node
temp_node_names = self.node_names
for (index, edge) in enumerate(path):
edge_pattern = 'edge_(?P<begin_node>\\w+)_(?P<end_node>\\w+)_(?P<iterator>\\w+)'
match = r... |
def add_node(self, node_name, edge_into_node_begin, edge_into_node_function, edge_out_node_end, edge_out_node_function, node_description=None):
'Adds a node to the graph. Required input is node_name (a string with no spaces),\n a reference to an entering node,the function mapping the entering node to the new... | -7,575,784,914,703,229,000 | Adds a node to the graph. Required input is node_name (a string with no spaces),
a reference to an entering node,the function mapping the entering node to the new node,
a reference to an exiting node and the function mapping the
new node to the exiting node. | Code/DataHandlers/GraphModels.py | add_node | aricsanders/pyMez3 | python | def add_node(self, node_name, edge_into_node_begin, edge_into_node_function, edge_out_node_end, edge_out_node_function, node_description=None):
'Adds a node to the graph. Required input is node_name (a string with no spaces),\n a reference to an entering node,the function mapping the entering node to the new... |
def add_external_node(self, external_node_name, jump_into_node_begin, jump_into_node_function, external_node_description=None):
'Adds an external node to the graph. Required input is node_name (a string with no spaces),\n a reference to an entering node,the function mapping the entering node to the new exter... | 9,169,020,437,954,371,000 | Adds an external node to the graph. Required input is node_name (a string with no spaces),
a reference to an entering node,the function mapping the entering node to the new external node | Code/DataHandlers/GraphModels.py | add_external_node | aricsanders/pyMez3 | python | def add_external_node(self, external_node_name, jump_into_node_begin, jump_into_node_function, external_node_description=None):
'Adds an external node to the graph. Required input is node_name (a string with no spaces),\n a reference to an entering node,the function mapping the entering node to the new exter... |
def jump_to_external_node(self, external_node_name, **options):
'Returns the result of the jump, the graph is left in the node that is the begining of the jump'
end_node = external_node_name
jump_pattern = 'jump_(?P<begin_node>\\w+)_{0}_(?P<iterator>\\w+)'.format(end_node)
for jump in self.jumps[:]:
... | -9,191,175,292,956,245,000 | Returns the result of the jump, the graph is left in the node that is the begining of the jump | Code/DataHandlers/GraphModels.py | jump_to_external_node | aricsanders/pyMez3 | python | def jump_to_external_node(self, external_node_name, **options):
end_node = external_node_name
jump_pattern = 'jump_(?P<begin_node>\\w+)_{0}_(?P<iterator>\\w+)'.format(end_node)
for jump in self.jumps[:]:
jump_match = re.match(jump_pattern, jump, re.IGNORECASE)
if jump_match:
... |
def path_length(self, path, num_repeats=10):
'Determines the length of a given path, currently the metric is based on the time to move to.'
begin_time = datetime.datetime.now()
for i in range(num_repeats):
self.virtual_move_to(path)
end_time = datetime.datetime.now()
delta_t = (end_time - be... | -6,202,180,433,333,419,000 | Determines the length of a given path, currently the metric is based on the time to move to. | Code/DataHandlers/GraphModels.py | path_length | aricsanders/pyMez3 | python | def path_length(self, path, num_repeats=10):
begin_time = datetime.datetime.now()
for i in range(num_repeats):
self.virtual_move_to(path)
end_time = datetime.datetime.now()
delta_t = (end_time - begin_time)
path_length = (delta_t.total_seconds() / float(num_repeats))
if (path_length... |
def is_path_valid(self, path):
'Returns True if the path is valid from the current node position or False otherwise'
null_state = [0 for i in range(len(self.node_names))]
null_state_matrix = np.matrix(null_state).T
new_state = np.matrix(self.state).T
for (index, edge) in enumerate(path):
edg... | 5,951,362,793,279,655,000 | Returns True if the path is valid from the current node position or False otherwise | Code/DataHandlers/GraphModels.py | is_path_valid | aricsanders/pyMez3 | python | def is_path_valid(self, path):
null_state = [0 for i in range(len(self.node_names))]
null_state_matrix = np.matrix(null_state).T
new_state = np.matrix(self.state).T
for (index, edge) in enumerate(path):
edge_position = self.edges.index(edge)
move_matrix = self.edge_matrices[edge_pos... |
def get_entering_nodes(self, node):
'Returns all nodes that have an edge that enter the specificed node'
enter_edge_pattern = re.compile('edge_(?P<begin_node>\\w+)_{0}_(?P<iterator>\\w+)'.format(node))
enter_nodes = []
for (index, edge) in enumerate(self.edges):
enter_match = re.match(enter_edge... | -7,463,785,023,597,199,000 | Returns all nodes that have an edge that enter the specificed node | Code/DataHandlers/GraphModels.py | get_entering_nodes | aricsanders/pyMez3 | python | def get_entering_nodes(self, node):
enter_edge_pattern = re.compile('edge_(?P<begin_node>\\w+)_{0}_(?P<iterator>\\w+)'.format(node))
enter_nodes = []
for (index, edge) in enumerate(self.edges):
enter_match = re.match(enter_edge_pattern, edge)
if enter_match:
enter_node = ent... |
def get_entering_edges(self, node):
'Returns all edges that enter the specificed node'
enter_edge_pattern = re.compile('edge_(?P<begin_node>\\w+)_{0}_(?P<iterator>\\w+)'.format(node))
enter_edges = []
for (index, edge) in enumerate(self.edges):
if re.match(enter_edge_pattern, edge):
... | -624,790,509,428,448,400 | Returns all edges that enter the specificed node | Code/DataHandlers/GraphModels.py | get_entering_edges | aricsanders/pyMez3 | python | def get_entering_edges(self, node):
enter_edge_pattern = re.compile('edge_(?P<begin_node>\\w+)_{0}_(?P<iterator>\\w+)'.format(node))
enter_edges = []
for (index, edge) in enumerate(self.edges):
if re.match(enter_edge_pattern, edge):
enter_edges.append(edge)
return enter_edges |
def get_exiting_edges(self, node):
'Returns all edges that exit the specificed node'
exit_edge_pattern = re.compile('edge_{0}_(?P<end_node>\\w+)_(?P<iterator>\\w+)'.format(node))
exit_edges = []
for (index, edge) in enumerate(self.edges):
if re.match(exit_edge_pattern, edge):
exit_ed... | 5,830,406,898,505,011,000 | Returns all edges that exit the specificed node | Code/DataHandlers/GraphModels.py | get_exiting_edges | aricsanders/pyMez3 | python | def get_exiting_edges(self, node):
exit_edge_pattern = re.compile('edge_{0}_(?P<end_node>\\w+)_(?P<iterator>\\w+)'.format(node))
exit_edges = []
for (index, edge) in enumerate(self.edges):
if re.match(exit_edge_pattern, edge):
exit_edges.append(edge)
return exit_edges |
def get_exiting_nodes(self, node):
'Returns all nodes that have an edge leaving the specificed node'
exit_edge_pattern = re.compile('edge_{0}_(?P<end_node>\\w+)_(?P<iterator>\\w+)'.format(node))
exit_nodes = []
for (index, edge) in enumerate(self.edges):
exit_match = re.match(exit_edge_pattern, ... | -8,701,546,965,773,499,000 | Returns all nodes that have an edge leaving the specificed node | Code/DataHandlers/GraphModels.py | get_exiting_nodes | aricsanders/pyMez3 | python | def get_exiting_nodes(self, node):
exit_edge_pattern = re.compile('edge_{0}_(?P<end_node>\\w+)_(?P<iterator>\\w+)'.format(node))
exit_nodes = []
for (index, edge) in enumerate(self.edges):
exit_match = re.match(exit_edge_pattern, edge)
if exit_match:
exit_node = exit_match.g... |
def get_path(self, first_node, last_node, **options):
'Returns the first path found between first node and last node, uses a breadth first search algorithm'
defaults = {'debug': False, 'method': 'BreathFirst'}
self.get_path_options = {}
for (key, value) in defaults.items():
self.get_path_options... | -9,194,866,650,367,668,000 | Returns the first path found between first node and last node, uses a breadth first search algorithm | Code/DataHandlers/GraphModels.py | get_path | aricsanders/pyMez3 | python | def get_path(self, first_node, last_node, **options):
defaults = {'debug': False, 'method': 'BreathFirst'}
self.get_path_options = {}
for (key, value) in defaults.items():
self.get_path_options[key] = value
for (key, value) in options.items():
self.get_path_options[key] = value
... |
def move_to_node(self, node):
'Moves from current_node to the specified node'
path = self.get_path(self.current_node, node)
self.move_to(path) | 2,212,070,975,144,242,000 | Moves from current_node to the specified node | Code/DataHandlers/GraphModels.py | move_to_node | aricsanders/pyMez3 | python | def move_to_node(self, node):
path = self.get_path(self.current_node, node)
self.move_to(path) |
def check_closed_path(self):
'Checks that data is not changed for the first closed path found. Returns True if data==data after\n moving around the closed path, False otherwise. Starting point is current_node '
temp_data = self.data
path = self.get_path(self.current_node, self.current_node)
if se... | 6,040,080,610,919,660,000 | Checks that data is not changed for the first closed path found. Returns True if data==data after
moving around the closed path, False otherwise. Starting point is current_node | Code/DataHandlers/GraphModels.py | check_closed_path | aricsanders/pyMez3 | python | def check_closed_path(self):
'Checks that data is not changed for the first closed path found. Returns True if data==data after\n moving around the closed path, False otherwise. Starting point is current_node '
temp_data = self.data
path = self.get_path(self.current_node, self.current_node)
if se... |
def is_graph_isomorphic(self):
'Returns True if all nodes have closed paths that preserve the data, False otherwise'
out = True
for node in self.node_names:
self.move_to_node(node)
if (not self.check_closed_path):
out = False
return out | -5,432,437,518,856,279,000 | Returns True if all nodes have closed paths that preserve the data, False otherwise | Code/DataHandlers/GraphModels.py | is_graph_isomorphic | aricsanders/pyMez3 | python | def is_graph_isomorphic(self):
out = True
for node in self.node_names:
self.move_to_node(node)
if (not self.check_closed_path):
out = False
return out |
def show(self, **options):
'Shows the graph using matplotlib and networkx'
defaults = {'descriptions': False, 'edge_descriptions': False, 'save_plot': False, 'path': None, 'active_node': True, 'directory': None, 'specific_descriptor': self.graph_name.replace(' ', '_'), 'general_descriptor': 'plot', 'file_name':... | 3,518,758,878,185,004,000 | Shows the graph using matplotlib and networkx | Code/DataHandlers/GraphModels.py | show | aricsanders/pyMez3 | python | def show(self, **options):
defaults = {'descriptions': False, 'edge_descriptions': False, 'save_plot': False, 'path': None, 'active_node': True, 'directory': None, 'specific_descriptor': self.graph_name.replace(' ', '_'), 'general_descriptor': 'plot', 'file_name': None, 'arrows': True, 'node_size': 1000, 'font... |
def __init__(self, **options):
'Intializes the StringGraph Class by defining nodes and edges'
defaults = {'graph_name': 'StringGraph', 'node_names': ['String', 'StringList'], 'node_descriptions': ['A plain string', 'A list of strings with no \\n, created with string.splitlines()'], 'current_node': 'String', 'st... | -2,571,014,828,930,411,500 | Intializes the StringGraph Class by defining nodes and edges | Code/DataHandlers/GraphModels.py | __init__ | aricsanders/pyMez3 | python | def __init__(self, **options):
defaults = {'graph_name': 'StringGraph', 'node_names': ['String', 'StringList'], 'node_descriptions': ['A plain string', 'A list of strings with no \\n, created with string.splitlines()'], 'current_node': 'String', 'state': [1, 0], 'data': 'This is a test string\n it has to have ... |
def __init__(self, **options):
'Intializes the metadata graph class'
defaults = {'graph_name': 'Metadata Graph', 'node_names': ['Dictionary', 'JsonString'], 'node_descriptions': ['Python Dictionary', 'Json string'], 'current_node': 'Dictionary', 'state': [1, 0], 'data': {'a': 'First', 'b': 'Second'}, 'edge_2_to... | 5,817,421,687,380,620,000 | Intializes the metadata graph class | Code/DataHandlers/GraphModels.py | __init__ | aricsanders/pyMez3 | python | def __init__(self, **options):
defaults = {'graph_name': 'Metadata Graph', 'node_names': ['Dictionary', 'JsonString'], 'node_descriptions': ['Python Dictionary', 'Json string'], 'current_node': 'Dictionary', 'state': [1, 0], 'data': {'a': 'First', 'b': 'Second'}, 'edge_2_to_1': JsonString_to_Dictionary, 'edge_... |
def update_setting(self, setting: dict):
'\n Update strategy parameter wtih value in setting dict.\n '
for name in self.parameters:
if (name in setting):
setattr(self, name, setting[name]) | 6,207,766,873,134,563,000 | Update strategy parameter wtih value in setting dict. | vnpy/app/cta_strategy_pro/template.py | update_setting | UtorYeung/vnpy | python | def update_setting(self, setting: dict):
'\n \n '
for name in self.parameters:
if (name in setting):
setattr(self, name, setting[name]) |
@classmethod
def get_class_parameters(cls):
'\n Get default parameters dict of strategy class.\n '
class_parameters = {}
for name in cls.parameters:
class_parameters[name] = getattr(cls, name)
return class_parameters | 2,000,523,763,530,372,900 | Get default parameters dict of strategy class. | vnpy/app/cta_strategy_pro/template.py | get_class_parameters | UtorYeung/vnpy | python | @classmethod
def get_class_parameters(cls):
'\n \n '
class_parameters = {}
for name in cls.parameters:
class_parameters[name] = getattr(cls, name)
return class_parameters |
def get_parameters(self):
'\n Get strategy parameters dict.\n '
strategy_parameters = {}
for name in self.parameters:
strategy_parameters[name] = getattr(self, name)
return strategy_parameters | -8,479,214,757,587,884,000 | Get strategy parameters dict. | vnpy/app/cta_strategy_pro/template.py | get_parameters | UtorYeung/vnpy | python | def get_parameters(self):
'\n \n '
strategy_parameters = {}
for name in self.parameters:
strategy_parameters[name] = getattr(self, name)
return strategy_parameters |
def get_variables(self):
'\n Get strategy variables dict.\n '
strategy_variables = {}
for name in self.variables:
strategy_variables[name] = getattr(self, name)
return strategy_variables | 3,869,490,173,995,033,000 | Get strategy variables dict. | vnpy/app/cta_strategy_pro/template.py | get_variables | UtorYeung/vnpy | python | def get_variables(self):
'\n \n '
strategy_variables = {}
for name in self.variables:
strategy_variables[name] = getattr(self, name)
return strategy_variables |
def get_data(self):
'\n Get strategy data.\n '
strategy_data = {'strategy_name': self.strategy_name, 'vt_symbol': self.vt_symbol, 'class_name': self.__class__.__name__, 'author': self.author, 'parameters': self.get_parameters(), 'variables': self.get_variables()}
return strategy_data | 2,946,753,334,977,945,000 | Get strategy data. | vnpy/app/cta_strategy_pro/template.py | get_data | UtorYeung/vnpy | python | def get_data(self):
'\n \n '
strategy_data = {'strategy_name': self.strategy_name, 'vt_symbol': self.vt_symbol, 'class_name': self.__class__.__name__, 'author': self.author, 'parameters': self.get_parameters(), 'variables': self.get_variables()}
return strategy_data |
def get_positions(self):
' 返回持仓数量'
pos_list = []
if (self.pos > 0):
pos_list.append({'vt_symbol': self.vt_symbol, 'direction': 'long', 'volume': self.pos})
elif (self.pos < 0):
pos_list.append({'vt_symbol': self.vt_symbol, 'direction': 'short', 'volume': abs(self.pos)})
return pos_li... | -827,901,046,592,274,400 | 返回持仓数量 | vnpy/app/cta_strategy_pro/template.py | get_positions | UtorYeung/vnpy | python | def get_positions(self):
' '
pos_list = []
if (self.pos > 0):
pos_list.append({'vt_symbol': self.vt_symbol, 'direction': 'long', 'volume': self.pos})
elif (self.pos < 0):
pos_list.append({'vt_symbol': self.vt_symbol, 'direction': 'short', 'volume': abs(self.pos)})
return pos_list |
@virtual
def on_init(self):
'\n Callback when strategy is inited.\n '
pass | -6,602,614,612,649,703,000 | Callback when strategy is inited. | vnpy/app/cta_strategy_pro/template.py | on_init | UtorYeung/vnpy | python | @virtual
def on_init(self):
'\n \n '
pass |
@virtual
def on_start(self):
'\n Callback when strategy is started.\n '
pass | 5,431,041,852,391,603,000 | Callback when strategy is started. | vnpy/app/cta_strategy_pro/template.py | on_start | UtorYeung/vnpy | python | @virtual
def on_start(self):
'\n \n '
pass |
@virtual
def on_stop(self):
'\n Callback when strategy is stopped.\n '
pass | 807,889,883,735,305,900 | Callback when strategy is stopped. | vnpy/app/cta_strategy_pro/template.py | on_stop | UtorYeung/vnpy | python | @virtual
def on_stop(self):
'\n \n '
pass |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.