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_documentation_string
stringlengths
1
47.2k
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 "...
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 ...
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())
Takes a hook, and optionally calls hook.run on a function
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...
Check if a transition between two states is allowed
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...
Add an allowed transition from initial_state to allowed_states
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)
Define a string parameter coming from a shell command to be used within this YAML file. Trailing newlines will be stripped.
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)
Exports an environment variable with the given value
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) ...
Load an external malcolm module (e.g. ADCore/etc/malcolm)
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...
Pass response from server to process receive queue Args: message(str): Received message
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 ...
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
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...
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
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...
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
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: ...
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
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...
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
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...
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 ...
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...
Disconnect anyone listening to any of the given mris
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
Add a Source Port tag to the tags list, removing any other Source Ports
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...
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
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....
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
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 ...
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
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...
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
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...
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
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
Make a child View of data[child_name]
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...
Called with the lock taken
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....
Called with the lock taken
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...
Called with the lock taken
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...
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
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...
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. ...
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...
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...
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
Sets the return value of work associated with the future. Should only be used by Task and unit tests.
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...
Sets the result of the future as being the given exception. Should only be used by Task and unit tests.
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__._...
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)
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
Create a Return Response object to signal a return value
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
Create an Error Response object to signal an error
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 ...
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...
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)
Put a value to the Attribute and wait for completion
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...
Calculate the exposure to set the detector to given the duration of the frame and the readout_time and frequency_accuracy
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...
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
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 ...
Take a single change from a Delta and apply it to this model
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...
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
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...
Return an instance of this class from an Anno
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] ...
Register this class as a converter for Anno instances
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 =...
Look up a vmeta based on an Anno
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 ...
Set value, calculating alarm and ts if requested
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...
Set value with pre-validated alarm and timeStamp
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
Optionally sleep <sleep> seconds, then return a greeting to <name>
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( ...
Extracts the version number from the version.py file.
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 ...
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...
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...
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
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) ...
Service self._send_queue, sending requests to server
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
Respond to the person waiting
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...
Service socket recv, returning responses to the correct queue
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: ...
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}
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 ...
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)
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...
Will be called when a context passed to a hooked function is about to dispatch a request
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...
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...
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 = {} ...
Calculate what is connected to what Args: ports: {part_name: [PortInfo]} from other ports
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
Handle a Subscribe request from outside. Called with lock taken
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:]) ...
Handle a Unsubscribe request from outside. Called with lock taken
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...
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
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 ...
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
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...
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
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...
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
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: ...
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
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)
Add a string parameter to be passed when instantiating this YAML file
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)
Add a float64 parameter to be passed when instantiating this YAML file
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)
Add an int32 parameter to be passed when instantiating this YAML file
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 ...
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...
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) ...
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...
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...
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: ...
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} ...
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"...
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...
Makes a ramp that looks like this: v1 \______ pad_velocity | |\ | | \v2 t1 tp t2 Such that whole section takes total_time
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 ...
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
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...
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 ...
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 ...
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
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...
Set the layout table value. Called on attribute put
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)
Save the current design to file
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...
Make config dir and return full file path and extension Args: name (str): Filename without dir or extension Returns: str: Full path including extension
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 ...
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
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 ...
Register a function to be added to the block
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...
Register a function to be added to the Block as a MethodModel
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...
Register a pre-existing AttributeModel to be added to the Block
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: ...
Return objective bounds Returns ------- lower : list of floats Lower boundaries for the objectives Upper : list of floats Upper boundaries for the objectives
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...
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
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...
Return n_clusters centroids of points
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...
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: ...
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. ...
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...
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)]
Return vector values as minimized
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....
Handle references piped from file
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") ...
Initialize nautilus method Parameters ---------- method Interactive method used for the process Returns ------- PreferenceInformation subclass to be initialized
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...
Iterate NAUTILUS method either interactively, or using given preferences if given Parameters ---------- method : instance of NAUTILUS subclass Fully initialized NAUTILUS method instance
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
Check that value is in values
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...
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...
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]])
Search for the first focusable window within the node tree
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...
Find the first parent split relative to the given node according to the desired orientation
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), ...
Cycle through windows of the current workspace
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) ...
Cycle through directions
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...
Entry point
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
Return functions with the class
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] == "<>": ...
Return classification information as reference point
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( ...
Solve River Pollution problem with NAUTILUS V1 and E-NAUTILUS Methods
https://github.com/industrial-optimization-group/DESDEO/blob/c7aebe8adb20942d200b9a411d4cdec21f5f4bff/examples/article_nautilus.py#L91-L173