code stringlengths 75 104k | docstring stringlengths 1 46.9k |
|---|---|
def FromSpec(self, spec):
"""
Args:
spec: (name, {...}), or Parameter object
Dict keys:
"caption" -- (optional) text for label in editor. Defaults to the
keyword argument name
"toolTip" (optional)
"type" -- (optional, defaults to... | Args:
spec: (name, {...}), or Parameter object
Dict keys:
"caption" -- (optional) text for label in editor. Defaults to the
keyword argument name
"toolTip" (optional)
"type" -- (optional, defaults to type("value") or int if "value" is
... |
def from_ndarray(cls, a_ndarray, bigdl_type="float"):
"""
Convert a ndarray to a DenseTensor which would be used in Java side.
>>> import numpy as np
>>> from bigdl.util.common import JTensor
>>> from bigdl.util.common import callBigDlFunc
>>> np.random.seed(123)
... | Convert a ndarray to a DenseTensor which would be used in Java side.
>>> import numpy as np
>>> from bigdl.util.common import JTensor
>>> from bigdl.util.common import callBigDlFunc
>>> np.random.seed(123)
>>> data = np.random.uniform(0, 1, (2, 3)).astype("float32")
>>> ... |
def _contribute_to_class(self, mcs_args: McsArgs):
"""
Where the magic happens. Takes one parameter, the :class:`McsArgs` of the
class-under-construction, and processes the declared ``class Meta`` from
it (if any). We fill ourself with the declared meta options' name/value pairs,
... | Where the magic happens. Takes one parameter, the :class:`McsArgs` of the
class-under-construction, and processes the declared ``class Meta`` from
it (if any). We fill ourself with the declared meta options' name/value pairs,
give the declared meta options a chance to also contribute to the clas... |
def argparse(argv, parser, arguments):
""" A command line argument parser.
Parses arguments coming from the argv Observable and outputs them as
Argument items in the output observable.
Parameters
-----------
argv : Observable
An Observable of strings.
parser : Observable
An ... | A command line argument parser.
Parses arguments coming from the argv Observable and outputs them as
Argument items in the output observable.
Parameters
-----------
argv : Observable
An Observable of strings.
parser : Observable
An Observable containing one Parser item.
argu... |
def prep_bootstrap(mpt):
'''
Update and get the random script to a random place
CLI Example:
.. code-block:: bash
salt '*' seed.prep_bootstrap /tmp
'''
# Verify that the boostrap script is downloaded
bs_ = __salt__['config.gather_bootstrap_script']()
fpd_ = os.path.join(mpt, ... | Update and get the random script to a random place
CLI Example:
.. code-block:: bash
salt '*' seed.prep_bootstrap /tmp |
def pop(self):
"""Pop an entry off the stack and make its node a child of the last."""
dfa, state, node = self.stack.pop()
if self.stack:
self.stack[-1][2].children.append(node)
else:
self.root = node | Pop an entry off the stack and make its node a child of the last. |
def from_tabledata(self, value, is_overwrite_table_name=True):
"""
Set following attributes from |TableData|
- :py:attr:`~.table_name`.
- :py:attr:`~.headers`.
- :py:attr:`~.value_matrix`.
And create worksheet named from :py:attr:`~.table_name` ABC
if not existe... | Set following attributes from |TableData|
- :py:attr:`~.table_name`.
- :py:attr:`~.headers`.
- :py:attr:`~.value_matrix`.
And create worksheet named from :py:attr:`~.table_name` ABC
if not existed yet.
:param tabledata.TableData value: Input table data. |
def find(max_depth=3):
"""Returns the path of a Pipfile in parent directories."""
i = 0
for c, d, f in walk_up(os.getcwd()):
i += 1
if i < max_depth:
if 'Pipfile':
p = os.path.join(c, 'Pipfile')
if os.path.isfile(p)... | Returns the path of a Pipfile in parent directories. |
def extend_with_ms(self, req, sms_dict):
"""
Add signed metadata statements to a request
:param req: The request
:param sms_dict: A dictionary with FO IDs as keys and signed metadata
statements (sms) or uris pointing to sms as values.
:return: The updated request
... | Add signed metadata statements to a request
:param req: The request
:param sms_dict: A dictionary with FO IDs as keys and signed metadata
statements (sms) or uris pointing to sms as values.
:return: The updated request |
def set_pkg_summary(self, doc, text):
"""Set's the package summary.
Raises CardinalityError if summary already set.
Raises OrderError if no package previously defined.
"""
self.assert_package_exists()
if not self.package_summary_set:
self.package_summary_set =... | Set's the package summary.
Raises CardinalityError if summary already set.
Raises OrderError if no package previously defined. |
def sparql(self, stringa):
""" wrapper around a sparql query """
qres = self.rdfgraph.query(stringa)
return list(qres) | wrapper around a sparql query |
def apply_new_outcome_name(self, path, new_name):
"""Apply the newly entered outcome name it is was changed
:param str path: The path string of the renderer
:param str new_name: Newly entered outcome name
"""
# Don't do anything if outcome name didn't change
if new_name ... | Apply the newly entered outcome name it is was changed
:param str path: The path string of the renderer
:param str new_name: Newly entered outcome name |
def get_favourite_accounts(self) -> List[Account]:
""" Provides a list of favourite accounts """
from gnucash_portfolio.lib.settings import Settings
settings = Settings()
favourite_accts = settings.favourite_accounts
accounts = self.get_list(favourite_accts)
return accou... | Provides a list of favourite accounts |
def metadata_index_json(self):
"""str: Path to the INDEX_JSON file."""
try:
return op.join(self.metadata_dir, 'INDEX.json')
except FileNotFoundError:
return op.join(self.metadata_dir, 'INDEX_JSON') | str: Path to the INDEX_JSON file. |
def load_plugins(self):
"""Refresh the list of available collectors and auditors
Returns:
`None`
"""
for entry_point in CINQ_PLUGINS['cloud_inquisitor.plugins.collectors']['plugins']:
cls = entry_point.load()
if cls.enabled():
self.log... | Refresh the list of available collectors and auditors
Returns:
`None` |
def DirectoryStimuliFactory(loader):
"""
Takes an input path to the images folder of an experiment and generates
automatically the category - filenumber list needed to construct an
appropriate _categories object.
Parameters :
loader : Loader object which contains
impath : s... | Takes an input path to the images folder of an experiment and generates
automatically the category - filenumber list needed to construct an
appropriate _categories object.
Parameters :
loader : Loader object which contains
impath : string
path to the input, i.e. ima... |
def strnum(prefix: str, num: int, suffix: str = "") -> str:
"""
Makes a string of the format ``<prefix><number><suffix>``.
"""
return "{}{}{}".format(prefix, num, suffix) | Makes a string of the format ``<prefix><number><suffix>``. |
def proper_path(path):
"""
Clean up the path specification so it looks like something I could use.
"./" <path> "/"
"""
if path.startswith("./"):
pass
elif path.startswith("/"):
path = ".%s" % path
elif path.startswith("."):
while path.startswith("."):
path... | Clean up the path specification so it looks like something I could use.
"./" <path> "/" |
def record(self, person, event, properties=None, timestamp=None,
path=KISSmetrics.RECORD_PATH):
"""Record `event` for `person` with any `properties`.
:param person: the individual performing the `event`
:param event: the `event` name that was performed
:param properties: ... | Record `event` for `person` with any `properties`.
:param person: the individual performing the `event`
:param event: the `event` name that was performed
:param properties: any additional data to include
:type properties: dict
:param timestamp: when the `event` was performed; op... |
def _processHandler(self, securityHandler, param_dict):
"""proceses the handler and returns the cookiejar"""
cj = None
handler = None
if securityHandler is None:
cj = cookiejar.CookieJar()
elif securityHandler.method.lower() == "token" or \
securityHandle... | proceses the handler and returns the cookiejar |
def find_jump_targets(self, debug):
"""
Detect all offsets in a byte code which are jump targets
where we might insert a COME_FROM instruction.
Return the list of offsets.
Return the list of offsets. An instruction can be jumped
to in from multiple instructions.
... | Detect all offsets in a byte code which are jump targets
where we might insert a COME_FROM instruction.
Return the list of offsets.
Return the list of offsets. An instruction can be jumped
to in from multiple instructions. |
def xmoe2_v1_l4k():
"""With sequence length 4096."""
hparams = xmoe2_v1()
hparams.batch_size = 32
hparams.max_length = 4096
hparams.split_to_length = 4096
hparams.reshape_logits_hack = True
return hparams | With sequence length 4096. |
def all_files_in_directory(path):
""" Recursively ist all files under a directory """
file_list = []
for dirname, dirnames, filenames in os.walk(path):
for filename in filenames:
file_list.append(os.path.join(dirname, filename))
return file_list | Recursively ist all files under a directory |
def comicPageLink(self, comic, url, prevUrl):
"""Write previous link into JSON."""
pageInfo = self.getPageInfo(comic, url)
pageInfo['prev'] = prevUrl | Write previous link into JSON. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.