repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
dls-controls/pymalcolm | malcolm/core/hook.py | Hookable.register_hooked | def register_hooked(self,
hooks, # type: Union[Type[Hook], Sequence[Type[Hook]]]
func, # type: Hooked
args_gen=None # type: Optional[ArgsGen]
):
# type: (Type[Hook], Callable, Optional[Callable]) -> None
"... | python | def register_hooked(self,
hooks, # type: Union[Type[Hook], Sequence[Type[Hook]]]
func, # type: Hooked
args_gen=None # type: Optional[ArgsGen]
):
# type: (Type[Hook], Callable, Optional[Callable]) -> None
"... | [
"def",
"register_hooked",
"(",
"self",
",",
"hooks",
",",
"# type: Union[Type[Hook], Sequence[Type[Hook]]]",
"func",
",",
"# type: Hooked",
"args_gen",
"=",
"None",
"# type: Optional[ArgsGen]",
")",
":",
"# type: (Type[Hook], Callable, Optional[Callable]) -> None",
"if",
"self"... | Register func to be run when any of the hooks are run by parent
Args:
hooks: A Hook class or list of Hook classes of interest
func: The callable that should be run on that Hook
args_gen: Optionally specify the argument names that should be
passed to func. If ... | [
"Register",
"func",
"to",
"be",
"run",
"when",
"any",
"of",
"the",
"hooks",
"are",
"run",
"by",
"parent"
] | train | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/core/hook.py#L30-L51 |
dls-controls/pymalcolm | malcolm/core/hook.py | Hookable.on_hook | def on_hook(self, hook):
# type: (Hook) -> None
"""Takes a hook, and optionally calls hook.run on a function"""
try:
func, args_gen = self.hooked[type(hook)]
except (KeyError, TypeError):
return
else:
hook(func, args_gen()) | python | def on_hook(self, hook):
# type: (Hook) -> None
"""Takes a hook, and optionally calls hook.run on a function"""
try:
func, args_gen = self.hooked[type(hook)]
except (KeyError, TypeError):
return
else:
hook(func, args_gen()) | [
"def",
"on_hook",
"(",
"self",
",",
"hook",
")",
":",
"# type: (Hook) -> None",
"try",
":",
"func",
",",
"args_gen",
"=",
"self",
".",
"hooked",
"[",
"type",
"(",
"hook",
")",
"]",
"except",
"(",
"KeyError",
",",
"TypeError",
")",
":",
"return",
"else"... | Takes a hook, and optionally calls hook.run on a function | [
"Takes",
"a",
"hook",
"and",
"optionally",
"calls",
"hook",
".",
"run",
"on",
"a",
"function"
] | train | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/core/hook.py#L53-L61 |
dls-controls/pymalcolm | malcolm/core/stateset.py | StateSet.transition_allowed | def transition_allowed(self, initial_state, target_state):
# type: (str, str) -> bool
"""Check if a transition between two states is allowed"""
assert initial_state in self._allowed, \
"%s is not in %s" % (initial_state, list(self._allowed))
return target_state in self._allow... | python | def transition_allowed(self, initial_state, target_state):
# type: (str, str) -> bool
"""Check if a transition between two states is allowed"""
assert initial_state in self._allowed, \
"%s is not in %s" % (initial_state, list(self._allowed))
return target_state in self._allow... | [
"def",
"transition_allowed",
"(",
"self",
",",
"initial_state",
",",
"target_state",
")",
":",
"# type: (str, str) -> bool",
"assert",
"initial_state",
"in",
"self",
".",
"_allowed",
",",
"\"%s is not in %s\"",
"%",
"(",
"initial_state",
",",
"list",
"(",
"self",
... | Check if a transition between two states is allowed | [
"Check",
"if",
"a",
"transition",
"between",
"two",
"states",
"is",
"allowed"
] | train | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/core/stateset.py#L11-L16 |
dls-controls/pymalcolm | malcolm/core/stateset.py | StateSet.set_allowed | def set_allowed(self, initial_state, *allowed_states):
# type: (str, *str) -> None
"""Add an allowed transition from initial_state to allowed_states"""
allowed_states = list(allowed_states)
self._allowed.setdefault(initial_state, set()).update(allowed_states)
for state in allowed... | python | def set_allowed(self, initial_state, *allowed_states):
# type: (str, *str) -> None
"""Add an allowed transition from initial_state to allowed_states"""
allowed_states = list(allowed_states)
self._allowed.setdefault(initial_state, set()).update(allowed_states)
for state in allowed... | [
"def",
"set_allowed",
"(",
"self",
",",
"initial_state",
",",
"*",
"allowed_states",
")",
":",
"# type: (str, *str) -> None",
"allowed_states",
"=",
"list",
"(",
"allowed_states",
")",
"self",
".",
"_allowed",
".",
"setdefault",
"(",
"initial_state",
",",
"set",
... | Add an allowed transition from initial_state to allowed_states | [
"Add",
"an",
"allowed",
"transition",
"from",
"initial_state",
"to",
"allowed_states"
] | train | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/core/stateset.py#L18-L25 |
dls-controls/pymalcolm | malcolm/modules/builtin/defines.py | cmd_string | def cmd_string(name, cmd):
# type: (AName, ACmd) -> ADefine
"""Define a string parameter coming from a shell command to be used within
this YAML file. Trailing newlines will be stripped."""
value = subprocess.check_output(cmd, shell=True).rstrip("\n")
return Define(name, value) | python | def cmd_string(name, cmd):
# type: (AName, ACmd) -> ADefine
"""Define a string parameter coming from a shell command to be used within
this YAML file. Trailing newlines will be stripped."""
value = subprocess.check_output(cmd, shell=True).rstrip("\n")
return Define(name, value) | [
"def",
"cmd_string",
"(",
"name",
",",
"cmd",
")",
":",
"# type: (AName, ACmd) -> ADefine",
"value",
"=",
"subprocess",
".",
"check_output",
"(",
"cmd",
",",
"shell",
"=",
"True",
")",
".",
"rstrip",
"(",
"\"\\n\"",
")",
"return",
"Define",
"(",
"name",
",... | Define a string parameter coming from a shell command to be used within
this YAML file. Trailing newlines will be stripped. | [
"Define",
"a",
"string",
"parameter",
"coming",
"from",
"a",
"shell",
"command",
"to",
"be",
"used",
"within",
"this",
"YAML",
"file",
".",
"Trailing",
"newlines",
"will",
"be",
"stripped",
"."
] | train | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/modules/builtin/defines.py#L82-L87 |
dls-controls/pymalcolm | malcolm/modules/builtin/defines.py | export_env_string | def export_env_string(name, value):
# type: (AEnvName, AEnvValue) -> ADefine
"""Exports an environment variable with the given value"""
os.environ[name] = value
return Define(name, value) | python | def export_env_string(name, value):
# type: (AEnvName, AEnvValue) -> ADefine
"""Exports an environment variable with the given value"""
os.environ[name] = value
return Define(name, value) | [
"def",
"export_env_string",
"(",
"name",
",",
"value",
")",
":",
"# type: (AEnvName, AEnvValue) -> ADefine",
"os",
".",
"environ",
"[",
"name",
"]",
"=",
"value",
"return",
"Define",
"(",
"name",
",",
"value",
")"
] | Exports an environment variable with the given value | [
"Exports",
"an",
"environment",
"variable",
"with",
"the",
"given",
"value"
] | train | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/modules/builtin/defines.py#L97-L101 |
dls-controls/pymalcolm | malcolm/modules/builtin/defines.py | module_path | def module_path(name, path):
# type: (AModuleName, AModulePath) -> ADefine
"""Load an external malcolm module (e.g. ADCore/etc/malcolm)"""
define = Define(name, path)
assert os.path.isdir(path), "%r doesn't exist" % path
name = "malcolm.modules.%s" % name
import_package_from_path(name, path)
... | python | def module_path(name, path):
# type: (AModuleName, AModulePath) -> ADefine
"""Load an external malcolm module (e.g. ADCore/etc/malcolm)"""
define = Define(name, path)
assert os.path.isdir(path), "%r doesn't exist" % path
name = "malcolm.modules.%s" % name
import_package_from_path(name, path)
... | [
"def",
"module_path",
"(",
"name",
",",
"path",
")",
":",
"# type: (AModuleName, AModulePath) -> ADefine",
"define",
"=",
"Define",
"(",
"name",
",",
"path",
")",
"assert",
"os",
".",
"path",
".",
"isdir",
"(",
"path",
")",
",",
"\"%r doesn't exist\"",
"%",
... | Load an external malcolm module (e.g. ADCore/etc/malcolm) | [
"Load",
"an",
"external",
"malcolm",
"module",
"(",
"e",
".",
"g",
".",
"ADCore",
"/",
"etc",
"/",
"malcolm",
")"
] | train | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/modules/builtin/defines.py#L112-L119 |
dls-controls/pymalcolm | malcolm/modules/web/controllers/websocketclientcomms.py | WebsocketClientComms.on_message | def on_message(self, message):
"""Pass response from server to process receive queue
Args:
message(str): Received message
"""
# Called in tornado loop
try:
self.log.debug("Got message %s", message)
d = json_decode(message)
response... | python | def on_message(self, message):
"""Pass response from server to process receive queue
Args:
message(str): Received message
"""
# Called in tornado loop
try:
self.log.debug("Got message %s", message)
d = json_decode(message)
response... | [
"def",
"on_message",
"(",
"self",
",",
"message",
")",
":",
"# Called in tornado loop",
"try",
":",
"self",
".",
"log",
".",
"debug",
"(",
"\"Got message %s\"",
",",
"message",
")",
"d",
"=",
"json_decode",
"(",
"message",
")",
"response",
"=",
"deserialize_... | Pass response from server to process receive queue
Args:
message(str): Received message | [
"Pass",
"response",
"from",
"server",
"to",
"process",
"receive",
"queue"
] | train | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/modules/web/controllers/websocketclientcomms.py#L79-L102 |
dls-controls/pymalcolm | malcolm/modules/web/controllers/websocketclientcomms.py | WebsocketClientComms.sync_proxy | def sync_proxy(self, mri, block):
"""Abstract method telling the ClientComms to sync this proxy Block
with its remote counterpart. Should wait until it is connected
Args:
mri (str): The mri for the remote block
block (BlockModel): The local proxy Block to keep in sync
... | python | def sync_proxy(self, mri, block):
"""Abstract method telling the ClientComms to sync this proxy Block
with its remote counterpart. Should wait until it is connected
Args:
mri (str): The mri for the remote block
block (BlockModel): The local proxy Block to keep in sync
... | [
"def",
"sync_proxy",
"(",
"self",
",",
"mri",
",",
"block",
")",
":",
"# Send a root Subscribe to the server",
"subscribe",
"=",
"Subscribe",
"(",
"path",
"=",
"[",
"mri",
"]",
",",
"delta",
"=",
"True",
")",
"done_queue",
"=",
"Queue",
"(",
")",
"def",
... | Abstract method telling the ClientComms to sync this proxy Block
with its remote counterpart. Should wait until it is connected
Args:
mri (str): The mri for the remote block
block (BlockModel): The local proxy Block to keep in sync | [
"Abstract",
"method",
"telling",
"the",
"ClientComms",
"to",
"sync",
"this",
"proxy",
"Block",
"with",
"its",
"remote",
"counterpart",
".",
"Should",
"wait",
"until",
"it",
"is",
"connected"
] | train | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/modules/web/controllers/websocketclientcomms.py#L139-L163 |
dls-controls/pymalcolm | malcolm/modules/web/controllers/websocketclientcomms.py | WebsocketClientComms.send_put | def send_put(self, mri, attribute_name, value):
"""Abstract method to dispatch a Put to the server
Args:
mri (str): The mri of the Block
attribute_name (str): The name of the Attribute within the Block
value: The value to put
"""
q = Queue()
r... | python | def send_put(self, mri, attribute_name, value):
"""Abstract method to dispatch a Put to the server
Args:
mri (str): The mri of the Block
attribute_name (str): The name of the Attribute within the Block
value: The value to put
"""
q = Queue()
r... | [
"def",
"send_put",
"(",
"self",
",",
"mri",
",",
"attribute_name",
",",
"value",
")",
":",
"q",
"=",
"Queue",
"(",
")",
"request",
"=",
"Put",
"(",
"path",
"=",
"[",
"mri",
",",
"attribute_name",
",",
"\"value\"",
"]",
",",
"value",
"=",
"value",
"... | Abstract method to dispatch a Put to the server
Args:
mri (str): The mri of the Block
attribute_name (str): The name of the Attribute within the Block
value: The value to put | [
"Abstract",
"method",
"to",
"dispatch",
"a",
"Put",
"to",
"the",
"server"
] | train | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/modules/web/controllers/websocketclientcomms.py#L214-L232 |
dls-controls/pymalcolm | malcolm/modules/web/controllers/websocketclientcomms.py | WebsocketClientComms.send_post | def send_post(self, mri, method_name, **params):
"""Abstract method to dispatch a Post to the server
Args:
mri (str): The mri of the Block
method_name (str): The name of the Method within the Block
params: The parameters to send
Returns:
The retu... | python | def send_post(self, mri, method_name, **params):
"""Abstract method to dispatch a Post to the server
Args:
mri (str): The mri of the Block
method_name (str): The name of the Method within the Block
params: The parameters to send
Returns:
The retu... | [
"def",
"send_post",
"(",
"self",
",",
"mri",
",",
"method_name",
",",
"*",
"*",
"params",
")",
":",
"q",
"=",
"Queue",
"(",
")",
"request",
"=",
"Post",
"(",
"path",
"=",
"[",
"mri",
",",
"method_name",
"]",
",",
"parameters",
"=",
"params",
")",
... | Abstract method to dispatch a Post to the server
Args:
mri (str): The mri of the Block
method_name (str): The name of the Method within the Block
params: The parameters to send
Returns:
The return results from the server | [
"Abstract",
"method",
"to",
"dispatch",
"a",
"Post",
"to",
"the",
"server"
] | train | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/modules/web/controllers/websocketclientcomms.py#L234-L255 |
dls-controls/pymalcolm | malcolm/core/info.py | Info.filter_parts | def filter_parts(cls, part_info):
# type: (Type[T], PartInfo) -> Dict[str, List[T]]
"""Filter the part_info dict looking for instances of our class
Args:
part_info (dict): {part_name: [Info] or None} as returned from
Controller.run_hook()
Returns:
... | python | def filter_parts(cls, part_info):
# type: (Type[T], PartInfo) -> Dict[str, List[T]]
"""Filter the part_info dict looking for instances of our class
Args:
part_info (dict): {part_name: [Info] or None} as returned from
Controller.run_hook()
Returns:
... | [
"def",
"filter_parts",
"(",
"cls",
",",
"part_info",
")",
":",
"# type: (Type[T], PartInfo) -> Dict[str, List[T]]",
"filtered",
"=",
"OrderedDict",
"(",
")",
"for",
"part_name",
",",
"info_list",
"in",
"part_info",
".",
"items",
"(",
")",
":",
"if",
"info_list",
... | Filter the part_info dict looking for instances of our class
Args:
part_info (dict): {part_name: [Info] or None} as returned from
Controller.run_hook()
Returns:
dict: {part_name: [info]} where info is a subclass of cls | [
"Filter",
"the",
"part_info",
"dict",
"looking",
"for",
"instances",
"of",
"our",
"class"
] | train | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/core/info.py#L26-L44 |
dls-controls/pymalcolm | malcolm/core/info.py | Info.filter_values | def filter_values(cls, part_info):
# type: (Type[T], PartInfo) -> List[T]
"""Filter the part_info dict list looking for instances of our class
Args:
part_info (dict): {part_name: [Info] or None} as returned from
Controller.run_hook()
Returns:
lis... | python | def filter_values(cls, part_info):
# type: (Type[T], PartInfo) -> List[T]
"""Filter the part_info dict list looking for instances of our class
Args:
part_info (dict): {part_name: [Info] or None} as returned from
Controller.run_hook()
Returns:
lis... | [
"def",
"filter_values",
"(",
"cls",
",",
"part_info",
")",
":",
"# type: (Type[T], PartInfo) -> List[T]",
"filtered",
"=",
"[",
"]",
"for",
"info_list",
"in",
"cls",
".",
"filter_parts",
"(",
"part_info",
")",
".",
"values",
"(",
")",
":",
"filtered",
"+=",
... | Filter the part_info dict list looking for instances of our class
Args:
part_info (dict): {part_name: [Info] or None} as returned from
Controller.run_hook()
Returns:
list: [info] where info is a subclass of cls | [
"Filter",
"the",
"part_info",
"dict",
"list",
"looking",
"for",
"instances",
"of",
"our",
"class"
] | train | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/core/info.py#L47-L61 |
dls-controls/pymalcolm | malcolm/core/info.py | Info.filter_single_value | def filter_single_value(cls, part_info, error_msg=None):
# type: (Type[T], PartInfo, str) -> T
"""Filter the part_info dict list looking for a single instance of our
class
Args:
part_info (dict): {part_name: [Info] or None} as returned from
Controller.run_hoo... | python | def filter_single_value(cls, part_info, error_msg=None):
# type: (Type[T], PartInfo, str) -> T
"""Filter the part_info dict list looking for a single instance of our
class
Args:
part_info (dict): {part_name: [Info] or None} as returned from
Controller.run_hoo... | [
"def",
"filter_single_value",
"(",
"cls",
",",
"part_info",
",",
"error_msg",
"=",
"None",
")",
":",
"# type: (Type[T], PartInfo, str) -> T",
"filtered",
"=",
"cls",
".",
"filter_values",
"(",
"part_info",
")",
"if",
"len",
"(",
"filtered",
")",
"!=",
"1",
":"... | Filter the part_info dict list looking for a single instance of our
class
Args:
part_info (dict): {part_name: [Info] or None} as returned from
Controller.run_hook()
error_msg (str, optional): Specific error message to show if
there isn't a single ... | [
"Filter",
"the",
"part_info",
"dict",
"list",
"looking",
"for",
"a",
"single",
"instance",
"of",
"our",
"class"
] | train | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/core/info.py#L64-L84 |
dls-controls/pymalcolm | malcolm/modules/pva/controllers/pvaservercomms.py | PvaServerComms.disconnect_pv_clients | def disconnect_pv_clients(self, mris):
# type: (List[str]) -> None
"""Disconnect anyone listening to any of the given mris"""
for mri in mris:
for pv in self._pvs.pop(mri, {}).values():
# Close pv with force destroy on, this will call
# onLastDisconnec... | python | def disconnect_pv_clients(self, mris):
# type: (List[str]) -> None
"""Disconnect anyone listening to any of the given mris"""
for mri in mris:
for pv in self._pvs.pop(mri, {}).values():
# Close pv with force destroy on, this will call
# onLastDisconnec... | [
"def",
"disconnect_pv_clients",
"(",
"self",
",",
"mris",
")",
":",
"# type: (List[str]) -> None",
"for",
"mri",
"in",
"mris",
":",
"for",
"pv",
"in",
"self",
".",
"_pvs",
".",
"pop",
"(",
"mri",
",",
"{",
"}",
")",
".",
"values",
"(",
")",
":",
"# C... | Disconnect anyone listening to any of the given mris | [
"Disconnect",
"anyone",
"listening",
"to",
"any",
"of",
"the",
"given",
"mris"
] | train | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/modules/pva/controllers/pvaservercomms.py#L317-L324 |
dls-controls/pymalcolm | malcolm/core/tags.py | Port.with_source_port_tag | def with_source_port_tag(self, tags, connected_value):
"""Add a Source Port tag to the tags list, removing any other Source
Ports"""
new_tags = [t for t in tags if not t.startswith("sourcePort:")]
new_tags.append(self.source_port_tag(connected_value))
return new_tags | python | def with_source_port_tag(self, tags, connected_value):
"""Add a Source Port tag to the tags list, removing any other Source
Ports"""
new_tags = [t for t in tags if not t.startswith("sourcePort:")]
new_tags.append(self.source_port_tag(connected_value))
return new_tags | [
"def",
"with_source_port_tag",
"(",
"self",
",",
"tags",
",",
"connected_value",
")",
":",
"new_tags",
"=",
"[",
"t",
"for",
"t",
"in",
"tags",
"if",
"not",
"t",
".",
"startswith",
"(",
"\"sourcePort:\"",
")",
"]",
"new_tags",
".",
"append",
"(",
"self",... | Add a Source Port tag to the tags list, removing any other Source
Ports | [
"Add",
"a",
"Source",
"Port",
"tag",
"to",
"the",
"tags",
"list",
"removing",
"any",
"other",
"Source",
"Ports"
] | train | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/core/tags.py#L67-L72 |
dls-controls/pymalcolm | malcolm/core/tags.py | Port.port_tag_details | def port_tag_details(cls, tags):
# type: (Sequence[str]) -> Union[Tuple[bool, Port, str], None]
"""Search tags for port info, returning it
Args:
tags: A list of tags to check
Returns:
None or (is_source, port, connected_value|disconnected_value)
wher... | python | def port_tag_details(cls, tags):
# type: (Sequence[str]) -> Union[Tuple[bool, Port, str], None]
"""Search tags for port info, returning it
Args:
tags: A list of tags to check
Returns:
None or (is_source, port, connected_value|disconnected_value)
wher... | [
"def",
"port_tag_details",
"(",
"cls",
",",
"tags",
")",
":",
"# type: (Sequence[str]) -> Union[Tuple[bool, Port, str], None]",
"for",
"tag",
"in",
"tags",
":",
"match",
"=",
"port_tag_re",
".",
"match",
"(",
"tag",
")",
"if",
"match",
":",
"source_sink",
",",
"... | Search tags for port info, returning it
Args:
tags: A list of tags to check
Returns:
None or (is_source, port, connected_value|disconnected_value)
where port is one of the Enum entries of Port | [
"Search",
"tags",
"for",
"port",
"info",
"returning",
"it"
] | train | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/core/tags.py#L75-L90 |
dls-controls/pymalcolm | malcolm/modules/builtin/controllers/statefulcontroller.py | StatefulController.transition | def transition(self, state, message=""):
"""Change to a new state if the transition is allowed
Args:
state (str): State to transition to
message (str): Message if the transition is to a fault state
"""
with self.changes_squashed:
initial_state = self.... | python | def transition(self, state, message=""):
"""Change to a new state if the transition is allowed
Args:
state (str): State to transition to
message (str): Message if the transition is to a fault state
"""
with self.changes_squashed:
initial_state = self.... | [
"def",
"transition",
"(",
"self",
",",
"state",
",",
"message",
"=",
"\"\"",
")",
":",
"with",
"self",
".",
"changes_squashed",
":",
"initial_state",
"=",
"self",
".",
"state",
".",
"value",
"if",
"self",
".",
"state_set",
".",
"transition_allowed",
"(",
... | Change to a new state if the transition is allowed
Args:
state (str): State to transition to
message (str): Message if the transition is to a fault state | [
"Change",
"to",
"a",
"new",
"state",
"if",
"the",
"transition",
"is",
"allowed"
] | train | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/modules/builtin/controllers/statefulcontroller.py#L97-L127 |
dls-controls/pymalcolm | malcolm/modules/pva/controllers/pvaclientcomms.py | PvaClientComms.sync_proxy | def sync_proxy(self, mri, block):
"""Abstract method telling the ClientComms to sync this proxy Block
with its remote counterpart. Should wait until it is connected
Args:
mri (str): The mri for the remote block
block (BlockModel): The local proxy Block to keep in sync
... | python | def sync_proxy(self, mri, block):
"""Abstract method telling the ClientComms to sync this proxy Block
with its remote counterpart. Should wait until it is connected
Args:
mri (str): The mri for the remote block
block (BlockModel): The local proxy Block to keep in sync
... | [
"def",
"sync_proxy",
"(",
"self",
",",
"mri",
",",
"block",
")",
":",
"done_queue",
"=",
"Queue",
"(",
")",
"self",
".",
"_queues",
"[",
"mri",
"]",
"=",
"done_queue",
"update_fields",
"=",
"set",
"(",
")",
"def",
"callback",
"(",
"value",
"=",
"None... | Abstract method telling the ClientComms to sync this proxy Block
with its remote counterpart. Should wait until it is connected
Args:
mri (str): The mri for the remote block
block (BlockModel): The local proxy Block to keep in sync | [
"Abstract",
"method",
"telling",
"the",
"ClientComms",
"to",
"sync",
"this",
"proxy",
"Block",
"with",
"its",
"remote",
"counterpart",
".",
"Should",
"wait",
"until",
"it",
"is",
"connected"
] | train | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/modules/pva/controllers/pvaclientcomms.py#L48-L81 |
dls-controls/pymalcolm | malcolm/modules/pva/controllers/pvaclientcomms.py | PvaClientComms.send_put | def send_put(self, mri, attribute_name, value):
"""Abstract method to dispatch a Put to the server
Args:
mri (str): The mri of the Block
attribute_name (str): The name of the Attribute within the Block
value: The value to put
"""
path = attribute_name... | python | def send_put(self, mri, attribute_name, value):
"""Abstract method to dispatch a Put to the server
Args:
mri (str): The mri of the Block
attribute_name (str): The name of the Attribute within the Block
value: The value to put
"""
path = attribute_name... | [
"def",
"send_put",
"(",
"self",
",",
"mri",
",",
"attribute_name",
",",
"value",
")",
":",
"path",
"=",
"attribute_name",
"+",
"\".value\"",
"typ",
",",
"value",
"=",
"convert_to_type_tuple_value",
"(",
"serialize_object",
"(",
"value",
")",
")",
"if",
"isin... | Abstract method to dispatch a Put to the server
Args:
mri (str): The mri of the Block
attribute_name (str): The name of the Attribute within the Block
value: The value to put | [
"Abstract",
"method",
"to",
"dispatch",
"a",
"Put",
"to",
"the",
"server"
] | train | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/modules/pva/controllers/pvaclientcomms.py#L119-L143 |
dls-controls/pymalcolm | malcolm/modules/pva/controllers/pvaclientcomms.py | PvaClientComms.send_post | def send_post(self, mri, method_name, **params):
"""Abstract method to dispatch a Post to the server
Args:
mri (str): The mri of the Block
method_name (str): The name of the Method within the Block
params: The parameters to send
Returns:
The retu... | python | def send_post(self, mri, method_name, **params):
"""Abstract method to dispatch a Post to the server
Args:
mri (str): The mri of the Block
method_name (str): The name of the Method within the Block
params: The parameters to send
Returns:
The retu... | [
"def",
"send_post",
"(",
"self",
",",
"mri",
",",
"method_name",
",",
"*",
"*",
"params",
")",
":",
"typ",
",",
"parameters",
"=",
"convert_to_type_tuple_value",
"(",
"serialize_object",
"(",
"params",
")",
")",
"uri",
"=",
"NTURI",
"(",
"typ",
"[",
"2",... | Abstract method to dispatch a Post to the server
Args:
mri (str): The mri of the Block
method_name (str): The name of the Method within the Block
params: The parameters to send
Returns:
The return results from the server | [
"Abstract",
"method",
"to",
"dispatch",
"a",
"Post",
"to",
"the",
"server"
] | train | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/modules/pva/controllers/pvaclientcomms.py#L145-L165 |
dls-controls/pymalcolm | malcolm/core/controller.py | Controller.make_view | def make_view(self, context, data, child_name):
# type: (Context, Model, str) -> Any
"""Make a child View of data[child_name]"""
with self._lock:
child = data[child_name]
child_view = make_view(self, context, child)
return child_view | python | def make_view(self, context, data, child_name):
# type: (Context, Model, str) -> Any
"""Make a child View of data[child_name]"""
with self._lock:
child = data[child_name]
child_view = make_view(self, context, child)
return child_view | [
"def",
"make_view",
"(",
"self",
",",
"context",
",",
"data",
",",
"child_name",
")",
":",
"# type: (Context, Model, str) -> Any",
"with",
"self",
".",
"_lock",
":",
"child",
"=",
"data",
"[",
"child_name",
"]",
"child_view",
"=",
"make_view",
"(",
"self",
"... | Make a child View of data[child_name] | [
"Make",
"a",
"child",
"View",
"of",
"data",
"[",
"child_name",
"]"
] | train | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/core/controller.py#L110-L116 |
dls-controls/pymalcolm | malcolm/core/controller.py | Controller._handle_get | def _handle_get(self, request):
# type: (Get) -> CallbackResponses
"""Called with the lock taken"""
data = self._block
for i, endpoint in enumerate(request.path[1:]):
try:
data = data[endpoint]
except KeyError:
if hasattr(data, "ty... | python | def _handle_get(self, request):
# type: (Get) -> CallbackResponses
"""Called with the lock taken"""
data = self._block
for i, endpoint in enumerate(request.path[1:]):
try:
data = data[endpoint]
except KeyError:
if hasattr(data, "ty... | [
"def",
"_handle_get",
"(",
"self",
",",
"request",
")",
":",
"# type: (Get) -> CallbackResponses",
"data",
"=",
"self",
".",
"_block",
"for",
"i",
",",
"endpoint",
"in",
"enumerate",
"(",
"request",
".",
"path",
"[",
"1",
":",
"]",
")",
":",
"try",
":",
... | Called with the lock taken | [
"Called",
"with",
"the",
"lock",
"taken"
] | train | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/core/controller.py#L151-L170 |
dls-controls/pymalcolm | malcolm/core/controller.py | Controller._handle_put | def _handle_put(self, request):
# type: (Put) -> CallbackResponses
"""Called with the lock taken"""
attribute_name = request.path[1]
attribute = self._block[attribute_name]
assert isinstance(attribute, AttributeModel), \
"Cannot Put to %s which is a %s" % (attribute.... | python | def _handle_put(self, request):
# type: (Put) -> CallbackResponses
"""Called with the lock taken"""
attribute_name = request.path[1]
attribute = self._block[attribute_name]
assert isinstance(attribute, AttributeModel), \
"Cannot Put to %s which is a %s" % (attribute.... | [
"def",
"_handle_put",
"(",
"self",
",",
"request",
")",
":",
"# type: (Put) -> CallbackResponses",
"attribute_name",
"=",
"request",
".",
"path",
"[",
"1",
"]",
"attribute",
"=",
"self",
".",
"_block",
"[",
"attribute_name",
"]",
"assert",
"isinstance",
"(",
"... | Called with the lock taken | [
"Called",
"with",
"the",
"lock",
"taken"
] | train | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/core/controller.py#L185-L210 |
dls-controls/pymalcolm | malcolm/core/controller.py | Controller._handle_post | def _handle_post(self, request):
# type: (Post) -> CallbackResponses
"""Called with the lock taken"""
method_name = request.path[1]
method = self._block[method_name]
assert isinstance(method, MethodModel), \
"Cannot Post to %s which is a %s" % (method.path, type(meth... | python | def _handle_post(self, request):
# type: (Post) -> CallbackResponses
"""Called with the lock taken"""
method_name = request.path[1]
method = self._block[method_name]
assert isinstance(method, MethodModel), \
"Cannot Post to %s which is a %s" % (method.path, type(meth... | [
"def",
"_handle_post",
"(",
"self",
",",
"request",
")",
":",
"# type: (Post) -> CallbackResponses",
"method_name",
"=",
"request",
".",
"path",
"[",
"1",
"]",
"method",
"=",
"self",
".",
"_block",
"[",
"method_name",
"]",
"assert",
"isinstance",
"(",
"method"... | Called with the lock taken | [
"Called",
"with",
"the",
"lock",
"taken"
] | train | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/core/controller.py#L215-L233 |
dls-controls/pymalcolm | malcolm/modules/builtin/util.py | wait_for_stateful_block_init | def wait_for_stateful_block_init(context, mri, timeout=DEFAULT_TIMEOUT):
"""Wait until a Block backed by a StatefulController has initialized
Args:
context (Context): The context to use to make the child block
mri (str): The mri of the child block
timeout (float): The maximum time to wa... | python | def wait_for_stateful_block_init(context, mri, timeout=DEFAULT_TIMEOUT):
"""Wait until a Block backed by a StatefulController has initialized
Args:
context (Context): The context to use to make the child block
mri (str): The mri of the child block
timeout (float): The maximum time to wa... | [
"def",
"wait_for_stateful_block_init",
"(",
"context",
",",
"mri",
",",
"timeout",
"=",
"DEFAULT_TIMEOUT",
")",
":",
"context",
".",
"when_matches",
"(",
"[",
"mri",
",",
"\"state\"",
",",
"\"value\"",
"]",
",",
"StatefulStates",
".",
"READY",
",",
"bad_values... | Wait until a Block backed by a StatefulController has initialized
Args:
context (Context): The context to use to make the child block
mri (str): The mri of the child block
timeout (float): The maximum time to wait | [
"Wait",
"until",
"a",
"Block",
"backed",
"by",
"a",
"StatefulController",
"has",
"initialized"
] | train | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/modules/builtin/util.py#L89-L100 |
dls-controls/pymalcolm | malcolm/core/future.py | Future.result | def result(self, timeout=None):
"""Return the result of the call that the future represents.
Args:
timeout: The number of seconds to wait for the result if the future
isn't done. If None, then there is no limit on the wait time.
Returns:
The result of th... | python | def result(self, timeout=None):
"""Return the result of the call that the future represents.
Args:
timeout: The number of seconds to wait for the result if the future
isn't done. If None, then there is no limit on the wait time.
Returns:
The result of th... | [
"def",
"result",
"(",
"self",
",",
"timeout",
"=",
"None",
")",
":",
"if",
"self",
".",
"_state",
"==",
"self",
".",
"RUNNING",
":",
"self",
".",
"_context",
".",
"wait_all_futures",
"(",
"[",
"self",
"]",
",",
"timeout",
")",
"return",
"self",
".",
... | Return the result of the call that the future represents.
Args:
timeout: The number of seconds to wait for the result if the future
isn't done. If None, then there is no limit on the wait time.
Returns:
The result of the call that the future represents.
... | [
"Return",
"the",
"result",
"of",
"the",
"call",
"that",
"the",
"future",
"represents",
"."
] | train | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/core/future.py#L30-L48 |
dls-controls/pymalcolm | malcolm/core/future.py | Future.exception | def exception(self, timeout=None):
"""Return the exception raised by the call that the future represents.
Args:
timeout: The number of seconds to wait for the exception if the
future isn't done. If None, then there is no limit on the wait
time.
Retur... | python | def exception(self, timeout=None):
"""Return the exception raised by the call that the future represents.
Args:
timeout: The number of seconds to wait for the exception if the
future isn't done. If None, then there is no limit on the wait
time.
Retur... | [
"def",
"exception",
"(",
"self",
",",
"timeout",
"=",
"None",
")",
":",
"if",
"self",
".",
"_state",
"==",
"self",
".",
"RUNNING",
":",
"self",
".",
"_context",
".",
"wait_all_futures",
"(",
"[",
"self",
"]",
",",
"timeout",
")",
"return",
"self",
".... | Return the exception raised by the call that the future represents.
Args:
timeout: The number of seconds to wait for the exception if the
future isn't done. If None, then there is no limit on the wait
time.
Returns:
The exception raised by the ca... | [
"Return",
"the",
"exception",
"raised",
"by",
"the",
"call",
"that",
"the",
"future",
"represents",
"."
] | train | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/core/future.py#L50-L68 |
dls-controls/pymalcolm | malcolm/core/future.py | Future.set_result | def set_result(self, result):
"""Sets the return value of work associated with the future.
Should only be used by Task and unit tests.
"""
self._result = result
self._state = self.FINISHED | python | def set_result(self, result):
"""Sets the return value of work associated with the future.
Should only be used by Task and unit tests.
"""
self._result = result
self._state = self.FINISHED | [
"def",
"set_result",
"(",
"self",
",",
"result",
")",
":",
"self",
".",
"_result",
"=",
"result",
"self",
".",
"_state",
"=",
"self",
".",
"FINISHED"
] | Sets the return value of work associated with the future.
Should only be used by Task and unit tests. | [
"Sets",
"the",
"return",
"value",
"of",
"work",
"associated",
"with",
"the",
"future",
"."
] | train | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/core/future.py#L72-L78 |
dls-controls/pymalcolm | malcolm/core/future.py | Future.set_exception | def set_exception(self, exception):
"""Sets the result of the future as being the given exception.
Should only be used by Task and unit tests.
"""
assert isinstance(exception, Exception), \
"%r should be an Exception" % exception
self._exception = exception
s... | python | def set_exception(self, exception):
"""Sets the result of the future as being the given exception.
Should only be used by Task and unit tests.
"""
assert isinstance(exception, Exception), \
"%r should be an Exception" % exception
self._exception = exception
s... | [
"def",
"set_exception",
"(",
"self",
",",
"exception",
")",
":",
"assert",
"isinstance",
"(",
"exception",
",",
"Exception",
")",
",",
"\"%r should be an Exception\"",
"%",
"exception",
"self",
".",
"_exception",
"=",
"exception",
"self",
".",
"_state",
"=",
"... | Sets the result of the future as being the given exception.
Should only be used by Task and unit tests. | [
"Sets",
"the",
"result",
"of",
"the",
"future",
"as",
"being",
"the",
"given",
"exception",
"."
] | train | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/core/future.py#L80-L88 |
dls-controls/pymalcolm | malcolm/core/loggable.py | Loggable.set_logger | def set_logger(self, **fields):
"""Change the name of the logger that log.* should call
Args:
**fields: Extra fields to be logged. Logger name will be:
".".join([<module_name>, <cls_name>] + fields_sorted_on_key)
"""
names = [self.__module__, self.__class__._... | python | def set_logger(self, **fields):
"""Change the name of the logger that log.* should call
Args:
**fields: Extra fields to be logged. Logger name will be:
".".join([<module_name>, <cls_name>] + fields_sorted_on_key)
"""
names = [self.__module__, self.__class__._... | [
"def",
"set_logger",
"(",
"self",
",",
"*",
"*",
"fields",
")",
":",
"names",
"=",
"[",
"self",
".",
"__module__",
",",
"self",
".",
"__class__",
".",
"__name__",
"]",
"for",
"field",
",",
"value",
"in",
"sorted",
"(",
"fields",
".",
"items",
"(",
... | Change the name of the logger that log.* should call
Args:
**fields: Extra fields to be logged. Logger name will be:
".".join([<module_name>, <cls_name>] + fields_sorted_on_key) | [
"Change",
"the",
"name",
"of",
"the",
"logger",
"that",
"log",
".",
"*",
"should",
"call"
] | train | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/core/loggable.py#L20-L36 |
dls-controls/pymalcolm | malcolm/core/request.py | Request.return_response | def return_response(self, value=None):
# type: (Any) -> Tuple[Callback, Return]
"""Create a Return Response object to signal a return value"""
response = Return(id=self.id, value=value)
return self.callback, response | python | def return_response(self, value=None):
# type: (Any) -> Tuple[Callback, Return]
"""Create a Return Response object to signal a return value"""
response = Return(id=self.id, value=value)
return self.callback, response | [
"def",
"return_response",
"(",
"self",
",",
"value",
"=",
"None",
")",
":",
"# type: (Any) -> Tuple[Callback, Return]",
"response",
"=",
"Return",
"(",
"id",
"=",
"self",
".",
"id",
",",
"value",
"=",
"value",
")",
"return",
"self",
".",
"callback",
",",
"... | Create a Return Response object to signal a return value | [
"Create",
"a",
"Return",
"Response",
"object",
"to",
"signal",
"a",
"return",
"value"
] | train | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/core/request.py#L52-L56 |
dls-controls/pymalcolm | malcolm/core/request.py | Request.error_response | def error_response(self, exception):
# type: (Exception) -> Tuple[Callback, Error]
"""Create an Error Response object to signal an error"""
response = Error(id=self.id, message=exception)
log.exception("Exception raised for request %s", self)
return self.callback, response | python | def error_response(self, exception):
# type: (Exception) -> Tuple[Callback, Error]
"""Create an Error Response object to signal an error"""
response = Error(id=self.id, message=exception)
log.exception("Exception raised for request %s", self)
return self.callback, response | [
"def",
"error_response",
"(",
"self",
",",
"exception",
")",
":",
"# type: (Exception) -> Tuple[Callback, Error]",
"response",
"=",
"Error",
"(",
"id",
"=",
"self",
".",
"id",
",",
"message",
"=",
"exception",
")",
"log",
".",
"exception",
"(",
"\"Exception rais... | Create an Error Response object to signal an error | [
"Create",
"an",
"Error",
"Response",
"object",
"to",
"signal",
"an",
"error"
] | train | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/core/request.py#L58-L63 |
dls-controls/pymalcolm | malcolm/core/views.py | make_view | def make_view(controller, context, data):
# type: (Controller, Context, Any) -> Any
"""Make a View subclass containing properties specific for given data
Args:
controller (Controller): The child controller that hosts the data
context (Context): The context the parent has made that the View ... | python | def make_view(controller, context, data):
# type: (Controller, Context, Any) -> Any
"""Make a View subclass containing properties specific for given data
Args:
controller (Controller): The child controller that hosts the data
context (Context): The context the parent has made that the View ... | [
"def",
"make_view",
"(",
"controller",
",",
"context",
",",
"data",
")",
":",
"# type: (Controller, Context, Any) -> Any",
"if",
"isinstance",
"(",
"data",
",",
"BlockModel",
")",
":",
"# Make an Block View",
"view",
"=",
"_make_view_subclass",
"(",
"Block",
",",
... | Make a View subclass containing properties specific for given data
Args:
controller (Controller): The child controller that hosts the data
context (Context): The context the parent has made that the View should
use for manipulating the data
data (Model): The actual data that con... | [
"Make",
"a",
"View",
"subclass",
"containing",
"properties",
"specific",
"for",
"given",
"data"
] | train | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/core/views.py#L224-L262 |
dls-controls/pymalcolm | malcolm/core/views.py | Attribute.put_value | def put_value(self, value, timeout=None):
"""Put a value to the Attribute and wait for completion"""
self._context.put(self._data.path + ["value"], value, timeout=timeout) | python | def put_value(self, value, timeout=None):
"""Put a value to the Attribute and wait for completion"""
self._context.put(self._data.path + ["value"], value, timeout=timeout) | [
"def",
"put_value",
"(",
"self",
",",
"value",
",",
"timeout",
"=",
"None",
")",
":",
"self",
".",
"_context",
".",
"put",
"(",
"self",
".",
"_data",
".",
"path",
"+",
"[",
"\"value\"",
"]",
",",
"value",
",",
"timeout",
"=",
"timeout",
")"
] | Put a value to the Attribute and wait for completion | [
"Put",
"a",
"value",
"to",
"the",
"Attribute",
"and",
"wait",
"for",
"completion"
] | train | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/core/views.py#L78-L80 |
dls-controls/pymalcolm | malcolm/modules/ADCore/infos.py | ExposureDeadtimeInfo.calculate_exposure | def calculate_exposure(self, duration):
# type: (float) -> float
"""Calculate the exposure to set the detector to given the duration of
the frame and the readout_time and frequency_accuracy"""
exposure = duration - self.frequency_accuracy * duration / 1000000.0 - \
sel... | python | def calculate_exposure(self, duration):
# type: (float) -> float
"""Calculate the exposure to set the detector to given the duration of
the frame and the readout_time and frequency_accuracy"""
exposure = duration - self.frequency_accuracy * duration / 1000000.0 - \
sel... | [
"def",
"calculate_exposure",
"(",
"self",
",",
"duration",
")",
":",
"# type: (float) -> float",
"exposure",
"=",
"duration",
"-",
"self",
".",
"frequency_accuracy",
"*",
"duration",
"/",
"1000000.0",
"-",
"self",
".",
"readout_time",
"assert",
"exposure",
">",
... | Calculate the exposure to set the detector to given the duration of
the frame and the readout_time and frequency_accuracy | [
"Calculate",
"the",
"exposure",
"to",
"set",
"the",
"detector",
"to",
"given",
"the",
"duration",
"of",
"the",
"frame",
"and",
"the",
"readout_time",
"and",
"frequency_accuracy"
] | train | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/modules/ADCore/infos.py#L46-L55 |
dls-controls/pymalcolm | malcolm/core/models.py | Model.set_notifier_path | def set_notifier_path(self, notifier, path):
"""Sets the notifier, and the path from the path from block root
Args:
notifier (Notifier): The Notifier to tell when endpoint data changes
path (list): The absolute path to get to this object
"""
# type: (Union[Notifi... | python | def set_notifier_path(self, notifier, path):
"""Sets the notifier, and the path from the path from block root
Args:
notifier (Notifier): The Notifier to tell when endpoint data changes
path (list): The absolute path to get to this object
"""
# type: (Union[Notifi... | [
"def",
"set_notifier_path",
"(",
"self",
",",
"notifier",
",",
"path",
")",
":",
"# type: (Union[Notifier, DummyNotifier], List[str]) -> None",
"# This function should either change from the DummyNotifier or to",
"# the DummyNotifier, never between two valid notifiers",
"assert",
"self",... | Sets the notifier, and the path from the path from block root
Args:
notifier (Notifier): The Notifier to tell when endpoint data changes
path (list): The absolute path to get to this object | [
"Sets",
"the",
"notifier",
"and",
"the",
"path",
"from",
"the",
"path",
"from",
"block",
"root"
] | train | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/core/models.py#L32-L57 |
dls-controls/pymalcolm | malcolm/core/models.py | Model.apply_change | def apply_change(self, path, *args):
# type: (List[str], Any) -> None
"""Take a single change from a Delta and apply it to this model"""
if len(path) > 1:
# This is for a child
self[path[0]].apply_change(path[1:], *args)
else:
# This is for us
... | python | def apply_change(self, path, *args):
# type: (List[str], Any) -> None
"""Take a single change from a Delta and apply it to this model"""
if len(path) > 1:
# This is for a child
self[path[0]].apply_change(path[1:], *args)
else:
# This is for us
... | [
"def",
"apply_change",
"(",
"self",
",",
"path",
",",
"*",
"args",
")",
":",
"# type: (List[str], Any) -> None",
"if",
"len",
"(",
"path",
")",
">",
"1",
":",
"# This is for a child",
"self",
"[",
"path",
"[",
"0",
"]",
"]",
".",
"apply_change",
"(",
"pa... | Take a single change from a Delta and apply it to this model | [
"Take",
"a",
"single",
"change",
"from",
"a",
"Delta",
"and",
"apply",
"it",
"to",
"this",
"model"
] | train | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/core/models.py#L116-L126 |
dls-controls/pymalcolm | malcolm/core/models.py | VMeta.create_attribute_model | def create_attribute_model(self, initial_value=None):
# type: (Any) -> AttributeModel
"""Make an AttributeModel instance of the correct type for this Meta
Args:
initial_value: The initial value the Attribute should take
Returns:
AttributeModel: The created attri... | python | def create_attribute_model(self, initial_value=None):
# type: (Any) -> AttributeModel
"""Make an AttributeModel instance of the correct type for this Meta
Args:
initial_value: The initial value the Attribute should take
Returns:
AttributeModel: The created attri... | [
"def",
"create_attribute_model",
"(",
"self",
",",
"initial_value",
"=",
"None",
")",
":",
"# type: (Any) -> AttributeModel",
"attr",
"=",
"self",
".",
"attribute_class",
"(",
"meta",
"=",
"self",
",",
"value",
"=",
"initial_value",
")",
"return",
"attr"
] | Make an AttributeModel instance of the correct type for this Meta
Args:
initial_value: The initial value the Attribute should take
Returns:
AttributeModel: The created attribute model instance | [
"Make",
"an",
"AttributeModel",
"instance",
"of",
"the",
"correct",
"type",
"for",
"this",
"Meta"
] | train | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/core/models.py#L189-L200 |
dls-controls/pymalcolm | malcolm/core/models.py | VMeta.from_annotype | def from_annotype(cls, anno, writeable, **kwargs):
# type: (Anno, bool, **Any) -> VMeta
"""Return an instance of this class from an Anno"""
ret = cls(description=anno.description, writeable=writeable, **kwargs)
widget = ret.default_widget()
if widget != Widget.NONE:
r... | python | def from_annotype(cls, anno, writeable, **kwargs):
# type: (Anno, bool, **Any) -> VMeta
"""Return an instance of this class from an Anno"""
ret = cls(description=anno.description, writeable=writeable, **kwargs)
widget = ret.default_widget()
if widget != Widget.NONE:
r... | [
"def",
"from_annotype",
"(",
"cls",
",",
"anno",
",",
"writeable",
",",
"*",
"*",
"kwargs",
")",
":",
"# type: (Anno, bool, **Any) -> VMeta",
"ret",
"=",
"cls",
"(",
"description",
"=",
"anno",
".",
"description",
",",
"writeable",
"=",
"writeable",
",",
"*"... | Return an instance of this class from an Anno | [
"Return",
"an",
"instance",
"of",
"this",
"class",
"from",
"an",
"Anno"
] | train | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/core/models.py#L216-L223 |
dls-controls/pymalcolm | malcolm/core/models.py | VMeta.register_annotype_converter | def register_annotype_converter(cls, types, is_array=False,
is_mapping=False):
# type: (Union[Sequence[type], type], bool, bool) -> Any
"""Register this class as a converter for Anno instances"""
if not isinstance(types, Sequence):
types = [types]
... | python | def register_annotype_converter(cls, types, is_array=False,
is_mapping=False):
# type: (Union[Sequence[type], type], bool, bool) -> Any
"""Register this class as a converter for Anno instances"""
if not isinstance(types, Sequence):
types = [types]
... | [
"def",
"register_annotype_converter",
"(",
"cls",
",",
"types",
",",
"is_array",
"=",
"False",
",",
"is_mapping",
"=",
"False",
")",
":",
"# type: (Union[Sequence[type], type], bool, bool) -> Any",
"if",
"not",
"isinstance",
"(",
"types",
",",
"Sequence",
")",
":",
... | Register this class as a converter for Anno instances | [
"Register",
"this",
"class",
"as",
"a",
"converter",
"for",
"Anno",
"instances"
] | train | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/core/models.py#L226-L238 |
dls-controls/pymalcolm | malcolm/core/models.py | VMeta.lookup_annotype_converter | def lookup_annotype_converter(cls, anno):
# type: (Anno) -> Type[VMeta]
"""Look up a vmeta based on an Anno"""
if hasattr(anno.typ, "__bases__"):
# This is a proper type
bases = inspect.getmro(anno.typ)
else:
# This is a numpy dtype
bases =... | python | def lookup_annotype_converter(cls, anno):
# type: (Anno) -> Type[VMeta]
"""Look up a vmeta based on an Anno"""
if hasattr(anno.typ, "__bases__"):
# This is a proper type
bases = inspect.getmro(anno.typ)
else:
# This is a numpy dtype
bases =... | [
"def",
"lookup_annotype_converter",
"(",
"cls",
",",
"anno",
")",
":",
"# type: (Anno) -> Type[VMeta]",
"if",
"hasattr",
"(",
"anno",
".",
"typ",
",",
"\"__bases__\"",
")",
":",
"# This is a proper type",
"bases",
"=",
"inspect",
".",
"getmro",
"(",
"anno",
".",... | Look up a vmeta based on an Anno | [
"Look",
"up",
"a",
"vmeta",
"based",
"on",
"an",
"Anno"
] | train | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/core/models.py#L241-L256 |
dls-controls/pymalcolm | malcolm/core/models.py | AttributeModel.set_value | def set_value(self, value, set_alarm_ts=True, alarm=None, ts=None):
# type: (Any, bool, Alarm, TimeStamp) -> Any
"""Set value, calculating alarm and ts if requested"""
value = self.meta.validate(value)
if set_alarm_ts:
if alarm is None:
alarm = Alarm.ok
... | python | def set_value(self, value, set_alarm_ts=True, alarm=None, ts=None):
# type: (Any, bool, Alarm, TimeStamp) -> Any
"""Set value, calculating alarm and ts if requested"""
value = self.meta.validate(value)
if set_alarm_ts:
if alarm is None:
alarm = Alarm.ok
... | [
"def",
"set_value",
"(",
"self",
",",
"value",
",",
"set_alarm_ts",
"=",
"True",
",",
"alarm",
"=",
"None",
",",
"ts",
"=",
"None",
")",
":",
"# type: (Any, bool, Alarm, TimeStamp) -> Any",
"value",
"=",
"self",
".",
"meta",
".",
"validate",
"(",
"value",
... | Set value, calculating alarm and ts if requested | [
"Set",
"value",
"calculating",
"alarm",
"and",
"ts",
"if",
"requested"
] | train | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/core/models.py#L301-L317 |
dls-controls/pymalcolm | malcolm/core/models.py | AttributeModel.set_value_alarm_ts | def set_value_alarm_ts(self, value, alarm, ts):
"""Set value with pre-validated alarm and timeStamp"""
# type: (Any, Alarm, TimeStamp) -> None
with self.notifier.changes_squashed:
# Assume they are of the right format
self.value = value
self.notifier.add_squas... | python | def set_value_alarm_ts(self, value, alarm, ts):
"""Set value with pre-validated alarm and timeStamp"""
# type: (Any, Alarm, TimeStamp) -> None
with self.notifier.changes_squashed:
# Assume they are of the right format
self.value = value
self.notifier.add_squas... | [
"def",
"set_value_alarm_ts",
"(",
"self",
",",
"value",
",",
"alarm",
",",
"ts",
")",
":",
"# type: (Any, Alarm, TimeStamp) -> None",
"with",
"self",
".",
"notifier",
".",
"changes_squashed",
":",
"# Assume they are of the right format",
"self",
".",
"value",
"=",
"... | Set value with pre-validated alarm and timeStamp | [
"Set",
"value",
"with",
"pre",
"-",
"validated",
"alarm",
"and",
"timeStamp"
] | train | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/core/models.py#L319-L330 |
dls-controls/pymalcolm | malcolm/modules/demo/parts/hellopart.py | HelloPart.greet | def greet(self, name, sleep=0):
# type: (AName, ASleep) -> AGreeting
"""Optionally sleep <sleep> seconds, then return a greeting to <name>"""
print("Manufacturing greeting...")
sleep_for(sleep)
greeting = "Hello %s" % name
return greeting | python | def greet(self, name, sleep=0):
# type: (AName, ASleep) -> AGreeting
"""Optionally sleep <sleep> seconds, then return a greeting to <name>"""
print("Manufacturing greeting...")
sleep_for(sleep)
greeting = "Hello %s" % name
return greeting | [
"def",
"greet",
"(",
"self",
",",
"name",
",",
"sleep",
"=",
"0",
")",
":",
"# type: (AName, ASleep) -> AGreeting",
"print",
"(",
"\"Manufacturing greeting...\"",
")",
"sleep_for",
"(",
"sleep",
")",
"greeting",
"=",
"\"Hello %s\"",
"%",
"name",
"return",
"greet... | Optionally sleep <sleep> seconds, then return a greeting to <name> | [
"Optionally",
"sleep",
"<sleep",
">",
"seconds",
"then",
"return",
"a",
"greeting",
"to",
"<name",
">"
] | train | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/modules/demo/parts/hellopart.py#L24-L30 |
dls-controls/pymalcolm | docs/conf.py | get_version | def get_version():
"""Extracts the version number from the version.py file."""
VERSION_FILE = '../malcolm/version.py'
mo = re.search(r'^__version__ = [\'"]([^\'"]*)[\'"]',
open(VERSION_FILE, 'rt').read(), re.M)
if mo:
return mo.group(1)
else:
raise RuntimeError(
... | python | def get_version():
"""Extracts the version number from the version.py file."""
VERSION_FILE = '../malcolm/version.py'
mo = re.search(r'^__version__ = [\'"]([^\'"]*)[\'"]',
open(VERSION_FILE, 'rt').read(), re.M)
if mo:
return mo.group(1)
else:
raise RuntimeError(
... | [
"def",
"get_version",
"(",
")",
":",
"VERSION_FILE",
"=",
"'../malcolm/version.py'",
"mo",
"=",
"re",
".",
"search",
"(",
"r'^__version__ = [\\'\"]([^\\'\"]*)[\\'\"]'",
",",
"open",
"(",
"VERSION_FILE",
",",
"'rt'",
")",
".",
"read",
"(",
")",
",",
"re",
".",
... | Extracts the version number from the version.py file. | [
"Extracts",
"the",
"version",
"number",
"from",
"the",
"version",
".",
"py",
"file",
"."
] | train | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/docs/conf.py#L12-L21 |
dls-controls/pymalcolm | malcolm/modules/ADOdin/parts/odinwriterpart.py | add_nexus_nodes | def add_nexus_nodes(generator, vds_file_path):
""" Add in the additional information to make this into a standard nexus
format file:-
(a) create the standard structure under the 'entry' group with a
subgroup for each dataset. 'set_bases' lists the data sets we make here.
(b) save a dataset for each ... | python | def add_nexus_nodes(generator, vds_file_path):
""" Add in the additional information to make this into a standard nexus
format file:-
(a) create the standard structure under the 'entry' group with a
subgroup for each dataset. 'set_bases' lists the data sets we make here.
(b) save a dataset for each ... | [
"def",
"add_nexus_nodes",
"(",
"generator",
",",
"vds_file_path",
")",
":",
"# create the axes dimensions attribute, a comma separated list giving size",
"# of the axis dimensions padded with . for the detector dimensions and",
"# multidimensional dimensions",
"pad_dims",
"=",
"[",
"]",
... | Add in the additional information to make this into a standard nexus
format file:-
(a) create the standard structure under the 'entry' group with a
subgroup for each dataset. 'set_bases' lists the data sets we make here.
(b) save a dataset for each axis in each of the dimensions of the scan
represen... | [
"Add",
"in",
"the",
"additional",
"information",
"to",
"make",
"this",
"into",
"a",
"standard",
"nexus",
"format",
"file",
":",
"-",
"(",
"a",
")",
"create",
"the",
"standard",
"structure",
"under",
"the",
"entry",
"group",
"with",
"a",
"subgroup",
"for",
... | train | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/modules/ADOdin/parts/odinwriterpart.py#L130-L187 |
dls-controls/pymalcolm | malcolm/modules/pandablocks/pandablocksclient.py | PandABlocksClient.send_recv | def send_recv(self, message, timeout=10.0):
"""Send a message to a PandABox and wait for the response
Args:
message (str): The message to send
timeout (float): How long to wait before raising queue.Empty
Returns:
str: The response
"""
respons... | python | def send_recv(self, message, timeout=10.0):
"""Send a message to a PandABox and wait for the response
Args:
message (str): The message to send
timeout (float): How long to wait before raising queue.Empty
Returns:
str: The response
"""
respons... | [
"def",
"send_recv",
"(",
"self",
",",
"message",
",",
"timeout",
"=",
"10.0",
")",
":",
"response_queue",
"=",
"self",
".",
"send",
"(",
"message",
")",
"response",
"=",
"self",
".",
"recv",
"(",
"response_queue",
",",
"timeout",
")",
"return",
"response... | Send a message to a PandABox and wait for the response
Args:
message (str): The message to send
timeout (float): How long to wait before raising queue.Empty
Returns:
str: The response | [
"Send",
"a",
"message",
"to",
"a",
"PandABox",
"and",
"wait",
"for",
"the",
"response"
] | train | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/modules/pandablocks/pandablocksclient.py#L99-L111 |
dls-controls/pymalcolm | malcolm/modules/pandablocks/pandablocksclient.py | PandABlocksClient._send_loop | def _send_loop(self):
"""Service self._send_queue, sending requests to server"""
while True:
message, response_queue = self._send_queue.get()
if message is self.STOP:
break
try:
self._response_queues.put(response_queue)
... | python | def _send_loop(self):
"""Service self._send_queue, sending requests to server"""
while True:
message, response_queue = self._send_queue.get()
if message is self.STOP:
break
try:
self._response_queues.put(response_queue)
... | [
"def",
"_send_loop",
"(",
"self",
")",
":",
"while",
"True",
":",
"message",
",",
"response_queue",
"=",
"self",
".",
"_send_queue",
".",
"get",
"(",
")",
"if",
"message",
"is",
"self",
".",
"STOP",
":",
"break",
"try",
":",
"self",
".",
"_response_que... | Service self._send_queue, sending requests to server | [
"Service",
"self",
".",
"_send_queue",
"sending",
"requests",
"to",
"server"
] | train | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/modules/pandablocks/pandablocksclient.py#L113-L123 |
dls-controls/pymalcolm | malcolm/modules/pandablocks/pandablocksclient.py | PandABlocksClient._respond | def _respond(self, resp):
"""Respond to the person waiting"""
response_queue = self._response_queues.get(timeout=0.1)
response_queue.put(resp)
self._completed_response_lines = []
self._is_multiline = None | python | def _respond(self, resp):
"""Respond to the person waiting"""
response_queue = self._response_queues.get(timeout=0.1)
response_queue.put(resp)
self._completed_response_lines = []
self._is_multiline = None | [
"def",
"_respond",
"(",
"self",
",",
"resp",
")",
":",
"response_queue",
"=",
"self",
".",
"_response_queues",
".",
"get",
"(",
"timeout",
"=",
"0.1",
")",
"response_queue",
".",
"put",
"(",
"resp",
")",
"self",
".",
"_completed_response_lines",
"=",
"[",
... | Respond to the person waiting | [
"Respond",
"to",
"the",
"person",
"waiting"
] | train | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/modules/pandablocks/pandablocksclient.py#L138-L143 |
dls-controls/pymalcolm | malcolm/modules/pandablocks/pandablocksclient.py | PandABlocksClient._recv_loop | def _recv_loop(self):
"""Service socket recv, returning responses to the correct queue"""
self._completed_response_lines = []
self._is_multiline = None
lines_iterator = self._get_lines()
while True:
try:
line = next(lines_iterator)
if s... | python | def _recv_loop(self):
"""Service socket recv, returning responses to the correct queue"""
self._completed_response_lines = []
self._is_multiline = None
lines_iterator = self._get_lines()
while True:
try:
line = next(lines_iterator)
if s... | [
"def",
"_recv_loop",
"(",
"self",
")",
":",
"self",
".",
"_completed_response_lines",
"=",
"[",
"]",
"self",
".",
"_is_multiline",
"=",
"None",
"lines_iterator",
"=",
"self",
".",
"_get_lines",
"(",
")",
"while",
"True",
":",
"try",
":",
"line",
"=",
"ne... | Service socket recv, returning responses to the correct queue | [
"Service",
"socket",
"recv",
"returning",
"responses",
"to",
"the",
"correct",
"queue"
] | train | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/modules/pandablocks/pandablocksclient.py#L145-L171 |
dls-controls/pymalcolm | malcolm/modules/pandablocks/pandablocksclient.py | PandABlocksClient.parameterized_send | def parameterized_send(self, request, parameter_list):
"""Send batched requests for a list of parameters
Args:
request (str): Request to send, like "%s.*?\n"
parameter_list (list): parameters to format with, like
["TTLIN", "TTLOUT"]
Returns:
... | python | def parameterized_send(self, request, parameter_list):
"""Send batched requests for a list of parameters
Args:
request (str): Request to send, like "%s.*?\n"
parameter_list (list): parameters to format with, like
["TTLIN", "TTLOUT"]
Returns:
... | [
"def",
"parameterized_send",
"(",
"self",
",",
"request",
",",
"parameter_list",
")",
":",
"response_queues",
"=",
"OrderedDict",
"(",
")",
"for",
"parameter",
"in",
"parameter_list",
":",
"response_queues",
"[",
"parameter",
"]",
"=",
"self",
".",
"send",
"("... | Send batched requests for a list of parameters
Args:
request (str): Request to send, like "%s.*?\n"
parameter_list (list): parameters to format with, like
["TTLIN", "TTLOUT"]
Returns:
dict: {parameter: response_queue} | [
"Send",
"batched",
"requests",
"for",
"a",
"list",
"of",
"parameters"
] | train | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/modules/pandablocks/pandablocksclient.py#L180-L194 |
dls-controls/pymalcolm | malcolm/modules/ADAndor/parts/andordriverpart.py | AndorDriverPart.get_readout_time | def get_readout_time(self, child, duration):
"""Calculate the readout time of the detector from the EPICS driver:
- Set exposure and acquire period to same value
- Acquire period will be set to lowest acceptable value
- Difference will be readout time (this value is affected ... | python | def get_readout_time(self, child, duration):
"""Calculate the readout time of the detector from the EPICS driver:
- Set exposure and acquire period to same value
- Acquire period will be set to lowest acceptable value
- Difference will be readout time (this value is affected ... | [
"def",
"get_readout_time",
"(",
"self",
",",
"child",
",",
"duration",
")",
":",
"child",
".",
"exposure",
".",
"put_value",
"(",
"duration",
")",
"child",
".",
"acquirePeriod",
".",
"put_value",
"(",
"duration",
")",
"readout_time",
"=",
"child",
".",
"ac... | Calculate the readout time of the detector from the EPICS driver:
- Set exposure and acquire period to same value
- Acquire period will be set to lowest acceptable value
- Difference will be readout time (this value is affected by
detector settings) | [
"Calculate",
"the",
"readout",
"time",
"of",
"the",
"detector",
"from",
"the",
"EPICS",
"driver",
":",
"-",
"Set",
"exposure",
"and",
"acquire",
"period",
"to",
"same",
"value",
"-",
"Acquire",
"period",
"will",
"be",
"set",
"to",
"lowest",
"acceptable",
"... | train | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/modules/ADAndor/parts/andordriverpart.py#L28-L42 |
dls-controls/pymalcolm | malcolm/modules/builtin/parts/childpart.py | ChildPart.notify_dispatch_request | def notify_dispatch_request(self, request):
# type: (Request) -> None
"""Will be called when a context passed to a hooked function is about
to dispatch a request"""
if isinstance(request, Put) and request.path[0] == self.mri:
# This means the context we were passed has just m... | python | def notify_dispatch_request(self, request):
# type: (Request) -> None
"""Will be called when a context passed to a hooked function is about
to dispatch a request"""
if isinstance(request, Put) and request.path[0] == self.mri:
# This means the context we were passed has just m... | [
"def",
"notify_dispatch_request",
"(",
"self",
",",
"request",
")",
":",
"# type: (Request) -> None",
"if",
"isinstance",
"(",
"request",
",",
"Put",
")",
"and",
"request",
".",
"path",
"[",
"0",
"]",
"==",
"self",
".",
"mri",
":",
"# This means the context we... | Will be called when a context passed to a hooked function is about
to dispatch a request | [
"Will",
"be",
"called",
"when",
"a",
"context",
"passed",
"to",
"a",
"hooked",
"function",
"is",
"about",
"to",
"dispatch",
"a",
"request"
] | train | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/modules/builtin/parts/childpart.py#L38-L51 |
dls-controls/pymalcolm | malcolm/modules/builtin/parts/childpart.py | ChildPart.sever_sink_ports | def sever_sink_ports(self, context, ports, connected_to=None):
# type: (AContext, APortMap, str) -> None
"""Conditionally sever Sink Ports of the child. If connected_to
is then None then sever all, otherwise restrict to connected_to's
Source Ports
Args:
context (Cont... | python | def sever_sink_ports(self, context, ports, connected_to=None):
# type: (AContext, APortMap, str) -> None
"""Conditionally sever Sink Ports of the child. If connected_to
is then None then sever all, otherwise restrict to connected_to's
Source Ports
Args:
context (Cont... | [
"def",
"sever_sink_ports",
"(",
"self",
",",
"context",
",",
"ports",
",",
"connected_to",
"=",
"None",
")",
":",
"# type: (AContext, APortMap, str) -> None",
"# Find the Source Ports to connect to",
"if",
"connected_to",
":",
"# Calculate a lookup of the Source Port \"name\" t... | Conditionally sever Sink Ports of the child. If connected_to
is then None then sever all, otherwise restrict to connected_to's
Source Ports
Args:
context (Context): The context to use
ports (dict): {part_name: [PortInfo]}
connected_to (str): Restrict severing... | [
"Conditionally",
"sever",
"Sink",
"Ports",
"of",
"the",
"child",
".",
"If",
"connected_to",
"is",
"then",
"None",
"then",
"sever",
"all",
"otherwise",
"restrict",
"to",
"connected_to",
"s",
"Source",
"Ports"
] | train | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/modules/builtin/parts/childpart.py#L307-L337 |
dls-controls/pymalcolm | malcolm/modules/builtin/parts/childpart.py | ChildPart.calculate_part_visibility | def calculate_part_visibility(self, ports):
# type: (APortMap) -> None
"""Calculate what is connected to what
Args:
ports: {part_name: [PortInfo]} from other ports
"""
# Calculate a lookup of Source Port connected_value to part_name
source_port_lookup = {}
... | python | def calculate_part_visibility(self, ports):
# type: (APortMap) -> None
"""Calculate what is connected to what
Args:
ports: {part_name: [PortInfo]} from other ports
"""
# Calculate a lookup of Source Port connected_value to part_name
source_port_lookup = {}
... | [
"def",
"calculate_part_visibility",
"(",
"self",
",",
"ports",
")",
":",
"# type: (APortMap) -> None",
"# Calculate a lookup of Source Port connected_value to part_name",
"source_port_lookup",
"=",
"{",
"}",
"for",
"part_name",
",",
"port_infos",
"in",
"SourcePortInfo",
".",
... | Calculate what is connected to what
Args:
ports: {part_name: [PortInfo]} from other ports | [
"Calculate",
"what",
"is",
"connected",
"to",
"what"
] | train | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/modules/builtin/parts/childpart.py#L339-L364 |
dls-controls/pymalcolm | malcolm/core/notifier.py | Notifier.handle_subscribe | def handle_subscribe(self, request):
# type: (Subscribe) -> CallbackResponses
"""Handle a Subscribe request from outside. Called with lock taken"""
ret = self._tree.handle_subscribe(request, request.path[1:])
self._subscription_keys[request.generate_key()] = request
return ret | python | def handle_subscribe(self, request):
# type: (Subscribe) -> CallbackResponses
"""Handle a Subscribe request from outside. Called with lock taken"""
ret = self._tree.handle_subscribe(request, request.path[1:])
self._subscription_keys[request.generate_key()] = request
return ret | [
"def",
"handle_subscribe",
"(",
"self",
",",
"request",
")",
":",
"# type: (Subscribe) -> CallbackResponses",
"ret",
"=",
"self",
".",
"_tree",
".",
"handle_subscribe",
"(",
"request",
",",
"request",
".",
"path",
"[",
"1",
":",
"]",
")",
"self",
".",
"_subs... | Handle a Subscribe request from outside. Called with lock taken | [
"Handle",
"a",
"Subscribe",
"request",
"from",
"outside",
".",
"Called",
"with",
"lock",
"taken"
] | train | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/core/notifier.py#L47-L52 |
dls-controls/pymalcolm | malcolm/core/notifier.py | Notifier.handle_unsubscribe | def handle_unsubscribe(self, request):
# type: (Unsubscribe) -> CallbackResponses
"""Handle a Unsubscribe request from outside. Called with lock taken"""
subscribe = self._subscription_keys.pop(request.generate_key())
ret = self._tree.handle_unsubscribe(subscribe, subscribe.path[1:])
... | python | def handle_unsubscribe(self, request):
# type: (Unsubscribe) -> CallbackResponses
"""Handle a Unsubscribe request from outside. Called with lock taken"""
subscribe = self._subscription_keys.pop(request.generate_key())
ret = self._tree.handle_unsubscribe(subscribe, subscribe.path[1:])
... | [
"def",
"handle_unsubscribe",
"(",
"self",
",",
"request",
")",
":",
"# type: (Unsubscribe) -> CallbackResponses",
"subscribe",
"=",
"self",
".",
"_subscription_keys",
".",
"pop",
"(",
"request",
".",
"generate_key",
"(",
")",
")",
"ret",
"=",
"self",
".",
"_tree... | Handle a Unsubscribe request from outside. Called with lock taken | [
"Handle",
"a",
"Unsubscribe",
"request",
"from",
"outside",
".",
"Called",
"with",
"lock",
"taken"
] | train | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/core/notifier.py#L54-L59 |
dls-controls/pymalcolm | malcolm/core/notifier.py | Notifier.add_squashed_change | def add_squashed_change(self, path, data):
# type: (List[str], Any) -> None
"""Register a squashed change to a particular path
Args:
path (list): The path of what has changed, relative from Block
data (object): The new data
"""
assert self._squashed_count... | python | def add_squashed_change(self, path, data):
# type: (List[str], Any) -> None
"""Register a squashed change to a particular path
Args:
path (list): The path of what has changed, relative from Block
data (object): The new data
"""
assert self._squashed_count... | [
"def",
"add_squashed_change",
"(",
"self",
",",
"path",
",",
"data",
")",
":",
"# type: (List[str], Any) -> None",
"assert",
"self",
".",
"_squashed_count",
",",
"\"Called while not squashing changes\"",
"self",
".",
"_squashed_changes",
".",
"append",
"(",
"[",
"path... | Register a squashed change to a particular path
Args:
path (list): The path of what has changed, relative from Block
data (object): The new data | [
"Register",
"a",
"squashed",
"change",
"to",
"a",
"particular",
"path"
] | train | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/core/notifier.py#L73-L82 |
dls-controls/pymalcolm | malcolm/core/notifier.py | NotifierNode.notify_changes | def notify_changes(self, changes):
# type: (List[List]) -> CallbackResponses
"""Set our data and notify anyone listening
Args:
changes (list): [[path, optional data]] where path is the path to
what has changed, and data is the unserialized object that has
... | python | def notify_changes(self, changes):
# type: (List[List]) -> CallbackResponses
"""Set our data and notify anyone listening
Args:
changes (list): [[path, optional data]] where path is the path to
what has changed, and data is the unserialized object that has
... | [
"def",
"notify_changes",
"(",
"self",
",",
"changes",
")",
":",
"# type: (List[List]) -> CallbackResponses",
"ret",
"=",
"[",
"]",
"child_changes",
"=",
"{",
"}",
"for",
"change",
"in",
"changes",
":",
"# Add any changes that our children need to know about",
"self",
... | Set our data and notify anyone listening
Args:
changes (list): [[path, optional data]] where path is the path to
what has changed, and data is the unserialized object that has
changed
Returns:
list: [(callback, Response)] that need to be called | [
"Set",
"our",
"data",
"and",
"notify",
"anyone",
"listening"
] | train | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/core/notifier.py#L136-L170 |
dls-controls/pymalcolm | malcolm/core/notifier.py | NotifierNode._update_data | def _update_data(self, data):
# type: (Any) -> Dict[str, List]
"""Set our data and notify any subscribers of children what has changed
Args:
data (object): The new data
Returns:
dict: {child_name: [path_list, optional child_data]} of the change
t... | python | def _update_data(self, data):
# type: (Any) -> Dict[str, List]
"""Set our data and notify any subscribers of children what has changed
Args:
data (object): The new data
Returns:
dict: {child_name: [path_list, optional child_data]} of the change
t... | [
"def",
"_update_data",
"(",
"self",
",",
"data",
")",
":",
"# type: (Any) -> Dict[str, List]",
"self",
".",
"data",
"=",
"data",
"child_change_dict",
"=",
"{",
"}",
"# Reflect change of data to children",
"for",
"name",
"in",
"self",
".",
"children",
":",
"child_d... | Set our data and notify any subscribers of children what has changed
Args:
data (object): The new data
Returns:
dict: {child_name: [path_list, optional child_data]} of the change
that needs to be passed to a child as a result of this | [
"Set",
"our",
"data",
"and",
"notify",
"any",
"subscribers",
"of",
"children",
"what",
"has",
"changed"
] | train | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/core/notifier.py#L193-L215 |
dls-controls/pymalcolm | malcolm/core/notifier.py | NotifierNode.handle_subscribe | def handle_subscribe(self, request, path):
# type: (Subscribe, List[str]) -> CallbackResponses
"""Add to the list of request to notify, and notify the initial value of
the data held
Args:
request (Subscribe): The subscribe request
path (list): The relative path f... | python | def handle_subscribe(self, request, path):
# type: (Subscribe, List[str]) -> CallbackResponses
"""Add to the list of request to notify, and notify the initial value of
the data held
Args:
request (Subscribe): The subscribe request
path (list): The relative path f... | [
"def",
"handle_subscribe",
"(",
"self",
",",
"request",
",",
"path",
")",
":",
"# type: (Subscribe, List[str]) -> CallbackResponses",
"ret",
"=",
"[",
"]",
"if",
"path",
":",
"# Recurse down",
"name",
"=",
"path",
"[",
"0",
"]",
"if",
"name",
"not",
"in",
"s... | Add to the list of request to notify, and notify the initial value of
the data held
Args:
request (Subscribe): The subscribe request
path (list): The relative path from ourself
Returns:
list: [(callback, Response)] that need to be called | [
"Add",
"to",
"the",
"list",
"of",
"request",
"to",
"notify",
"and",
"notify",
"the",
"initial",
"value",
"of",
"the",
"data",
"held"
] | train | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/core/notifier.py#L217-L246 |
dls-controls/pymalcolm | malcolm/core/notifier.py | NotifierNode.handle_unsubscribe | def handle_unsubscribe(self, request, path):
# type: (Subscribe, List[str]) -> CallbackResponses
"""Remove from the notifier list and send a return
Args:
request (Subscribe): The original subscribe request
path (list): The relative path from ourself
Returns:
... | python | def handle_unsubscribe(self, request, path):
# type: (Subscribe, List[str]) -> CallbackResponses
"""Remove from the notifier list and send a return
Args:
request (Subscribe): The original subscribe request
path (list): The relative path from ourself
Returns:
... | [
"def",
"handle_unsubscribe",
"(",
"self",
",",
"request",
",",
"path",
")",
":",
"# type: (Subscribe, List[str]) -> CallbackResponses",
"ret",
"=",
"[",
"]",
"if",
"path",
":",
"# Recurse down",
"name",
"=",
"path",
"[",
"0",
"]",
"child",
"=",
"self",
".",
... | Remove from the notifier list and send a return
Args:
request (Subscribe): The original subscribe request
path (list): The relative path from ourself
Returns:
list: [(callback, Response)] that need to be called | [
"Remove",
"from",
"the",
"notifier",
"list",
"and",
"send",
"a",
"return"
] | train | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/core/notifier.py#L248-L275 |
dls-controls/pymalcolm | malcolm/modules/builtin/parameters.py | string | def string(name, description, default=None):
# type: (AName, ADescription, AStringDefault) -> AAnno
"""Add a string parameter to be passed when instantiating this YAML file"""
args = common_args(name, default)
return Anno(description, typ=str, **args) | python | def string(name, description, default=None):
# type: (AName, ADescription, AStringDefault) -> AAnno
"""Add a string parameter to be passed when instantiating this YAML file"""
args = common_args(name, default)
return Anno(description, typ=str, **args) | [
"def",
"string",
"(",
"name",
",",
"description",
",",
"default",
"=",
"None",
")",
":",
"# type: (AName, ADescription, AStringDefault) -> AAnno",
"args",
"=",
"common_args",
"(",
"name",
",",
"default",
")",
"return",
"Anno",
"(",
"description",
",",
"typ",
"="... | Add a string parameter to be passed when instantiating this YAML file | [
"Add",
"a",
"string",
"parameter",
"to",
"be",
"passed",
"when",
"instantiating",
"this",
"YAML",
"file"
] | train | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/modules/builtin/parameters.py#L33-L37 |
dls-controls/pymalcolm | malcolm/modules/builtin/parameters.py | float64 | def float64(name, description, default=None):
# type: (AName, ADescription, AFloat64Default) -> AAnno
"""Add a float64 parameter to be passed when instantiating this YAML file"""
args = common_args(name, default)
return Anno(description, typ=float, **args) | python | def float64(name, description, default=None):
# type: (AName, ADescription, AFloat64Default) -> AAnno
"""Add a float64 parameter to be passed when instantiating this YAML file"""
args = common_args(name, default)
return Anno(description, typ=float, **args) | [
"def",
"float64",
"(",
"name",
",",
"description",
",",
"default",
"=",
"None",
")",
":",
"# type: (AName, ADescription, AFloat64Default) -> AAnno",
"args",
"=",
"common_args",
"(",
"name",
",",
"default",
")",
"return",
"Anno",
"(",
"description",
",",
"typ",
"... | Add a float64 parameter to be passed when instantiating this YAML file | [
"Add",
"a",
"float64",
"parameter",
"to",
"be",
"passed",
"when",
"instantiating",
"this",
"YAML",
"file"
] | train | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/modules/builtin/parameters.py#L41-L45 |
dls-controls/pymalcolm | malcolm/modules/builtin/parameters.py | int32 | def int32(name, description, default=None):
# type: (AName, ADescription, AInt32Default) -> AAnno
"""Add an int32 parameter to be passed when instantiating this YAML file"""
args = common_args(name, default)
return Anno(description, typ=int, **args) | python | def int32(name, description, default=None):
# type: (AName, ADescription, AInt32Default) -> AAnno
"""Add an int32 parameter to be passed when instantiating this YAML file"""
args = common_args(name, default)
return Anno(description, typ=int, **args) | [
"def",
"int32",
"(",
"name",
",",
"description",
",",
"default",
"=",
"None",
")",
":",
"# type: (AName, ADescription, AInt32Default) -> AAnno",
"args",
"=",
"common_args",
"(",
"name",
",",
"default",
")",
"return",
"Anno",
"(",
"description",
",",
"typ",
"=",
... | Add an int32 parameter to be passed when instantiating this YAML file | [
"Add",
"an",
"int32",
"parameter",
"to",
"be",
"passed",
"when",
"instantiating",
"this",
"YAML",
"file"
] | train | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/modules/builtin/parameters.py#L49-L53 |
dls-controls/pymalcolm | malcolm/yamlutil.py | make_block_creator | def make_block_creator(yaml_path, filename=None):
# type: (str, str) -> Callable[..., List[Controller]]
"""Make a collection function that will create a list of blocks
Args:
yaml_path (str): File path to YAML file, or a file in the same dir
filename (str): If give, use this filename as the ... | python | def make_block_creator(yaml_path, filename=None):
# type: (str, str) -> Callable[..., List[Controller]]
"""Make a collection function that will create a list of blocks
Args:
yaml_path (str): File path to YAML file, or a file in the same dir
filename (str): If give, use this filename as the ... | [
"def",
"make_block_creator",
"(",
"yaml_path",
",",
"filename",
"=",
"None",
")",
":",
"# type: (str, str) -> Callable[..., List[Controller]]",
"sections",
",",
"yamlname",
",",
"docstring",
"=",
"Section",
".",
"from_yaml",
"(",
"yaml_path",
",",
"filename",
")",
"... | Make a collection function that will create a list of blocks
Args:
yaml_path (str): File path to YAML file, or a file in the same dir
filename (str): If give, use this filename as the last element in
the yaml_path (so yaml_path can be __file__)
Returns:
function: A collecti... | [
"Make",
"a",
"collection",
"function",
"that",
"will",
"create",
"a",
"list",
"of",
"blocks"
] | train | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/yamlutil.py#L138-L177 |
dls-controls/pymalcolm | malcolm/yamlutil.py | Section.instantiate | def instantiate(self, substitutions):
"""Keep recursing down from base using dotted name, then call it with
self.params and args
Args:
substitutions (dict): Substitutions to make to self.param_dict
Returns:
The found object called with (*args, map_from_d)
... | python | def instantiate(self, substitutions):
"""Keep recursing down from base using dotted name, then call it with
self.params and args
Args:
substitutions (dict): Substitutions to make to self.param_dict
Returns:
The found object called with (*args, map_from_d)
... | [
"def",
"instantiate",
"(",
"self",
",",
"substitutions",
")",
":",
"param_dict",
"=",
"self",
".",
"substitute_params",
"(",
"substitutions",
")",
"pkg",
",",
"ident",
"=",
"self",
".",
"name",
".",
"rsplit",
"(",
"\".\"",
",",
"1",
")",
"pkg",
"=",
"\... | Keep recursing down from base using dotted name, then call it with
self.params and args
Args:
substitutions (dict): Substitutions to make to self.param_dict
Returns:
The found object called with (*args, map_from_d)
E.g. if ob is malcolm.parts, and name is "ca.C... | [
"Keep",
"recursing",
"down",
"from",
"base",
"using",
"dotted",
"name",
"then",
"call",
"it",
"with",
"self",
".",
"params",
"and",
"args"
] | train | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/yamlutil.py#L202-L241 |
dls-controls/pymalcolm | malcolm/yamlutil.py | Section.from_yaml | def from_yaml(cls, yaml_path, filename=None):
"""Split a dictionary into parameters controllers parts blocks defines
Args:
yaml_path (str): File path to YAML file, or a file in the same dir
filename (str): If give, use this filename as the last element in
the yam... | python | def from_yaml(cls, yaml_path, filename=None):
"""Split a dictionary into parameters controllers parts blocks defines
Args:
yaml_path (str): File path to YAML file, or a file in the same dir
filename (str): If give, use this filename as the last element in
the yam... | [
"def",
"from_yaml",
"(",
"cls",
",",
"yaml_path",
",",
"filename",
"=",
"None",
")",
":",
"if",
"filename",
":",
"# different filename to support passing __file__",
"yaml_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"("... | Split a dictionary into parameters controllers parts blocks defines
Args:
yaml_path (str): File path to YAML file, or a file in the same dir
filename (str): If give, use this filename as the last element in
the yaml_path (so yaml_path can be __file__)
Returns:
... | [
"Split",
"a",
"dictionary",
"into",
"parameters",
"controllers",
"parts",
"blocks",
"defines"
] | train | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/yamlutil.py#L244-L279 |
dls-controls/pymalcolm | malcolm/yamlutil.py | Section.substitute_params | def substitute_params(self, substitutions):
"""Substitute param values in our param_dict from params
Args:
substitutions (Map or dict): Values to substitute. E.g. Map of
{"name": "me"}
E.g. if self.param_dict is:
{"name": "$(name):pos", "exposure": 1.0}
... | python | def substitute_params(self, substitutions):
"""Substitute param values in our param_dict from params
Args:
substitutions (Map or dict): Values to substitute. E.g. Map of
{"name": "me"}
E.g. if self.param_dict is:
{"name": "$(name):pos", "exposure": 1.0}
... | [
"def",
"substitute_params",
"(",
"self",
",",
"substitutions",
")",
":",
"param_dict",
"=",
"{",
"}",
"# TODO: this should be yaml.add_implicit_resolver()",
"for",
"k",
",",
"v",
"in",
"self",
".",
"param_dict",
".",
"items",
"(",
")",
":",
"param_dict",
"[",
... | Substitute param values in our param_dict from params
Args:
substitutions (Map or dict): Values to substitute. E.g. Map of
{"name": "me"}
E.g. if self.param_dict is:
{"name": "$(name):pos", "exposure": 1.0}
And substitutions is:
{"name": "me"... | [
"Substitute",
"param",
"values",
"in",
"our",
"param_dict",
"from",
"params"
] | train | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/yamlutil.py#L281-L299 |
dls-controls/pymalcolm | malcolm/modules/pmac/infos.py | MotorInfo._make_padded_ramp | def _make_padded_ramp(self, v1, v2, pad_velocity, total_time):
"""Makes a ramp that looks like this:
v1 \______ pad_velocity
| |\
| | \v2
t1 tp t2
Such that whole section takes total_time
"""
# The time taken to ramp from v1 to pad_ve... | python | def _make_padded_ramp(self, v1, v2, pad_velocity, total_time):
"""Makes a ramp that looks like this:
v1 \______ pad_velocity
| |\
| | \v2
t1 tp t2
Such that whole section takes total_time
"""
# The time taken to ramp from v1 to pad_ve... | [
"def",
"_make_padded_ramp",
"(",
"self",
",",
"v1",
",",
"v2",
",",
"pad_velocity",
",",
"total_time",
")",
":",
"# The time taken to ramp from v1 to pad_velocity",
"t1",
"=",
"self",
".",
"acceleration_time",
"(",
"v1",
",",
"pad_velocity",
")",
"# Then on to v2",
... | Makes a ramp that looks like this:
v1 \______ pad_velocity
| |\
| | \v2
t1 tp t2
Such that whole section takes total_time | [
"Makes",
"a",
"ramp",
"that",
"looks",
"like",
"this",
":"
] | train | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/modules/pmac/infos.py#L83-L101 |
dls-controls/pymalcolm | malcolm/modules/pmac/infos.py | MotorInfo._make_hat | def _make_hat(self, v1, v2, acceleration, distance, min_time):
"""Make a hat that looks like this:
______ vm
v1 /| | \
d1| dm|d2\ v2
| |
t1 tm t2
Such that the area under the graph (d1+d2+d3) is distance and
t1+t2+t3 >= min_time
... | python | def _make_hat(self, v1, v2, acceleration, distance, min_time):
"""Make a hat that looks like this:
______ vm
v1 /| | \
d1| dm|d2\ v2
| |
t1 tm t2
Such that the area under the graph (d1+d2+d3) is distance and
t1+t2+t3 >= min_time
... | [
"def",
"_make_hat",
"(",
"self",
",",
"v1",
",",
"v2",
",",
"acceleration",
",",
"distance",
",",
"min_time",
")",
":",
"if",
"min_time",
">",
"0",
":",
"# We are trying to meet time constraints",
"# Solve quadratic to give vm",
"b",
"=",
"v1",
"+",
"v2",
"+",... | Make a hat that looks like this:
______ vm
v1 /| | \
d1| dm|d2\ v2
| |
t1 tm t2
Such that the area under the graph (d1+d2+d3) is distance and
t1+t2+t3 >= min_time | [
"Make",
"a",
"hat",
"that",
"looks",
"like",
"this",
":"
] | train | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/modules/pmac/infos.py#L117-L183 |
dls-controls/pymalcolm | malcolm/modules/pmac/infos.py | MotorInfo.make_velocity_profile | def make_velocity_profile(self, v1, v2, distance, min_time):
"""Calculate PVT points that will perform the move within motor params
Args:
v1 (float): Starting velocity in EGUs/s
v2 (float): Ending velocity in EGUs/s
distance (float): Relative distance to travel in EG... | python | def make_velocity_profile(self, v1, v2, distance, min_time):
"""Calculate PVT points that will perform the move within motor params
Args:
v1 (float): Starting velocity in EGUs/s
v2 (float): Ending velocity in EGUs/s
distance (float): Relative distance to travel in EG... | [
"def",
"make_velocity_profile",
"(",
"self",
",",
"v1",
",",
"v2",
",",
"distance",
",",
"min_time",
")",
":",
"# Take off the settle time and distance",
"if",
"min_time",
">",
"0",
":",
"min_time",
"-=",
"self",
".",
"velocity_settle",
"distance",
"-=",
"self",... | Calculate PVT points that will perform the move within motor params
Args:
v1 (float): Starting velocity in EGUs/s
v2 (float): Ending velocity in EGUs/s
distance (float): Relative distance to travel in EGUs
min_time (float): The minimum time the move should take
... | [
"Calculate",
"PVT",
"points",
"that",
"will",
"perform",
"the",
"move",
"within",
"motor",
"params"
] | train | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/modules/pmac/infos.py#L185-L250 |
dls-controls/pymalcolm | malcolm/modules/pmac/infos.py | MotorInfo.cs_axis_mapping | def cs_axis_mapping(cls,
part_info, # type: Dict[str, Optional[Sequence]]
axes_to_move # type: Sequence[str]
):
# type: (...) -> Tuple[str, Dict[str, MotorInfo]]
"""Given the motor infos for the parts, filter those with scannable
... | python | def cs_axis_mapping(cls,
part_info, # type: Dict[str, Optional[Sequence]]
axes_to_move # type: Sequence[str]
):
# type: (...) -> Tuple[str, Dict[str, MotorInfo]]
"""Given the motor infos for the parts, filter those with scannable
... | [
"def",
"cs_axis_mapping",
"(",
"cls",
",",
"part_info",
",",
"# type: Dict[str, Optional[Sequence]]",
"axes_to_move",
"# type: Sequence[str]",
")",
":",
"# type: (...) -> Tuple[str, Dict[str, MotorInfo]]",
"cs_ports",
"=",
"set",
"(",
")",
"# type: Set[str]",
"axis_mapping",
... | Given the motor infos for the parts, filter those with scannable
names in axes_to_move, check they are all in the same CS, and return
the cs_port and mapping of cs_axis to MotorInfo | [
"Given",
"the",
"motor",
"infos",
"for",
"the",
"parts",
"filter",
"those",
"with",
"scannable",
"names",
"in",
"axes_to_move",
"check",
"they",
"are",
"all",
"in",
"the",
"same",
"CS",
"and",
"return",
"the",
"cs_port",
"and",
"mapping",
"of",
"cs_axis",
... | train | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/modules/pmac/infos.py#L253-L282 |
dls-controls/pymalcolm | malcolm/modules/builtin/controllers/managercontroller.py | ManagerController.set_layout | def set_layout(self, value):
"""Set the layout table value. Called on attribute put"""
# Can't do this with changes_squashed as it will call update_modified
# from another thread and deadlock. Need RLock.is_owned() from update_*
part_info = self.run_hooks(
LayoutHook(p, c, se... | python | def set_layout(self, value):
"""Set the layout table value. Called on attribute put"""
# Can't do this with changes_squashed as it will call update_modified
# from another thread and deadlock. Need RLock.is_owned() from update_*
part_info = self.run_hooks(
LayoutHook(p, c, se... | [
"def",
"set_layout",
"(",
"self",
",",
"value",
")",
":",
"# Can't do this with changes_squashed as it will call update_modified",
"# from another thread and deadlock. Need RLock.is_owned() from update_*",
"part_info",
"=",
"self",
".",
"run_hooks",
"(",
"LayoutHook",
"(",
"p",
... | Set the layout table value. Called on attribute put | [
"Set",
"the",
"layout",
"table",
"value",
".",
"Called",
"on",
"attribute",
"put"
] | train | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/modules/builtin/controllers/managercontroller.py#L167-L206 |
dls-controls/pymalcolm | malcolm/modules/builtin/controllers/managercontroller.py | ManagerController.save | def save(self, designName=""):
# type: (ASaveDesign) -> None
"""Save the current design to file"""
self.try_stateful_function(
ss.SAVING, ss.READY, self.do_save, designName) | python | def save(self, designName=""):
# type: (ASaveDesign) -> None
"""Save the current design to file"""
self.try_stateful_function(
ss.SAVING, ss.READY, self.do_save, designName) | [
"def",
"save",
"(",
"self",
",",
"designName",
"=",
"\"\"",
")",
":",
"# type: (ASaveDesign) -> None",
"self",
".",
"try_stateful_function",
"(",
"ss",
".",
"SAVING",
",",
"ss",
".",
"READY",
",",
"self",
".",
"do_save",
",",
"designName",
")"
] | Save the current design to file | [
"Save",
"the",
"current",
"design",
"to",
"file"
] | train | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/modules/builtin/controllers/managercontroller.py#L419-L423 |
dls-controls/pymalcolm | malcolm/modules/builtin/controllers/managercontroller.py | ManagerController._validated_config_filename | def _validated_config_filename(self, name):
"""Make config dir and return full file path and extension
Args:
name (str): Filename without dir or extension
Returns:
str: Full path including extension
"""
dir_name = self._make_config_dir()
filename... | python | def _validated_config_filename(self, name):
"""Make config dir and return full file path and extension
Args:
name (str): Filename without dir or extension
Returns:
str: Full path including extension
"""
dir_name = self._make_config_dir()
filename... | [
"def",
"_validated_config_filename",
"(",
"self",
",",
"name",
")",
":",
"dir_name",
"=",
"self",
".",
"_make_config_dir",
"(",
")",
"filename",
"=",
"os",
".",
"path",
".",
"join",
"(",
"dir_name",
",",
"name",
".",
"split",
"(",
"\".json\"",
")",
"[",
... | Make config dir and return full file path and extension
Args:
name (str): Filename without dir or extension
Returns:
str: Full path including extension | [
"Make",
"config",
"dir",
"and",
"return",
"full",
"file",
"path",
"and",
"extension"
] | train | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/modules/builtin/controllers/managercontroller.py#L473-L484 |
dls-controls/pymalcolm | malcolm/modules/builtin/controllers/managercontroller.py | ManagerController.do_load | def do_load(self, design, init=False):
# type: (str, bool) -> None
"""Load a design name, running the child LoadHooks.
Args:
design: Name of the design json file, without extension
init: Passed to the LoadHook to tell the children if this is being
run at ... | python | def do_load(self, design, init=False):
# type: (str, bool) -> None
"""Load a design name, running the child LoadHooks.
Args:
design: Name of the design json file, without extension
init: Passed to the LoadHook to tell the children if this is being
run at ... | [
"def",
"do_load",
"(",
"self",
",",
"design",
",",
"init",
"=",
"False",
")",
":",
"# type: (str, bool) -> None",
"if",
"design",
":",
"filename",
"=",
"self",
".",
"_validated_config_filename",
"(",
"design",
")",
"with",
"open",
"(",
"filename",
",",
"\"r\... | Load a design name, running the child LoadHooks.
Args:
design: Name of the design json file, without extension
init: Passed to the LoadHook to tell the children if this is being
run at Init or not | [
"Load",
"a",
"design",
"name",
"running",
"the",
"child",
"LoadHooks",
"."
] | train | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/modules/builtin/controllers/managercontroller.py#L500-L543 |
dls-controls/pymalcolm | malcolm/core/part.py | FieldRegistry.add_method_model | def add_method_model(self,
func, # type: Callable
name=None, # type: Optional[str]
description=None, # type: Optional[str]
owner=None, # type: object
):
# type: (...) -> MethodModel
... | python | def add_method_model(self,
func, # type: Callable
name=None, # type: Optional[str]
description=None, # type: Optional[str]
owner=None, # type: object
):
# type: (...) -> MethodModel
... | [
"def",
"add_method_model",
"(",
"self",
",",
"func",
",",
"# type: Callable",
"name",
"=",
"None",
",",
"# type: Optional[str]",
"description",
"=",
"None",
",",
"# type: Optional[str]",
"owner",
"=",
"None",
",",
"# type: object",
")",
":",
"# type: (...) -> Method... | Register a function to be added to the block | [
"Register",
"a",
"function",
"to",
"be",
"added",
"to",
"the",
"block"
] | train | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/core/part.py#L41-L53 |
dls-controls/pymalcolm | malcolm/core/part.py | PartRegistrar.add_method_model | def add_method_model(self,
func, # type: Callable
name=None, # type: Optional[str]
description=None, # type: Optional[str]
):
# type: (...) -> MethodModel
"""Register a function to be added to the Bloc... | python | def add_method_model(self,
func, # type: Callable
name=None, # type: Optional[str]
description=None, # type: Optional[str]
):
# type: (...) -> MethodModel
"""Register a function to be added to the Bloc... | [
"def",
"add_method_model",
"(",
"self",
",",
"func",
",",
"# type: Callable",
"name",
"=",
"None",
",",
"# type: Optional[str]",
"description",
"=",
"None",
",",
"# type: Optional[str]",
")",
":",
"# type: (...) -> MethodModel",
"return",
"self",
".",
"_field_registry... | Register a function to be added to the Block as a MethodModel | [
"Register",
"a",
"function",
"to",
"be",
"added",
"to",
"the",
"Block",
"as",
"a",
"MethodModel"
] | train | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/core/part.py#L127-L135 |
dls-controls/pymalcolm | malcolm/core/part.py | PartRegistrar.add_attribute_model | def add_attribute_model(self,
name, # type: str
attr, # type: AttributeModel
writeable_func=None, # type: Optional[Callable]
):
# type: (...) -> AttributeModel
"""Register a pre-existing At... | python | def add_attribute_model(self,
name, # type: str
attr, # type: AttributeModel
writeable_func=None, # type: Optional[Callable]
):
# type: (...) -> AttributeModel
"""Register a pre-existing At... | [
"def",
"add_attribute_model",
"(",
"self",
",",
"name",
",",
"# type: str",
"attr",
",",
"# type: AttributeModel",
"writeable_func",
"=",
"None",
",",
"# type: Optional[Callable]",
")",
":",
"# type: (...) -> AttributeModel",
"return",
"self",
".",
"_field_registry",
".... | Register a pre-existing AttributeModel to be added to the Block | [
"Register",
"a",
"pre",
"-",
"existing",
"AttributeModel",
"to",
"be",
"added",
"to",
"the",
"Block"
] | train | https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/core/part.py#L137-L145 |
industrial-optimization-group/DESDEO | desdeo/problem/Problem.py | MOProblem.objective_bounds | def objective_bounds(self):
"""
Return objective bounds
Returns
-------
lower : list of floats
Lower boundaries for the objectives
Upper : list of floats
Upper boundaries for the objectives
"""
if self.ideal and self.nadir:
... | python | def objective_bounds(self):
"""
Return objective bounds
Returns
-------
lower : list of floats
Lower boundaries for the objectives
Upper : list of floats
Upper boundaries for the objectives
"""
if self.ideal and self.nadir:
... | [
"def",
"objective_bounds",
"(",
"self",
")",
":",
"if",
"self",
".",
"ideal",
"and",
"self",
".",
"nadir",
":",
"return",
"self",
".",
"ideal",
",",
"self",
".",
"nadir",
"raise",
"NotImplementedError",
"(",
"\"Ideal and nadir value calculation is not yet implemen... | Return objective bounds
Returns
-------
lower : list of floats
Lower boundaries for the objectives
Upper : list of floats
Upper boundaries for the objectives | [
"Return",
"objective",
"bounds"
] | train | https://github.com/industrial-optimization-group/DESDEO/blob/c7aebe8adb20942d200b9a411d4cdec21f5f4bff/desdeo/problem/Problem.py#L91-L109 |
industrial-optimization-group/DESDEO | desdeo/problem/Problem.py | MOProblem.add_variables | def add_variables(
self, variables: Union[List["Variable"], "Variable"], index: int = None
) -> None:
"""
Parameters
----------
variable : list of variables or single variable
Add variables as problem variables
index : int
Location to add vari... | python | def add_variables(
self, variables: Union[List["Variable"], "Variable"], index: int = None
) -> None:
"""
Parameters
----------
variable : list of variables or single variable
Add variables as problem variables
index : int
Location to add vari... | [
"def",
"add_variables",
"(",
"self",
",",
"variables",
":",
"Union",
"[",
"List",
"[",
"\"Variable\"",
"]",
",",
"\"Variable\"",
"]",
",",
"index",
":",
"int",
"=",
"None",
")",
"->",
"None",
":",
"if",
"isinstance",
"(",
"variables",
",",
"Variable",
... | Parameters
----------
variable : list of variables or single variable
Add variables as problem variables
index : int
Location to add variables, if None add to the end | [
"Parameters",
"----------",
"variable",
":",
"list",
"of",
"variables",
"or",
"single",
"variable",
"Add",
"variables",
"as",
"problem",
"variables"
] | train | https://github.com/industrial-optimization-group/DESDEO/blob/c7aebe8adb20942d200b9a411d4cdec21f5f4bff/desdeo/problem/Problem.py#L121-L142 |
industrial-optimization-group/DESDEO | desdeo/utils/misc.py | _centroids | def _centroids(n_clusters: int, points: List[List[float]]) -> List[List[float]]:
""" Return n_clusters centroids of points
"""
k_means = KMeans(n_clusters=n_clusters)
k_means.fit(points)
closest, _ = pairwise_distances_argmin_min(k_means.cluster_centers_, points)
return list(map(list, np.arra... | python | def _centroids(n_clusters: int, points: List[List[float]]) -> List[List[float]]:
""" Return n_clusters centroids of points
"""
k_means = KMeans(n_clusters=n_clusters)
k_means.fit(points)
closest, _ = pairwise_distances_argmin_min(k_means.cluster_centers_, points)
return list(map(list, np.arra... | [
"def",
"_centroids",
"(",
"n_clusters",
":",
"int",
",",
"points",
":",
"List",
"[",
"List",
"[",
"float",
"]",
"]",
")",
"->",
"List",
"[",
"List",
"[",
"float",
"]",
"]",
":",
"k_means",
"=",
"KMeans",
"(",
"n_clusters",
"=",
"n_clusters",
")",
"... | Return n_clusters centroids of points | [
"Return",
"n_clusters",
"centroids",
"of",
"points"
] | train | https://github.com/industrial-optimization-group/DESDEO/blob/c7aebe8adb20942d200b9a411d4cdec21f5f4bff/desdeo/utils/misc.py#L51-L60 |
industrial-optimization-group/DESDEO | desdeo/utils/misc.py | random_weights | def random_weights(nobj: int, nweight: int) -> List[List[float]]:
""" Generatate nw random weight vectors for nof objectives as per Tchebycheff method [SteCho83]_
.. [SteCho83] Steuer, R. E. & Choo, E.-U. An interactive weighted Tchebycheff procedure for multiple objective programming, Mathematical programming... | python | def random_weights(nobj: int, nweight: int) -> List[List[float]]:
""" Generatate nw random weight vectors for nof objectives as per Tchebycheff method [SteCho83]_
.. [SteCho83] Steuer, R. E. & Choo, E.-U. An interactive weighted Tchebycheff procedure for multiple objective programming, Mathematical programming... | [
"def",
"random_weights",
"(",
"nobj",
":",
"int",
",",
"nweight",
":",
"int",
")",
"->",
"List",
"[",
"List",
"[",
"float",
"]",
"]",
":",
"# Initial wector space as per",
"# Miettinen, K. Nonlinear Multiobjective Optimization",
"# Kluwer Academic Publishers, 1999",
"ws... | Generatate nw random weight vectors for nof objectives as per Tchebycheff method [SteCho83]_
.. [SteCho83] Steuer, R. E. & Choo, E.-U. An interactive weighted Tchebycheff procedure for multiple objective programming, Mathematical programming, Springer, 1983, 26, 326-344
Parameters
----------
nobj:
... | [
"Generatate",
"nw",
"random",
"weight",
"vectors",
"for",
"nof",
"objectives",
"as",
"per",
"Tchebycheff",
"method",
"[",
"SteCho83",
"]",
"_"
] | train | https://github.com/industrial-optimization-group/DESDEO/blob/c7aebe8adb20942d200b9a411d4cdec21f5f4bff/desdeo/utils/misc.py#L63-L92 |
industrial-optimization-group/DESDEO | desdeo/utils/misc.py | new_points | def new_points(
factory: IterationPointFactory, solution, weights: List[List[float]] = None
) -> List[Tuple[np.ndarray, List[float]]]:
"""Generate approximate set of points
Generate set of Pareto optimal solutions projecting from the Pareto optimal solution
using weights to determine the direction.
... | python | def new_points(
factory: IterationPointFactory, solution, weights: List[List[float]] = None
) -> List[Tuple[np.ndarray, List[float]]]:
"""Generate approximate set of points
Generate set of Pareto optimal solutions projecting from the Pareto optimal solution
using weights to determine the direction.
... | [
"def",
"new_points",
"(",
"factory",
":",
"IterationPointFactory",
",",
"solution",
",",
"weights",
":",
"List",
"[",
"List",
"[",
"float",
"]",
"]",
"=",
"None",
")",
"->",
"List",
"[",
"Tuple",
"[",
"np",
".",
"ndarray",
",",
"List",
"[",
"float",
... | Generate approximate set of points
Generate set of Pareto optimal solutions projecting from the Pareto optimal solution
using weights to determine the direction.
Parameters
----------
factory:
IterationPointFactory with suitable optimization problem
solution:
Current solutio... | [
"Generate",
"approximate",
"set",
"of",
"points"
] | train | https://github.com/industrial-optimization-group/DESDEO/blob/c7aebe8adb20942d200b9a411d4cdec21f5f4bff/desdeo/utils/misc.py#L95-L128 |
industrial-optimization-group/DESDEO | desdeo/utils/misc.py | as_minimized | def as_minimized(values: List[float], maximized: List[bool]) -> List[float]:
""" Return vector values as minimized
"""
return [v * -1. if m else v for v, m in zip(values, maximized)] | python | def as_minimized(values: List[float], maximized: List[bool]) -> List[float]:
""" Return vector values as minimized
"""
return [v * -1. if m else v for v, m in zip(values, maximized)] | [
"def",
"as_minimized",
"(",
"values",
":",
"List",
"[",
"float",
"]",
",",
"maximized",
":",
"List",
"[",
"bool",
"]",
")",
"->",
"List",
"[",
"float",
"]",
":",
"return",
"[",
"v",
"*",
"-",
"1.",
"if",
"m",
"else",
"v",
"for",
"v",
",",
"m",
... | Return vector values as minimized | [
"Return",
"vector",
"values",
"as",
"minimized"
] | train | https://github.com/industrial-optimization-group/DESDEO/blob/c7aebe8adb20942d200b9a411d4cdec21f5f4bff/desdeo/utils/misc.py#L131-L134 |
industrial-optimization-group/DESDEO | desdeo/utils/tui.py | _prompt_wrapper | def _prompt_wrapper(message, default=None, validator=None):
""" Handle references piped from file
"""
class MockDocument:
def __init__(self, text):
self.text = text
if HAS_INPUT:
ret = prompt(message, default=default, validator=validator)
else:
ret = sys.stdin.... | python | def _prompt_wrapper(message, default=None, validator=None):
""" Handle references piped from file
"""
class MockDocument:
def __init__(self, text):
self.text = text
if HAS_INPUT:
ret = prompt(message, default=default, validator=validator)
else:
ret = sys.stdin.... | [
"def",
"_prompt_wrapper",
"(",
"message",
",",
"default",
"=",
"None",
",",
"validator",
"=",
"None",
")",
":",
"class",
"MockDocument",
":",
"def",
"__init__",
"(",
"self",
",",
"text",
")",
":",
"self",
".",
"text",
"=",
"text",
"if",
"HAS_INPUT",
":... | Handle references piped from file | [
"Handle",
"references",
"piped",
"from",
"file"
] | train | https://github.com/industrial-optimization-group/DESDEO/blob/c7aebe8adb20942d200b9a411d4cdec21f5f4bff/desdeo/utils/tui.py#L146-L166 |
industrial-optimization-group/DESDEO | desdeo/utils/tui.py | init_nautilus | def init_nautilus(method):
"""Initialize nautilus method
Parameters
----------
method
Interactive method used for the process
Returns
-------
PreferenceInformation subclass to be initialized
"""
print("Preference elicitation options:")
print("\t1 - Percentages")
... | python | def init_nautilus(method):
"""Initialize nautilus method
Parameters
----------
method
Interactive method used for the process
Returns
-------
PreferenceInformation subclass to be initialized
"""
print("Preference elicitation options:")
print("\t1 - Percentages")
... | [
"def",
"init_nautilus",
"(",
"method",
")",
":",
"print",
"(",
"\"Preference elicitation options:\"",
")",
"print",
"(",
"\"\\t1 - Percentages\"",
")",
"print",
"(",
"\"\\t2 - Relative ranks\"",
")",
"print",
"(",
"\"\\t3 - Direct\"",
")",
"PREFCLASSES",
"=",
"[",
"... | Initialize nautilus method
Parameters
----------
method
Interactive method used for the process
Returns
-------
PreferenceInformation subclass to be initialized | [
"Initialize",
"nautilus",
"method"
] | train | https://github.com/industrial-optimization-group/DESDEO/blob/c7aebe8adb20942d200b9a411d4cdec21f5f4bff/desdeo/utils/tui.py#L187-L234 |
industrial-optimization-group/DESDEO | desdeo/utils/tui.py | iter_nautilus | def iter_nautilus(method):
""" Iterate NAUTILUS method either interactively, or using given preferences if given
Parameters
----------
method : instance of NAUTILUS subclass
Fully initialized NAUTILUS method instance
"""
solution = None
while method.current_iter:
preference... | python | def iter_nautilus(method):
""" Iterate NAUTILUS method either interactively, or using given preferences if given
Parameters
----------
method : instance of NAUTILUS subclass
Fully initialized NAUTILUS method instance
"""
solution = None
while method.current_iter:
preference... | [
"def",
"iter_nautilus",
"(",
"method",
")",
":",
"solution",
"=",
"None",
"while",
"method",
".",
"current_iter",
":",
"preference_class",
"=",
"init_nautilus",
"(",
"method",
")",
"pref",
"=",
"preference_class",
"(",
"method",
",",
"None",
")",
"default",
... | Iterate NAUTILUS method either interactively, or using given preferences if given
Parameters
----------
method : instance of NAUTILUS subclass
Fully initialized NAUTILUS method instance | [
"Iterate",
"NAUTILUS",
"method",
"either",
"interactively",
"or",
"using",
"given",
"preferences",
"if",
"given"
] | train | https://github.com/industrial-optimization-group/DESDEO/blob/c7aebe8adb20942d200b9a411d4cdec21f5f4bff/desdeo/utils/tui.py#L237-L272 |
industrial-optimization-group/DESDEO | desdeo/utils/__init__.py | isin | def isin(value, values):
""" Check that value is in values """
for i, v in enumerate(value):
if v not in np.array(values)[:, i]:
return False
return True | python | def isin(value, values):
""" Check that value is in values """
for i, v in enumerate(value):
if v not in np.array(values)[:, i]:
return False
return True | [
"def",
"isin",
"(",
"value",
",",
"values",
")",
":",
"for",
"i",
",",
"v",
"in",
"enumerate",
"(",
"value",
")",
":",
"if",
"v",
"not",
"in",
"np",
".",
"array",
"(",
"values",
")",
"[",
":",
",",
"i",
"]",
":",
"return",
"False",
"return",
... | Check that value is in values | [
"Check",
"that",
"value",
"is",
"in",
"values"
] | train | https://github.com/industrial-optimization-group/DESDEO/blob/c7aebe8adb20942d200b9a411d4cdec21f5f4bff/desdeo/utils/__init__.py#L18-L23 |
industrial-optimization-group/DESDEO | desdeo/method/NIMBUS.py | NIMBUS.between | def between(self, objs1: List[float], objs2: List[float], n=1):
"""
Generate `n` solutions which attempt to trade-off `objs1` and `objs2`.
Parameters
----------
objs1
First boundary point for desired objective function values
objs2
Second boundar... | python | def between(self, objs1: List[float], objs2: List[float], n=1):
"""
Generate `n` solutions which attempt to trade-off `objs1` and `objs2`.
Parameters
----------
objs1
First boundary point for desired objective function values
objs2
Second boundar... | [
"def",
"between",
"(",
"self",
",",
"objs1",
":",
"List",
"[",
"float",
"]",
",",
"objs2",
":",
"List",
"[",
"float",
"]",
",",
"n",
"=",
"1",
")",
":",
"from",
"desdeo",
".",
"preference",
".",
"base",
"import",
"ReferencePoint",
"objs1_arr",
"=",
... | Generate `n` solutions which attempt to trade-off `objs1` and `objs2`.
Parameters
----------
objs1
First boundary point for desired objective function values
objs2
Second boundary point for desired objective function values
n
Number of solut... | [
"Generate",
"n",
"solutions",
"which",
"attempt",
"to",
"trade",
"-",
"off",
"objs1",
"and",
"objs2",
"."
] | train | https://github.com/industrial-optimization-group/DESDEO/blob/c7aebe8adb20942d200b9a411d4cdec21f5f4bff/desdeo/method/NIMBUS.py#L116-L143 |
mota/i3-cycle | i3_cycle.py | find_focusable | def find_focusable(node):
"""
Search for the first focusable window within the node tree
"""
if not node.children:
return node
if node.focus:
return find_focusable(node.children_dict[node.focus[0]]) | python | def find_focusable(node):
"""
Search for the first focusable window within the node tree
"""
if not node.children:
return node
if node.focus:
return find_focusable(node.children_dict[node.focus[0]]) | [
"def",
"find_focusable",
"(",
"node",
")",
":",
"if",
"not",
"node",
".",
"children",
":",
"return",
"node",
"if",
"node",
".",
"focus",
":",
"return",
"find_focusable",
"(",
"node",
".",
"children_dict",
"[",
"node",
".",
"focus",
"[",
"0",
"]",
"]",
... | Search for the first focusable window within the node tree | [
"Search",
"for",
"the",
"first",
"focusable",
"window",
"within",
"the",
"node",
"tree"
] | train | https://github.com/mota/i3-cycle/blob/58947cccb1060c0543a6d9c1f974ee80069110e1/i3_cycle.py#L13-L22 |
mota/i3-cycle | i3_cycle.py | find_parent_split | def find_parent_split(node, orientation):
"""
Find the first parent split relative to the given node
according to the desired orientation
"""
if (node and node.orientation == orientation
and len(node.children) > 1):
return node
if not node or node.type == "workspace":
r... | python | def find_parent_split(node, orientation):
"""
Find the first parent split relative to the given node
according to the desired orientation
"""
if (node and node.orientation == orientation
and len(node.children) > 1):
return node
if not node or node.type == "workspace":
r... | [
"def",
"find_parent_split",
"(",
"node",
",",
"orientation",
")",
":",
"if",
"(",
"node",
"and",
"node",
".",
"orientation",
"==",
"orientation",
"and",
"len",
"(",
"node",
".",
"children",
")",
">",
"1",
")",
":",
"return",
"node",
"if",
"not",
"node"... | Find the first parent split relative to the given node
according to the desired orientation | [
"Find",
"the",
"first",
"parent",
"split",
"relative",
"to",
"the",
"given",
"node",
"according",
"to",
"the",
"desired",
"orientation"
] | train | https://github.com/mota/i3-cycle/blob/58947cccb1060c0543a6d9c1f974ee80069110e1/i3_cycle.py#L25-L38 |
mota/i3-cycle | i3_cycle.py | cycle_windows | def cycle_windows(tree, direction):
"""
Cycle through windows of the current workspace
"""
wanted = {
"orientation": ("vertical" if direction in ("up", "down")
else "horizontal"),
"direction": (1 if direction in ("down", "right")
else -1),
... | python | def cycle_windows(tree, direction):
"""
Cycle through windows of the current workspace
"""
wanted = {
"orientation": ("vertical" if direction in ("up", "down")
else "horizontal"),
"direction": (1 if direction in ("down", "right")
else -1),
... | [
"def",
"cycle_windows",
"(",
"tree",
",",
"direction",
")",
":",
"wanted",
"=",
"{",
"\"orientation\"",
":",
"(",
"\"vertical\"",
"if",
"direction",
"in",
"(",
"\"up\"",
",",
"\"down\"",
")",
"else",
"\"horizontal\"",
")",
",",
"\"direction\"",
":",
"(",
"... | Cycle through windows of the current workspace | [
"Cycle",
"through",
"windows",
"of",
"the",
"current",
"workspace"
] | train | https://github.com/mota/i3-cycle/blob/58947cccb1060c0543a6d9c1f974ee80069110e1/i3_cycle.py#L41-L60 |
mota/i3-cycle | i3_cycle.py | cycle_outputs | def cycle_outputs(tree, direction):
"""
Cycle through directions
"""
direction = 1 if direction == "next" else -1
outputs = [output for output in tree.root.children
if output.name != "__i3"]
focus_idx = outputs.index(tree.root.focused_child)
next_idx = (focus_idx + direction) ... | python | def cycle_outputs(tree, direction):
"""
Cycle through directions
"""
direction = 1 if direction == "next" else -1
outputs = [output for output in tree.root.children
if output.name != "__i3"]
focus_idx = outputs.index(tree.root.focused_child)
next_idx = (focus_idx + direction) ... | [
"def",
"cycle_outputs",
"(",
"tree",
",",
"direction",
")",
":",
"direction",
"=",
"1",
"if",
"direction",
"==",
"\"next\"",
"else",
"-",
"1",
"outputs",
"=",
"[",
"output",
"for",
"output",
"in",
"tree",
".",
"root",
".",
"children",
"if",
"output",
"... | Cycle through directions | [
"Cycle",
"through",
"directions"
] | train | https://github.com/mota/i3-cycle/blob/58947cccb1060c0543a6d9c1f974ee80069110e1/i3_cycle.py#L63-L73 |
mota/i3-cycle | i3_cycle.py | main | def main():
"""
Entry point
"""
parser = ArgumentParser()
parser.add_argument("direction",
choices=(
"up", "down", "left", "right",
"next", "prev"
),
help="Direction to put... | python | def main():
"""
Entry point
"""
parser = ArgumentParser()
parser.add_argument("direction",
choices=(
"up", "down", "left", "right",
"next", "prev"
),
help="Direction to put... | [
"def",
"main",
"(",
")",
":",
"parser",
"=",
"ArgumentParser",
"(",
")",
"parser",
".",
"add_argument",
"(",
"\"direction\"",
",",
"choices",
"=",
"(",
"\"up\"",
",",
"\"down\"",
",",
"\"left\"",
",",
"\"right\"",
",",
"\"next\"",
",",
"\"prev\"",
")",
"... | Entry point | [
"Entry",
"point"
] | train | https://github.com/mota/i3-cycle/blob/58947cccb1060c0543a6d9c1f974ee80069110e1/i3_cycle.py#L76-L98 |
industrial-optimization-group/DESDEO | desdeo/preference/nimbus.py | NIMBUSClassification.with_class | def with_class(self, cls):
""" Return functions with the class
"""
rcls = []
for key, value in self._classification.items():
if value[0] == cls:
rcls.append(key)
return rcls | python | def with_class(self, cls):
""" Return functions with the class
"""
rcls = []
for key, value in self._classification.items():
if value[0] == cls:
rcls.append(key)
return rcls | [
"def",
"with_class",
"(",
"self",
",",
"cls",
")",
":",
"rcls",
"=",
"[",
"]",
"for",
"key",
",",
"value",
"in",
"self",
".",
"_classification",
".",
"items",
"(",
")",
":",
"if",
"value",
"[",
"0",
"]",
"==",
"cls",
":",
"rcls",
".",
"append",
... | Return functions with the class | [
"Return",
"functions",
"with",
"the",
"class"
] | train | https://github.com/industrial-optimization-group/DESDEO/blob/c7aebe8adb20942d200b9a411d4cdec21f5f4bff/desdeo/preference/nimbus.py#L77-L84 |
industrial-optimization-group/DESDEO | desdeo/preference/nimbus.py | NIMBUSClassification._as_reference_point | def _as_reference_point(self) -> np.ndarray:
""" Return classification information as reference point
"""
ref_val = []
for fn, f in self._classification.items():
if f[0] == "<":
ref_val.append(self._method.problem.ideal[fn])
elif f[0] == "<>":
... | python | def _as_reference_point(self) -> np.ndarray:
""" Return classification information as reference point
"""
ref_val = []
for fn, f in self._classification.items():
if f[0] == "<":
ref_val.append(self._method.problem.ideal[fn])
elif f[0] == "<>":
... | [
"def",
"_as_reference_point",
"(",
"self",
")",
"->",
"np",
".",
"ndarray",
":",
"ref_val",
"=",
"[",
"]",
"for",
"fn",
",",
"f",
"in",
"self",
".",
"_classification",
".",
"items",
"(",
")",
":",
"if",
"f",
"[",
"0",
"]",
"==",
"\"<\"",
":",
"re... | Return classification information as reference point | [
"Return",
"classification",
"information",
"as",
"reference",
"point"
] | train | https://github.com/industrial-optimization-group/DESDEO/blob/c7aebe8adb20942d200b9a411d4cdec21f5f4bff/desdeo/preference/nimbus.py#L86-L98 |
industrial-optimization-group/DESDEO | examples/article_nautilus.py | main | def main(logfile=False):
""" Solve River Pollution problem with NAUTILUS V1 and E-NAUTILUS Methods
"""
# Duplicate output to log file
class NAUTILUSOptionValidator(Validator):
def validate(self, document):
if document.text not in "ao":
raise ValidationError(
... | python | def main(logfile=False):
""" Solve River Pollution problem with NAUTILUS V1 and E-NAUTILUS Methods
"""
# Duplicate output to log file
class NAUTILUSOptionValidator(Validator):
def validate(self, document):
if document.text not in "ao":
raise ValidationError(
... | [
"def",
"main",
"(",
"logfile",
"=",
"False",
")",
":",
"# Duplicate output to log file",
"class",
"NAUTILUSOptionValidator",
"(",
"Validator",
")",
":",
"def",
"validate",
"(",
"self",
",",
"document",
")",
":",
"if",
"document",
".",
"text",
"not",
"in",
"\... | Solve River Pollution problem with NAUTILUS V1 and E-NAUTILUS Methods | [
"Solve",
"River",
"Pollution",
"problem",
"with",
"NAUTILUS",
"V1",
"and",
"E",
"-",
"NAUTILUS",
"Methods"
] | train | https://github.com/industrial-optimization-group/DESDEO/blob/c7aebe8adb20942d200b9a411d4cdec21f5f4bff/examples/article_nautilus.py#L91-L173 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.