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 merge_subsets(a, b):
'Merges field subset definitions together. The b subset is merged into the a subset. Assumes that subsets have been stripped of non-ecs options.'
for key in b:
if (key not in a):
a[key] = b[key]
elif (('fields' in a[key]) and ('fields' in b[key])):
... | -50,387,666,115,584,190 | Merges field subset definitions together. The b subset is merged into the a subset. Assumes that subsets have been stripped of non-ecs options. | scripts/schema/subset_filter.py | merge_subsets | 6un9-h0-Dan/ecs | python | def merge_subsets(a, b):
for key in b:
if (key not in a):
a[key] = b[key]
elif (('fields' in a[key]) and ('fields' in b[key])):
if (b[key]['fields'] == '*'):
a[key]['fields'] = '*'
elif (isinstance(a[key]['fields'], dict) and isinstance(b[key]... |
def extract_matching_fields(fields, subset_definitions):
'Removes fields that are not in the subset definition. Returns a copy without modifying the input fields dict.'
retained_fields = {x: fields[x].copy() for x in subset_definitions}
for (key, val) in subset_definitions.items():
retained_fields[k... | -6,010,733,992,487,650,000 | Removes fields that are not in the subset definition. Returns a copy without modifying the input fields dict. | scripts/schema/subset_filter.py | extract_matching_fields | 6un9-h0-Dan/ecs | python | def extract_matching_fields(fields, subset_definitions):
retained_fields = {x: fields[x].copy() for x in subset_definitions}
for (key, val) in subset_definitions.items():
retained_fields[key]['field_details'] = fields[key]['field_details'].copy()
for option in val:
if (option !=... |
@staticmethod
def from_file(filename: str) -> 'WallpaperConfig':
' Creates a WallpaperConfig from a YAML file '
with open(filename, 'r') as input_file:
return jsons.load(yaml.load(input_file, Loader=yaml.SafeLoader), WallpaperConfig) | -5,361,020,704,774,841,000 | Creates a WallpaperConfig from a YAML file | config_objects.py | from_file | JimTheCactus/RedditWallpaperWatcher | python | @staticmethod
def from_file(filename: str) -> 'WallpaperConfig':
' '
with open(filename, 'r') as input_file:
return jsons.load(yaml.load(input_file, Loader=yaml.SafeLoader), WallpaperConfig) |
@staticmethod
def from_file(filename: str) -> 'RedditAuthInfo':
' Creates a RedditAuthInfo from a YAML file '
with open(filename, 'r') as input_file:
auth = jsons.load(yaml.load(input_file, Loader=yaml.SafeLoader), RedditAuthInfo)
return auth | 7,710,573,328,413,913,000 | Creates a RedditAuthInfo from a YAML file | config_objects.py | from_file | JimTheCactus/RedditWallpaperWatcher | python | @staticmethod
def from_file(filename: str) -> 'RedditAuthInfo':
' '
with open(filename, 'r') as input_file:
auth = jsons.load(yaml.load(input_file, Loader=yaml.SafeLoader), RedditAuthInfo)
return auth |
def __init__(self, success=None, message=None, error_code=None, data=None):
'Constructor for the GetScheduledMessageResponse class'
self.success = success
self.message = message
self.error_code = error_code
self.data = data | -3,612,874,773,586,269,700 | Constructor for the GetScheduledMessageResponse class | unifonicnextgen/models/get_scheduled_message_response.py | __init__ | masaar/unifonic_python_sdk | python | def __init__(self, success=None, message=None, error_code=None, data=None):
self.success = success
self.message = message
self.error_code = error_code
self.data = data |
@classmethod
def from_dictionary(cls, dictionary):
"Creates an instance of this model from a dictionary\n\n Args:\n dictionary (dictionary): A dictionary representation of the object as\n obtained from the deserialization of the server's response. The keys\n MUST match proper... | -1,881,683,673,075,648,500 | Creates an instance of this model from a dictionary
Args:
dictionary (dictionary): A dictionary representation of the object as
obtained from the deserialization of the server's response. The keys
MUST match property names in the API description.
Returns:
object: An instance of this structure class. | unifonicnextgen/models/get_scheduled_message_response.py | from_dictionary | masaar/unifonic_python_sdk | python | @classmethod
def from_dictionary(cls, dictionary):
"Creates an instance of this model from a dictionary\n\n Args:\n dictionary (dictionary): A dictionary representation of the object as\n obtained from the deserialization of the server's response. The keys\n MUST match proper... |
def testing_job(progress_steps=None, retval=None, fail=False, skip=False, log_messages=None, step_duration=0):
'\n Job used for testing purposes.\n\n :param progress_steps:\n A list of tuples: ``(<group_name>, <steps>)``, where "group_name"\n is a tuple of name "levels", "steps" an integer repre... | 4,464,256,424,644,385,000 | Job used for testing purposes.
:param progress_steps:
A list of tuples: ``(<group_name>, <steps>)``, where "group_name"
is a tuple of name "levels", "steps" an integer representing how
many steps should that level have.
Progress reports will be sent in randomized order.
:param retval:
The return ... | jobcontrol/utils/testing.py | testing_job | rshk/jobcontrol | python | def testing_job(progress_steps=None, retval=None, fail=False, skip=False, log_messages=None, step_duration=0):
'\n Job used for testing purposes.\n\n :param progress_steps:\n A list of tuples: ``(<group_name>, <steps>)``, where "group_name"\n is a tuple of name "levels", "steps" an integer repre... |
def job_failing_once():
'\n This job will fail exactly once; retry will be successful\n '
from jobcontrol.globals import current_job
exec_count = len(list(current_job.iter_runs()))
if (exec_count <= 1):
raise RuntimeError('Simulating failure')
return exec_count | 665,967,870,671,782,900 | This job will fail exactly once; retry will be successful | jobcontrol/utils/testing.py | job_failing_once | rshk/jobcontrol | python | def job_failing_once():
'\n \n '
from jobcontrol.globals import current_job
exec_count = len(list(current_job.iter_runs()))
if (exec_count <= 1):
raise RuntimeError('Simulating failure')
return exec_count |
def job_echo_config(*args, **kwargs):
'\n Simple job, "echoing" back the current configuration.\n '
from jobcontrol.globals import current_job, current_build
return {'args': args, 'kwargs': kwargs, 'build_id': current_build.id, 'job_id': current_job.id, 'dependencies': current_build.config['dependenci... | 3,529,256,724,884,849,700 | Simple job, "echoing" back the current configuration. | jobcontrol/utils/testing.py | job_echo_config | rshk/jobcontrol | python | def job_echo_config(*args, **kwargs):
'\n \n '
from jobcontrol.globals import current_job, current_build
return {'args': args, 'kwargs': kwargs, 'build_id': current_build.id, 'job_id': current_job.id, 'dependencies': current_build.config['dependencies'], 'config': current_build.config} |
def CrossValidationFolds_Traversal(estimator, vdataset):
"\n Arguments: \n - estimator = classifer of model\n - vdataset = vehicld dataset \n \n This function computes acccuracy score with the\n Cross Validation Score for each KFold with K from 2 to 10 \n \n Output:\n ret... | -815,941,616,666,243,500 | Arguments:
- estimator = classifer of model
- vdataset = vehicld dataset
This function computes acccuracy score with the
Cross Validation Score for each KFold with K from 2 to 10
Output:
returns matrix conatining value of K with it's corresponding performance score | dev/shiza16/Calibration plot/CrossValidationFold_Traversal.py | CrossValidationFolds_Traversal | Bolaji61/PRESC | python | def CrossValidationFolds_Traversal(estimator, vdataset):
"\n Arguments: \n - estimator = classifer of model\n - vdataset = vehicld dataset \n \n This function computes acccuracy score with the\n Cross Validation Score for each KFold with K from 2 to 10 \n \n Output:\n ret... |
def Visulaize_CrossValidationFolds_Traversal(matrix):
"\n Argument:\n - matrix: Dataframe named matrix\n \n Line Plot is drawn for each KFold value with it's respective performance score.\n \n Output:\n - plot the line graph\n "
ax = plt.gca()
matrix.plot(kind='line', x='KFol... | 1,476,091,193,718,027,800 | Argument:
- matrix: Dataframe named matrix
Line Plot is drawn for each KFold value with it's respective performance score.
Output:
- plot the line graph | dev/shiza16/Calibration plot/CrossValidationFold_Traversal.py | Visulaize_CrossValidationFolds_Traversal | Bolaji61/PRESC | python | def Visulaize_CrossValidationFolds_Traversal(matrix):
"\n Argument:\n - matrix: Dataframe named matrix\n \n Line Plot is drawn for each KFold value with it's respective performance score.\n \n Output:\n - plot the line graph\n "
ax = plt.gca()
matrix.plot(kind='line', x='KFol... |
def addPath(rel_path, prepend=False):
" Adds a directory to the system python path, either by append (doesn't\n override default or globally installed package names) or by prepend\n (overrides default/global package names).\n "
path = (lambda *paths: (os.path.abspath(os.path.join(os.path.dirname(__file... | -3,591,457,979,364,174,300 | Adds a directory to the system python path, either by append (doesn't
override default or globally installed package names) or by prepend
(overrides default/global package names). | example/manage.py | addPath | Locu/djoauth2 | python | def addPath(rel_path, prepend=False):
" Adds a directory to the system python path, either by append (doesn't\n override default or globally installed package names) or by prepend\n (overrides default/global package names).\n "
path = (lambda *paths: (os.path.abspath(os.path.join(os.path.dirname(__file... |
def act(self, state):
'Returns actions for given state(s) as per current policy.'
state = np.reshape(state, [(- 1), self.state_size])
action = self.actor_local.model.predict(state)[0]
return list((action + self.noise.sample())) | -7,804,609,446,734,043,000 | Returns actions for given state(s) as per current policy. | home/agents/agent.py | act | GabrielTourinho/dlnd-teach-a-quadcopter-how-to-fly | python | def act(self, state):
state = np.reshape(state, [(- 1), self.state_size])
action = self.actor_local.model.predict(state)[0]
return list((action + self.noise.sample())) |
def learn(self, experiences):
'Update policy and value parameters using given batch of experience tuples.'
states = np.vstack([e.state for e in experiences if (e is not None)])
actions = np.array([e.action for e in experiences if (e is not None)]).astype(np.float32).reshape((- 1), self.action_size)
rewa... | 9,061,022,206,806,542,000 | Update policy and value parameters using given batch of experience tuples. | home/agents/agent.py | learn | GabrielTourinho/dlnd-teach-a-quadcopter-how-to-fly | python | def learn(self, experiences):
states = np.vstack([e.state for e in experiences if (e is not None)])
actions = np.array([e.action for e in experiences if (e is not None)]).astype(np.float32).reshape((- 1), self.action_size)
rewards = np.array([e.reward for e in experiences if (e is not None)]).astype(np... |
def soft_update(self, local_model, target_model):
'Soft update model parameters.'
local_weights = np.array(local_model.get_weights())
target_weights = np.array(target_model.get_weights())
assert (len(local_weights) == len(target_weights)), 'Local and target model parameters must have the same size'
... | -6,402,697,941,261,341,000 | Soft update model parameters. | home/agents/agent.py | soft_update | GabrielTourinho/dlnd-teach-a-quadcopter-how-to-fly | python | def soft_update(self, local_model, target_model):
local_weights = np.array(local_model.get_weights())
target_weights = np.array(target_model.get_weights())
assert (len(local_weights) == len(target_weights)), 'Local and target model parameters must have the same size'
new_weights = ((self.tau * loca... |
def plotfft(s, fmax, doplot=False):
' This functions computes the fft of a signal, returning the frequency\n and their magnitude values.\n\n Parameters\n ----------\n s: array-like\n the input signal.\n fmax: int\n the sampling frequency.\n doplot: boolean\n a variable to indicate w... | -2,794,040,221,416,781,000 | This functions computes the fft of a signal, returning the frequency
and their magnitude values.
Parameters
----------
s: array-like
the input signal.
fmax: int
the sampling frequency.
doplot: boolean
a variable to indicate whether the plot is done or not.
Returns
-------
f: array-like
the frequency values (x... | novainstrumentation/tools.py | plotfft | novabiosignals/novainstrumentation | python | def plotfft(s, fmax, doplot=False):
' This functions computes the fft of a signal, returning the frequency\n and their magnitude values.\n\n Parameters\n ----------\n s: array-like\n the input signal.\n fmax: int\n the sampling frequency.\n doplot: boolean\n a variable to indicate w... |
def load_with_cache(file_, recache=False, sampling=1, columns=None, temp_dir='.', data_type='int16'):
"@brief This function loads a file from the current directory and saves\n the cached file to later executions. It's also possible to make a recache\n or a subsampling of the signal and choose only a few colum... | 4,169,040,887,613,408,000 | @brief This function loads a file from the current directory and saves
the cached file to later executions. It's also possible to make a recache
or a subsampling of the signal and choose only a few columns of the signal,
to accelerate the opening process.
@param file String: the name of the file to open.
@param recach... | novainstrumentation/tools.py | load_with_cache | novabiosignals/novainstrumentation | python | def load_with_cache(file_, recache=False, sampling=1, columns=None, temp_dir='.', data_type='int16'):
"@brief This function loads a file from the current directory and saves\n the cached file to later executions. It's also possible to make a recache\n or a subsampling of the signal and choose only a few colum... |
def load_data(filename):
'\n :rtype : numpy matrix\n '
data = pandas.read_csv(filename, header=None, delimiter='\t', skiprows=9)
return data.as_matrix() | 4,191,160,812,623,671,000 | :rtype : numpy matrix | novainstrumentation/tools.py | load_data | novabiosignals/novainstrumentation | python | def load_data(filename):
'\n \n '
data = pandas.read_csv(filename, header=None, delimiter='\t', skiprows=9)
return data.as_matrix() |
def test_experiment_variables(jikken_experiment):
'test variables are initialized properly and are not settable'
(exp, expected_variables, *_) = jikken_experiment
assert (exp.variables == expected_variables)
with pytest.raises(AttributeError):
exp.variables = expected_variables | 4,985,580,147,700,100,000 | test variables are initialized properly and are not settable | tests/unit/test_experiment.py | test_experiment_variables | outcastofmusic/jikken | python | def test_experiment_variables(jikken_experiment):
(exp, expected_variables, *_) = jikken_experiment
assert (exp.variables == expected_variables)
with pytest.raises(AttributeError):
exp.variables = expected_variables |
def test_experiment_tags(jikken_experiment):
'test tags are initialized properly and are not settable'
(exp, _, expected_tags, _) = jikken_experiment
assert (exp.tags == expected_tags)
with pytest.raises(AttributeError):
exp.tags = expected_tags | -8,382,541,816,748,046,000 | test tags are initialized properly and are not settable | tests/unit/test_experiment.py | test_experiment_tags | outcastofmusic/jikken | python | def test_experiment_tags(jikken_experiment):
(exp, _, expected_tags, _) = jikken_experiment
assert (exp.tags == expected_tags)
with pytest.raises(AttributeError):
exp.tags = expected_tags |
def test_experiment_schema(jikken_experiment):
'test schema is constructed properly'
(exp, expected_variables, _, tmpdir) = jikken_experiment
expected_hash = '40a3f5106cf9426bd4b13b168717e7bf'
assert (exp.schema_hash == expected_hash)
exp_2 = Experiment(name='exp1', variables=expected_variables, cod... | -2,649,363,590,991,716,000 | test schema is constructed properly | tests/unit/test_experiment.py | test_experiment_schema | outcastofmusic/jikken | python | def test_experiment_schema(jikken_experiment):
(exp, expected_variables, _, tmpdir) = jikken_experiment
expected_hash = '40a3f5106cf9426bd4b13b168717e7bf'
assert (exp.schema_hash == expected_hash)
exp_2 = Experiment(name='exp1', variables=expected_variables, code_dir=tmpdir.strpath)
assert (exp... |
def test_experiment_parameters_schema(jikken_experiment):
'test schema with parameters is constructed properly'
(exp, expected_variables, _, tmpdir) = jikken_experiment
expected_hash = '77c861c501833128e1cfb5b398588a7e'
assert (exp.parameters_hash == expected_hash) | 5,444,041,656,221,252,000 | test schema with parameters is constructed properly | tests/unit/test_experiment.py | test_experiment_parameters_schema | outcastofmusic/jikken | python | def test_experiment_parameters_schema(jikken_experiment):
(exp, expected_variables, _, tmpdir) = jikken_experiment
expected_hash = '77c861c501833128e1cfb5b398588a7e'
assert (exp.parameters_hash == expected_hash) |
def test_log_info(self):
'Test that INFO log entry does not go to the audit log.'
logging.setup(self.cfg_path)
log = logging.getLogger(__name__)
msg = uuid.uuid4().hex
log.info(msg)
info_log_entries = open(self.info_log_path).read()
self.assertIn(msg, info_log_entries)
audit_log_entries ... | 2,806,284,644,488,858,000 | Test that INFO log entry does not go to the audit log. | st2common/tests/unit/test_logger.py | test_log_info | Anshika-Gautam/st2 | python | def test_log_info(self):
logging.setup(self.cfg_path)
log = logging.getLogger(__name__)
msg = uuid.uuid4().hex
log.info(msg)
info_log_entries = open(self.info_log_path).read()
self.assertIn(msg, info_log_entries)
audit_log_entries = open(self.audit_log_path).read()
self.assertNotIn(... |
def test_log_critical(self):
'Test that CRITICAL log entry does not go to the audit log.'
logging.setup(self.cfg_path)
log = logging.getLogger(__name__)
msg = uuid.uuid4().hex
log.critical(msg)
info_log_entries = open(self.info_log_path).read()
self.assertIn(msg, info_log_entries)
audit_... | 1,073,219,046,804,395,500 | Test that CRITICAL log entry does not go to the audit log. | st2common/tests/unit/test_logger.py | test_log_critical | Anshika-Gautam/st2 | python | def test_log_critical(self):
logging.setup(self.cfg_path)
log = logging.getLogger(__name__)
msg = uuid.uuid4().hex
log.critical(msg)
info_log_entries = open(self.info_log_path).read()
self.assertIn(msg, info_log_entries)
audit_log_entries = open(self.audit_log_path).read()
self.asse... |
def test_log_audit(self):
'Test that AUDIT log entry goes to the audit log.'
logging.setup(self.cfg_path)
log = logging.getLogger(__name__)
msg = uuid.uuid4().hex
log.audit(msg)
info_log_entries = open(self.info_log_path).read()
self.assertIn(msg, info_log_entries)
audit_log_entries = op... | 1,515,286,437,568,597,800 | Test that AUDIT log entry goes to the audit log. | st2common/tests/unit/test_logger.py | test_log_audit | Anshika-Gautam/st2 | python | def test_log_audit(self):
logging.setup(self.cfg_path)
log = logging.getLogger(__name__)
msg = uuid.uuid4().hex
log.audit(msg)
info_log_entries = open(self.info_log_path).read()
self.assertIn(msg, info_log_entries)
audit_log_entries = open(self.audit_log_path).read()
self.assertIn(m... |
def stats(fname, times=True):
'Return stats on the file which should have been preserved'
with open(fname) as fd:
st = os.fstat(fd.fileno())
stats = (st.st_mode, st.st_uid, st.st_gid, st.st_size)
if times:
return (stats + (st.st_atime, st.st_mtime))
else:
... | -4,470,607,643,816,927,000 | Return stats on the file which should have been preserved | datalad/customremotes/tests/test_archives.py | stats | soichih/datalad | python | def stats(fname, times=True):
with open(fname) as fd:
st = os.fstat(fd.fileno())
stats = (st.st_mode, st.st_uid, st.st_gid, st.st_size)
if times:
return (stats + (st.st_atime, st.st_mtime))
else:
return stats |
def turnAlarm(on):
'write command into file - pass enable/disable command'
print(('turn alarm on? %s' % on))
enable = on
disable = (not on)
alarm = AlarmService()
alarm.load()
alarm.save(enable, disable)
return True | 666,391,020,835,512,300 | write command into file - pass enable/disable command | web/home.py | turnAlarm | tommykoch/pyhome | python | def turnAlarm(on):
print(('turn alarm on? %s' % on))
enable = on
disable = (not on)
alarm = AlarmService()
alarm.load()
alarm.save(enable, disable)
return True |
async def async_setup_entry(hass, config_entry, async_add_entities):
'Set up config entry.'
discovery_info = config_entry.data
device_ids = set()
def supported(event):
return (isinstance(event.device, rfxtrxmod.LightingDevice) and event.device.known_to_be_dimmable)
entities = []
for (pa... | 2,629,040,797,358,438,400 | Set up config entry. | homeassistant/components/rfxtrx/light.py | async_setup_entry | 1e1/core-1 | python | async def async_setup_entry(hass, config_entry, async_add_entities):
discovery_info = config_entry.data
device_ids = set()
def supported(event):
return (isinstance(event.device, rfxtrxmod.LightingDevice) and event.device.known_to_be_dimmable)
entities = []
for (packet_id, entity_info) ... |
@callback
def light_update(event, device_id):
'Handle light updates from the RFXtrx gateway.'
if (not supported(event)):
return
if (device_id in device_ids):
return
device_ids.add(device_id)
_LOGGER.info('Added light (Device ID: %s Class: %s Sub: %s, Event: %s)', event.device.id_stri... | -5,317,690,462,523,536,000 | Handle light updates from the RFXtrx gateway. | homeassistant/components/rfxtrx/light.py | light_update | 1e1/core-1 | python | @callback
def light_update(event, device_id):
if (not supported(event)):
return
if (device_id in device_ids):
return
device_ids.add(device_id)
_LOGGER.info('Added light (Device ID: %s Class: %s Sub: %s, Event: %s)', event.device.id_string.lower(), event.device.__class__.__name__, ev... |
async def async_added_to_hass(self):
'Restore RFXtrx device state (ON/OFF).'
(await super().async_added_to_hass())
if (self._event is None):
old_state = (await self.async_get_last_state())
if (old_state is not None):
self._state = (old_state.state == STATE_ON)
self._b... | 229,973,618,490,358,560 | Restore RFXtrx device state (ON/OFF). | homeassistant/components/rfxtrx/light.py | async_added_to_hass | 1e1/core-1 | python | async def async_added_to_hass(self):
(await super().async_added_to_hass())
if (self._event is None):
old_state = (await self.async_get_last_state())
if (old_state is not None):
self._state = (old_state.state == STATE_ON)
self._brightness = old_state.attributes.get(AT... |
@property
def brightness(self):
'Return the brightness of this light between 0..255.'
return self._brightness | -3,846,976,056,796,552,000 | Return the brightness of this light between 0..255. | homeassistant/components/rfxtrx/light.py | brightness | 1e1/core-1 | python | @property
def brightness(self):
return self._brightness |
@property
def supported_features(self):
'Flag supported features.'
return SUPPORT_RFXTRX | -5,159,653,584,670,436,000 | Flag supported features. | homeassistant/components/rfxtrx/light.py | supported_features | 1e1/core-1 | python | @property
def supported_features(self):
return SUPPORT_RFXTRX |
@property
def is_on(self):
'Return true if device is on.'
return self._state | -3,559,686,018,939,803,600 | Return true if device is on. | homeassistant/components/rfxtrx/light.py | is_on | 1e1/core-1 | python | @property
def is_on(self):
return self._state |
async def async_turn_on(self, **kwargs):
'Turn the device on.'
brightness = kwargs.get(ATTR_BRIGHTNESS)
self._state = True
if (brightness is None):
(await self._async_send(self._device.send_on))
self._brightness = 255
else:
(await self._async_send(self._device.send_dim, ((bri... | -27,936,814,387,729,360 | Turn the device on. | homeassistant/components/rfxtrx/light.py | async_turn_on | 1e1/core-1 | python | async def async_turn_on(self, **kwargs):
brightness = kwargs.get(ATTR_BRIGHTNESS)
self._state = True
if (brightness is None):
(await self._async_send(self._device.send_on))
self._brightness = 255
else:
(await self._async_send(self._device.send_dim, ((brightness * 100) // 255... |
async def async_turn_off(self, **kwargs):
'Turn the device off.'
(await self._async_send(self._device.send_off))
self._state = False
self._brightness = 0
self.async_write_ha_state() | -1,614,410,703,092,717,800 | Turn the device off. | homeassistant/components/rfxtrx/light.py | async_turn_off | 1e1/core-1 | python | async def async_turn_off(self, **kwargs):
(await self._async_send(self._device.send_off))
self._state = False
self._brightness = 0
self.async_write_ha_state() |
def _apply_event(self, event):
'Apply command from rfxtrx.'
super()._apply_event(event)
if (event.values['Command'] in COMMAND_ON_LIST):
self._state = True
elif (event.values['Command'] in COMMAND_OFF_LIST):
self._state = False
elif (event.values['Command'] == 'Set level'):
s... | -4,045,686,276,709,932,500 | Apply command from rfxtrx. | homeassistant/components/rfxtrx/light.py | _apply_event | 1e1/core-1 | python | def _apply_event(self, event):
super()._apply_event(event)
if (event.values['Command'] in COMMAND_ON_LIST):
self._state = True
elif (event.values['Command'] in COMMAND_OFF_LIST):
self._state = False
elif (event.values['Command'] == 'Set level'):
self._brightness = ((event.va... |
@callback
def _handle_event(self, event, device_id):
'Check if event applies to me and update.'
if (device_id != self._device_id):
return
self._apply_event(event)
self.async_write_ha_state() | 8,437,661,162,664,978,000 | Check if event applies to me and update. | homeassistant/components/rfxtrx/light.py | _handle_event | 1e1/core-1 | python | @callback
def _handle_event(self, event, device_id):
if (device_id != self._device_id):
return
self._apply_event(event)
self.async_write_ha_state() |
def test_api_pages_list_success(self):
'\n\t\tEnsure get request returns 200.\n\t\t'
response = self.client.get(reverse('page_list', kwargs={'language': 'nl'}))
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(response.data['count'], 1) | 1,200,097,847,982,713,000 | Ensure get request returns 200. | bluebottle/pages/tests/test_api.py | test_api_pages_list_success | maykinmedia/bluebottle | python | def test_api_pages_list_success(self):
'\n\t\t\n\t\t'
response = self.client.get(reverse('page_list', kwargs={'language': 'nl'}))
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(response.data['count'], 1) |
def test_api_pages_list_content(self):
'\n\t\tEnsure get request returns record with correct data.\n\t\t'
response = self.client.get(reverse('page_list', kwargs={'language': 'nl'}))
page = response.data['results'][0]
self.assertEqual(page['title'], self.page1.title)
self.assertEqual(page['language']... | -4,210,556,589,173,268,000 | Ensure get request returns record with correct data. | bluebottle/pages/tests/test_api.py | test_api_pages_list_content | maykinmedia/bluebottle | python | def test_api_pages_list_content(self):
'\n\t\t\n\t\t'
response = self.client.get(reverse('page_list', kwargs={'language': 'nl'}))
page = response.data['results'][0]
self.assertEqual(page['title'], self.page1.title)
self.assertEqual(page['language'], self.page1.language)
self.assertEqual(page['bo... |
def test_api_pages_detail_content(self):
'\n\t\tEnsure get request returns record with correct data.\n\t\t'
response = self.client.get(reverse('page_detail', kwargs={'language': 'en', 'slug': self.page2.slug}))
results = response.data
self.assertEqual(results['title'], self.page2.title)
self.assertE... | 1,916,083,978,927,994,400 | Ensure get request returns record with correct data. | bluebottle/pages/tests/test_api.py | test_api_pages_detail_content | maykinmedia/bluebottle | python | def test_api_pages_detail_content(self):
'\n\t\t\n\t\t'
response = self.client.get(reverse('page_detail', kwargs={'language': 'en', 'slug': self.page2.slug}))
results = response.data
self.assertEqual(results['title'], self.page2.title)
self.assertEqual(results['language'], self.page2.language)
s... |
def _update_project(self, request, data):
'Update project info'
domain_id = identity.get_domain_id_for_operation(request)
try:
project_id = data['project_id']
EXTRA_INFO = settings.PROJECT_TABLE_EXTRA_INFO
kwargs = dict(((key, data.get(key)) for key in EXTRA_INFO))
return api... | 753,130,235,582,491,000 | Update project info | openstack_dashboard/dashboards/identity/projects/workflows.py | _update_project | LinkleYping/horizon-vul | python | def _update_project(self, request, data):
domain_id = identity.get_domain_id_for_operation(request)
try:
project_id = data['project_id']
EXTRA_INFO = settings.PROJECT_TABLE_EXTRA_INFO
kwargs = dict(((key, data.get(key)) for key in EXTRA_INFO))
return api.keystone.tenant_upda... |
def alphanum_key(s):
' Turn a string into a list of string and number chunks.\n "z23a" -> ["z", 23, "a"]\n '
return [tryInt(c) for c in re.split('([0-9]+)', s)] | 2,718,573,483,697,511,000 | Turn a string into a list of string and number chunks.
"z23a" -> ["z", 23, "a"] | firstsession/measurement/measure_program.py | alphanum_key | Saqqe/Cream | python | def alphanum_key(s):
' Turn a string into a list of string and number chunks.\n "z23a" -> ["z", 23, "a"]\n '
return [tryInt(c) for c in re.split('([0-9]+)', s)] |
def sort_nicely(l):
' Sort the given list in the way that humans expect.\n '
l.sort(key=alphanum_key) | 7,898,580,595,700,768,000 | Sort the given list in the way that humans expect. | firstsession/measurement/measure_program.py | sort_nicely | Saqqe/Cream | python | def sort_nicely(l):
' \n '
l.sort(key=alphanum_key) |
@app.route('/', methods=['POST', 'GET'])
def index():
'\n Default app index.\n '
return 'Please contact your System Administrator.' | 1,470,829,655,005,580,500 | Default app index. | views.py | index | ayushrusiya47/quiz-extensions | python | @app.route('/', methods=['POST', 'GET'])
def index():
'\n \n '
return 'Please contact your System Administrator.' |
@app.route('/status', methods=['GET'])
def status():
'\n Runs smoke tests and reports status\n '
try:
job_queue_length = len(q.jobs)
except ConnectionError:
job_queue_length = (- 1)
status = {'tool': 'Quiz Extensions', 'checks': {'index': False, 'xml': False, 'api_key': False, 'red... | 8,651,372,796,350,657,000 | Runs smoke tests and reports status | views.py | status | ayushrusiya47/quiz-extensions | python | @app.route('/status', methods=['GET'])
def status():
'\n \n '
try:
job_queue_length = len(q.jobs)
except ConnectionError:
job_queue_length = (- 1)
status = {'tool': 'Quiz Extensions', 'checks': {'index': False, 'xml': False, 'api_key': False, 'redis': False, 'db': False, 'worker': ... |
@app.route('/lti.xml', methods=['GET'])
def xml():
'\n Returns the lti.xml file for the app.\n '
from urllib.parse import urlparse
domain = urlparse(request.url_root).netloc
return Response(render_template('lti.xml', tool_id=config.LTI_TOOL_ID, domain=domain), mimetype='application/xml') | 4,551,775,549,191,905,000 | Returns the lti.xml file for the app. | views.py | xml | ayushrusiya47/quiz-extensions | python | @app.route('/lti.xml', methods=['GET'])
def xml():
'\n \n '
from urllib.parse import urlparse
domain = urlparse(request.url_root).netloc
return Response(render_template('lti.xml', tool_id=config.LTI_TOOL_ID, domain=domain), mimetype='application/xml') |
@app.route('/quiz/<course_id>/', methods=['GET'])
@check_valid_user
@lti(error=error, request='session', role='staff', app=app)
def quiz(lti=lti, course_id=None):
'\n Main landing page for the app.\n\n Displays a page to the user that allows them to select students\n to moderate quizzes for.\n '
ret... | -1,338,936,958,936,886,800 | Main landing page for the app.
Displays a page to the user that allows them to select students
to moderate quizzes for. | views.py | quiz | ayushrusiya47/quiz-extensions | python | @app.route('/quiz/<course_id>/', methods=['GET'])
@check_valid_user
@lti(error=error, request='session', role='staff', app=app)
def quiz(lti=lti, course_id=None):
'\n Main landing page for the app.\n\n Displays a page to the user that allows them to select students\n to moderate quizzes for.\n '
ret... |
@app.route('/refresh/<course_id>/', methods=['POST'])
def refresh(course_id=None):
'\n Creates a new `refresh_background` job.\n\n :param course_id: The Canvas ID of the Course.\n :type course_id: int\n :rtype: flask.Response\n :returns: A JSON-formatted response containing a url for the started job.... | -9,084,823,866,377,085,000 | Creates a new `refresh_background` job.
:param course_id: The Canvas ID of the Course.
:type course_id: int
:rtype: flask.Response
:returns: A JSON-formatted response containing a url for the started job. | views.py | refresh | ayushrusiya47/quiz-extensions | python | @app.route('/refresh/<course_id>/', methods=['POST'])
def refresh(course_id=None):
'\n Creates a new `refresh_background` job.\n\n :param course_id: The Canvas ID of the Course.\n :type course_id: int\n :rtype: flask.Response\n :returns: A JSON-formatted response containing a url for the started job.... |
@app.route('/update/<course_id>/', methods=['POST'])
@check_valid_user
@lti(error=error, request='session', role='staff', app=app)
def update(lti=lti, course_id=None):
'\n Creates a new `update_background` job.\n\n :param course_id: The Canvas ID of the Course.\n :type coruse_id: int\n :rtype: flask.Res... | -8,826,940,118,246,629,000 | Creates a new `update_background` job.
:param course_id: The Canvas ID of the Course.
:type coruse_id: int
:rtype: flask.Response
:returns: A JSON-formatted response containing urls for the started jobs. | views.py | update | ayushrusiya47/quiz-extensions | python | @app.route('/update/<course_id>/', methods=['POST'])
@check_valid_user
@lti(error=error, request='session', role='staff', app=app)
def update(lti=lti, course_id=None):
'\n Creates a new `update_background` job.\n\n :param course_id: The Canvas ID of the Course.\n :type coruse_id: int\n :rtype: flask.Res... |
def update_background(course_id, extension_dict):
"\n Update time on selected students' quizzes to a specified percentage.\n\n :param course_id: The Canvas ID of the Course to update in\n :type course_id: int\n :param extension_dict: A dictionary that includes the percent of\n time and a list of ... | -4,985,010,300,237,697,000 | Update time on selected students' quizzes to a specified percentage.
:param course_id: The Canvas ID of the Course to update in
:type course_id: int
:param extension_dict: A dictionary that includes the percent of
time and a list of canvas user ids.
Example:
{
'percent': '300',
'user_ids':... | views.py | update_background | ayushrusiya47/quiz-extensions | python | def update_background(course_id, extension_dict):
"\n Update time on selected students' quizzes to a specified percentage.\n\n :param course_id: The Canvas ID of the Course to update in\n :type course_id: int\n :param extension_dict: A dictionary that includes the percent of\n time and a list of ... |
def refresh_background(course_id):
'\n Look up existing extensions and apply them to new quizzes.\n\n :param course_id: The Canvas ID of the Course.\n :type course_id: int\n :rtype: dict\n :returns: A dictionary containing two parts:\n\n - success `bool` False if there was an error, True other... | -606,887,113,193,659,500 | Look up existing extensions and apply them to new quizzes.
:param course_id: The Canvas ID of the Course.
:type course_id: int
:rtype: dict
:returns: A dictionary containing two parts:
- success `bool` False if there was an error, True otherwise.
- message `str` A long description of success or failure. | views.py | refresh_background | ayushrusiya47/quiz-extensions | python | def refresh_background(course_id):
'\n Look up existing extensions and apply them to new quizzes.\n\n :param course_id: The Canvas ID of the Course.\n :type course_id: int\n :rtype: dict\n :returns: A dictionary containing two parts:\n\n - success `bool` False if there was an error, True other... |
@app.route('/missing_and_stale_quizzes/<course_id>/', methods=['GET'])
def missing_and_stale_quizzes_check(course_id):
'\n Check if there are missing quizzes.\n\n :param course_id: The Canvas ID of the Course.\n :type course_id: int\n :rtype: str\n :returns: A JSON-formatted string representation of ... | -8,747,239,967,523,165,000 | Check if there are missing quizzes.
:param course_id: The Canvas ID of the Course.
:type course_id: int
:rtype: str
:returns: A JSON-formatted string representation of a boolean.
"true" if there are missing quizzes, "false" if there are not. | views.py | missing_and_stale_quizzes_check | ayushrusiya47/quiz-extensions | python | @app.route('/missing_and_stale_quizzes/<course_id>/', methods=['GET'])
def missing_and_stale_quizzes_check(course_id):
'\n Check if there are missing quizzes.\n\n :param course_id: The Canvas ID of the Course.\n :type course_id: int\n :rtype: str\n :returns: A JSON-formatted string representation of ... |
@app.route('/filter/<course_id>/', methods=['GET'])
@check_valid_user
@lti(error=error, request='session', role='staff', app=app)
def filter(lti=lti, course_id=None):
'\n Display a filtered and paginated list of students in the course.\n\n :param course_id:\n :type: int\n :rtype: str\n :returns: A li... | -5,975,147,192,149,251,000 | Display a filtered and paginated list of students in the course.
:param course_id:
:type: int
:rtype: str
:returns: A list of students in the course using the template
user_list.html. | views.py | filter | ayushrusiya47/quiz-extensions | python | @app.route('/filter/<course_id>/', methods=['GET'])
@check_valid_user
@lti(error=error, request='session', role='staff', app=app)
def filter(lti=lti, course_id=None):
'\n Display a filtered and paginated list of students in the course.\n\n :param course_id:\n :type: int\n :rtype: str\n :returns: A li... |
@app.route('/launch', methods=['POST'])
@lti(error=error, request='initial', role='staff', app=app)
def lti_tool(lti=lti):
'\n Bootstrapper for lti.\n '
course_id = request.values.get('custom_canvas_course_id')
canvas_user_id = request.values.get('custom_canvas_user_id')
canvas_domain = request.va... | 1,882,419,556,337,132,300 | Bootstrapper for lti. | views.py | lti_tool | ayushrusiya47/quiz-extensions | python | @app.route('/launch', methods=['POST'])
@lti(error=error, request='initial', role='staff', app=app)
def lti_tool(lti=lti):
'\n \n '
course_id = request.values.get('custom_canvas_course_id')
canvas_user_id = request.values.get('custom_canvas_user_id')
canvas_domain = request.values.get('custom_canv... |
@wraps(f)
def decorated_function(*args, **kwargs):
'\n Decorator to check if the user is allowed access to the app.\n If user is allowed, return the decorated function.\n Otherwise, return an error page with corresponding message.\n '
canvas_user_id = session.get('canvas_user_id')
... | -1,688,540,081,320,270,000 | Decorator to check if the user is allowed access to the app.
If user is allowed, return the decorated function.
Otherwise, return an error page with corresponding message. | views.py | decorated_function | ayushrusiya47/quiz-extensions | python | @wraps(f)
def decorated_function(*args, **kwargs):
'\n Decorator to check if the user is allowed access to the app.\n If user is allowed, return the decorated function.\n Otherwise, return an error page with corresponding message.\n '
canvas_user_id = session.get('canvas_user_id')
... |
def deferToThreadPool(reactor, threadpool, f, *args, **kwargs):
"\n Call the function C{f} using a thread from the given threadpool and return\n the result as a Deferred.\n\n This function is only used by client code which is maintaining its own\n threadpool. To run a function in the reactor's threadpo... | 4,905,041,117,132,150,000 | Call the function C{f} using a thread from the given threadpool and return
the result as a Deferred.
This function is only used by client code which is maintaining its own
threadpool. To run a function in the reactor's threadpool, use
C{deferToThread}.
@param reactor: The reactor in whose main thread the Deferred wi... | src/twisted/internet/threads.py | deferToThreadPool | adamtheturtle/twisted | python | def deferToThreadPool(reactor, threadpool, f, *args, **kwargs):
"\n Call the function C{f} using a thread from the given threadpool and return\n the result as a Deferred.\n\n This function is only used by client code which is maintaining its own\n threadpool. To run a function in the reactor's threadpo... |
def deferToThread(f, *args, **kwargs):
'\n Run a function in a thread and return the result as a Deferred.\n\n @param f: The function to call.\n @param *args: positional arguments to pass to f.\n @param **kwargs: keyword arguments to pass to f.\n\n @return: A Deferred which fires a callback with the ... | 6,221,264,868,728,162,000 | Run a function in a thread and return the result as a Deferred.
@param f: The function to call.
@param *args: positional arguments to pass to f.
@param **kwargs: keyword arguments to pass to f.
@return: A Deferred which fires a callback with the result of f,
or an errback with a L{twisted.python.failure.Failure} if f... | src/twisted/internet/threads.py | deferToThread | adamtheturtle/twisted | python | def deferToThread(f, *args, **kwargs):
'\n Run a function in a thread and return the result as a Deferred.\n\n @param f: The function to call.\n @param *args: positional arguments to pass to f.\n @param **kwargs: keyword arguments to pass to f.\n\n @return: A Deferred which fires a callback with the ... |
def _runMultiple(tupleList):
'\n Run a list of functions.\n '
for (f, args, kwargs) in tupleList:
f(*args, **kwargs) | 5,765,581,595,930,412,000 | Run a list of functions. | src/twisted/internet/threads.py | _runMultiple | adamtheturtle/twisted | python | def _runMultiple(tupleList):
'\n \n '
for (f, args, kwargs) in tupleList:
f(*args, **kwargs) |
def callMultipleInThread(tupleList):
'\n Run a list of functions in the same thread.\n\n tupleList should be a list of (function, argsList, kwargsDict) tuples.\n '
from twisted.internet import reactor
reactor.callInThread(_runMultiple, tupleList) | -7,280,785,097,039,103,000 | Run a list of functions in the same thread.
tupleList should be a list of (function, argsList, kwargsDict) tuples. | src/twisted/internet/threads.py | callMultipleInThread | adamtheturtle/twisted | python | def callMultipleInThread(tupleList):
'\n Run a list of functions in the same thread.\n\n tupleList should be a list of (function, argsList, kwargsDict) tuples.\n '
from twisted.internet import reactor
reactor.callInThread(_runMultiple, tupleList) |
def blockingCallFromThread(reactor, f, *a, **kw):
"\n Run a function in the reactor from a thread, and wait for the result\n synchronously. If the function returns a L{Deferred}, wait for its\n result and return that.\n\n @param reactor: The L{IReactorThreads} provider which will be used to\n sc... | -6,062,473,800,116,598,000 | Run a function in the reactor from a thread, and wait for the result
synchronously. If the function returns a L{Deferred}, wait for its
result and return that.
@param reactor: The L{IReactorThreads} provider which will be used to
schedule the function call.
@param f: the callable to run in the reactor thread
@typ... | src/twisted/internet/threads.py | blockingCallFromThread | adamtheturtle/twisted | python | def blockingCallFromThread(reactor, f, *a, **kw):
"\n Run a function in the reactor from a thread, and wait for the result\n synchronously. If the function returns a L{Deferred}, wait for its\n result and return that.\n\n @param reactor: The L{IReactorThreads} provider which will be used to\n sc... |
def read_tle_file(tlefile, **kwargs):
'\n \n Read in a TLE file and return the TLE that is closest to the date you want to\n propagate the orbit to.\n '
times = []
line1 = []
line2 = []
from os import path
from datetime import datetime
try:
f = open(tlefile, 'r')
exce... | 8,202,728,023,310,814,000 | Read in a TLE file and return the TLE that is closest to the date you want to
propagate the orbit to. | nustar_lunar_pointing/tracking.py | read_tle_file | bwgref/nustar_lunar_pointing | python | def read_tle_file(tlefile, **kwargs):
'\n \n Read in a TLE file and return the TLE that is closest to the date you want to\n propagate the orbit to.\n '
times = []
line1 = []
line2 = []
from os import path
from datetime import datetime
try:
f = open(tlefile, 'r')
exce... |
def get_epoch_tle(epoch, tlefile):
'\n \n Find the TLE that is closest to the epoch you want to search.\n \n epoch is a datetime object, tlefile is the file you want to search through.\n \n '
(times, line1, line2) = read_tle_file(tlefile)
from datetime import datetime
from astropy.time... | -7,966,222,560,800,649,000 | Find the TLE that is closest to the epoch you want to search.
epoch is a datetime object, tlefile is the file you want to search through. | nustar_lunar_pointing/tracking.py | get_epoch_tle | bwgref/nustar_lunar_pointing | python | def get_epoch_tle(epoch, tlefile):
'\n \n Find the TLE that is closest to the epoch you want to search.\n \n epoch is a datetime object, tlefile is the file you want to search through.\n \n '
(times, line1, line2) = read_tle_file(tlefile)
from datetime import datetime
from astropy.time... |
def convert_nustar_time(t, leap=5):
' \n \n Converts MET seconds to a datetime object.\n \n Default is to subtract off 5 leap seconds.\n\n '
import astropy.units as u
mjdref = (55197 * u.d)
met = (((t - leap) * u.s) + mjdref)
met_datetime = Time(met.to(u.d), format='mjd').datetime
... | 1,218,465,157,810,114,300 | Converts MET seconds to a datetime object.
Default is to subtract off 5 leap seconds. | nustar_lunar_pointing/tracking.py | convert_nustar_time | bwgref/nustar_lunar_pointing | python | def convert_nustar_time(t, leap=5):
' \n \n Converts MET seconds to a datetime object.\n \n Default is to subtract off 5 leap seconds.\n\n '
import astropy.units as u
mjdref = (55197 * u.d)
met = (((t - leap) * u.s) + mjdref)
met_datetime = Time(met.to(u.d), format='mjd').datetime
... |
def get_nustar_location(checktime, line1, line2):
' \n \n Code to determine the spacecraft location from the TLE.\n \n Inputs are a datetime object and the two lines of the TLE you want to use.\n \n Returns a tuple that has the X, Y, and Z geocentric coordinates (in km).\n \n '
from sgp4... | 167,206,073,857,276,930 | Code to determine the spacecraft location from the TLE.
Inputs are a datetime object and the two lines of the TLE you want to use.
Returns a tuple that has the X, Y, and Z geocentric coordinates (in km). | nustar_lunar_pointing/tracking.py | get_nustar_location | bwgref/nustar_lunar_pointing | python | def get_nustar_location(checktime, line1, line2):
' \n \n Code to determine the spacecraft location from the TLE.\n \n Inputs are a datetime object and the two lines of the TLE you want to use.\n \n Returns a tuple that has the X, Y, and Z geocentric coordinates (in km).\n \n '
from sgp4... |
def eci2el(x, y, z, dt):
'\n Convert Earth-Centered Inertial (ECI) cartesian coordinates to ITRS for astropy EarthLocation object.\n\n Inputs :\n x = ECI X-coordinate \n y = ECI Y-coordinate \n z = ECI Z-coordinate \n dt = UTC time (datetime object)\n '
from astropy.coordinates import GCRS,... | 339,705,923,134,611,260 | Convert Earth-Centered Inertial (ECI) cartesian coordinates to ITRS for astropy EarthLocation object.
Inputs :
x = ECI X-coordinate
y = ECI Y-coordinate
z = ECI Z-coordinate
dt = UTC time (datetime object) | nustar_lunar_pointing/tracking.py | eci2el | bwgref/nustar_lunar_pointing | python | def eci2el(x, y, z, dt):
'\n Convert Earth-Centered Inertial (ECI) cartesian coordinates to ITRS for astropy EarthLocation object.\n\n Inputs :\n x = ECI X-coordinate \n y = ECI Y-coordinate \n z = ECI Z-coordinate \n dt = UTC time (datetime object)\n '
from astropy.coordinates import GCRS,... |
def get_moon_j2000(epoch, line1, line2, position=None):
'\n \n Code to determine the apparent J2000 position for a given\n time and at a given position for the observatory.\n \n epoch needs to be a datetime or Time object.\n \n position is a list/tuple of X/Y/Z positions\n \n '
from a... | 6,202,994,355,039,850,000 | Code to determine the apparent J2000 position for a given
time and at a given position for the observatory.
epoch needs to be a datetime or Time object.
position is a list/tuple of X/Y/Z positions | nustar_lunar_pointing/tracking.py | get_moon_j2000 | bwgref/nustar_lunar_pointing | python | def get_moon_j2000(epoch, line1, line2, position=None):
'\n \n Code to determine the apparent J2000 position for a given\n time and at a given position for the observatory.\n \n epoch needs to be a datetime or Time object.\n \n position is a list/tuple of X/Y/Z positions\n \n '
from a... |
def __init__(self, form, context, *args, **kwargs):
'\n Dynamically add each of the form fields for the given form model\n instance and its related field model instances.\n '
self.form = form
self.form_fields = form.fields.visible()
initial = kwargs.pop('initial', {})
field_entr... | 827,790,042,888,069,000 | Dynamically add each of the form fields for the given form model
instance and its related field model instances. | zhiliao/forms/forms.py | __init__ | gladgod/zhiliao | python | def __init__(self, form, context, *args, **kwargs):
'\n Dynamically add each of the form fields for the given form model\n instance and its related field model instances.\n '
self.form = form
self.form_fields = form.fields.visible()
initial = kwargs.pop('initial', {})
field_entr... |
def save(self, **kwargs):
'\n Create a ``FormEntry`` instance and related ``FieldEntry``\n instances for each form field.\n '
entry = super(FormForForm, self).save(commit=False)
entry.form = self.form
entry.entry_time = now()
entry.save()
entry_fields = entry.fields.values_l... | -4,948,100,640,383,101,000 | Create a ``FormEntry`` instance and related ``FieldEntry``
instances for each form field. | zhiliao/forms/forms.py | save | gladgod/zhiliao | python | def save(self, **kwargs):
'\n Create a ``FormEntry`` instance and related ``FieldEntry``\n instances for each form field.\n '
entry = super(FormForForm, self).save(commit=False)
entry.form = self.form
entry.entry_time = now()
entry.save()
entry_fields = entry.fields.values_l... |
def email_to(self):
'\n Return the value entered for the first field of type\n ``forms.fields.EMAIL``.\n '
for field in self.form_fields:
if field.is_a(fields.EMAIL):
return self.cleaned_data[('field_%s' % field.id)]
return None | -6,057,552,900,015,576,000 | Return the value entered for the first field of type
``forms.fields.EMAIL``. | zhiliao/forms/forms.py | email_to | gladgod/zhiliao | python | def email_to(self):
'\n Return the value entered for the first field of type\n ``forms.fields.EMAIL``.\n '
for field in self.form_fields:
if field.is_a(fields.EMAIL):
return self.cleaned_data[('field_%s' % field.id)]
return None |
def __init__(self, form, request, *args, **kwargs):
'\n Iterate through the fields of the ``forms.models.Form`` instance and\n create the form fields required to control including the field in\n the export (with a checkbox) or filtering the field which differs\n across field types. User ... | -7,674,941,775,648,542,000 | Iterate through the fields of the ``forms.models.Form`` instance and
create the form fields required to control including the field in
the export (with a checkbox) or filtering the field which differs
across field types. User a list of checkboxes when a fixed set of
choices can be chosen from, a pair of date fields for... | zhiliao/forms/forms.py | __init__ | gladgod/zhiliao | python | def __init__(self, form, request, *args, **kwargs):
'\n Iterate through the fields of the ``forms.models.Form`` instance and\n create the form fields required to control including the field in\n the export (with a checkbox) or filtering the field which differs\n across field types. User ... |
def __iter__(self):
'\n Yield pairs of include checkbox / filters for each field.\n '
for field_id in ([f.id for f in self.form_fields] + [0]):
prefix = ('field_%s_' % field_id)
fields = [f for f in super(EntriesForm, self).__iter__() if f.name.startswith(prefix)]
(yield (f... | 1,984,044,150,900,896,500 | Yield pairs of include checkbox / filters for each field. | zhiliao/forms/forms.py | __iter__ | gladgod/zhiliao | python | def __iter__(self):
'\n \n '
for field_id in ([f.id for f in self.form_fields] + [0]):
prefix = ('field_%s_' % field_id)
fields = [f for f in super(EntriesForm, self).__iter__() if f.name.startswith(prefix)]
(yield (fields[0], fields[1], fields[2:])) |
def columns(self):
'\n Returns the list of selected column names.\n '
fields = [f.label for f in self.form_fields if self.cleaned_data[('field_%s_export' % f.id)]]
if self.cleaned_data['field_0_export']:
fields.append(self.entry_time_name)
return fields | 2,414,668,977,055,500,000 | Returns the list of selected column names. | zhiliao/forms/forms.py | columns | gladgod/zhiliao | python | def columns(self):
'\n \n '
fields = [f.label for f in self.form_fields if self.cleaned_data[('field_%s_export' % f.id)]]
if self.cleaned_data['field_0_export']:
fields.append(self.entry_time_name)
return fields |
def rows(self, csv=False):
'\n Returns each row based on the selected criteria.\n '
field_indexes = {}
file_field_ids = []
date_field_ids = []
for field in self.form_fields:
if self.cleaned_data[('field_%s_export' % field.id)]:
field_indexes[field.id] = len(field_in... | 6,989,815,682,023,497,000 | Returns each row based on the selected criteria. | zhiliao/forms/forms.py | rows | gladgod/zhiliao | python | def rows(self, csv=False):
'\n \n '
field_indexes = {}
file_field_ids = []
date_field_ids = []
for field in self.form_fields:
if self.cleaned_data[('field_%s_export' % field.id)]:
field_indexes[field.id] = len(field_indexes)
if field.is_a(fields.FILE):
... |
def check_line_match(self, index, stripped, data_rows):
'Find lines matching stripped from lineMatchKeys and set value to immediately following row'
for (key, value) in self.lineMatches.items():
if (stripped == key):
next_row = data_rows[(index + 1)]
if next_row.find_all('b'):
... | 7,381,854,148,757,062,000 | Find lines matching stripped from lineMatchKeys and set value to immediately following row | DataObjects.py | check_line_match | ataboo/CalloutScrape | python | def check_line_match(self, index, stripped, data_rows):
for (key, value) in self.lineMatches.items():
if (stripped == key):
next_row = data_rows[(index + 1)]
if next_row.find_all('b'):
print('Next row was bold element: {0}. Skipping...'.format(next_row))
... |
def __init__(self, app_id=None, state=None, x_request_id=None):
'StopAppResponse - a model defined in huaweicloud sdk'
super(StopAppResponse, self).__init__()
self._app_id = None
self._state = None
self._x_request_id = None
self.discriminator = None
if (app_id is not None):
self.app_... | 7,441,684,750,325,065,000 | StopAppResponse - a model defined in huaweicloud sdk | huaweicloud-sdk-cloudrtc/huaweicloudsdkcloudrtc/v2/model/stop_app_response.py | __init__ | huaweicloud/huaweicloud-sdk-python-v3 | python | def __init__(self, app_id=None, state=None, x_request_id=None):
super(StopAppResponse, self).__init__()
self._app_id = None
self._state = None
self._x_request_id = None
self.discriminator = None
if (app_id is not None):
self.app_id = app_id
if (state is not None):
self.s... |
@property
def app_id(self):
'Gets the app_id of this StopAppResponse.\n\n 应用id\n\n :return: The app_id of this StopAppResponse.\n :rtype: str\n '
return self._app_id | 8,293,203,077,026,026,000 | Gets the app_id of this StopAppResponse.
应用id
:return: The app_id of this StopAppResponse.
:rtype: str | huaweicloud-sdk-cloudrtc/huaweicloudsdkcloudrtc/v2/model/stop_app_response.py | app_id | huaweicloud/huaweicloud-sdk-python-v3 | python | @property
def app_id(self):
'Gets the app_id of this StopAppResponse.\n\n 应用id\n\n :return: The app_id of this StopAppResponse.\n :rtype: str\n '
return self._app_id |
@app_id.setter
def app_id(self, app_id):
'Sets the app_id of this StopAppResponse.\n\n 应用id\n\n :param app_id: The app_id of this StopAppResponse.\n :type: str\n '
self._app_id = app_id | -5,006,926,596,443,253,000 | Sets the app_id of this StopAppResponse.
应用id
:param app_id: The app_id of this StopAppResponse.
:type: str | huaweicloud-sdk-cloudrtc/huaweicloudsdkcloudrtc/v2/model/stop_app_response.py | app_id | huaweicloud/huaweicloud-sdk-python-v3 | python | @app_id.setter
def app_id(self, app_id):
'Sets the app_id of this StopAppResponse.\n\n 应用id\n\n :param app_id: The app_id of this StopAppResponse.\n :type: str\n '
self._app_id = app_id |
@property
def state(self):
'Gets the state of this StopAppResponse.\n\n\n :return: The state of this StopAppResponse.\n :rtype: AppState\n '
return self._state | 8,748,824,888,664,394,000 | Gets the state of this StopAppResponse.
:return: The state of this StopAppResponse.
:rtype: AppState | huaweicloud-sdk-cloudrtc/huaweicloudsdkcloudrtc/v2/model/stop_app_response.py | state | huaweicloud/huaweicloud-sdk-python-v3 | python | @property
def state(self):
'Gets the state of this StopAppResponse.\n\n\n :return: The state of this StopAppResponse.\n :rtype: AppState\n '
return self._state |
@state.setter
def state(self, state):
'Sets the state of this StopAppResponse.\n\n\n :param state: The state of this StopAppResponse.\n :type: AppState\n '
self._state = state | 4,817,263,328,804,627,000 | Sets the state of this StopAppResponse.
:param state: The state of this StopAppResponse.
:type: AppState | huaweicloud-sdk-cloudrtc/huaweicloudsdkcloudrtc/v2/model/stop_app_response.py | state | huaweicloud/huaweicloud-sdk-python-v3 | python | @state.setter
def state(self, state):
'Sets the state of this StopAppResponse.\n\n\n :param state: The state of this StopAppResponse.\n :type: AppState\n '
self._state = state |
@property
def x_request_id(self):
'Gets the x_request_id of this StopAppResponse.\n\n\n :return: The x_request_id of this StopAppResponse.\n :rtype: str\n '
return self._x_request_id | -72,288,185,045,706,720 | Gets the x_request_id of this StopAppResponse.
:return: The x_request_id of this StopAppResponse.
:rtype: str | huaweicloud-sdk-cloudrtc/huaweicloudsdkcloudrtc/v2/model/stop_app_response.py | x_request_id | huaweicloud/huaweicloud-sdk-python-v3 | python | @property
def x_request_id(self):
'Gets the x_request_id of this StopAppResponse.\n\n\n :return: The x_request_id of this StopAppResponse.\n :rtype: str\n '
return self._x_request_id |
@x_request_id.setter
def x_request_id(self, x_request_id):
'Sets the x_request_id of this StopAppResponse.\n\n\n :param x_request_id: The x_request_id of this StopAppResponse.\n :type: str\n '
self._x_request_id = x_request_id | -4,375,000,343,484,576,000 | Sets the x_request_id of this StopAppResponse.
:param x_request_id: The x_request_id of this StopAppResponse.
:type: str | huaweicloud-sdk-cloudrtc/huaweicloudsdkcloudrtc/v2/model/stop_app_response.py | x_request_id | huaweicloud/huaweicloud-sdk-python-v3 | python | @x_request_id.setter
def x_request_id(self, x_request_id):
'Sets the x_request_id of this StopAppResponse.\n\n\n :param x_request_id: The x_request_id of this StopAppResponse.\n :type: str\n '
self._x_request_id = x_request_id |
def to_dict(self):
'Returns the model properties as a dict'
result = {}
for (attr, _) in six.iteritems(self.openapi_types):
value = getattr(self, attr)
if isinstance(value, list):
result[attr] = list(map((lambda x: (x.to_dict() if hasattr(x, 'to_dict') else x)), value))
e... | 2,594,216,033,120,720,000 | Returns the model properties as a dict | huaweicloud-sdk-cloudrtc/huaweicloudsdkcloudrtc/v2/model/stop_app_response.py | to_dict | huaweicloud/huaweicloud-sdk-python-v3 | python | def to_dict(self):
result = {}
for (attr, _) in six.iteritems(self.openapi_types):
value = getattr(self, attr)
if isinstance(value, list):
result[attr] = list(map((lambda x: (x.to_dict() if hasattr(x, 'to_dict') else x)), value))
elif hasattr(value, 'to_dict'):
... |
def to_str(self):
'Returns the string representation of the model'
import simplejson as json
if six.PY2:
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
return json.dumps(sanitize_for_serialization(self), ensure_ascii=False) | -6,095,553,759,700,562,000 | Returns the string representation of the model | huaweicloud-sdk-cloudrtc/huaweicloudsdkcloudrtc/v2/model/stop_app_response.py | to_str | huaweicloud/huaweicloud-sdk-python-v3 | python | def to_str(self):
import simplejson as json
if six.PY2:
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
return json.dumps(sanitize_for_serialization(self), ensure_ascii=False) |
def __repr__(self):
'For `print`'
return self.to_str() | -1,581,176,371,750,213,000 | For `print` | huaweicloud-sdk-cloudrtc/huaweicloudsdkcloudrtc/v2/model/stop_app_response.py | __repr__ | huaweicloud/huaweicloud-sdk-python-v3 | python | def __repr__(self):
return self.to_str() |
def __eq__(self, other):
'Returns true if both objects are equal'
if (not isinstance(other, StopAppResponse)):
return False
return (self.__dict__ == other.__dict__) | 2,557,606,281,473,039,000 | Returns true if both objects are equal | huaweicloud-sdk-cloudrtc/huaweicloudsdkcloudrtc/v2/model/stop_app_response.py | __eq__ | huaweicloud/huaweicloud-sdk-python-v3 | python | def __eq__(self, other):
if (not isinstance(other, StopAppResponse)):
return False
return (self.__dict__ == other.__dict__) |
def __ne__(self, other):
'Returns true if both objects are not equal'
return (not (self == other)) | 7,764,124,047,908,058,000 | Returns true if both objects are not equal | huaweicloud-sdk-cloudrtc/huaweicloudsdkcloudrtc/v2/model/stop_app_response.py | __ne__ | huaweicloud/huaweicloud-sdk-python-v3 | python | def __ne__(self, other):
return (not (self == other)) |
def _expand_name(name):
'Replaces common shorthands with respective full names.\n\n "tf.xxx" --> "tensorflow.xxx"\n "tx.xxx" --> "texar.tf.xxx"\n '
return name | 8,329,032,541,764,644,000 | Replaces common shorthands with respective full names.
"tf.xxx" --> "tensorflow.xxx"
"tx.xxx" --> "texar.tf.xxx" | texar/tf/utils/utils.py | _expand_name | awesomemachinelearning/texar | python | def _expand_name(name):
'Replaces common shorthands with respective full names.\n\n "tf.xxx" --> "tensorflow.xxx"\n "tx.xxx" --> "texar.tf.xxx"\n '
return name |
def _inspect_getargspec(fn):
'Returns `inspect.getargspec(fn)` for Py2 and `inspect.getfullargspec(fn)`\n for Py3\n '
try:
return inspect.getfullargspec(fn)
except AttributeError:
try:
return inspect.getargspec(fn)
except TypeError:
return inspect.getarg... | -8,735,037,290,325,360,000 | Returns `inspect.getargspec(fn)` for Py2 and `inspect.getfullargspec(fn)`
for Py3 | texar/tf/utils/utils.py | _inspect_getargspec | awesomemachinelearning/texar | python | def _inspect_getargspec(fn):
'Returns `inspect.getargspec(fn)` for Py2 and `inspect.getfullargspec(fn)`\n for Py3\n '
try:
return inspect.getfullargspec(fn)
except AttributeError:
try:
return inspect.getargspec(fn)
except TypeError:
return inspect.getarg... |
def get_args(fn):
'Gets the arguments of a function.\n\n Args:\n fn (callable): The function to inspect.\n\n Returns:\n list: A list of argument names (str) of the function.\n '
argspec = _inspect_getargspec(fn)
args = argspec.args
if (len(args) == 0):
args = funcsigs.sign... | -8,241,205,280,697,680,000 | Gets the arguments of a function.
Args:
fn (callable): The function to inspect.
Returns:
list: A list of argument names (str) of the function. | texar/tf/utils/utils.py | get_args | awesomemachinelearning/texar | python | def get_args(fn):
'Gets the arguments of a function.\n\n Args:\n fn (callable): The function to inspect.\n\n Returns:\n list: A list of argument names (str) of the function.\n '
argspec = _inspect_getargspec(fn)
args = argspec.args
if (len(args) == 0):
args = funcsigs.sign... |
def get_default_arg_values(fn):
'Gets the arguments and respective default values of a function.\n\n Only arguments with default values are included in the output dictionary.\n\n Args:\n fn (callable): The function to inspect.\n\n Returns:\n dict: A dictionary that maps argument names (str) t... | 3,098,645,701,942,710,000 | Gets the arguments and respective default values of a function.
Only arguments with default values are included in the output dictionary.
Args:
fn (callable): The function to inspect.
Returns:
dict: A dictionary that maps argument names (str) to their default
values. The dictionary is empty if no argumen... | texar/tf/utils/utils.py | get_default_arg_values | awesomemachinelearning/texar | python | def get_default_arg_values(fn):
'Gets the arguments and respective default values of a function.\n\n Only arguments with default values are included in the output dictionary.\n\n Args:\n fn (callable): The function to inspect.\n\n Returns:\n dict: A dictionary that maps argument names (str) t... |
def check_or_get_class(class_or_name, module_path=None, superclass=None):
'Returns the class and checks if the class inherits :attr:`superclass`.\n\n Args:\n class_or_name: Name or full path to the class, or the class itself.\n module_paths (list, optional): Paths to candidate modules to search\n ... | 7,885,878,717,375,071,000 | Returns the class and checks if the class inherits :attr:`superclass`.
Args:
class_or_name: Name or full path to the class, or the class itself.
module_paths (list, optional): Paths to candidate modules to search
for the class. This is used if :attr:`class_or_name` is a string and
the class can... | texar/tf/utils/utils.py | check_or_get_class | awesomemachinelearning/texar | python | def check_or_get_class(class_or_name, module_path=None, superclass=None):
'Returns the class and checks if the class inherits :attr:`superclass`.\n\n Args:\n class_or_name: Name or full path to the class, or the class itself.\n module_paths (list, optional): Paths to candidate modules to search\n ... |
def get_class(class_name, module_paths=None):
'Returns the class based on class name.\n\n Args:\n class_name (str): Name or full path to the class.\n module_paths (list): Paths to candidate modules to search for the\n class. This is used if the class cannot be located solely based on\n ... | 2,376,394,911,442,920,000 | Returns the class based on class name.
Args:
class_name (str): Name or full path to the class.
module_paths (list): Paths to candidate modules to search for the
class. This is used if the class cannot be located solely based on
`class_name`. The first module in the list that contains the class
... | texar/tf/utils/utils.py | get_class | awesomemachinelearning/texar | python | def get_class(class_name, module_paths=None):
'Returns the class based on class name.\n\n Args:\n class_name (str): Name or full path to the class.\n module_paths (list): Paths to candidate modules to search for the\n class. This is used if the class cannot be located solely based on\n ... |
def check_or_get_instance(ins_or_class_or_name, kwargs, module_paths=None, classtype=None):
'Returns a class instance and checks types.\n\n Args:\n ins_or_class_or_name: Can be of 3 types:\n\n - A class to instantiate.\n - A string of the name or full path to a class to ... | 3,205,836,329,023,062,500 | Returns a class instance and checks types.
Args:
ins_or_class_or_name: Can be of 3 types:
- A class to instantiate.
- A string of the name or full path to a class to instantiate.
- The class instance to check types.
kwargs (dict): Keyword arguments for the class construc... | texar/tf/utils/utils.py | check_or_get_instance | awesomemachinelearning/texar | python | def check_or_get_instance(ins_or_class_or_name, kwargs, module_paths=None, classtype=None):
'Returns a class instance and checks types.\n\n Args:\n ins_or_class_or_name: Can be of 3 types:\n\n - A class to instantiate.\n - A string of the name or full path to a class to ... |
def get_instance(class_or_name, kwargs, module_paths=None):
'Creates a class instance.\n\n Args:\n class_or_name: A class, or its name or full path to a class to\n instantiate.\n kwargs (dict): Keyword arguments for the class constructor.\n module_paths (list, optional): Paths to ... | -7,312,332,245,295,531,000 | Creates a class instance.
Args:
class_or_name: A class, or its name or full path to a class to
instantiate.
kwargs (dict): Keyword arguments for the class constructor.
module_paths (list, optional): Paths to candidate modules to
search for the class. This is used if the class cannot be
... | texar/tf/utils/utils.py | get_instance | awesomemachinelearning/texar | python | def get_instance(class_or_name, kwargs, module_paths=None):
'Creates a class instance.\n\n Args:\n class_or_name: A class, or its name or full path to a class to\n instantiate.\n kwargs (dict): Keyword arguments for the class constructor.\n module_paths (list, optional): Paths to ... |
def check_or_get_instance_with_redundant_kwargs(ins_or_class_or_name, kwargs, module_paths=None, classtype=None):
'Returns a class instance and checks types.\n\n Only those keyword arguments in :attr:`kwargs` that are included in the\n class construction method are used.\n\n Args:\n ins_or_class_or_... | 7,174,078,021,465,491,000 | Returns a class instance and checks types.
Only those keyword arguments in :attr:`kwargs` that are included in the
class construction method are used.
Args:
ins_or_class_or_name: Can be of 3 types:
- A class to instantiate.
- A string of the name or module path to a class to instant... | texar/tf/utils/utils.py | check_or_get_instance_with_redundant_kwargs | awesomemachinelearning/texar | python | def check_or_get_instance_with_redundant_kwargs(ins_or_class_or_name, kwargs, module_paths=None, classtype=None):
'Returns a class instance and checks types.\n\n Only those keyword arguments in :attr:`kwargs` that are included in the\n class construction method are used.\n\n Args:\n ins_or_class_or_... |
def get_instance_with_redundant_kwargs(class_name, kwargs, module_paths=None):
'Creates a class instance.\n\n Only those keyword arguments in :attr:`kwargs` that are included in the\n class construction method are used.\n\n Args:\n class_name (str): A class or its name or module path.\n kwarg... | -2,217,281,050,100,717,800 | Creates a class instance.
Only those keyword arguments in :attr:`kwargs` that are included in the
class construction method are used.
Args:
class_name (str): A class or its name or module path.
kwargs (dict): A dictionary of arguments for the class constructor. It
may include invalid arguments which w... | texar/tf/utils/utils.py | get_instance_with_redundant_kwargs | awesomemachinelearning/texar | python | def get_instance_with_redundant_kwargs(class_name, kwargs, module_paths=None):
'Creates a class instance.\n\n Only those keyword arguments in :attr:`kwargs` that are included in the\n class construction method are used.\n\n Args:\n class_name (str): A class or its name or module path.\n kwarg... |
def get_function(fn_or_name, module_paths=None):
'Returns the function of specified name and module.\n\n Args:\n fn_or_name (str or callable): Name or full path to a function, or the\n function itself.\n module_paths (list, optional): A list of paths to candidate modules to\n ... | 6,214,399,954,028,135,000 | Returns the function of specified name and module.
Args:
fn_or_name (str or callable): Name or full path to a function, or the
function itself.
module_paths (list, optional): A list of paths to candidate modules to
search for the function. This is used only when the function
cannot be l... | texar/tf/utils/utils.py | get_function | awesomemachinelearning/texar | python | def get_function(fn_or_name, module_paths=None):
'Returns the function of specified name and module.\n\n Args:\n fn_or_name (str or callable): Name or full path to a function, or the\n function itself.\n module_paths (list, optional): A list of paths to candidate modules to\n ... |
def call_function_with_redundant_kwargs(fn, kwargs):
"Calls a function and returns the results.\n\n Only those keyword arguments in :attr:`kwargs` that are included in the\n function's argument list are used to call the function.\n\n Args:\n fn (function): A callable. If :attr:`fn` is not a python f... | -4,426,932,169,605,291,500 | Calls a function and returns the results.
Only those keyword arguments in :attr:`kwargs` that are included in the
function's argument list are used to call the function.
Args:
fn (function): A callable. If :attr:`fn` is not a python function,
:attr:`fn.__call__` is called.
kwargs (dict): A `dict` of a... | texar/tf/utils/utils.py | call_function_with_redundant_kwargs | awesomemachinelearning/texar | python | def call_function_with_redundant_kwargs(fn, kwargs):
"Calls a function and returns the results.\n\n Only those keyword arguments in :attr:`kwargs` that are included in the\n function's argument list are used to call the function.\n\n Args:\n fn (function): A callable. If :attr:`fn` is not a python f... |
def get_instance_kwargs(kwargs, hparams):
"Makes a dict of keyword arguments with the following structure:\n\n `kwargs_ = {'hparams': dict(hparams), **kwargs}`.\n\n This is typically used for constructing a module which takes a set of\n arguments as well as a argument named `hparams`.\n\n Args:\n ... | -3,281,419,015,722,989,000 | Makes a dict of keyword arguments with the following structure:
`kwargs_ = {'hparams': dict(hparams), **kwargs}`.
This is typically used for constructing a module which takes a set of
arguments as well as a argument named `hparams`.
Args:
kwargs (dict): A dict of keyword arguments. Can be `None`.
hparams: A ... | texar/tf/utils/utils.py | get_instance_kwargs | awesomemachinelearning/texar | python | def get_instance_kwargs(kwargs, hparams):
"Makes a dict of keyword arguments with the following structure:\n\n `kwargs_ = {'hparams': dict(hparams), **kwargs}`.\n\n This is typically used for constructing a module which takes a set of\n arguments as well as a argument named `hparams`.\n\n Args:\n ... |
def dict_patch(tgt_dict, src_dict):
'Recursively patch :attr:`tgt_dict` by adding items from :attr:`src_dict`\n that do not exist in :attr:`tgt_dict`.\n\n If respective items in :attr:`src_dict` and :attr:`tgt_dict` are both\n `dict`, the :attr:`tgt_dict` item is patched recursively.\n\n Args:\n ... | -3,271,779,255,991,127,600 | Recursively patch :attr:`tgt_dict` by adding items from :attr:`src_dict`
that do not exist in :attr:`tgt_dict`.
If respective items in :attr:`src_dict` and :attr:`tgt_dict` are both
`dict`, the :attr:`tgt_dict` item is patched recursively.
Args:
tgt_dict (dict): Target dictionary to patch.
src_dict (dict): So... | texar/tf/utils/utils.py | dict_patch | awesomemachinelearning/texar | python | def dict_patch(tgt_dict, src_dict):
'Recursively patch :attr:`tgt_dict` by adding items from :attr:`src_dict`\n that do not exist in :attr:`tgt_dict`.\n\n If respective items in :attr:`src_dict` and :attr:`tgt_dict` are both\n `dict`, the :attr:`tgt_dict` item is patched recursively.\n\n Args:\n ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.