repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
project-rig/rig | rig/machine_control/machine_controller.py | SlicedMemoryIO.write | def write(self, bytes):
"""Write data to the memory.
.. note::
Writes beyond the specified memory range will be truncated and a
:py:exc:`.TruncationWarning` is produced. These warnings can be
converted into exceptions using :py:func:`warnings.simplefilter`::
... | python | def write(self, bytes):
"""Write data to the memory.
.. note::
Writes beyond the specified memory range will be truncated and a
:py:exc:`.TruncationWarning` is produced. These warnings can be
converted into exceptions using :py:func:`warnings.simplefilter`::
... | [
"def",
"write",
"(",
"self",
",",
"bytes",
")",
":",
"if",
"self",
".",
"address",
"+",
"len",
"(",
"bytes",
")",
">",
"self",
".",
"_end_address",
":",
"n_bytes",
"=",
"self",
".",
"_end_address",
"-",
"self",
".",
"address",
"warnings",
".",
"warn"... | Write data to the memory.
.. note::
Writes beyond the specified memory range will be truncated and a
:py:exc:`.TruncationWarning` is produced. These warnings can be
converted into exceptions using :py:func:`warnings.simplefilter`::
>>> import warnings
... | [
"Write",
"data",
"to",
"the",
"memory",
"."
] | train | https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/machine_controller.py#L2635-L2671 |
project-rig/rig | rig/machine_control/machine_controller.py | SlicedMemoryIO.seek | def seek(self, n_bytes, from_what=os.SEEK_SET):
"""Seek to a new position in the memory region.
Parameters
----------
n_bytes : int
Number of bytes to seek.
from_what : int
As in the Python standard: `0` seeks from the start of the memory
regi... | python | def seek(self, n_bytes, from_what=os.SEEK_SET):
"""Seek to a new position in the memory region.
Parameters
----------
n_bytes : int
Number of bytes to seek.
from_what : int
As in the Python standard: `0` seeks from the start of the memory
regi... | [
"def",
"seek",
"(",
"self",
",",
"n_bytes",
",",
"from_what",
"=",
"os",
".",
"SEEK_SET",
")",
":",
"if",
"from_what",
"==",
"0",
":",
"self",
".",
"_offset",
"=",
"n_bytes",
"elif",
"from_what",
"==",
"1",
":",
"self",
".",
"_offset",
"+=",
"n_bytes... | Seek to a new position in the memory region.
Parameters
----------
n_bytes : int
Number of bytes to seek.
from_what : int
As in the Python standard: `0` seeks from the start of the memory
region, `1` seeks from the current position and `2` seeks from ... | [
"Seek",
"to",
"a",
"new",
"position",
"in",
"the",
"memory",
"region",
"."
] | train | https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/machine_controller.py#L2706-L2735 |
project-rig/rig | rig/machine_control/machine_controller.py | MemoryIO.free | def free(self):
"""Free the memory referred to by the file-like, any subsequent
operations on this file-like or slices of it will fail.
"""
# Free the memory
self._machine_controller.sdram_free(self._start_address,
self._x, self._y)
... | python | def free(self):
"""Free the memory referred to by the file-like, any subsequent
operations on this file-like or slices of it will fail.
"""
# Free the memory
self._machine_controller.sdram_free(self._start_address,
self._x, self._y)
... | [
"def",
"free",
"(",
"self",
")",
":",
"# Free the memory",
"self",
".",
"_machine_controller",
".",
"sdram_free",
"(",
"self",
".",
"_start_address",
",",
"self",
".",
"_x",
",",
"self",
".",
"_y",
")",
"# Mark as freed",
"self",
".",
"_freed",
"=",
"True"... | Free the memory referred to by the file-like, any subsequent
operations on this file-like or slices of it will fail. | [
"Free",
"the",
"memory",
"referred",
"to",
"by",
"the",
"file",
"-",
"like",
"any",
"subsequent",
"operations",
"on",
"this",
"file",
"-",
"like",
"or",
"slices",
"of",
"it",
"will",
"fail",
"."
] | train | https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/machine_controller.py#L2810-L2819 |
project-rig/rig | rig/machine_control/machine_controller.py | MemoryIO._perform_read | def _perform_read(self, addr, size):
"""Perform a read using the machine controller."""
return self._machine_controller.read(addr, size, self._x, self._y, 0) | python | def _perform_read(self, addr, size):
"""Perform a read using the machine controller."""
return self._machine_controller.read(addr, size, self._x, self._y, 0) | [
"def",
"_perform_read",
"(",
"self",
",",
"addr",
",",
"size",
")",
":",
"return",
"self",
".",
"_machine_controller",
".",
"read",
"(",
"addr",
",",
"size",
",",
"self",
".",
"_x",
",",
"self",
".",
"_y",
",",
"0",
")"
] | Perform a read using the machine controller. | [
"Perform",
"a",
"read",
"using",
"the",
"machine",
"controller",
"."
] | train | https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/machine_controller.py#L2822-L2824 |
project-rig/rig | rig/machine_control/machine_controller.py | MemoryIO._perform_write | def _perform_write(self, addr, data):
"""Perform a write using the machine controller."""
return self._machine_controller.write(addr, data, self._x, self._y, 0) | python | def _perform_write(self, addr, data):
"""Perform a write using the machine controller."""
return self._machine_controller.write(addr, data, self._x, self._y, 0) | [
"def",
"_perform_write",
"(",
"self",
",",
"addr",
",",
"data",
")",
":",
"return",
"self",
".",
"_machine_controller",
".",
"write",
"(",
"addr",
",",
"data",
",",
"self",
".",
"_x",
",",
"self",
".",
"_y",
",",
"0",
")"
] | Perform a write using the machine controller. | [
"Perform",
"a",
"write",
"using",
"the",
"machine",
"controller",
"."
] | train | https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/machine_controller.py#L2827-L2829 |
project-rig/rig | rig/machine_control/packets.py | _unpack_sdp_into_packet | def _unpack_sdp_into_packet(packet, bytestring):
"""Unpack the SDP header from a bytestring into a packet.
Parameters
----------
packet : :py:class:`.SDPPacket`
Packet into which to store the unpacked header.
bytestring : bytes
Bytes from which to unpack the header data.
"""
... | python | def _unpack_sdp_into_packet(packet, bytestring):
"""Unpack the SDP header from a bytestring into a packet.
Parameters
----------
packet : :py:class:`.SDPPacket`
Packet into which to store the unpacked header.
bytestring : bytes
Bytes from which to unpack the header data.
"""
... | [
"def",
"_unpack_sdp_into_packet",
"(",
"packet",
",",
"bytestring",
")",
":",
"# Extract the header and the data from the packet",
"packet",
".",
"data",
"=",
"bytestring",
"[",
"10",
":",
"]",
"# Everything but the header",
"# Unpack the header",
"(",
"flags",
",",
"pa... | Unpack the SDP header from a bytestring into a packet.
Parameters
----------
packet : :py:class:`.SDPPacket`
Packet into which to store the unpacked header.
bytestring : bytes
Bytes from which to unpack the header data. | [
"Unpack",
"the",
"SDP",
"header",
"from",
"a",
"bytestring",
"into",
"a",
"packet",
"."
] | train | https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/packets.py#L237-L260 |
project-rig/rig | rig/machine_control/packets.py | SCPPacket.packed_data | def packed_data(self):
"""Pack the data for the SCP packet."""
# Pack the header
scp_header = struct.pack("<2H", self.cmd_rc, self.seq)
# Potential loop intentionally unrolled
if self.arg1 is not None:
scp_header += struct.pack('<I', self.arg1)
if self.arg2 i... | python | def packed_data(self):
"""Pack the data for the SCP packet."""
# Pack the header
scp_header = struct.pack("<2H", self.cmd_rc, self.seq)
# Potential loop intentionally unrolled
if self.arg1 is not None:
scp_header += struct.pack('<I', self.arg1)
if self.arg2 i... | [
"def",
"packed_data",
"(",
"self",
")",
":",
"# Pack the header",
"scp_header",
"=",
"struct",
".",
"pack",
"(",
"\"<2H\"",
",",
"self",
".",
"cmd_rc",
",",
"self",
".",
"seq",
")",
"# Potential loop intentionally unrolled",
"if",
"self",
".",
"arg1",
"is",
... | Pack the data for the SCP packet. | [
"Pack",
"the",
"data",
"for",
"the",
"SCP",
"packet",
"."
] | train | https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/packets.py#L208-L222 |
Parsely/probably | probably/hashfunctions.py | hash64 | def hash64(key, seed):
"""
Wrapper around mmh3.hash64 to get us single 64-bit value.
This also does the extra work of ensuring that we always treat the
returned values as big-endian unsigned long, like smhasher used to
do.
"""
hash_val = mmh3.hash64(key, seed)[0]
return struct.unpack('>... | python | def hash64(key, seed):
"""
Wrapper around mmh3.hash64 to get us single 64-bit value.
This also does the extra work of ensuring that we always treat the
returned values as big-endian unsigned long, like smhasher used to
do.
"""
hash_val = mmh3.hash64(key, seed)[0]
return struct.unpack('>... | [
"def",
"hash64",
"(",
"key",
",",
"seed",
")",
":",
"hash_val",
"=",
"mmh3",
".",
"hash64",
"(",
"key",
",",
"seed",
")",
"[",
"0",
"]",
"return",
"struct",
".",
"unpack",
"(",
"'>Q'",
",",
"struct",
".",
"pack",
"(",
"'q'",
",",
"hash_val",
")",... | Wrapper around mmh3.hash64 to get us single 64-bit value.
This also does the extra work of ensuring that we always treat the
returned values as big-endian unsigned long, like smhasher used to
do. | [
"Wrapper",
"around",
"mmh3",
".",
"hash64",
"to",
"get",
"us",
"single",
"64",
"-",
"bit",
"value",
"."
] | train | https://github.com/Parsely/probably/blob/5d80855c1645fb2813678d5bcfe6108e33d80b9e/probably/hashfunctions.py#L8-L17 |
Parsely/probably | probably/hashfunctions.py | generate_hashfunctions | def generate_hashfunctions(nbr_bits, nbr_slices):
"""Generate a set of hash functions.
The core method is a 64-bit murmur3 hash which has a good distribution.
Multiple hashes can be generate using the previous hash value as a seed.
"""
def _make_hashfuncs(key):
if isinstance(key, text_type)... | python | def generate_hashfunctions(nbr_bits, nbr_slices):
"""Generate a set of hash functions.
The core method is a 64-bit murmur3 hash which has a good distribution.
Multiple hashes can be generate using the previous hash value as a seed.
"""
def _make_hashfuncs(key):
if isinstance(key, text_type)... | [
"def",
"generate_hashfunctions",
"(",
"nbr_bits",
",",
"nbr_slices",
")",
":",
"def",
"_make_hashfuncs",
"(",
"key",
")",
":",
"if",
"isinstance",
"(",
"key",
",",
"text_type",
")",
":",
"key",
"=",
"key",
".",
"encode",
"(",
"'utf-8'",
")",
"else",
":",... | Generate a set of hash functions.
The core method is a 64-bit murmur3 hash which has a good distribution.
Multiple hashes can be generate using the previous hash value as a seed. | [
"Generate",
"a",
"set",
"of",
"hash",
"functions",
"."
] | train | https://github.com/Parsely/probably/blob/5d80855c1645fb2813678d5bcfe6108e33d80b9e/probably/hashfunctions.py#L20-L38 |
project-rig/rig | rig/utils/contexts.py | ContextMixin.get_context_arguments | def get_context_arguments(self):
"""Return a dictionary containing the current context arguments."""
cargs = {}
for context in self.__context_stack:
cargs.update(context.context_arguments)
return cargs | python | def get_context_arguments(self):
"""Return a dictionary containing the current context arguments."""
cargs = {}
for context in self.__context_stack:
cargs.update(context.context_arguments)
return cargs | [
"def",
"get_context_arguments",
"(",
"self",
")",
":",
"cargs",
"=",
"{",
"}",
"for",
"context",
"in",
"self",
".",
"__context_stack",
":",
"cargs",
".",
"update",
"(",
"context",
".",
"context_arguments",
")",
"return",
"cargs"
] | Return a dictionary containing the current context arguments. | [
"Return",
"a",
"dictionary",
"containing",
"the",
"current",
"context",
"arguments",
"."
] | train | https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/utils/contexts.py#L83-L88 |
project-rig/rig | rig/utils/contexts.py | ContextMixin.use_contextual_arguments | def use_contextual_arguments(**kw_only_args_defaults):
"""Decorator function which allows the wrapped function to accept
arguments not specified in the call from the context.
Arguments whose default value is set to the Required sentinel must be
supplied either by the context or the call... | python | def use_contextual_arguments(**kw_only_args_defaults):
"""Decorator function which allows the wrapped function to accept
arguments not specified in the call from the context.
Arguments whose default value is set to the Required sentinel must be
supplied either by the context or the call... | [
"def",
"use_contextual_arguments",
"(",
"*",
"*",
"kw_only_args_defaults",
")",
":",
"def",
"decorator",
"(",
"f",
")",
":",
"# Extract any positional and positional-and-key-word arguments",
"# which may be set.",
"arg_names",
",",
"varargs",
",",
"keywords",
",",
"defaul... | Decorator function which allows the wrapped function to accept
arguments not specified in the call from the context.
Arguments whose default value is set to the Required sentinel must be
supplied either by the context or the caller and a TypeError is raised
if not.
.. warning::... | [
"Decorator",
"function",
"which",
"allows",
"the",
"wrapped",
"function",
"to",
"accept",
"arguments",
"not",
"specified",
"in",
"the",
"call",
"from",
"the",
"context",
"."
] | train | https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/utils/contexts.py#L91-L175 |
project-rig/rig | rig/routing_table/ordered_covering.py | minimise | def minimise(routing_table, target_length):
"""Reduce the size of a routing table by merging together entries where
possible and by removing any remaining default routes.
.. warning::
The input routing table *must* also include entries which could be
removed and replaced by default routing... | python | def minimise(routing_table, target_length):
"""Reduce the size of a routing table by merging together entries where
possible and by removing any remaining default routes.
.. warning::
The input routing table *must* also include entries which could be
removed and replaced by default routing... | [
"def",
"minimise",
"(",
"routing_table",
",",
"target_length",
")",
":",
"table",
",",
"_",
"=",
"ordered_covering",
"(",
"routing_table",
",",
"target_length",
",",
"no_raise",
"=",
"True",
")",
"return",
"remove_default_routes",
"(",
"table",
",",
"target_leng... | Reduce the size of a routing table by merging together entries where
possible and by removing any remaining default routes.
.. warning::
The input routing table *must* also include entries which could be
removed and replaced by default routing.
.. warning::
It is assumed that the... | [
"Reduce",
"the",
"size",
"of",
"a",
"routing",
"table",
"by",
"merging",
"together",
"entries",
"where",
"possible",
"and",
"by",
"removing",
"any",
"remaining",
"default",
"routes",
"."
] | train | https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/routing_table/ordered_covering.py#L134-L185 |
project-rig/rig | rig/routing_table/ordered_covering.py | ordered_covering | def ordered_covering(routing_table, target_length, aliases=dict(),
no_raise=False):
"""Reduce the size of a routing table by merging together entries where
possible.
.. warning::
The input routing table *must* also include entries which could be
removed and replaced by... | python | def ordered_covering(routing_table, target_length, aliases=dict(),
no_raise=False):
"""Reduce the size of a routing table by merging together entries where
possible.
.. warning::
The input routing table *must* also include entries which could be
removed and replaced by... | [
"def",
"ordered_covering",
"(",
"routing_table",
",",
"target_length",
",",
"aliases",
"=",
"dict",
"(",
")",
",",
"no_raise",
"=",
"False",
")",
":",
"# Copy the aliases dictionary",
"aliases",
"=",
"dict",
"(",
"aliases",
")",
"# Perform an initial sort of the rou... | Reduce the size of a routing table by merging together entries where
possible.
.. warning::
The input routing table *must* also include entries which could be
removed and replaced by default routing.
.. warning::
It is assumed that the input routing table is not in any particular... | [
"Reduce",
"the",
"size",
"of",
"a",
"routing",
"table",
"by",
"merging",
"together",
"entries",
"where",
"possible",
"."
] | train | https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/routing_table/ordered_covering.py#L188-L285 |
project-rig/rig | rig/routing_table/ordered_covering.py | _get_generality | def _get_generality(key, mask):
"""Count the number of Xs in the key-mask pair.
For example, there are 32 Xs in ``0x00000000/0x00000000``::
>>> _get_generality(0x0, 0x0)
32
And no Xs in ``0xffffffff/0xffffffff``::
>>> _get_generality(0xffffffff, 0xffffffff)
0
"""
... | python | def _get_generality(key, mask):
"""Count the number of Xs in the key-mask pair.
For example, there are 32 Xs in ``0x00000000/0x00000000``::
>>> _get_generality(0x0, 0x0)
32
And no Xs in ``0xffffffff/0xffffffff``::
>>> _get_generality(0xffffffff, 0xffffffff)
0
"""
... | [
"def",
"_get_generality",
"(",
"key",
",",
"mask",
")",
":",
"xs",
"=",
"(",
"~",
"key",
")",
"&",
"(",
"~",
"mask",
")",
"return",
"sum",
"(",
"1",
"for",
"i",
"in",
"range",
"(",
"32",
")",
"if",
"xs",
"&",
"(",
"1",
"<<",
"i",
")",
")"
] | Count the number of Xs in the key-mask pair.
For example, there are 32 Xs in ``0x00000000/0x00000000``::
>>> _get_generality(0x0, 0x0)
32
And no Xs in ``0xffffffff/0xffffffff``::
>>> _get_generality(0xffffffff, 0xffffffff)
0 | [
"Count",
"the",
"number",
"of",
"Xs",
"in",
"the",
"key",
"-",
"mask",
"pair",
"."
] | train | https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/routing_table/ordered_covering.py#L288-L302 |
project-rig/rig | rig/routing_table/ordered_covering.py | _get_best_merge | def _get_best_merge(routing_table, aliases):
"""Inspect all possible merges for the routing table and return the merge
which would combine the greatest number of entries.
Returns
-------
:py:class:`~.Merge`
"""
# Create an empty merge to start with
best_merge = _Merge(routing_table)
... | python | def _get_best_merge(routing_table, aliases):
"""Inspect all possible merges for the routing table and return the merge
which would combine the greatest number of entries.
Returns
-------
:py:class:`~.Merge`
"""
# Create an empty merge to start with
best_merge = _Merge(routing_table)
... | [
"def",
"_get_best_merge",
"(",
"routing_table",
",",
"aliases",
")",
":",
"# Create an empty merge to start with",
"best_merge",
"=",
"_Merge",
"(",
"routing_table",
")",
"best_goodness",
"=",
"0",
"# Look through every merge, discarding those that are no better than the",
"# b... | Inspect all possible merges for the routing table and return the merge
which would combine the greatest number of entries.
Returns
-------
:py:class:`~.Merge` | [
"Inspect",
"all",
"possible",
"merges",
"for",
"the",
"routing",
"table",
"and",
"return",
"the",
"merge",
"which",
"would",
"combine",
"the",
"greatest",
"number",
"of",
"entries",
"."
] | train | https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/routing_table/ordered_covering.py#L305-L336 |
project-rig/rig | rig/routing_table/ordered_covering.py | _get_all_merges | def _get_all_merges(routing_table):
"""Get possible sets of entries to merge.
Yields
------
:py:class:`~.Merge`
"""
# Memorise entries that have been considered as part of a merge
considered_entries = set()
for i, entry in enumerate(routing_table):
# If we've already considered... | python | def _get_all_merges(routing_table):
"""Get possible sets of entries to merge.
Yields
------
:py:class:`~.Merge`
"""
# Memorise entries that have been considered as part of a merge
considered_entries = set()
for i, entry in enumerate(routing_table):
# If we've already considered... | [
"def",
"_get_all_merges",
"(",
"routing_table",
")",
":",
"# Memorise entries that have been considered as part of a merge",
"considered_entries",
"=",
"set",
"(",
")",
"for",
"i",
",",
"entry",
"in",
"enumerate",
"(",
"routing_table",
")",
":",
"# If we've already consid... | Get possible sets of entries to merge.
Yields
------
:py:class:`~.Merge` | [
"Get",
"possible",
"sets",
"of",
"entries",
"to",
"merge",
"."
] | train | https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/routing_table/ordered_covering.py#L339-L367 |
project-rig/rig | rig/routing_table/ordered_covering.py | _get_insertion_index | def _get_insertion_index(routing_table, generality):
"""Determine the index in the routing table where a new entry should be
inserted.
"""
# We insert before blocks of equivalent generality, so decrement the given
# generality.
generality -= 1
# Wrapper for _get_generality which accepts a r... | python | def _get_insertion_index(routing_table, generality):
"""Determine the index in the routing table where a new entry should be
inserted.
"""
# We insert before blocks of equivalent generality, so decrement the given
# generality.
generality -= 1
# Wrapper for _get_generality which accepts a r... | [
"def",
"_get_insertion_index",
"(",
"routing_table",
",",
"generality",
")",
":",
"# We insert before blocks of equivalent generality, so decrement the given",
"# generality.",
"generality",
"-=",
"1",
"# Wrapper for _get_generality which accepts a routing entry",
"def",
"gg",
"(",
... | Determine the index in the routing table where a new entry should be
inserted. | [
"Determine",
"the",
"index",
"in",
"the",
"routing",
"table",
"where",
"a",
"new",
"entry",
"should",
"be",
"inserted",
"."
] | train | https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/routing_table/ordered_covering.py#L370-L402 |
project-rig/rig | rig/routing_table/ordered_covering.py | _refine_merge | def _refine_merge(merge, aliases, min_goodness):
"""Remove entries from a merge to generate a valid merge which may be
applied to the routing table.
Parameters
----------
merge : :py:class:`~.Merge`
Initial merge to refine.
aliases : {(key, mask): {(key, mask), ...}, ...}
Map of... | python | def _refine_merge(merge, aliases, min_goodness):
"""Remove entries from a merge to generate a valid merge which may be
applied to the routing table.
Parameters
----------
merge : :py:class:`~.Merge`
Initial merge to refine.
aliases : {(key, mask): {(key, mask), ...}, ...}
Map of... | [
"def",
"_refine_merge",
"(",
"merge",
",",
"aliases",
",",
"min_goodness",
")",
":",
"# Perform the down-check",
"merge",
"=",
"_refine_downcheck",
"(",
"merge",
",",
"aliases",
",",
"min_goodness",
")",
"# If the merge is still sufficiently good then continue to refine it.... | Remove entries from a merge to generate a valid merge which may be
applied to the routing table.
Parameters
----------
merge : :py:class:`~.Merge`
Initial merge to refine.
aliases : {(key, mask): {(key, mask), ...}, ...}
Map of key-mask pairs to the sets of key-mask pairs that they ... | [
"Remove",
"entries",
"from",
"a",
"merge",
"to",
"generate",
"a",
"valid",
"merge",
"which",
"may",
"be",
"applied",
"to",
"the",
"routing",
"table",
"."
] | train | https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/routing_table/ordered_covering.py#L516-L550 |
project-rig/rig | rig/routing_table/ordered_covering.py | _refine_upcheck | def _refine_upcheck(merge, min_goodness):
"""Remove from the merge any entries which would be covered by entries
between their current position and the merge insertion position.
For example, the third entry of::
0011 -> N
0100 -> N
1000 -> N
X000 -> NE
Cannot be merged... | python | def _refine_upcheck(merge, min_goodness):
"""Remove from the merge any entries which would be covered by entries
between their current position and the merge insertion position.
For example, the third entry of::
0011 -> N
0100 -> N
1000 -> N
X000 -> NE
Cannot be merged... | [
"def",
"_refine_upcheck",
"(",
"merge",
",",
"min_goodness",
")",
":",
"# Remove any entries which would be covered by entries above the merge",
"# position.",
"changed",
"=",
"False",
"for",
"i",
"in",
"sorted",
"(",
"merge",
".",
"entries",
",",
"reverse",
"=",
"Tru... | Remove from the merge any entries which would be covered by entries
between their current position and the merge insertion position.
For example, the third entry of::
0011 -> N
0100 -> N
1000 -> N
X000 -> NE
Cannot be merged with the first two entries because that would ge... | [
"Remove",
"from",
"the",
"merge",
"any",
"entries",
"which",
"would",
"be",
"covered",
"by",
"entries",
"between",
"their",
"current",
"position",
"and",
"the",
"merge",
"insertion",
"position",
"."
] | train | https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/routing_table/ordered_covering.py#L553-L598 |
project-rig/rig | rig/routing_table/ordered_covering.py | _refine_downcheck | def _refine_downcheck(merge, aliases, min_goodness):
"""Prune the merge to avoid it covering up any entries which are below the
merge insertion position.
For example, in the (non-orthogonal) table::
00001 -> N S
00011 -> N S
00100 -> N S
00X00 -> N S
XX1XX -> 3 5
... | python | def _refine_downcheck(merge, aliases, min_goodness):
"""Prune the merge to avoid it covering up any entries which are below the
merge insertion position.
For example, in the (non-orthogonal) table::
00001 -> N S
00011 -> N S
00100 -> N S
00X00 -> N S
XX1XX -> 3 5
... | [
"def",
"_refine_downcheck",
"(",
"merge",
",",
"aliases",
",",
"min_goodness",
")",
":",
"# Operation",
"# ---------",
"# While the merge is still better than `min_goodness` we determine which",
"# entries below it in the table it covers. For each of these covered",
"# entries we find wh... | Prune the merge to avoid it covering up any entries which are below the
merge insertion position.
For example, in the (non-orthogonal) table::
00001 -> N S
00011 -> N S
00100 -> N S
00X00 -> N S
XX1XX -> 3 5
Merging the first four entries would generate the new key... | [
"Prune",
"the",
"merge",
"to",
"avoid",
"it",
"covering",
"up",
"any",
"entries",
"which",
"are",
"below",
"the",
"merge",
"insertion",
"position",
"."
] | train | https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/routing_table/ordered_covering.py#L601-L801 |
project-rig/rig | rig/routing_table/ordered_covering.py | _get_covered_keys_and_masks | def _get_covered_keys_and_masks(merge, aliases):
"""Get keys and masks which would be covered by the entry resulting from
the merge.
Parameters
----------
aliases : {(key, mask): {(key, mask), ...}, ...}
Map of key-mask pairs to the sets of key-mask pairs that they actually
represen... | python | def _get_covered_keys_and_masks(merge, aliases):
"""Get keys and masks which would be covered by the entry resulting from
the merge.
Parameters
----------
aliases : {(key, mask): {(key, mask), ...}, ...}
Map of key-mask pairs to the sets of key-mask pairs that they actually
represen... | [
"def",
"_get_covered_keys_and_masks",
"(",
"merge",
",",
"aliases",
")",
":",
"# For every entry in the table below the insertion index see which keys",
"# and masks would overlap with the key and mask of the merged entry.",
"for",
"entry",
"in",
"merge",
".",
"routing_table",
"[",
... | Get keys and masks which would be covered by the entry resulting from
the merge.
Parameters
----------
aliases : {(key, mask): {(key, mask), ...}, ...}
Map of key-mask pairs to the sets of key-mask pairs that they actually
represent.
Yields
------
(key, mask)
Pairs ... | [
"Get",
"keys",
"and",
"masks",
"which",
"would",
"be",
"covered",
"by",
"the",
"entry",
"resulting",
"from",
"the",
"merge",
"."
] | train | https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/routing_table/ordered_covering.py#L804-L828 |
project-rig/rig | rig/routing_table/ordered_covering.py | _Merge.apply | def apply(self, aliases):
"""Apply the merge to the routing table it is defined against and get a
new routing table and alias dictionary.
Returns
-------
[:py:class:`~rig.routing_table.RoutingTableEntry`, ...]
A new routing table which may be minimised further.
... | python | def apply(self, aliases):
"""Apply the merge to the routing table it is defined against and get a
new routing table and alias dictionary.
Returns
-------
[:py:class:`~rig.routing_table.RoutingTableEntry`, ...]
A new routing table which may be minimised further.
... | [
"def",
"apply",
"(",
"self",
",",
"aliases",
")",
":",
"# Create a new routing table of the correct size",
"new_size",
"=",
"len",
"(",
"self",
".",
"routing_table",
")",
"-",
"len",
"(",
"self",
".",
"entries",
")",
"+",
"1",
"new_table",
"=",
"[",
"None",
... | Apply the merge to the routing table it is defined against and get a
new routing table and alias dictionary.
Returns
-------
[:py:class:`~rig.routing_table.RoutingTableEntry`, ...]
A new routing table which may be minimised further.
{(key, mask): {(key, mask), ...}}
... | [
"Apply",
"the",
"merge",
"to",
"the",
"routing",
"table",
"it",
"is",
"defined",
"against",
"and",
"get",
"a",
"new",
"routing",
"table",
"and",
"alias",
"dictionary",
"."
] | train | https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/routing_table/ordered_covering.py#L464-L513 |
Metatab/metapack | metapack/cli/install_file.py | find_packages | def find_packages(name, pkg_dir):
"""Locate pre-built packages in the _packages directory"""
for c in (FileSystemPackageBuilder, ZipPackageBuilder, ExcelPackageBuilder):
package_path, cache_path = c.make_package_path(pkg_dir, name)
if package_path.exists():
yield c.type_code, pack... | python | def find_packages(name, pkg_dir):
"""Locate pre-built packages in the _packages directory"""
for c in (FileSystemPackageBuilder, ZipPackageBuilder, ExcelPackageBuilder):
package_path, cache_path = c.make_package_path(pkg_dir, name)
if package_path.exists():
yield c.type_code, pack... | [
"def",
"find_packages",
"(",
"name",
",",
"pkg_dir",
")",
":",
"for",
"c",
"in",
"(",
"FileSystemPackageBuilder",
",",
"ZipPackageBuilder",
",",
"ExcelPackageBuilder",
")",
":",
"package_path",
",",
"cache_path",
"=",
"c",
".",
"make_package_path",
"(",
"pkg_dir... | Locate pre-built packages in the _packages directory | [
"Locate",
"pre",
"-",
"built",
"packages",
"in",
"the",
"_packages",
"directory"
] | train | https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/cli/install_file.py#L60-L68 |
Metatab/metapack | metapack/cli/new.py | new_args | def new_args(subparsers):
"""
The `mp new` command creates source package directories
with a proper name, a `.gitignore` file, and optionally, example data,
entries and code. Typical usage, for creating a new package with most
of the example options, is ::
mp new -o metatab.org -d tutor... | python | def new_args(subparsers):
"""
The `mp new` command creates source package directories
with a proper name, a `.gitignore` file, and optionally, example data,
entries and code. Typical usage, for creating a new package with most
of the example options, is ::
mp new -o metatab.org -d tutor... | [
"def",
"new_args",
"(",
"subparsers",
")",
":",
"parser",
"=",
"subparsers",
".",
"add_parser",
"(",
"'new'",
",",
"help",
"=",
"'Create new Metatab packages'",
",",
"description",
"=",
"new_args",
".",
"__doc__",
",",
"formatter_class",
"=",
"argparse",
".",
... | The `mp new` command creates source package directories
with a proper name, a `.gitignore` file, and optionally, example data,
entries and code. Typical usage, for creating a new package with most
of the example options, is ::
mp new -o metatab.org -d tutorial -L -E -T "Quickstart Example Packa... | [
"The",
"mp",
"new",
"command",
"creates",
"source",
"package",
"directories",
"with",
"a",
"proper",
"name",
"a",
".",
"gitignore",
"file",
"and",
"optionally",
"example",
"data",
"entries",
"and",
"code",
".",
"Typical",
"usage",
"for",
"creating",
"a",
"ne... | train | https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/cli/new.py#L29-L83 |
Parsely/probably | probably/temporal_daily.py | DailyTemporalBloomFilter.initialize_bitarray | def initialize_bitarray(self):
"""Initialize both bitarray.
This BF contain two bit arrays instead of single one like a plain BF. bitarray
is the main bit array where all the historical items are stored. It's the one
used for the membership query. The second one, current_day_bitarray is... | python | def initialize_bitarray(self):
"""Initialize both bitarray.
This BF contain two bit arrays instead of single one like a plain BF. bitarray
is the main bit array where all the historical items are stored. It's the one
used for the membership query. The second one, current_day_bitarray is... | [
"def",
"initialize_bitarray",
"(",
"self",
")",
":",
"self",
".",
"bitarray",
"=",
"bitarray",
".",
"bitarray",
"(",
"self",
".",
"nbr_bits",
")",
"self",
".",
"current_day_bitarray",
"=",
"bitarray",
".",
"bitarray",
"(",
"self",
".",
"nbr_bits",
")",
"se... | Initialize both bitarray.
This BF contain two bit arrays instead of single one like a plain BF. bitarray
is the main bit array where all the historical items are stored. It's the one
used for the membership query. The second one, current_day_bitarray is the one
used for creating the dai... | [
"Initialize",
"both",
"bitarray",
"."
] | train | https://github.com/Parsely/probably/blob/5d80855c1645fb2813678d5bcfe6108e33d80b9e/probably/temporal_daily.py#L51-L62 |
Parsely/probably | probably/temporal_daily.py | DailyTemporalBloomFilter.initialize_period | def initialize_period(self, period=None):
"""Initialize the period of BF.
:period: datetime.datetime for setting the period explicity.
"""
if not period:
self.current_period = dt.datetime.now()
else:
self.current_period = period
self.current_perio... | python | def initialize_period(self, period=None):
"""Initialize the period of BF.
:period: datetime.datetime for setting the period explicity.
"""
if not period:
self.current_period = dt.datetime.now()
else:
self.current_period = period
self.current_perio... | [
"def",
"initialize_period",
"(",
"self",
",",
"period",
"=",
"None",
")",
":",
"if",
"not",
"period",
":",
"self",
".",
"current_period",
"=",
"dt",
".",
"datetime",
".",
"now",
"(",
")",
"else",
":",
"self",
".",
"current_period",
"=",
"period",
"self... | Initialize the period of BF.
:period: datetime.datetime for setting the period explicity. | [
"Initialize",
"the",
"period",
"of",
"BF",
"."
] | train | https://github.com/Parsely/probably/blob/5d80855c1645fb2813678d5bcfe6108e33d80b9e/probably/temporal_daily.py#L87-L97 |
Parsely/probably | probably/temporal_daily.py | DailyTemporalBloomFilter.warm | def warm(self, jittering_ratio=0.2):
"""Progressively load the previous snapshot during the day.
Loading all the snapshots at once can takes a substantial amount of time. This method, if called
periodically during the day will progressively load those snapshots one by one. Because many workers ... | python | def warm(self, jittering_ratio=0.2):
"""Progressively load the previous snapshot during the day.
Loading all the snapshots at once can takes a substantial amount of time. This method, if called
periodically during the day will progressively load those snapshots one by one. Because many workers ... | [
"def",
"warm",
"(",
"self",
",",
"jittering_ratio",
"=",
"0.2",
")",
":",
"if",
"self",
".",
"snapshot_to_load",
"==",
"None",
":",
"last_period",
"=",
"self",
".",
"current_period",
"-",
"dt",
".",
"timedelta",
"(",
"days",
"=",
"self",
".",
"expiration... | Progressively load the previous snapshot during the day.
Loading all the snapshots at once can takes a substantial amount of time. This method, if called
periodically during the day will progressively load those snapshots one by one. Because many workers are
going to use this method at the same... | [
"Progressively",
"load",
"the",
"previous",
"snapshot",
"during",
"the",
"day",
"."
] | train | https://github.com/Parsely/probably/blob/5d80855c1645fb2813678d5bcfe6108e33d80b9e/probably/temporal_daily.py#L115-L141 |
Parsely/probably | probably/temporal_daily.py | DailyTemporalBloomFilter.restore_from_disk | def restore_from_disk(self, clean_old_snapshot=False):
"""Restore the state of the BF using previous snapshots.
:clean_old_snapshot: Delete the old snapshot on the disk (period < current - expiration)
"""
base_filename = "%s/%s_%s_*.dat" % (self.snapshot_path, self.name, self.expiration... | python | def restore_from_disk(self, clean_old_snapshot=False):
"""Restore the state of the BF using previous snapshots.
:clean_old_snapshot: Delete the old snapshot on the disk (period < current - expiration)
"""
base_filename = "%s/%s_%s_*.dat" % (self.snapshot_path, self.name, self.expiration... | [
"def",
"restore_from_disk",
"(",
"self",
",",
"clean_old_snapshot",
"=",
"False",
")",
":",
"base_filename",
"=",
"\"%s/%s_%s_*.dat\"",
"%",
"(",
"self",
".",
"snapshot_path",
",",
"self",
".",
"name",
",",
"self",
".",
"expiration",
")",
"availables_snapshots",... | Restore the state of the BF using previous snapshots.
:clean_old_snapshot: Delete the old snapshot on the disk (period < current - expiration) | [
"Restore",
"the",
"state",
"of",
"the",
"BF",
"using",
"previous",
"snapshots",
"."
] | train | https://github.com/Parsely/probably/blob/5d80855c1645fb2813678d5bcfe6108e33d80b9e/probably/temporal_daily.py#L151-L170 |
Parsely/probably | probably/temporal_daily.py | DailyTemporalBloomFilter.save_snaphot | def save_snaphot(self):
"""Save the current state of the current day bitarray on disk.
Save the internal representation (bitarray) into a binary file using this format:
filename : name_expiration_2013-01-01.dat
"""
filename = "%s/%s_%s_%s.dat" % (self.snapshot_path, self.nam... | python | def save_snaphot(self):
"""Save the current state of the current day bitarray on disk.
Save the internal representation (bitarray) into a binary file using this format:
filename : name_expiration_2013-01-01.dat
"""
filename = "%s/%s_%s_%s.dat" % (self.snapshot_path, self.nam... | [
"def",
"save_snaphot",
"(",
"self",
")",
":",
"filename",
"=",
"\"%s/%s_%s_%s.dat\"",
"%",
"(",
"self",
".",
"snapshot_path",
",",
"self",
".",
"name",
",",
"self",
".",
"expiration",
",",
"self",
".",
"date",
")",
"with",
"open",
"(",
"filename",
",",
... | Save the current state of the current day bitarray on disk.
Save the internal representation (bitarray) into a binary file using this format:
filename : name_expiration_2013-01-01.dat | [
"Save",
"the",
"current",
"state",
"of",
"the",
"current",
"day",
"bitarray",
"on",
"disk",
"."
] | train | https://github.com/Parsely/probably/blob/5d80855c1645fb2813678d5bcfe6108e33d80b9e/probably/temporal_daily.py#L172-L180 |
project-rig/rig | rig/place_and_route/place/sequential.py | place | def place(vertices_resources, nets, machine, constraints,
vertex_order=None, chip_order=None):
"""Blindly places vertices in sequential order onto chips in the machine.
This algorithm sequentially places vertices onto chips in the order
specified (or in an undefined order if not specified). This ... | python | def place(vertices_resources, nets, machine, constraints,
vertex_order=None, chip_order=None):
"""Blindly places vertices in sequential order onto chips in the machine.
This algorithm sequentially places vertices onto chips in the order
specified (or in an undefined order if not specified). This ... | [
"def",
"place",
"(",
"vertices_resources",
",",
"nets",
",",
"machine",
",",
"constraints",
",",
"vertex_order",
"=",
"None",
",",
"chip_order",
"=",
"None",
")",
":",
"# If no vertices to place, just stop (from here on we presume that at least",
"# one vertex will be place... | Blindly places vertices in sequential order onto chips in the machine.
This algorithm sequentially places vertices onto chips in the order
specified (or in an undefined order if not specified). This algorithm is
essentially the simplest possible valid placement algorithm and is intended
to form the bas... | [
"Blindly",
"places",
"vertices",
"in",
"sequential",
"order",
"onto",
"chips",
"in",
"the",
"machine",
"."
] | train | https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/place_and_route/place/sequential.py#L19-L163 |
project-rig/rig | rig/place_and_route/wrapper.py | place_and_route_wrapper | def place_and_route_wrapper(vertices_resources, vertices_applications,
nets, net_keys,
system_info, constraints=[],
place=default_place, place_kwargs={},
allocate=default_allocate, allocate_kwargs={},
... | python | def place_and_route_wrapper(vertices_resources, vertices_applications,
nets, net_keys,
system_info, constraints=[],
place=default_place, place_kwargs={},
allocate=default_allocate, allocate_kwargs={},
... | [
"def",
"place_and_route_wrapper",
"(",
"vertices_resources",
",",
"vertices_applications",
",",
"nets",
",",
"net_keys",
",",
"system_info",
",",
"constraints",
"=",
"[",
"]",
",",
"place",
"=",
"default_place",
",",
"place_kwargs",
"=",
"{",
"}",
",",
"allocate... | Wrapper for core place-and-route tasks for the common case.
This function takes a set of vertices and nets and produces placements,
allocations, minimised routing tables and application loading information.
.. note::
This function replaces the deprecated :py:func:`.wrapper` function and
m... | [
"Wrapper",
"for",
"core",
"place",
"-",
"and",
"-",
"route",
"tasks",
"for",
"the",
"common",
"case",
"."
] | train | https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/place_and_route/wrapper.py#L27-L168 |
project-rig/rig | rig/place_and_route/wrapper.py | wrapper | def wrapper(vertices_resources, vertices_applications,
nets, net_keys,
machine, constraints=[],
reserve_monitor=True, align_sdram=True,
place=default_place, place_kwargs={},
allocate=default_allocate, allocate_kwargs={},
route=default_route, route_... | python | def wrapper(vertices_resources, vertices_applications,
nets, net_keys,
machine, constraints=[],
reserve_monitor=True, align_sdram=True,
place=default_place, place_kwargs={},
allocate=default_allocate, allocate_kwargs={},
route=default_route, route_... | [
"def",
"wrapper",
"(",
"vertices_resources",
",",
"vertices_applications",
",",
"nets",
",",
"net_keys",
",",
"machine",
",",
"constraints",
"=",
"[",
"]",
",",
"reserve_monitor",
"=",
"True",
",",
"align_sdram",
"=",
"True",
",",
"place",
"=",
"default_place"... | Wrapper for core place-and-route tasks for the common case.
At a high level this function essentially takes a set of vertices and nets
and produces placements, memory allocations, routing tables and application
loading information.
.. warning::
This function is deprecated. New users should use... | [
"Wrapper",
"for",
"core",
"place",
"-",
"and",
"-",
"route",
"tasks",
"for",
"the",
"common",
"case",
".",
"At",
"a",
"high",
"level",
"this",
"function",
"essentially",
"takes",
"a",
"set",
"of",
"vertices",
"and",
"nets",
"and",
"produces",
"placements",... | train | https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/place_and_route/wrapper.py#L171-L296 |
project-rig/rig | rig/machine_control/regions.py | get_region_for_chip | def get_region_for_chip(x, y, level=3):
"""Get the region word for the given chip co-ordinates.
Parameters
----------
x : int
x co-ordinate
y : int
y co-ordinate
level : int
Level of region to build. 0 is the most coarse and 3 is the finest.
When 3 is used the sp... | python | def get_region_for_chip(x, y, level=3):
"""Get the region word for the given chip co-ordinates.
Parameters
----------
x : int
x co-ordinate
y : int
y co-ordinate
level : int
Level of region to build. 0 is the most coarse and 3 is the finest.
When 3 is used the sp... | [
"def",
"get_region_for_chip",
"(",
"x",
",",
"y",
",",
"level",
"=",
"3",
")",
":",
"shift",
"=",
"6",
"-",
"2",
"*",
"level",
"bit",
"=",
"(",
"(",
"x",
">>",
"shift",
")",
"&",
"3",
")",
"+",
"4",
"*",
"(",
"(",
"y",
">>",
"shift",
")",
... | Get the region word for the given chip co-ordinates.
Parameters
----------
x : int
x co-ordinate
y : int
y co-ordinate
level : int
Level of region to build. 0 is the most coarse and 3 is the finest.
When 3 is used the specified region will ONLY select the given chip,... | [
"Get",
"the",
"region",
"word",
"for",
"the",
"given",
"chip",
"co",
"-",
"ordinates",
"."
] | train | https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/regions.py#L20-L52 |
project-rig/rig | rig/machine_control/regions.py | compress_flood_fill_regions | def compress_flood_fill_regions(targets):
"""Generate a reduced set of flood fill parameters.
Parameters
----------
targets : {(x, y) : set([c, ...]), ...}
For each used chip a set of core numbers onto which an application
should be loaded. E.g., the output of
:py:func:`~rig.pl... | python | def compress_flood_fill_regions(targets):
"""Generate a reduced set of flood fill parameters.
Parameters
----------
targets : {(x, y) : set([c, ...]), ...}
For each used chip a set of core numbers onto which an application
should be loaded. E.g., the output of
:py:func:`~rig.pl... | [
"def",
"compress_flood_fill_regions",
"(",
"targets",
")",
":",
"t",
"=",
"RegionCoreTree",
"(",
")",
"for",
"(",
"x",
",",
"y",
")",
",",
"cores",
"in",
"iteritems",
"(",
"targets",
")",
":",
"for",
"p",
"in",
"cores",
":",
"t",
".",
"add_core",
"("... | Generate a reduced set of flood fill parameters.
Parameters
----------
targets : {(x, y) : set([c, ...]), ...}
For each used chip a set of core numbers onto which an application
should be loaded. E.g., the output of
:py:func:`~rig.place_and_route.util.build_application_map` when in... | [
"Generate",
"a",
"reduced",
"set",
"of",
"flood",
"fill",
"parameters",
"."
] | train | https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/regions.py#L55-L83 |
project-rig/rig | rig/machine_control/regions.py | RegionCoreTree.get_regions_and_coremasks | def get_regions_and_coremasks(self):
"""Generate a set of ordered paired region and core mask representations.
.. note::
The region and core masks are ordered such that ``(region << 32) |
core_mask`` is monotonically increasing. Consequently region and
core masks gen... | python | def get_regions_and_coremasks(self):
"""Generate a set of ordered paired region and core mask representations.
.. note::
The region and core masks are ordered such that ``(region << 32) |
core_mask`` is monotonically increasing. Consequently region and
core masks gen... | [
"def",
"get_regions_and_coremasks",
"(",
"self",
")",
":",
"region_code",
"=",
"(",
"(",
"self",
".",
"base_x",
"<<",
"24",
")",
"|",
"(",
"self",
".",
"base_y",
"<<",
"16",
")",
"|",
"(",
"self",
".",
"level",
"<<",
"16",
")",
")",
"# Generate core ... | Generate a set of ordered paired region and core mask representations.
.. note::
The region and core masks are ordered such that ``(region << 32) |
core_mask`` is monotonically increasing. Consequently region and
core masks generated by this method can be used with SCAMP's
... | [
"Generate",
"a",
"set",
"of",
"ordered",
"paired",
"region",
"and",
"core",
"mask",
"representations",
"."
] | train | https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/regions.py#L129-L167 |
project-rig/rig | rig/machine_control/regions.py | RegionCoreTree.add_core | def add_core(self, x, y, p):
"""Add a new core to the region tree.
Raises
------
ValueError
If the co-ordinate is not contained within this part of the tree or
the core number is out of range.
Returns
-------
bool
True if the ... | python | def add_core(self, x, y, p):
"""Add a new core to the region tree.
Raises
------
ValueError
If the co-ordinate is not contained within this part of the tree or
the core number is out of range.
Returns
-------
bool
True if the ... | [
"def",
"add_core",
"(",
"self",
",",
"x",
",",
"y",
",",
"p",
")",
":",
"# Check that the co-ordinate is contained in this region",
"if",
"(",
"(",
"p",
"<",
"0",
"or",
"p",
">",
"17",
")",
"or",
"(",
"x",
"<",
"self",
".",
"base_x",
"or",
"x",
">=",... | Add a new core to the region tree.
Raises
------
ValueError
If the co-ordinate is not contained within this part of the tree or
the core number is out of range.
Returns
-------
bool
True if the specified core is to be loaded to all su... | [
"Add",
"a",
"new",
"core",
"to",
"the",
"region",
"tree",
"."
] | train | https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/regions.py#L169-L217 |
project-rig/rig | rig/machine_control/bmp_controller.py | BMPController.send_scp | def send_scp(self, *args, **kwargs):
"""Transmit an SCP Packet to a specific board.
Automatically determines the appropriate connection to use.
See the arguments for
:py:meth:`~rig.machine_control.scp_connection.SCPConnection` for
details.
Parameters
----------... | python | def send_scp(self, *args, **kwargs):
"""Transmit an SCP Packet to a specific board.
Automatically determines the appropriate connection to use.
See the arguments for
:py:meth:`~rig.machine_control.scp_connection.SCPConnection` for
details.
Parameters
----------... | [
"def",
"send_scp",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# Retrieve contextual arguments from the keyword arguments. The",
"# context system ensures that these values are present.",
"cabinet",
"=",
"kwargs",
".",
"pop",
"(",
"\"cabinet\"",
")... | Transmit an SCP Packet to a specific board.
Automatically determines the appropriate connection to use.
See the arguments for
:py:meth:`~rig.machine_control.scp_connection.SCPConnection` for
details.
Parameters
----------
cabinet : int
frame : int
... | [
"Transmit",
"an",
"SCP",
"Packet",
"to",
"a",
"specific",
"board",
"."
] | train | https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/bmp_controller.py#L125-L145 |
project-rig/rig | rig/machine_control/bmp_controller.py | BMPController._send_scp | def _send_scp(self, cabinet, frame, board, *args, **kwargs):
"""Determine the best connection to use to send an SCP packet and use
it to transmit.
See the arguments for
:py:meth:`~rig.machine_control.scp_connection.SCPConnection` for
details.
"""
# Find the conne... | python | def _send_scp(self, cabinet, frame, board, *args, **kwargs):
"""Determine the best connection to use to send an SCP packet and use
it to transmit.
See the arguments for
:py:meth:`~rig.machine_control.scp_connection.SCPConnection` for
details.
"""
# Find the conne... | [
"def",
"_send_scp",
"(",
"self",
",",
"cabinet",
",",
"frame",
",",
"board",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# Find the connection which best matches the specified coordinates,",
"# preferring direct connections to a board when available.",
"connection... | Determine the best connection to use to send an SCP packet and use
it to transmit.
See the arguments for
:py:meth:`~rig.machine_control.scp_connection.SCPConnection` for
details. | [
"Determine",
"the",
"best",
"connection",
"to",
"use",
"to",
"send",
"an",
"SCP",
"packet",
"and",
"use",
"it",
"to",
"transmit",
"."
] | train | https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/bmp_controller.py#L147-L173 |
project-rig/rig | rig/machine_control/bmp_controller.py | BMPController.get_software_version | def get_software_version(self, cabinet, frame, board):
"""Get the software version for a given BMP.
Returns
-------
:py:class:`.BMPInfo`
Information about the software running on a BMP.
"""
sver = self._send_scp(cabinet, frame, board, SCPCommands.sver)
... | python | def get_software_version(self, cabinet, frame, board):
"""Get the software version for a given BMP.
Returns
-------
:py:class:`.BMPInfo`
Information about the software running on a BMP.
"""
sver = self._send_scp(cabinet, frame, board, SCPCommands.sver)
... | [
"def",
"get_software_version",
"(",
"self",
",",
"cabinet",
",",
"frame",
",",
"board",
")",
":",
"sver",
"=",
"self",
".",
"_send_scp",
"(",
"cabinet",
",",
"frame",
",",
"board",
",",
"SCPCommands",
".",
"sver",
")",
"# Format the result",
"# arg1",
"cod... | Get the software version for a given BMP.
Returns
-------
:py:class:`.BMPInfo`
Information about the software running on a BMP. | [
"Get",
"the",
"software",
"version",
"for",
"a",
"given",
"BMP",
"."
] | train | https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/bmp_controller.py#L176-L200 |
project-rig/rig | rig/machine_control/bmp_controller.py | BMPController.set_power | def set_power(self, state, cabinet, frame, board,
delay=0.0, post_power_on_delay=5.0):
"""Control power to the SpiNNaker chips and FPGAs on a board.
Returns
-------
state : bool
True for power on, False for power off.
board : int or iterable
... | python | def set_power(self, state, cabinet, frame, board,
delay=0.0, post_power_on_delay=5.0):
"""Control power to the SpiNNaker chips and FPGAs on a board.
Returns
-------
state : bool
True for power on, False for power off.
board : int or iterable
... | [
"def",
"set_power",
"(",
"self",
",",
"state",
",",
"cabinet",
",",
"frame",
",",
"board",
",",
"delay",
"=",
"0.0",
",",
"post_power_on_delay",
"=",
"5.0",
")",
":",
"if",
"isinstance",
"(",
"board",
",",
"int",
")",
":",
"boards",
"=",
"[",
"board"... | Control power to the SpiNNaker chips and FPGAs on a board.
Returns
-------
state : bool
True for power on, False for power off.
board : int or iterable
Specifies the board to control the power of. This may also be an
iterable of multiple boards (in th... | [
"Control",
"power",
"to",
"the",
"SpiNNaker",
"chips",
"and",
"FPGAs",
"on",
"a",
"board",
"."
] | train | https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/bmp_controller.py#L203-L251 |
project-rig/rig | rig/machine_control/bmp_controller.py | BMPController.set_led | def set_led(self, led, action=None,
cabinet=Required, frame=Required, board=Required):
"""Set or toggle the state of an LED.
.. note::
At the time of writing, LED 7 is only set by the BMP on start-up to
indicate that the watchdog timer reset the board. After this... | python | def set_led(self, led, action=None,
cabinet=Required, frame=Required, board=Required):
"""Set or toggle the state of an LED.
.. note::
At the time of writing, LED 7 is only set by the BMP on start-up to
indicate that the watchdog timer reset the board. After this... | [
"def",
"set_led",
"(",
"self",
",",
"led",
",",
"action",
"=",
"None",
",",
"cabinet",
"=",
"Required",
",",
"frame",
"=",
"Required",
",",
"board",
"=",
"Required",
")",
":",
"if",
"isinstance",
"(",
"led",
",",
"int",
")",
":",
"leds",
"=",
"[",
... | Set or toggle the state of an LED.
.. note::
At the time of writing, LED 7 is only set by the BMP on start-up to
indicate that the watchdog timer reset the board. After this point,
the LED is available for use by applications.
Parameters
----------
l... | [
"Set",
"or",
"toggle",
"the",
"state",
"of",
"an",
"LED",
"."
] | train | https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/bmp_controller.py#L254-L292 |
project-rig/rig | rig/machine_control/bmp_controller.py | BMPController.read_fpga_reg | def read_fpga_reg(self, fpga_num, addr, cabinet, frame, board):
"""Read the value of an FPGA (SPI) register.
See the SpI/O project's spinnaker_fpga design's `README`_ for a listing
of FPGA registers. The SpI/O project can be found on GitHub at:
https://github.com/SpiNNakerManchester/spi... | python | def read_fpga_reg(self, fpga_num, addr, cabinet, frame, board):
"""Read the value of an FPGA (SPI) register.
See the SpI/O project's spinnaker_fpga design's `README`_ for a listing
of FPGA registers. The SpI/O project can be found on GitHub at:
https://github.com/SpiNNakerManchester/spi... | [
"def",
"read_fpga_reg",
"(",
"self",
",",
"fpga_num",
",",
"addr",
",",
"cabinet",
",",
"frame",
",",
"board",
")",
":",
"arg1",
"=",
"addr",
"&",
"(",
"~",
"0x3",
")",
"arg2",
"=",
"4",
"# Read a 32-bit value",
"arg3",
"=",
"fpga_num",
"response",
"="... | Read the value of an FPGA (SPI) register.
See the SpI/O project's spinnaker_fpga design's `README`_ for a listing
of FPGA registers. The SpI/O project can be found on GitHub at:
https://github.com/SpiNNakerManchester/spio/
.. _README: https://github.com/SpiNNakerManchester/spio/\
... | [
"Read",
"the",
"value",
"of",
"an",
"FPGA",
"(",
"SPI",
")",
"register",
"."
] | train | https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/bmp_controller.py#L295-L324 |
project-rig/rig | rig/machine_control/bmp_controller.py | BMPController.write_fpga_reg | def write_fpga_reg(self, fpga_num, addr, value, cabinet, frame, board):
"""Write the value of an FPGA (SPI) register.
See the SpI/O project's spinnaker_fpga design's `README`_ for a listing
of FPGA registers. The SpI/O project can be found on GitHub at:
https://github.com/SpiNNakerManch... | python | def write_fpga_reg(self, fpga_num, addr, value, cabinet, frame, board):
"""Write the value of an FPGA (SPI) register.
See the SpI/O project's spinnaker_fpga design's `README`_ for a listing
of FPGA registers. The SpI/O project can be found on GitHub at:
https://github.com/SpiNNakerManch... | [
"def",
"write_fpga_reg",
"(",
"self",
",",
"fpga_num",
",",
"addr",
",",
"value",
",",
"cabinet",
",",
"frame",
",",
"board",
")",
":",
"arg1",
"=",
"addr",
"&",
"(",
"~",
"0x3",
")",
"arg2",
"=",
"4",
"# Write a 32-bit value",
"arg3",
"=",
"fpga_num",... | Write the value of an FPGA (SPI) register.
See the SpI/O project's spinnaker_fpga design's `README`_ for a listing
of FPGA registers. The SpI/O project can be found on GitHub at:
https://github.com/SpiNNakerManchester/spio/
.. _README: https://github.com/SpiNNakerManchester/spio/\
... | [
"Write",
"the",
"value",
"of",
"an",
"FPGA",
"(",
"SPI",
")",
"register",
"."
] | train | https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/bmp_controller.py#L327-L352 |
project-rig/rig | rig/machine_control/bmp_controller.py | BMPController.read_adc | def read_adc(self, cabinet, frame, board):
"""Read ADC data from the BMP including voltages and temperature.
Returns
-------
:py:class:`.ADCInfo`
"""
response = self._send_scp(cabinet, frame, board, SCPCommands.bmp_info,
arg1=BMPInfoType... | python | def read_adc(self, cabinet, frame, board):
"""Read ADC data from the BMP including voltages and temperature.
Returns
-------
:py:class:`.ADCInfo`
"""
response = self._send_scp(cabinet, frame, board, SCPCommands.bmp_info,
arg1=BMPInfoType... | [
"def",
"read_adc",
"(",
"self",
",",
"cabinet",
",",
"frame",
",",
"board",
")",
":",
"response",
"=",
"self",
".",
"_send_scp",
"(",
"cabinet",
",",
"frame",
",",
"board",
",",
"SCPCommands",
".",
"bmp_info",
",",
"arg1",
"=",
"BMPInfoType",
".",
"adc... | Read ADC data from the BMP including voltages and temperature.
Returns
-------
:py:class:`.ADCInfo` | [
"Read",
"ADC",
"data",
"from",
"the",
"BMP",
"including",
"voltages",
"and",
"temperature",
"."
] | train | https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/bmp_controller.py#L355-L388 |
project-rig/rig | rig/place_and_route/place/utils.py | add_resources | def add_resources(res_a, res_b):
"""Return the resources after adding res_b's resources to res_a.
Parameters
----------
res_a : dict
Dictionary `{resource: value, ...}`.
res_b : dict
Dictionary `{resource: value, ...}`. Must be a (non-strict) subset of
res_a. If A resource i... | python | def add_resources(res_a, res_b):
"""Return the resources after adding res_b's resources to res_a.
Parameters
----------
res_a : dict
Dictionary `{resource: value, ...}`.
res_b : dict
Dictionary `{resource: value, ...}`. Must be a (non-strict) subset of
res_a. If A resource i... | [
"def",
"add_resources",
"(",
"res_a",
",",
"res_b",
")",
":",
"return",
"{",
"resource",
":",
"value",
"+",
"res_b",
".",
"get",
"(",
"resource",
",",
"0",
")",
"for",
"resource",
",",
"value",
"in",
"iteritems",
"(",
"res_a",
")",
"}"
] | Return the resources after adding res_b's resources to res_a.
Parameters
----------
res_a : dict
Dictionary `{resource: value, ...}`.
res_b : dict
Dictionary `{resource: value, ...}`. Must be a (non-strict) subset of
res_a. If A resource is not present in res_b, the value is pre... | [
"Return",
"the",
"resources",
"after",
"adding",
"res_b",
"s",
"resources",
"to",
"res_a",
"."
] | train | https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/place_and_route/place/utils.py#L13-L26 |
project-rig/rig | rig/place_and_route/place/utils.py | subtract_resources | def subtract_resources(res_a, res_b):
"""Return the resources remaining after subtracting res_b's resources from
res_a.
Parameters
----------
res_a : dict
Dictionary `{resource: value, ...}`.
res_b : dict
Dictionary `{resource: value, ...}`. Must be a (non-strict) subset of
... | python | def subtract_resources(res_a, res_b):
"""Return the resources remaining after subtracting res_b's resources from
res_a.
Parameters
----------
res_a : dict
Dictionary `{resource: value, ...}`.
res_b : dict
Dictionary `{resource: value, ...}`. Must be a (non-strict) subset of
... | [
"def",
"subtract_resources",
"(",
"res_a",
",",
"res_b",
")",
":",
"return",
"{",
"resource",
":",
"value",
"-",
"res_b",
".",
"get",
"(",
"resource",
",",
"0",
")",
"for",
"resource",
",",
"value",
"in",
"iteritems",
"(",
"res_a",
")",
"}"
] | Return the resources remaining after subtracting res_b's resources from
res_a.
Parameters
----------
res_a : dict
Dictionary `{resource: value, ...}`.
res_b : dict
Dictionary `{resource: value, ...}`. Must be a (non-strict) subset of
res_a. If A resource is not present in re... | [
"Return",
"the",
"resources",
"remaining",
"after",
"subtracting",
"res_b",
"s",
"resources",
"from",
"res_a",
"."
] | train | https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/place_and_route/place/utils.py#L29-L43 |
project-rig/rig | rig/place_and_route/place/utils.py | resources_after_reservation | def resources_after_reservation(res, constraint):
"""Return the resources available after a specified
ReserveResourceConstraint has been applied.
Note: the caller is responsible for testing that the constraint is
applicable to the core whose resources are being constrained.
Note: this function doe... | python | def resources_after_reservation(res, constraint):
"""Return the resources available after a specified
ReserveResourceConstraint has been applied.
Note: the caller is responsible for testing that the constraint is
applicable to the core whose resources are being constrained.
Note: this function doe... | [
"def",
"resources_after_reservation",
"(",
"res",
",",
"constraint",
")",
":",
"res",
"=",
"res",
".",
"copy",
"(",
")",
"res",
"[",
"constraint",
".",
"resource",
"]",
"-=",
"(",
"constraint",
".",
"reservation",
".",
"stop",
"-",
"constraint",
".",
"re... | Return the resources available after a specified
ReserveResourceConstraint has been applied.
Note: the caller is responsible for testing that the constraint is
applicable to the core whose resources are being constrained.
Note: this function does not pay attention to the specific position of the
r... | [
"Return",
"the",
"resources",
"available",
"after",
"a",
"specified",
"ReserveResourceConstraint",
"has",
"been",
"applied",
"."
] | train | https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/place_and_route/place/utils.py#L52-L65 |
project-rig/rig | rig/place_and_route/place/utils.py | apply_reserve_resource_constraint | def apply_reserve_resource_constraint(machine, constraint):
"""Apply the changes implied by a reserve resource constraint to a
machine model."""
if constraint.location is None:
# Compensate for globally reserved resources
machine.chip_resources \
= resources_after_reservation(
... | python | def apply_reserve_resource_constraint(machine, constraint):
"""Apply the changes implied by a reserve resource constraint to a
machine model."""
if constraint.location is None:
# Compensate for globally reserved resources
machine.chip_resources \
= resources_after_reservation(
... | [
"def",
"apply_reserve_resource_constraint",
"(",
"machine",
",",
"constraint",
")",
":",
"if",
"constraint",
".",
"location",
"is",
"None",
":",
"# Compensate for globally reserved resources",
"machine",
".",
"chip_resources",
"=",
"resources_after_reservation",
"(",
"mac... | Apply the changes implied by a reserve resource constraint to a
machine model. | [
"Apply",
"the",
"changes",
"implied",
"by",
"a",
"reserve",
"resource",
"constraint",
"to",
"a",
"machine",
"model",
"."
] | train | https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/place_and_route/place/utils.py#L68-L93 |
project-rig/rig | rig/place_and_route/place/utils.py | apply_same_chip_constraints | def apply_same_chip_constraints(vertices_resources, nets, constraints):
"""Modify a set of vertices_resources, nets and constraints to account for
all SameChipConstraints.
To allow placement algorithms to handle SameChipConstraints without any
special cases, Vertices identified in a SameChipConstraint ... | python | def apply_same_chip_constraints(vertices_resources, nets, constraints):
"""Modify a set of vertices_resources, nets and constraints to account for
all SameChipConstraints.
To allow placement algorithms to handle SameChipConstraints without any
special cases, Vertices identified in a SameChipConstraint ... | [
"def",
"apply_same_chip_constraints",
"(",
"vertices_resources",
",",
"nets",
",",
"constraints",
")",
":",
"# Make a copy of the basic structures to be modified by this function",
"vertices_resources",
"=",
"vertices_resources",
".",
"copy",
"(",
")",
"nets",
"=",
"nets",
... | Modify a set of vertices_resources, nets and constraints to account for
all SameChipConstraints.
To allow placement algorithms to handle SameChipConstraints without any
special cases, Vertices identified in a SameChipConstraint are merged into
a new vertex whose vertices_resources are the sum total of ... | [
"Modify",
"a",
"set",
"of",
"vertices_resources",
"nets",
"and",
"constraints",
"to",
"account",
"for",
"all",
"SameChipConstraints",
"."
] | train | https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/place_and_route/place/utils.py#L107-L229 |
project-rig/rig | rig/place_and_route/place/utils.py | finalise_same_chip_constraints | def finalise_same_chip_constraints(substitutions, placements):
"""Given a set of placements containing the supplied
:py:class:`MergedVertex`, remove the merged vertices replacing them with
their constituent vertices (changing the placements inplace).
"""
for merged_vertex in reversed(substitutions):... | python | def finalise_same_chip_constraints(substitutions, placements):
"""Given a set of placements containing the supplied
:py:class:`MergedVertex`, remove the merged vertices replacing them with
their constituent vertices (changing the placements inplace).
"""
for merged_vertex in reversed(substitutions):... | [
"def",
"finalise_same_chip_constraints",
"(",
"substitutions",
",",
"placements",
")",
":",
"for",
"merged_vertex",
"in",
"reversed",
"(",
"substitutions",
")",
":",
"placement",
"=",
"placements",
".",
"pop",
"(",
"merged_vertex",
")",
"for",
"v",
"in",
"merged... | Given a set of placements containing the supplied
:py:class:`MergedVertex`, remove the merged vertices replacing them with
their constituent vertices (changing the placements inplace). | [
"Given",
"a",
"set",
"of",
"placements",
"containing",
"the",
"supplied",
":",
"py",
":",
"class",
":",
"MergedVertex",
"remove",
"the",
"merged",
"vertices",
"replacing",
"them",
"with",
"their",
"constituent",
"vertices",
"(",
"changing",
"the",
"placements",
... | train | https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/place_and_route/place/utils.py#L232-L240 |
Metatab/metapack | metapack/appurl.py | MetapackDocumentUrl.doc | def doc(self):
"""Return the metatab document for the URL"""
from metapack import MetapackDoc
t = self.get_resource().get_target()
return MetapackDoc(t, package_url=self.package_url) | python | def doc(self):
"""Return the metatab document for the URL"""
from metapack import MetapackDoc
t = self.get_resource().get_target()
return MetapackDoc(t, package_url=self.package_url) | [
"def",
"doc",
"(",
"self",
")",
":",
"from",
"metapack",
"import",
"MetapackDoc",
"t",
"=",
"self",
".",
"get_resource",
"(",
")",
".",
"get_target",
"(",
")",
"return",
"MetapackDoc",
"(",
"t",
",",
"package_url",
"=",
"self",
".",
"package_url",
")"
] | Return the metatab document for the URL | [
"Return",
"the",
"metatab",
"document",
"for",
"the",
"URL"
] | train | https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/appurl.py#L116-L120 |
Metatab/metapack | metapack/appurl.py | MetapackDocumentUrl.resolve_url | def resolve_url(self, resource_name):
"""Return a URL to a local copy of a resource, suitable for get_generator()"""
if self.target_format == 'csv' and self.target_file != DEFAULT_METATAB_FILE:
# For CSV packages, need to get the package and open it to get the resoruce URL, becuase
... | python | def resolve_url(self, resource_name):
"""Return a URL to a local copy of a resource, suitable for get_generator()"""
if self.target_format == 'csv' and self.target_file != DEFAULT_METATAB_FILE:
# For CSV packages, need to get the package and open it to get the resoruce URL, becuase
... | [
"def",
"resolve_url",
"(",
"self",
",",
"resource_name",
")",
":",
"if",
"self",
".",
"target_format",
"==",
"'csv'",
"and",
"self",
".",
"target_file",
"!=",
"DEFAULT_METATAB_FILE",
":",
"# For CSV packages, need to get the package and open it to get the resoruce URL, becu... | Return a URL to a local copy of a resource, suitable for get_generator() | [
"Return",
"a",
"URL",
"to",
"a",
"local",
"copy",
"of",
"a",
"resource",
"suitable",
"for",
"get_generator",
"()"
] | train | https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/appurl.py#L136-L149 |
Metatab/metapack | metapack/appurl.py | MetapackDocumentUrl.package_url | def package_url(self):
"""Return the package URL associated with this metadata"""
if self.resource_file == DEFAULT_METATAB_FILE or self.target_format in ('txt','ipynb'):
u = self.inner.clone().clear_fragment()
u.path = dirname(self.path) + '/'
u.scheme_extension = 'm... | python | def package_url(self):
"""Return the package URL associated with this metadata"""
if self.resource_file == DEFAULT_METATAB_FILE or self.target_format in ('txt','ipynb'):
u = self.inner.clone().clear_fragment()
u.path = dirname(self.path) + '/'
u.scheme_extension = 'm... | [
"def",
"package_url",
"(",
"self",
")",
":",
"if",
"self",
".",
"resource_file",
"==",
"DEFAULT_METATAB_FILE",
"or",
"self",
".",
"target_format",
"in",
"(",
"'txt'",
",",
"'ipynb'",
")",
":",
"u",
"=",
"self",
".",
"inner",
".",
"clone",
"(",
")",
"."... | Return the package URL associated with this metadata | [
"Return",
"the",
"package",
"URL",
"associated",
"with",
"this",
"metadata"
] | train | https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/appurl.py#L160-L170 |
Metatab/metapack | metapack/appurl.py | MetapackPackageUrl.join_resource_name | def join_resource_name(self, v):
"""Return a MetapackResourceUrl that includes a reference to the resource. Returns a
MetapackResourceUrl, which will have a fragment """
d = self.dict
d['fragment'] = [v, None]
return MetapackResourceUrl(downloader=self._downloader, **d) | python | def join_resource_name(self, v):
"""Return a MetapackResourceUrl that includes a reference to the resource. Returns a
MetapackResourceUrl, which will have a fragment """
d = self.dict
d['fragment'] = [v, None]
return MetapackResourceUrl(downloader=self._downloader, **d) | [
"def",
"join_resource_name",
"(",
"self",
",",
"v",
")",
":",
"d",
"=",
"self",
".",
"dict",
"d",
"[",
"'fragment'",
"]",
"=",
"[",
"v",
",",
"None",
"]",
"return",
"MetapackResourceUrl",
"(",
"downloader",
"=",
"self",
".",
"_downloader",
",",
"*",
... | Return a MetapackResourceUrl that includes a reference to the resource. Returns a
MetapackResourceUrl, which will have a fragment | [
"Return",
"a",
"MetapackResourceUrl",
"that",
"includes",
"a",
"reference",
"to",
"the",
"resource",
".",
"Returns",
"a",
"MetapackResourceUrl",
"which",
"will",
"have",
"a",
"fragment"
] | train | https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/appurl.py#L232-L237 |
Metatab/metapack | metapack/appurl.py | MetapackPackageUrl.resolve_url | def resolve_url(self, resource_name):
"""Return a URL to a local copy of a resource, suitable for get_generator()
For Package URLS, resolution involves generating a URL to a data file from the package URL and the
value of a resource. The resource value, the url, can be one of:
- An abs... | python | def resolve_url(self, resource_name):
"""Return a URL to a local copy of a resource, suitable for get_generator()
For Package URLS, resolution involves generating a URL to a data file from the package URL and the
value of a resource. The resource value, the url, can be one of:
- An abs... | [
"def",
"resolve_url",
"(",
"self",
",",
"resource_name",
")",
":",
"u",
"=",
"parse_app_url",
"(",
"resource_name",
")",
"if",
"u",
".",
"scheme",
"!=",
"'file'",
":",
"t",
"=",
"u",
"elif",
"self",
".",
"target_format",
"==",
"'csv'",
"and",
"self",
"... | Return a URL to a local copy of a resource, suitable for get_generator()
For Package URLS, resolution involves generating a URL to a data file from the package URL and the
value of a resource. The resource value, the url, can be one of:
- An absolute URL, with a web scheme
- A relative... | [
"Return",
"a",
"URL",
"to",
"a",
"local",
"copy",
"of",
"a",
"resource",
"suitable",
"for",
"get_generator",
"()"
] | train | https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/appurl.py#L250-L301 |
Metatab/metapack | metapack/appurl.py | MetapackResourceUrl.package_url | def package_url(self):
"""Return the package URL associated with this metadata"""
return MetapackDocumentUrl(str(self.clear_fragment()), downloader=self._downloader).package_url | python | def package_url(self):
"""Return the package URL associated with this metadata"""
return MetapackDocumentUrl(str(self.clear_fragment()), downloader=self._downloader).package_url | [
"def",
"package_url",
"(",
"self",
")",
":",
"return",
"MetapackDocumentUrl",
"(",
"str",
"(",
"self",
".",
"clear_fragment",
"(",
")",
")",
",",
"downloader",
"=",
"self",
".",
"_downloader",
")",
".",
"package_url"
] | Return the package URL associated with this metadata | [
"Return",
"the",
"package",
"URL",
"associated",
"with",
"this",
"metadata"
] | train | https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/appurl.py#L350-L352 |
Metatab/metapack | metapack/appurl.py | SearchUrl.search_json_indexed_directory | def search_json_indexed_directory(directory):
"""Return a search function for searching a directory of packages, which has an index.json file
created by the `mp install file` command.
This will only search the issued index; it will not return results for the source index
"""
fr... | python | def search_json_indexed_directory(directory):
"""Return a search function for searching a directory of packages, which has an index.json file
created by the `mp install file` command.
This will only search the issued index; it will not return results for the source index
"""
fr... | [
"def",
"search_json_indexed_directory",
"(",
"directory",
")",
":",
"from",
"metapack",
".",
"index",
"import",
"SearchIndex",
",",
"search_index_file",
"idx",
"=",
"SearchIndex",
"(",
"search_index_file",
"(",
")",
")",
"def",
"_search_function",
"(",
"url",
")",... | Return a search function for searching a directory of packages, which has an index.json file
created by the `mp install file` command.
This will only search the issued index; it will not return results for the source index | [
"Return",
"a",
"search",
"function",
"for",
"searching",
"a",
"directory",
"of",
"packages",
"which",
"has",
"an",
"index",
".",
"json",
"file",
"created",
"by",
"the",
"mp",
"install",
"file",
"command",
"."
] | train | https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/appurl.py#L467-L494 |
Metatab/metapack | metapack/appurl.py | SearchUrl.search | def search(self):
"""Search for a url by returning the value from the first callback that
returns a non-None value"""
for cb in SearchUrl.search_callbacks:
try:
v = cb(self)
if v is not None:
return v
except Exception ... | python | def search(self):
"""Search for a url by returning the value from the first callback that
returns a non-None value"""
for cb in SearchUrl.search_callbacks:
try:
v = cb(self)
if v is not None:
return v
except Exception ... | [
"def",
"search",
"(",
"self",
")",
":",
"for",
"cb",
"in",
"SearchUrl",
".",
"search_callbacks",
":",
"try",
":",
"v",
"=",
"cb",
"(",
"self",
")",
"if",
"v",
"is",
"not",
"None",
":",
"return",
"v",
"except",
"Exception",
"as",
"e",
":",
"raise"
] | Search for a url by returning the value from the first callback that
returns a non-None value | [
"Search",
"for",
"a",
"url",
"by",
"returning",
"the",
"value",
"from",
"the",
"first",
"callback",
"that",
"returns",
"a",
"non",
"-",
"None",
"value"
] | train | https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/appurl.py#L496-L507 |
Metatab/metapack | metapack/jupyter/core.py | ensure_source_package_dir | def ensure_source_package_dir(nb_path, pkg_name):
"""Ensure all of the important directories in a source package exist"""
pkg_path = join(dirname(nb_path), pkg_name)
makedirs(join(pkg_path,'notebooks'),exist_ok=True)
makedirs(join(pkg_path, 'docs'), exist_ok=True)
return pkg_path | python | def ensure_source_package_dir(nb_path, pkg_name):
"""Ensure all of the important directories in a source package exist"""
pkg_path = join(dirname(nb_path), pkg_name)
makedirs(join(pkg_path,'notebooks'),exist_ok=True)
makedirs(join(pkg_path, 'docs'), exist_ok=True)
return pkg_path | [
"def",
"ensure_source_package_dir",
"(",
"nb_path",
",",
"pkg_name",
")",
":",
"pkg_path",
"=",
"join",
"(",
"dirname",
"(",
"nb_path",
")",
",",
"pkg_name",
")",
"makedirs",
"(",
"join",
"(",
"pkg_path",
",",
"'notebooks'",
")",
",",
"exist_ok",
"=",
"Tru... | Ensure all of the important directories in a source package exist | [
"Ensure",
"all",
"of",
"the",
"important",
"directories",
"in",
"a",
"source",
"package",
"exist"
] | train | https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/jupyter/core.py#L57-L65 |
Metatab/metapack | metapack/jupyter/core.py | get_metatab_doc | def get_metatab_doc(nb_path):
"""Read a notebook and extract the metatab document. Only returns the first document"""
from metatab.generate import CsvDataRowGenerator
from metatab.rowgenerators import TextRowGenerator
from metatab import MetatabDoc
with open(nb_path) as f:
nb = nbformat.re... | python | def get_metatab_doc(nb_path):
"""Read a notebook and extract the metatab document. Only returns the first document"""
from metatab.generate import CsvDataRowGenerator
from metatab.rowgenerators import TextRowGenerator
from metatab import MetatabDoc
with open(nb_path) as f:
nb = nbformat.re... | [
"def",
"get_metatab_doc",
"(",
"nb_path",
")",
":",
"from",
"metatab",
".",
"generate",
"import",
"CsvDataRowGenerator",
"from",
"metatab",
".",
"rowgenerators",
"import",
"TextRowGenerator",
"from",
"metatab",
"import",
"MetatabDoc",
"with",
"open",
"(",
"nb_path",... | Read a notebook and extract the metatab document. Only returns the first document | [
"Read",
"a",
"notebook",
"and",
"extract",
"the",
"metatab",
"document",
".",
"Only",
"returns",
"the",
"first",
"document"
] | train | https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/jupyter/core.py#L68-L81 |
Metatab/metapack | metapack/jupyter/core.py | get_package_dir | def get_package_dir(nb_path):
"""Return the package directory for a Notebook that has an embeded Metatab doc, *not* for
notebooks that are part of a package """
doc = get_metatab_doc(nb_path)
doc.update_name(force=True, create_term=True)
pkg_name = doc['Root'].get_value('Root.Name')
assert pkg_n... | python | def get_package_dir(nb_path):
"""Return the package directory for a Notebook that has an embeded Metatab doc, *not* for
notebooks that are part of a package """
doc = get_metatab_doc(nb_path)
doc.update_name(force=True, create_term=True)
pkg_name = doc['Root'].get_value('Root.Name')
assert pkg_n... | [
"def",
"get_package_dir",
"(",
"nb_path",
")",
":",
"doc",
"=",
"get_metatab_doc",
"(",
"nb_path",
")",
"doc",
".",
"update_name",
"(",
"force",
"=",
"True",
",",
"create_term",
"=",
"True",
")",
"pkg_name",
"=",
"doc",
"[",
"'Root'",
"]",
".",
"get_valu... | Return the package directory for a Notebook that has an embeded Metatab doc, *not* for
notebooks that are part of a package | [
"Return",
"the",
"package",
"directory",
"for",
"a",
"Notebook",
"that",
"has",
"an",
"embeded",
"Metatab",
"doc",
"*",
"not",
"*",
"for",
"notebooks",
"that",
"are",
"part",
"of",
"a",
"package"
] | train | https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/jupyter/core.py#L84-L92 |
Metatab/metapack | metapack/jupyter/core.py | process_schema | def process_schema(doc, resource, df):
"""Add schema entiries to a metatab doc from a dataframe"""
from rowgenerators import SourceError
from requests.exceptions import ConnectionError
from metapack.cli.core import extract_path_name, alt_col_name, type_map
from tableintuit import TypeIntuiter
f... | python | def process_schema(doc, resource, df):
"""Add schema entiries to a metatab doc from a dataframe"""
from rowgenerators import SourceError
from requests.exceptions import ConnectionError
from metapack.cli.core import extract_path_name, alt_col_name, type_map
from tableintuit import TypeIntuiter
f... | [
"def",
"process_schema",
"(",
"doc",
",",
"resource",
",",
"df",
")",
":",
"from",
"rowgenerators",
"import",
"SourceError",
"from",
"requests",
".",
"exceptions",
"import",
"ConnectionError",
"from",
"metapack",
".",
"cli",
".",
"core",
"import",
"extract_path_... | Add schema entiries to a metatab doc from a dataframe | [
"Add",
"schema",
"entiries",
"to",
"a",
"metatab",
"doc",
"from",
"a",
"dataframe"
] | train | https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/jupyter/core.py#L95-L148 |
project-rig/rig | rig/machine_control/boot.py | boot | def boot(hostname, boot_port=consts.BOOT_PORT,
scamp_binary=None, sark_struct=None,
boot_delay=0.05, post_boot_delay=2.0,
sv_overrides=dict(), **kwargs):
"""Boot a SpiNNaker machine of the given size.
Parameters
----------
hostname : str
Hostname or IP address of the ... | python | def boot(hostname, boot_port=consts.BOOT_PORT,
scamp_binary=None, sark_struct=None,
boot_delay=0.05, post_boot_delay=2.0,
sv_overrides=dict(), **kwargs):
"""Boot a SpiNNaker machine of the given size.
Parameters
----------
hostname : str
Hostname or IP address of the ... | [
"def",
"boot",
"(",
"hostname",
",",
"boot_port",
"=",
"consts",
".",
"BOOT_PORT",
",",
"scamp_binary",
"=",
"None",
",",
"sark_struct",
"=",
"None",
",",
"boot_delay",
"=",
"0.05",
",",
"post_boot_delay",
"=",
"2.0",
",",
"sv_overrides",
"=",
"dict",
"(",... | Boot a SpiNNaker machine of the given size.
Parameters
----------
hostname : str
Hostname or IP address of the SpiNNaker chip to use to boot the system.
boot_port : int
The port number to sent boot packets to.
scamp_binary : filename or None
Filename of the binary to boot th... | [
"Boot",
"a",
"SpiNNaker",
"machine",
"of",
"the",
"given",
"size",
"."
] | train | https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/boot.py#L62-L164 |
project-rig/rig | rig/machine_control/boot.py | boot_packet | def boot_packet(sock, cmd, arg1=0, arg2=0, arg3=0, data=b""):
"""Create and transmit a packet to boot the machine.
Parameters
----------
sock : :py:class:`~socket.socket`
Connected socket to use to transmit the packet.
cmd : int
arg1 : int
arg2 : int
arg3 : int
data : :py:cl... | python | def boot_packet(sock, cmd, arg1=0, arg2=0, arg3=0, data=b""):
"""Create and transmit a packet to boot the machine.
Parameters
----------
sock : :py:class:`~socket.socket`
Connected socket to use to transmit the packet.
cmd : int
arg1 : int
arg2 : int
arg3 : int
data : :py:cl... | [
"def",
"boot_packet",
"(",
"sock",
",",
"cmd",
",",
"arg1",
"=",
"0",
",",
"arg2",
"=",
"0",
",",
"arg3",
"=",
"0",
",",
"data",
"=",
"b\"\"",
")",
":",
"PROTOCOL_VERSION",
"=",
"1",
"# Generate the (network-byte order) header",
"header",
"=",
"struct",
... | Create and transmit a packet to boot the machine.
Parameters
----------
sock : :py:class:`~socket.socket`
Connected socket to use to transmit the packet.
cmd : int
arg1 : int
arg2 : int
arg3 : int
data : :py:class:`bytes`
Optional data to include in the packet. | [
"Create",
"and",
"transmit",
"a",
"packet",
"to",
"boot",
"the",
"machine",
"."
] | train | https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/boot.py#L167-L195 |
project-rig/rig | rig/place_and_route/machine.py | Machine.copy | def copy(self):
"""Produce a copy of this datastructure."""
return Machine(
self.width, self.height,
self.chip_resources, self.chip_resource_exceptions,
self.dead_chips, self.dead_links) | python | def copy(self):
"""Produce a copy of this datastructure."""
return Machine(
self.width, self.height,
self.chip_resources, self.chip_resource_exceptions,
self.dead_chips, self.dead_links) | [
"def",
"copy",
"(",
"self",
")",
":",
"return",
"Machine",
"(",
"self",
".",
"width",
",",
"self",
".",
"height",
",",
"self",
".",
"chip_resources",
",",
"self",
".",
"chip_resource_exceptions",
",",
"self",
".",
"dead_chips",
",",
"self",
".",
"dead_li... | Produce a copy of this datastructure. | [
"Produce",
"a",
"copy",
"of",
"this",
"datastructure",
"."
] | train | https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/place_and_route/machine.py#L115-L120 |
project-rig/rig | rig/place_and_route/machine.py | Machine.issubset | def issubset(self, other):
"""Test whether the resources available in this machine description are
a (non-strict) subset of those available in another machine.
.. note::
This test being False does not imply that the this machine is
a superset of the other machine; machi... | python | def issubset(self, other):
"""Test whether the resources available in this machine description are
a (non-strict) subset of those available in another machine.
.. note::
This test being False does not imply that the this machine is
a superset of the other machine; machi... | [
"def",
"issubset",
"(",
"self",
",",
"other",
")",
":",
"return",
"(",
"set",
"(",
"self",
")",
".",
"issubset",
"(",
"set",
"(",
"other",
")",
")",
"and",
"set",
"(",
"self",
".",
"iter_links",
"(",
")",
")",
".",
"issubset",
"(",
"set",
"(",
... | Test whether the resources available in this machine description are
a (non-strict) subset of those available in another machine.
.. note::
This test being False does not imply that the this machine is
a superset of the other machine; machines may have disjoint
reso... | [
"Test",
"whether",
"the",
"resources",
"available",
"in",
"this",
"machine",
"description",
"are",
"a",
"(",
"non",
"-",
"strict",
")",
"subset",
"of",
"those",
"available",
"in",
"another",
"machine",
"."
] | train | https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/place_and_route/machine.py#L137-L152 |
project-rig/rig | rig/place_and_route/machine.py | Machine.iter_links | def iter_links(self):
"""An iterator over the working links in the machine.
Generates a series of (x, y, link) tuples.
"""
for x in range(self.width):
for y in range(self.height):
for link in Links:
if (x, y, link) in self:
... | python | def iter_links(self):
"""An iterator over the working links in the machine.
Generates a series of (x, y, link) tuples.
"""
for x in range(self.width):
for y in range(self.height):
for link in Links:
if (x, y, link) in self:
... | [
"def",
"iter_links",
"(",
"self",
")",
":",
"for",
"x",
"in",
"range",
"(",
"self",
".",
"width",
")",
":",
"for",
"y",
"in",
"range",
"(",
"self",
".",
"height",
")",
":",
"for",
"link",
"in",
"Links",
":",
"if",
"(",
"x",
",",
"y",
",",
"li... | An iterator over the working links in the machine.
Generates a series of (x, y, link) tuples. | [
"An",
"iterator",
"over",
"the",
"working",
"links",
"in",
"the",
"machine",
"."
] | train | https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/place_and_route/machine.py#L209-L218 |
project-rig/rig | rig/place_and_route/machine.py | Machine.has_wrap_around_links | def has_wrap_around_links(self, minimum_working=0.9):
"""Test if a machine has wrap-around connections installed.
Since the Machine object does not explicitly define whether a machine
has wrap-around links they must be tested for directly. This test
performs a "fuzzy" test on the number... | python | def has_wrap_around_links(self, minimum_working=0.9):
"""Test if a machine has wrap-around connections installed.
Since the Machine object does not explicitly define whether a machine
has wrap-around links they must be tested for directly. This test
performs a "fuzzy" test on the number... | [
"def",
"has_wrap_around_links",
"(",
"self",
",",
"minimum_working",
"=",
"0.9",
")",
":",
"working",
"=",
"0",
"for",
"x",
"in",
"range",
"(",
"self",
".",
"width",
")",
":",
"if",
"(",
"x",
",",
"0",
",",
"Links",
".",
"south",
")",
"in",
"self",... | Test if a machine has wrap-around connections installed.
Since the Machine object does not explicitly define whether a machine
has wrap-around links they must be tested for directly. This test
performs a "fuzzy" test on the number of wrap-around links which are
working to determine if w... | [
"Test",
"if",
"a",
"machine",
"has",
"wrap",
"-",
"around",
"connections",
"installed",
"."
] | train | https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/place_and_route/machine.py#L220-L265 |
Metatab/metapack | metapack/cli/core.py | write_doc | def write_doc(doc : MetapackDoc, mt_file=None):
"""
Write a Metatab doc to a CSV file, and update the Modified time
:param doc:
:param mt_file:
:return:
"""
from rowgenerators import parse_app_url
if not mt_file:
mt_file = doc.ref
add_giturl(doc)
u = parse_app_url(mt_... | python | def write_doc(doc : MetapackDoc, mt_file=None):
"""
Write a Metatab doc to a CSV file, and update the Modified time
:param doc:
:param mt_file:
:return:
"""
from rowgenerators import parse_app_url
if not mt_file:
mt_file = doc.ref
add_giturl(doc)
u = parse_app_url(mt_... | [
"def",
"write_doc",
"(",
"doc",
":",
"MetapackDoc",
",",
"mt_file",
"=",
"None",
")",
":",
"from",
"rowgenerators",
"import",
"parse_app_url",
"if",
"not",
"mt_file",
":",
"mt_file",
"=",
"doc",
".",
"ref",
"add_giturl",
"(",
"doc",
")",
"u",
"=",
"parse... | Write a Metatab doc to a CSV file, and update the Modified time
:param doc:
:param mt_file:
:return: | [
"Write",
"a",
"Metatab",
"doc",
"to",
"a",
"CSV",
"file",
"and",
"update",
"the",
"Modified",
"time",
":",
"param",
"doc",
":",
":",
"param",
"mt_file",
":",
":",
"return",
":"
] | train | https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/cli/core.py#L315-L336 |
Metatab/metapack | metapack/cli/core.py | update_resource_properties | def update_resource_properties(r, orig_columns={}, force=False):
"""Get descriptions and other properties from this, or upstream, packages, and add them to the schema. """
added = []
schema_term = r.schema_term
if not schema_term:
warn("No schema term for ", r.name)
return
rg = r... | python | def update_resource_properties(r, orig_columns={}, force=False):
"""Get descriptions and other properties from this, or upstream, packages, and add them to the schema. """
added = []
schema_term = r.schema_term
if not schema_term:
warn("No schema term for ", r.name)
return
rg = r... | [
"def",
"update_resource_properties",
"(",
"r",
",",
"orig_columns",
"=",
"{",
"}",
",",
"force",
"=",
"False",
")",
":",
"added",
"=",
"[",
"]",
"schema_term",
"=",
"r",
".",
"schema_term",
"if",
"not",
"schema_term",
":",
"warn",
"(",
"\"No schema term fo... | Get descriptions and other properties from this, or upstream, packages, and add them to the schema. | [
"Get",
"descriptions",
"and",
"other",
"properties",
"from",
"this",
"or",
"upstream",
"packages",
"and",
"add",
"them",
"to",
"the",
"schema",
"."
] | train | https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/cli/core.py#L458-L522 |
Metatab/metapack | metapack/cli/core.py | get_config | def get_config():
"""Return a configuration dict"""
from os import environ
from os.path import expanduser
from pathlib import Path
import yaml
def pexp(p):
try:
return Path(p).expanduser()
except AttributeError:
# python 3.4
return Path(expand... | python | def get_config():
"""Return a configuration dict"""
from os import environ
from os.path import expanduser
from pathlib import Path
import yaml
def pexp(p):
try:
return Path(p).expanduser()
except AttributeError:
# python 3.4
return Path(expand... | [
"def",
"get_config",
"(",
")",
":",
"from",
"os",
"import",
"environ",
"from",
"os",
".",
"path",
"import",
"expanduser",
"from",
"pathlib",
"import",
"Path",
"import",
"yaml",
"def",
"pexp",
"(",
"p",
")",
":",
"try",
":",
"return",
"Path",
"(",
"p",
... | Return a configuration dict | [
"Return",
"a",
"configuration",
"dict"
] | train | https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/cli/core.py#L669-L701 |
Metatab/metapack | metapack/cli/core.py | find_csv_packages | def find_csv_packages(m, downloader):
"""Locate the build CSV package, which will have distributions if it was generated as
and S3 package"""
from metapack.package import CsvPackageBuilder
pkg_dir = m.package_root
name = m.doc.get_value('Root.Name')
package_path, cache_path = CsvPackageBuilde... | python | def find_csv_packages(m, downloader):
"""Locate the build CSV package, which will have distributions if it was generated as
and S3 package"""
from metapack.package import CsvPackageBuilder
pkg_dir = m.package_root
name = m.doc.get_value('Root.Name')
package_path, cache_path = CsvPackageBuilde... | [
"def",
"find_csv_packages",
"(",
"m",
",",
"downloader",
")",
":",
"from",
"metapack",
".",
"package",
"import",
"CsvPackageBuilder",
"pkg_dir",
"=",
"m",
".",
"package_root",
"name",
"=",
"m",
".",
"doc",
".",
"get_value",
"(",
"'Root.Name'",
")",
"package_... | Locate the build CSV package, which will have distributions if it was generated as
and S3 package | [
"Locate",
"the",
"build",
"CSV",
"package",
"which",
"will",
"have",
"distributions",
"if",
"it",
"was",
"generated",
"as",
"and",
"S3",
"package"
] | train | https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/cli/core.py#L765-L776 |
Microsoft/vsts-cd-manager | continuous_delivery/continuous_delivery.py | ContinuousDelivery.provisioning_configuration | def provisioning_configuration(
self, body, custom_headers=None, raw=False, **operation_config):
"""ProvisioningConfiguration.
:param body:
:type body: :class:`ContinuousDeploymentConfiguration
<vsts_info_provider.models.ContinuousDeploymentConfiguration>`
:param di... | python | def provisioning_configuration(
self, body, custom_headers=None, raw=False, **operation_config):
"""ProvisioningConfiguration.
:param body:
:type body: :class:`ContinuousDeploymentConfiguration
<vsts_info_provider.models.ContinuousDeploymentConfiguration>`
:param di... | [
"def",
"provisioning_configuration",
"(",
"self",
",",
"body",
",",
"custom_headers",
"=",
"None",
",",
"raw",
"=",
"False",
",",
"*",
"*",
"operation_config",
")",
":",
"# Construct URL",
"url",
"=",
"'/_apis/continuousdelivery/provisioningconfigurations'",
"# Constr... | ProvisioningConfiguration.
:param body:
:type body: :class:`ContinuousDeploymentConfiguration
<vsts_info_provider.models.ContinuousDeploymentConfiguration>`
:param dict custom_headers: headers that will be added to the request
:param bool raw: returns the direct response alongs... | [
"ProvisioningConfiguration",
"."
] | train | https://github.com/Microsoft/vsts-cd-manager/blob/2649d236be94d119b13e0ac607964c94a9e51fde/continuous_delivery/continuous_delivery.py#L69-L126 |
Microsoft/vsts-cd-manager | continuous_delivery/continuous_delivery.py | ContinuousDelivery.get_provisioning_configuration | def get_provisioning_configuration(
self, provisioning_configuration_id, custom_headers=None, raw=False, **operation_config):
"""GetContinuousDeploymentOperation.
:param provisioning_configuration_id:
:type provisioning_configuration_id: str
:param dict custom_headers: heade... | python | def get_provisioning_configuration(
self, provisioning_configuration_id, custom_headers=None, raw=False, **operation_config):
"""GetContinuousDeploymentOperation.
:param provisioning_configuration_id:
:type provisioning_configuration_id: str
:param dict custom_headers: heade... | [
"def",
"get_provisioning_configuration",
"(",
"self",
",",
"provisioning_configuration_id",
",",
"custom_headers",
"=",
"None",
",",
"raw",
"=",
"False",
",",
"*",
"*",
"operation_config",
")",
":",
"# Construct URL",
"url",
"=",
"'/_apis/continuousdelivery/provisioning... | GetContinuousDeploymentOperation.
:param provisioning_configuration_id:
:type provisioning_configuration_id: str
:param dict custom_headers: headers that will be added to the request
:param bool raw: returns the direct response alongside the
deserialized response
:param... | [
"GetContinuousDeploymentOperation",
"."
] | train | https://github.com/Microsoft/vsts-cd-manager/blob/2649d236be94d119b13e0ac607964c94a9e51fde/continuous_delivery/continuous_delivery.py#L128-L180 |
NicolasLM/spinach | spinach/contrib/spinachd/mail.py | serialize_email_messages | def serialize_email_messages(messages: List[EmailMessage]):
"""Serialize EmailMessages to be passed as task argument.
Pickle is used because serializing an EmailMessage to json can be a bit
tricky and would probably break if Django modifies the structure of the
object in the future.
"""
return ... | python | def serialize_email_messages(messages: List[EmailMessage]):
"""Serialize EmailMessages to be passed as task argument.
Pickle is used because serializing an EmailMessage to json can be a bit
tricky and would probably break if Django modifies the structure of the
object in the future.
"""
return ... | [
"def",
"serialize_email_messages",
"(",
"messages",
":",
"List",
"[",
"EmailMessage",
"]",
")",
":",
"return",
"[",
"base64",
".",
"b64encode",
"(",
"zlib",
".",
"compress",
"(",
"pickle",
".",
"dumps",
"(",
"m",
",",
"protocol",
"=",
"4",
")",
")",
")... | Serialize EmailMessages to be passed as task argument.
Pickle is used because serializing an EmailMessage to json can be a bit
tricky and would probably break if Django modifies the structure of the
object in the future. | [
"Serialize",
"EmailMessages",
"to",
"be",
"passed",
"as",
"task",
"argument",
"."
] | train | https://github.com/NicolasLM/spinach/blob/0122f916643101eab5cdc1f3da662b9446e372aa/spinach/contrib/spinachd/mail.py#L25-L35 |
NicolasLM/spinach | spinach/contrib/spinachd/mail.py | deserialize_email_messages | def deserialize_email_messages(messages: List[str]):
"""Deserialize EmailMessages passed as task argument."""
return [
pickle.loads(zlib.decompress(base64.b64decode(m)))
for m in messages
] | python | def deserialize_email_messages(messages: List[str]):
"""Deserialize EmailMessages passed as task argument."""
return [
pickle.loads(zlib.decompress(base64.b64decode(m)))
for m in messages
] | [
"def",
"deserialize_email_messages",
"(",
"messages",
":",
"List",
"[",
"str",
"]",
")",
":",
"return",
"[",
"pickle",
".",
"loads",
"(",
"zlib",
".",
"decompress",
"(",
"base64",
".",
"b64decode",
"(",
"m",
")",
")",
")",
"for",
"m",
"in",
"messages",... | Deserialize EmailMessages passed as task argument. | [
"Deserialize",
"EmailMessages",
"passed",
"as",
"task",
"argument",
"."
] | train | https://github.com/NicolasLM/spinach/blob/0122f916643101eab5cdc1f3da662b9446e372aa/spinach/contrib/spinachd/mail.py#L38-L43 |
Parsely/probably | probably/cdbf.py | CountdownBloomFilter._estimate_count | def _estimate_count(self):
""" Update the count number using the estimation of the unset ratio """
if self.estimate_z == 0:
self.estimate_z = (1.0 / self.nbr_bits)
self.estimate_z = min(self.estimate_z, 0.999999)
self.count = int(-(self.nbr_bits / self.nbr_slices) * np.log(1 ... | python | def _estimate_count(self):
""" Update the count number using the estimation of the unset ratio """
if self.estimate_z == 0:
self.estimate_z = (1.0 / self.nbr_bits)
self.estimate_z = min(self.estimate_z, 0.999999)
self.count = int(-(self.nbr_bits / self.nbr_slices) * np.log(1 ... | [
"def",
"_estimate_count",
"(",
"self",
")",
":",
"if",
"self",
".",
"estimate_z",
"==",
"0",
":",
"self",
".",
"estimate_z",
"=",
"(",
"1.0",
"/",
"self",
".",
"nbr_bits",
")",
"self",
".",
"estimate_z",
"=",
"min",
"(",
"self",
".",
"estimate_z",
",... | Update the count number using the estimation of the unset ratio | [
"Update",
"the",
"count",
"number",
"using",
"the",
"estimation",
"of",
"the",
"unset",
"ratio"
] | train | https://github.com/Parsely/probably/blob/5d80855c1645fb2813678d5bcfe6108e33d80b9e/probably/cdbf.py#L42-L47 |
Parsely/probably | probably/cdbf.py | CountdownBloomFilter.expiration_maintenance | def expiration_maintenance(self):
""" Decrement cell value if not zero
This maintenance process need to executed each self.compute_refresh_time()
"""
if self.cellarray[self.refresh_head] != 0:
self.cellarray[self.refresh_head] -= 1
self.refresh_head = (self.refres... | python | def expiration_maintenance(self):
""" Decrement cell value if not zero
This maintenance process need to executed each self.compute_refresh_time()
"""
if self.cellarray[self.refresh_head] != 0:
self.cellarray[self.refresh_head] -= 1
self.refresh_head = (self.refres... | [
"def",
"expiration_maintenance",
"(",
"self",
")",
":",
"if",
"self",
".",
"cellarray",
"[",
"self",
".",
"refresh_head",
"]",
"!=",
"0",
":",
"self",
".",
"cellarray",
"[",
"self",
".",
"refresh_head",
"]",
"-=",
"1",
"self",
".",
"refresh_head",
"=",
... | Decrement cell value if not zero
This maintenance process need to executed each self.compute_refresh_time() | [
"Decrement",
"cell",
"value",
"if",
"not",
"zero",
"This",
"maintenance",
"process",
"need",
"to",
"executed",
"each",
"self",
".",
"compute_refresh_time",
"()"
] | train | https://github.com/Parsely/probably/blob/5d80855c1645fb2813678d5bcfe6108e33d80b9e/probably/cdbf.py#L49-L55 |
Parsely/probably | probably/cdbf.py | CountdownBloomFilter.batched_expiration_maintenance_dev | def batched_expiration_maintenance_dev(self, elapsed_time):
""" Batched version of expiration_maintenance() """
num_iterations = self.num_batched_maintenance(elapsed_time)
for i in range(num_iterations):
self.expiration_maintenance() | python | def batched_expiration_maintenance_dev(self, elapsed_time):
""" Batched version of expiration_maintenance() """
num_iterations = self.num_batched_maintenance(elapsed_time)
for i in range(num_iterations):
self.expiration_maintenance() | [
"def",
"batched_expiration_maintenance_dev",
"(",
"self",
",",
"elapsed_time",
")",
":",
"num_iterations",
"=",
"self",
".",
"num_batched_maintenance",
"(",
"elapsed_time",
")",
"for",
"i",
"in",
"range",
"(",
"num_iterations",
")",
":",
"self",
".",
"expiration_m... | Batched version of expiration_maintenance() | [
"Batched",
"version",
"of",
"expiration_maintenance",
"()"
] | train | https://github.com/Parsely/probably/blob/5d80855c1645fb2813678d5bcfe6108e33d80b9e/probably/cdbf.py#L57-L61 |
Parsely/probably | probably/cdbf.py | CountdownBloomFilter.batched_expiration_maintenance | def batched_expiration_maintenance(self, elapsed_time):
""" Batched version of expiration_maintenance()
Cython version
"""
num_iterations = self.num_batched_maintenance(elapsed_time)
self.refresh_head, nonzero = maintenance(self.cellarray, self.nbr_bits, num_iterations, self.... | python | def batched_expiration_maintenance(self, elapsed_time):
""" Batched version of expiration_maintenance()
Cython version
"""
num_iterations = self.num_batched_maintenance(elapsed_time)
self.refresh_head, nonzero = maintenance(self.cellarray, self.nbr_bits, num_iterations, self.... | [
"def",
"batched_expiration_maintenance",
"(",
"self",
",",
"elapsed_time",
")",
":",
"num_iterations",
"=",
"self",
".",
"num_batched_maintenance",
"(",
"elapsed_time",
")",
"self",
".",
"refresh_head",
",",
"nonzero",
"=",
"maintenance",
"(",
"self",
".",
"cellar... | Batched version of expiration_maintenance()
Cython version | [
"Batched",
"version",
"of",
"expiration_maintenance",
"()",
"Cython",
"version"
] | train | https://github.com/Parsely/probably/blob/5d80855c1645fb2813678d5bcfe6108e33d80b9e/probably/cdbf.py#L63-L73 |
Parsely/probably | probably/cdbf.py | CountdownBloomFilter.compute_refresh_time | def compute_refresh_time(self):
""" Compute the refresh period for the given expiration delay """
if self.z == 0:
self.z = 1E-10
s = float(self.expiration) * (1.0/(self.nbr_bits)) * (1.0/(self.counter_init - 1 + (1.0/(self.z * (self.nbr_slices + 1)))))
return s | python | def compute_refresh_time(self):
""" Compute the refresh period for the given expiration delay """
if self.z == 0:
self.z = 1E-10
s = float(self.expiration) * (1.0/(self.nbr_bits)) * (1.0/(self.counter_init - 1 + (1.0/(self.z * (self.nbr_slices + 1)))))
return s | [
"def",
"compute_refresh_time",
"(",
"self",
")",
":",
"if",
"self",
".",
"z",
"==",
"0",
":",
"self",
".",
"z",
"=",
"1E-10",
"s",
"=",
"float",
"(",
"self",
".",
"expiration",
")",
"*",
"(",
"1.0",
"/",
"(",
"self",
".",
"nbr_bits",
")",
")",
... | Compute the refresh period for the given expiration delay | [
"Compute",
"the",
"refresh",
"period",
"for",
"the",
"given",
"expiration",
"delay"
] | train | https://github.com/Parsely/probably/blob/5d80855c1645fb2813678d5bcfe6108e33d80b9e/probably/cdbf.py#L75-L80 |
NeuroML/NeuroMLlite | examples/Example7.py | generate | def generate():
################################################################################
### Build new network
net = Network(id='Example7_Brunel2000')
net.notes = 'Example 7: based on network of Brunel 2000'
net.parameters = { 'g': 4,
'eta': 1,
... | python | def generate():
################################################################################
### Build new network
net = Network(id='Example7_Brunel2000')
net.notes = 'Example 7: based on network of Brunel 2000'
net.parameters = { 'g': 4,
'eta': 1,
... | [
"def",
"generate",
"(",
")",
":",
"################################################################################",
"### Build new network",
"net",
"=",
"Network",
"(",
"id",
"=",
"'Example7_Brunel2000'",
")",
"net",
".",
"notes",
"=",
"'Example 7: based on network of Brune... | input_source = InputSource(id='iclamp0',
pynn_input='DCSource',
parameters={'amplitude':0.002, 'start':100., 'stop':900.})
input_source = InputSource(id='poissonFiringSyn',
neuroml2_input='poissonFiringSynapse',
... | [
"input_source",
"=",
"InputSource",
"(",
"id",
"=",
"iclamp0",
"pynn_input",
"=",
"DCSource",
"parameters",
"=",
"{",
"amplitude",
":",
"0",
".",
"002",
"start",
":",
"100",
".",
"stop",
":",
"900",
".",
"}",
")"
] | train | https://github.com/NeuroML/NeuroMLlite/blob/f3fa2ff662e40febfa97c045e7f0e6915ad04161/examples/Example7.py#L10-L137 |
project-rig/rig | rig/place_and_route/allocate/greedy.py | allocate | def allocate(vertices_resources, nets, machine, constraints, placements):
"""Allocate resources to vertices on cores arbitrarily using a simple greedy
algorithm.
"""
allocation = {}
# Globally reserved resource ranges {resource, [slice, ...], ...}
globally_reserved = defaultdict(list)
# Loc... | python | def allocate(vertices_resources, nets, machine, constraints, placements):
"""Allocate resources to vertices on cores arbitrarily using a simple greedy
algorithm.
"""
allocation = {}
# Globally reserved resource ranges {resource, [slice, ...], ...}
globally_reserved = defaultdict(list)
# Loc... | [
"def",
"allocate",
"(",
"vertices_resources",
",",
"nets",
",",
"machine",
",",
"constraints",
",",
"placements",
")",
":",
"allocation",
"=",
"{",
"}",
"# Globally reserved resource ranges {resource, [slice, ...], ...}",
"globally_reserved",
"=",
"defaultdict",
"(",
"l... | Allocate resources to vertices on cores arbitrarily using a simple greedy
algorithm. | [
"Allocate",
"resources",
"to",
"vertices",
"on",
"cores",
"arbitrarily",
"using",
"a",
"simple",
"greedy",
"algorithm",
"."
] | train | https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/place_and_route/allocate/greedy.py#L27-L99 |
openstack/networking-hyperv | networking_hyperv/neutron/qos/qos_driver.py | QosHyperVAgentDriver.create | def create(self, port, qos_policy):
"""Apply QoS rules on port for the first time.
:param port: port object.
:param qos_policy: the QoS policy to be applied on port.
"""
LOG.info("Setting QoS policy %(qos_policy)s on port %(port)s",
dict(qos_policy=qos_policy, p... | python | def create(self, port, qos_policy):
"""Apply QoS rules on port for the first time.
:param port: port object.
:param qos_policy: the QoS policy to be applied on port.
"""
LOG.info("Setting QoS policy %(qos_policy)s on port %(port)s",
dict(qos_policy=qos_policy, p... | [
"def",
"create",
"(",
"self",
",",
"port",
",",
"qos_policy",
")",
":",
"LOG",
".",
"info",
"(",
"\"Setting QoS policy %(qos_policy)s on port %(port)s\"",
",",
"dict",
"(",
"qos_policy",
"=",
"qos_policy",
",",
"port",
"=",
"port",
")",
")",
"policy_data",
"="... | Apply QoS rules on port for the first time.
:param port: port object.
:param qos_policy: the QoS policy to be applied on port. | [
"Apply",
"QoS",
"rules",
"on",
"port",
"for",
"the",
"first",
"time",
"."
] | train | https://github.com/openstack/networking-hyperv/blob/7a89306ab0586c95b99debb44d898f70834508b9/networking_hyperv/neutron/qos/qos_driver.py#L35-L45 |
openstack/networking-hyperv | networking_hyperv/neutron/qos/qos_driver.py | QosHyperVAgentDriver.delete | def delete(self, port, qos_policy=None):
"""Remove QoS rules from port.
:param port: port object.
:param qos_policy: the QoS policy to be removed from port.
"""
LOG.info("Deleting QoS policy %(qos_policy)s on port %(port)s",
dict(qos_policy=qos_policy, port=port... | python | def delete(self, port, qos_policy=None):
"""Remove QoS rules from port.
:param port: port object.
:param qos_policy: the QoS policy to be removed from port.
"""
LOG.info("Deleting QoS policy %(qos_policy)s on port %(port)s",
dict(qos_policy=qos_policy, port=port... | [
"def",
"delete",
"(",
"self",
",",
"port",
",",
"qos_policy",
"=",
"None",
")",
":",
"LOG",
".",
"info",
"(",
"\"Deleting QoS policy %(qos_policy)s on port %(port)s\"",
",",
"dict",
"(",
"qos_policy",
"=",
"qos_policy",
",",
"port",
"=",
"port",
")",
")",
"s... | Remove QoS rules from port.
:param port: port object.
:param qos_policy: the QoS policy to be removed from port. | [
"Remove",
"QoS",
"rules",
"from",
"port",
"."
] | train | https://github.com/openstack/networking-hyperv/blob/7a89306ab0586c95b99debb44d898f70834508b9/networking_hyperv/neutron/qos/qos_driver.py#L59-L68 |
NicolasLM/spinach | spinach/task.py | Tasks.task | def task(self, func: Optional[Callable]=None, name: Optional[str]=None,
queue: Optional[str]=None, max_retries: Optional[Number]=None,
periodicity: Optional[timedelta]=None):
"""Decorator to register a task function.
:arg name: name of the task, used later to schedule jobs
... | python | def task(self, func: Optional[Callable]=None, name: Optional[str]=None,
queue: Optional[str]=None, max_retries: Optional[Number]=None,
periodicity: Optional[timedelta]=None):
"""Decorator to register a task function.
:arg name: name of the task, used later to schedule jobs
... | [
"def",
"task",
"(",
"self",
",",
"func",
":",
"Optional",
"[",
"Callable",
"]",
"=",
"None",
",",
"name",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"queue",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"max_retries",
":",
"Optional... | Decorator to register a task function.
:arg name: name of the task, used later to schedule jobs
:arg queue: queue of the task, the default is used if not provided
:arg max_retries: maximum number of retries, the default is used if
not provided
:arg periodicity: for periodic... | [
"Decorator",
"to",
"register",
"a",
"task",
"function",
"."
] | train | https://github.com/NicolasLM/spinach/blob/0122f916643101eab5cdc1f3da662b9446e372aa/spinach/task.py#L99-L128 |
NicolasLM/spinach | spinach/task.py | Tasks.add | def add(self, func: Callable, name: Optional[str]=None,
queue: Optional[str]=None, max_retries: Optional[Number]=None,
periodicity: Optional[timedelta]=None):
"""Register a task function.
:arg func: a callable to be executed
:arg name: name of the task, used later to sch... | python | def add(self, func: Callable, name: Optional[str]=None,
queue: Optional[str]=None, max_retries: Optional[Number]=None,
periodicity: Optional[timedelta]=None):
"""Register a task function.
:arg func: a callable to be executed
:arg name: name of the task, used later to sch... | [
"def",
"add",
"(",
"self",
",",
"func",
":",
"Callable",
",",
"name",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"queue",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"max_retries",
":",
"Optional",
"[",
"Number",
"]",
"=",
"None",
... | Register a task function.
:arg func: a callable to be executed
:arg name: name of the task, used later to schedule jobs
:arg queue: queue of the task, the default is used if not provided
:arg max_retries: maximum number of retries, the default is used if
not provided
... | [
"Register",
"a",
"task",
"function",
"."
] | train | https://github.com/NicolasLM/spinach/blob/0122f916643101eab5cdc1f3da662b9446e372aa/spinach/task.py#L130-L170 |
NicolasLM/spinach | spinach/task.py | Tasks.schedule | def schedule(self, task: Schedulable, *args, **kwargs):
"""Schedule a job to be executed as soon as possible.
:arg task: the task or its name to execute in the background
:arg args: args to be passed to the task function
:arg kwargs: kwargs to be passed to the task function
Thi... | python | def schedule(self, task: Schedulable, *args, **kwargs):
"""Schedule a job to be executed as soon as possible.
:arg task: the task or its name to execute in the background
:arg args: args to be passed to the task function
:arg kwargs: kwargs to be passed to the task function
Thi... | [
"def",
"schedule",
"(",
"self",
",",
"task",
":",
"Schedulable",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_require_attached_tasks",
"(",
")",
"self",
".",
"_spin",
".",
"schedule",
"(",
"task",
",",
"*",
"args",
",",
"*",
... | Schedule a job to be executed as soon as possible.
:arg task: the task or its name to execute in the background
:arg args: args to be passed to the task function
:arg kwargs: kwargs to be passed to the task function
This method can only be used once tasks have been attached to a
... | [
"Schedule",
"a",
"job",
"to",
"be",
"executed",
"as",
"soon",
"as",
"possible",
"."
] | train | https://github.com/NicolasLM/spinach/blob/0122f916643101eab5cdc1f3da662b9446e372aa/spinach/task.py#L179-L190 |
NicolasLM/spinach | spinach/task.py | Tasks.schedule_at | def schedule_at(self, task: Schedulable, at: datetime, *args, **kwargs):
"""Schedule a job to be executed in the future.
:arg task: the task or its name to execute in the background
:arg at: Date at which the job should start. It is advised to pass a
timezone aware datetime to ... | python | def schedule_at(self, task: Schedulable, at: datetime, *args, **kwargs):
"""Schedule a job to be executed in the future.
:arg task: the task or its name to execute in the background
:arg at: Date at which the job should start. It is advised to pass a
timezone aware datetime to ... | [
"def",
"schedule_at",
"(",
"self",
",",
"task",
":",
"Schedulable",
",",
"at",
":",
"datetime",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_require_attached_tasks",
"(",
")",
"self",
".",
"_spin",
".",
"schedule_at",
"(",
"task"... | Schedule a job to be executed in the future.
:arg task: the task or its name to execute in the background
:arg at: Date at which the job should start. It is advised to pass a
timezone aware datetime to lift any ambiguity. However if a
timezone naive datetime if given, ... | [
"Schedule",
"a",
"job",
"to",
"be",
"executed",
"in",
"the",
"future",
"."
] | train | https://github.com/NicolasLM/spinach/blob/0122f916643101eab5cdc1f3da662b9446e372aa/spinach/task.py#L192-L207 |
NicolasLM/spinach | spinach/task.py | Batch.schedule | def schedule(self, task: Schedulable, *args, **kwargs):
"""Add a job to be executed ASAP to the batch.
:arg task: the task or its name to execute in the background
:arg args: args to be passed to the task function
:arg kwargs: kwargs to be passed to the task function
"""
... | python | def schedule(self, task: Schedulable, *args, **kwargs):
"""Add a job to be executed ASAP to the batch.
:arg task: the task or its name to execute in the background
:arg args: args to be passed to the task function
:arg kwargs: kwargs to be passed to the task function
"""
... | [
"def",
"schedule",
"(",
"self",
",",
"task",
":",
"Schedulable",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"at",
"=",
"datetime",
".",
"now",
"(",
"timezone",
".",
"utc",
")",
"self",
".",
"schedule_at",
"(",
"task",
",",
"at",
",",
"*... | Add a job to be executed ASAP to the batch.
:arg task: the task or its name to execute in the background
:arg args: args to be passed to the task function
:arg kwargs: kwargs to be passed to the task function | [
"Add",
"a",
"job",
"to",
"be",
"executed",
"ASAP",
"to",
"the",
"batch",
"."
] | train | https://github.com/NicolasLM/spinach/blob/0122f916643101eab5cdc1f3da662b9446e372aa/spinach/task.py#L243-L251 |
NicolasLM/spinach | spinach/task.py | Batch.schedule_at | def schedule_at(self, task: Schedulable, at: datetime, *args, **kwargs):
"""Add a job to be executed in the future to the batch.
:arg task: the task or its name to execute in the background
:arg at: Date at which the job should start. It is advised to pass a
timezone aware date... | python | def schedule_at(self, task: Schedulable, at: datetime, *args, **kwargs):
"""Add a job to be executed in the future to the batch.
:arg task: the task or its name to execute in the background
:arg at: Date at which the job should start. It is advised to pass a
timezone aware date... | [
"def",
"schedule_at",
"(",
"self",
",",
"task",
":",
"Schedulable",
",",
"at",
":",
"datetime",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"jobs_to_create",
".",
"append",
"(",
"(",
"task",
",",
"at",
",",
"args",
",",
"kwarg... | Add a job to be executed in the future to the batch.
:arg task: the task or its name to execute in the background
:arg at: Date at which the job should start. It is advised to pass a
timezone aware datetime to lift any ambiguity. However if a
timezone naive datetime if... | [
"Add",
"a",
"job",
"to",
"be",
"executed",
"in",
"the",
"future",
"to",
"the",
"batch",
"."
] | train | https://github.com/NicolasLM/spinach/blob/0122f916643101eab5cdc1f3da662b9446e372aa/spinach/task.py#L253-L264 |
project-rig/rig | rig/machine_control/common.py | unpack_sver_response_version | def unpack_sver_response_version(packet):
"""For internal use. Unpack the version-related parts of an sver (aka
CMD_VERSION) response.
Parameters
----------
packet : :py:class:`~rig.machine_control.packets.SCPPacket`
The packet recieved in response to the version command.
Returns
-... | python | def unpack_sver_response_version(packet):
"""For internal use. Unpack the version-related parts of an sver (aka
CMD_VERSION) response.
Parameters
----------
packet : :py:class:`~rig.machine_control.packets.SCPPacket`
The packet recieved in response to the version command.
Returns
-... | [
"def",
"unpack_sver_response_version",
"(",
"packet",
")",
":",
"software_name",
"=",
"packet",
".",
"data",
".",
"decode",
"(",
"\"utf-8\"",
")",
"legacy_version_field",
"=",
"packet",
".",
"arg2",
">>",
"16",
"if",
"legacy_version_field",
"!=",
"0xFFFF",
":",
... | For internal use. Unpack the version-related parts of an sver (aka
CMD_VERSION) response.
Parameters
----------
packet : :py:class:`~rig.machine_control.packets.SCPPacket`
The packet recieved in response to the version command.
Returns
-------
software_name : string
The nam... | [
"For",
"internal",
"use",
".",
"Unpack",
"the",
"version",
"-",
"related",
"parts",
"of",
"an",
"sver",
"(",
"aka",
"CMD_VERSION",
")",
"response",
"."
] | train | https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/common.py#L20-L62 |
NeuroML/NeuroMLlite | neuromllite/NetworkGenerator.py | _locate_file | def _locate_file(f, base_dir):
"""
Utility method for finding full path to a filename as string
"""
if base_dir == None:
return f
file_name = os.path.join(base_dir, f)
real = os.path.realpath(file_name)
#print_v('- Located %s at %s'%(f,real))
return real | python | def _locate_file(f, base_dir):
"""
Utility method for finding full path to a filename as string
"""
if base_dir == None:
return f
file_name = os.path.join(base_dir, f)
real = os.path.realpath(file_name)
#print_v('- Located %s at %s'%(f,real))
return real | [
"def",
"_locate_file",
"(",
"f",
",",
"base_dir",
")",
":",
"if",
"base_dir",
"==",
"None",
":",
"return",
"f",
"file_name",
"=",
"os",
".",
"path",
".",
"join",
"(",
"base_dir",
",",
"f",
")",
"real",
"=",
"os",
".",
"path",
".",
"realpath",
"(",
... | Utility method for finding full path to a filename as string | [
"Utility",
"method",
"for",
"finding",
"full",
"path",
"to",
"a",
"filename",
"as",
"string"
] | train | https://github.com/NeuroML/NeuroMLlite/blob/f3fa2ff662e40febfa97c045e7f0e6915ad04161/neuromllite/NetworkGenerator.py#L10-L19 |
NeuroML/NeuroMLlite | neuromllite/NetworkGenerator.py | generate_network | def generate_network(nl_model,
handler,
seed=1234,
always_include_props=False,
include_connections=True,
include_inputs=True,
base_dir=None):
"""
Generate the network model as describ... | python | def generate_network(nl_model,
handler,
seed=1234,
always_include_props=False,
include_connections=True,
include_inputs=True,
base_dir=None):
"""
Generate the network model as describ... | [
"def",
"generate_network",
"(",
"nl_model",
",",
"handler",
",",
"seed",
"=",
"1234",
",",
"always_include_props",
"=",
"False",
",",
"include_connections",
"=",
"True",
",",
"include_inputs",
"=",
"True",
",",
"base_dir",
"=",
"None",
")",
":",
"pop_locations... | Generate the network model as described in NeuroMLlite in a specific handler,
e.g. NeuroMLHandler, PyNNHandler, etc. | [
"Generate",
"the",
"network",
"model",
"as",
"described",
"in",
"NeuroMLlite",
"in",
"a",
"specific",
"handler",
"e",
".",
"g",
".",
"NeuroMLHandler",
"PyNNHandler",
"etc",
"."
] | train | https://github.com/NeuroML/NeuroMLlite/blob/f3fa2ff662e40febfa97c045e7f0e6915ad04161/neuromllite/NetworkGenerator.py#L22-L267 |
NeuroML/NeuroMLlite | neuromllite/NetworkGenerator.py | check_to_generate_or_run | def check_to_generate_or_run(argv, sim):
"""
Useful method for calling in main method after network and simulation are
generated, to handle some standard export options like -jnml, -graph etc.
"""
print_v("Checking arguments: %s to see whether anything should be run in simulation %s (net: %s).... | python | def check_to_generate_or_run(argv, sim):
"""
Useful method for calling in main method after network and simulation are
generated, to handle some standard export options like -jnml, -graph etc.
"""
print_v("Checking arguments: %s to see whether anything should be run in simulation %s (net: %s).... | [
"def",
"check_to_generate_or_run",
"(",
"argv",
",",
"sim",
")",
":",
"print_v",
"(",
"\"Checking arguments: %s to see whether anything should be run in simulation %s (net: %s)...\"",
"%",
"(",
"argv",
",",
"sim",
".",
"id",
",",
"sim",
".",
"network",
")",
")",
"if",... | Useful method for calling in main method after network and simulation are
generated, to handle some standard export options like -jnml, -graph etc. | [
"Useful",
"method",
"for",
"calling",
"in",
"main",
"method",
"after",
"network",
"and",
"simulation",
"are",
"generated",
"to",
"handle",
"some",
"standard",
"export",
"options",
"like",
"-",
"jnml",
"-",
"graph",
"etc",
"."
] | train | https://github.com/NeuroML/NeuroMLlite/blob/f3fa2ff662e40febfa97c045e7f0e6915ad04161/neuromllite/NetworkGenerator.py#L270-L329 |
NeuroML/NeuroMLlite | neuromllite/NetworkGenerator.py | _extract_pynn_components_to_neuroml | def _extract_pynn_components_to_neuroml(nl_model, nml_doc=None):
"""
Parse the NeuroMLlite description for cell, synapses and inputs described as
PyNN elements (e.g. IF_cond_alpha, DCSource) and parameters, and convert
these to the equivalent elements in a NeuroMLDocument
"""
if nml_doc =... | python | def _extract_pynn_components_to_neuroml(nl_model, nml_doc=None):
"""
Parse the NeuroMLlite description for cell, synapses and inputs described as
PyNN elements (e.g. IF_cond_alpha, DCSource) and parameters, and convert
these to the equivalent elements in a NeuroMLDocument
"""
if nml_doc =... | [
"def",
"_extract_pynn_components_to_neuroml",
"(",
"nl_model",
",",
"nml_doc",
"=",
"None",
")",
":",
"if",
"nml_doc",
"==",
"None",
":",
"from",
"neuroml",
"import",
"NeuroMLDocument",
"nml_doc",
"=",
"NeuroMLDocument",
"(",
"id",
"=",
"\"temp\"",
")",
"for",
... | Parse the NeuroMLlite description for cell, synapses and inputs described as
PyNN elements (e.g. IF_cond_alpha, DCSource) and parameters, and convert
these to the equivalent elements in a NeuroMLDocument | [
"Parse",
"the",
"NeuroMLlite",
"description",
"for",
"cell",
"synapses",
"and",
"inputs",
"described",
"as",
"PyNN",
"elements",
"(",
"e",
".",
"g",
".",
"IF_cond_alpha",
"DCSource",
")",
"and",
"parameters",
"and",
"convert",
"these",
"to",
"the",
"equivalent... | train | https://github.com/NeuroML/NeuroMLlite/blob/f3fa2ff662e40febfa97c045e7f0e6915ad04161/neuromllite/NetworkGenerator.py#L332-L410 |
NeuroML/NeuroMLlite | neuromllite/NetworkGenerator.py | generate_neuroml2_from_network | def generate_neuroml2_from_network(nl_model,
nml_file_name=None,
print_summary=True,
seed=1234,
format='xml',
base_dir=None,
... | python | def generate_neuroml2_from_network(nl_model,
nml_file_name=None,
print_summary=True,
seed=1234,
format='xml',
base_dir=None,
... | [
"def",
"generate_neuroml2_from_network",
"(",
"nl_model",
",",
"nml_file_name",
"=",
"None",
",",
"print_summary",
"=",
"True",
",",
"seed",
"=",
"1234",
",",
"format",
"=",
"'xml'",
",",
"base_dir",
"=",
"None",
",",
"copy_included_elements",
"=",
"False",
",... | Generate and save NeuroML2 file (in either XML or HDF5 format) from the
NeuroMLlite description | [
"Generate",
"and",
"save",
"NeuroML2",
"file",
"(",
"in",
"either",
"XML",
"or",
"HDF5",
"format",
")",
"from",
"the",
"NeuroMLlite",
"description"
] | train | https://github.com/NeuroML/NeuroMLlite/blob/f3fa2ff662e40febfa97c045e7f0e6915ad04161/neuromllite/NetworkGenerator.py#L413-L554 |
NeuroML/NeuroMLlite | neuromllite/NetworkGenerator.py | _generate_neuron_files_from_neuroml | def _generate_neuron_files_from_neuroml(network, verbose=False, dir_for_mod_files = None):
"""
Generate NEURON hoc/mod files from the NeuroML files which are marked as
included in the NeuroMLlite description; also compiles the mod files
"""
print_v("------------- Generating NEURON files from Neu... | python | def _generate_neuron_files_from_neuroml(network, verbose=False, dir_for_mod_files = None):
"""
Generate NEURON hoc/mod files from the NeuroML files which are marked as
included in the NeuroMLlite description; also compiles the mod files
"""
print_v("------------- Generating NEURON files from Neu... | [
"def",
"_generate_neuron_files_from_neuroml",
"(",
"network",
",",
"verbose",
"=",
"False",
",",
"dir_for_mod_files",
"=",
"None",
")",
":",
"print_v",
"(",
"\"------------- Generating NEURON files from NeuroML for %s (default dir: %s)...\"",
"%",
"(",
"network",
".",
"id... | Generate NEURON hoc/mod files from the NeuroML files which are marked as
included in the NeuroMLlite description; also compiles the mod files | [
"Generate",
"NEURON",
"hoc",
"/",
"mod",
"files",
"from",
"the",
"NeuroML",
"files",
"which",
"are",
"marked",
"as",
"included",
"in",
"the",
"NeuroMLlite",
"description",
";",
"also",
"compiles",
"the",
"mod",
"files"
] | train | https://github.com/NeuroML/NeuroMLlite/blob/f3fa2ff662e40febfa97c045e7f0e6915ad04161/neuromllite/NetworkGenerator.py#L559-L630 |
NeuroML/NeuroMLlite | neuromllite/NetworkGenerator.py | generate_and_run | def generate_and_run(simulation,
simulator,
network=None,
return_results=False,
base_dir=None,
target_dir=None,
num_processors=1):
"""
Generates the network in the specified simulato... | python | def generate_and_run(simulation,
simulator,
network=None,
return_results=False,
base_dir=None,
target_dir=None,
num_processors=1):
"""
Generates the network in the specified simulato... | [
"def",
"generate_and_run",
"(",
"simulation",
",",
"simulator",
",",
"network",
"=",
"None",
",",
"return_results",
"=",
"False",
",",
"base_dir",
"=",
"None",
",",
"target_dir",
"=",
"None",
",",
"num_processors",
"=",
"1",
")",
":",
"if",
"network",
"=="... | Generates the network in the specified simulator and runs, if appropriate | [
"Generates",
"the",
"network",
"in",
"the",
"specified",
"simulator",
"and",
"runs",
"if",
"appropriate"
] | train | https://github.com/NeuroML/NeuroMLlite/blob/f3fa2ff662e40febfa97c045e7f0e6915ad04161/neuromllite/NetworkGenerator.py#L633-L1046 |
NeuroML/NeuroMLlite | neuromllite/NetworkGenerator.py | _print_result_info | def _print_result_info(traces, events):
"""
Print a summary of the returned (voltage) traces and spike times
"""
print_v('Returning %i traces:'%len(traces))
for r in sorted(traces.keys()):
x = traces[r]
print_v(' %s (%s): %s -> %s (min: %s, max: %s, len: %i)'%(r, type(x), x[0],x[-1]... | python | def _print_result_info(traces, events):
"""
Print a summary of the returned (voltage) traces and spike times
"""
print_v('Returning %i traces:'%len(traces))
for r in sorted(traces.keys()):
x = traces[r]
print_v(' %s (%s): %s -> %s (min: %s, max: %s, len: %i)'%(r, type(x), x[0],x[-1]... | [
"def",
"_print_result_info",
"(",
"traces",
",",
"events",
")",
":",
"print_v",
"(",
"'Returning %i traces:'",
"%",
"len",
"(",
"traces",
")",
")",
"for",
"r",
"in",
"sorted",
"(",
"traces",
".",
"keys",
"(",
")",
")",
":",
"x",
"=",
"traces",
"[",
"... | Print a summary of the returned (voltage) traces and spike times | [
"Print",
"a",
"summary",
"of",
"the",
"returned",
"(",
"voltage",
")",
"traces",
"and",
"spike",
"times"
] | train | https://github.com/NeuroML/NeuroMLlite/blob/f3fa2ff662e40febfa97c045e7f0e6915ad04161/neuromllite/NetworkGenerator.py#L1049-L1060 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.