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
Karaage-Cluster/karaage
karaage/common/trace.py
get_formatter
def get_formatter(name): """Return the named formatter function. See the function "set_formatter" for details. """ if name in ('self', 'instance', 'this'): return af_self elif name == 'class': return af_class elif name in ('named', 'param', 'parameter'): return af_named ...
python
def get_formatter(name): """Return the named formatter function. See the function "set_formatter" for details. """ if name in ('self', 'instance', 'this'): return af_self elif name == 'class': return af_class elif name in ('named', 'param', 'parameter'): return af_named ...
Return the named formatter function. See the function "set_formatter" for details.
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/common/trace.py#L285-L302
Karaage-Cluster/karaage
karaage/common/trace.py
set_formatter
def set_formatter(name, func): """Replace the formatter function used by the trace decorator to handle formatting a specific kind of argument. There are several kinds of arguments that trace discriminates between: * instance argument - the object bound to an instance method. * class argument - the...
python
def set_formatter(name, func): """Replace the formatter function used by the trace decorator to handle formatting a specific kind of argument. There are several kinds of arguments that trace discriminates between: * instance argument - the object bound to an instance method. * class argument - the...
Replace the formatter function used by the trace decorator to handle formatting a specific kind of argument. There are several kinds of arguments that trace discriminates between: * instance argument - the object bound to an instance method. * class argument - the class object bound to a class method....
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/common/trace.py#L305-L355
Karaage-Cluster/karaage
karaage/common/trace.py
__lookup_builtin
def __lookup_builtin(name): """Lookup the parameter name and default parameter values for builtin functions. """ global __builtin_functions if __builtin_functions is None: builtins = dict() for proto in __builtins: pos = proto.find('(') name, params, defaults ...
python
def __lookup_builtin(name): """Lookup the parameter name and default parameter values for builtin functions. """ global __builtin_functions if __builtin_functions is None: builtins = dict() for proto in __builtins: pos = proto.find('(') name, params, defaults ...
Lookup the parameter name and default parameter values for builtin functions.
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/common/trace.py#L431-L463
Karaage-Cluster/karaage
karaage/common/trace.py
trace
def trace(_name): """Function decorator that logs function entry and exit details. \var{_name} a string, an instance of logging.Logger or a function. Construct a function or method proxy to generate call traces. """ def decorator(_func): """This is the actual decorator function that wraps ...
python
def trace(_name): """Function decorator that logs function entry and exit details. \var{_name} a string, an instance of logging.Logger or a function. Construct a function or method proxy to generate call traces. """ def decorator(_func): """This is the actual decorator function that wraps ...
Function decorator that logs function entry and exit details. \var{_name} a string, an instance of logging.Logger or a function. Construct a function or method proxy to generate call traces.
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/common/trace.py#L470-L673
Karaage-Cluster/karaage
karaage/common/trace.py
attach
def attach(decorator, obj, recursive=True): """attach(decorator, class_or_module[, recursive = True]) Utility to attach a \val{decorator} to the \val{obj} instance. If \val{obj} is a module, the decorator will be attached to every function and class in the module. If \val{obj} is a class, the dec...
python
def attach(decorator, obj, recursive=True): """attach(decorator, class_or_module[, recursive = True]) Utility to attach a \val{decorator} to the \val{obj} instance. If \val{obj} is a module, the decorator will be attached to every function and class in the module. If \val{obj} is a class, the dec...
attach(decorator, class_or_module[, recursive = True]) Utility to attach a \val{decorator} to the \val{obj} instance. If \val{obj} is a module, the decorator will be attached to every function and class in the module. If \val{obj} is a class, the decorator will be attached to every method and sub...
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/common/trace.py#L711-L730
Karaage-Cluster/karaage
karaage/projects/models.py
_leaders_changed
def _leaders_changed( sender, instance, action, reverse, model, pk_set, **kwargs): """ Hook that executes whenever the group members are changed. """ # print("'%s','%s','%s','%s','%s'" # %(instance, action, reverse, model, pk_set)) if action == "post_add": if not reverse: ...
python
def _leaders_changed( sender, instance, action, reverse, model, pk_set, **kwargs): """ Hook that executes whenever the group members are changed. """ # print("'%s','%s','%s','%s','%s'" # %(instance, action, reverse, model, pk_set)) if action == "post_add": if not reverse: ...
Hook that executes whenever the group members are changed.
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/projects/models.py#L244-L312
Karaage-Cluster/karaage
karaage/plugins/kgusage/alogger.py
parse_logs
def parse_logs(log_list, date, machine_name, log_type): """ Parse log file lines in log_type format. """ output = [] count = fail = skip = updated = 0 # Check things are setup correctly try: machine = Machine.objects.get(name=machine_name) except Machine.DoesNotExist: re...
python
def parse_logs(log_list, date, machine_name, log_type): """ Parse log file lines in log_type format. """ output = [] count = fail = skip = updated = 0 # Check things are setup correctly try: machine = Machine.objects.get(name=machine_name) except Machine.DoesNotExist: re...
Parse log file lines in log_type format.
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/plugins/kgusage/alogger.py#L46-L202
Karaage-Cluster/karaage
karaage/plugins/kgapplications/views/common.py
application_list
def application_list(request): """ a user wants to see all applications possible. """ if util.is_admin(request): queryset = Application.objects.all() else: queryset = Application.objects.get_for_applicant(request.user) q_filter = ApplicationFilter(request.GET, queryset=queryset) t...
python
def application_list(request): """ a user wants to see all applications possible. """ if util.is_admin(request): queryset = Application.objects.all() else: queryset = Application.objects.get_for_applicant(request.user) q_filter = ApplicationFilter(request.GET, queryset=queryset) t...
a user wants to see all applications possible.
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/plugins/kgapplications/views/common.py#L38-L65
Karaage-Cluster/karaage
karaage/plugins/kgapplications/views/common.py
profile_application_list
def profile_application_list(request): """ a logged in user wants to see all his pending applications. """ config = tables.RequestConfig(request, paginate={"per_page": 5}) person = request.user my_applications = Application.objects.get_for_applicant(person) my_applications = ApplicationTable(my_app...
python
def profile_application_list(request): """ a logged in user wants to see all his pending applications. """ config = tables.RequestConfig(request, paginate={"per_page": 5}) person = request.user my_applications = Application.objects.get_for_applicant(person) my_applications = ApplicationTable(my_app...
a logged in user wants to see all his pending applications.
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/plugins/kgapplications/views/common.py#L69-L89
Karaage-Cluster/karaage
karaage/plugins/kgapplications/views/common.py
application_detail
def application_detail(request, application_id, state=None, label=None): """ A authenticated used is trying to access an application. """ application = base.get_application(pk=application_id) state_machine = base.get_state_machine(application) return state_machine.process(request, application, state, la...
python
def application_detail(request, application_id, state=None, label=None): """ A authenticated used is trying to access an application. """ application = base.get_application(pk=application_id) state_machine = base.get_state_machine(application) return state_machine.process(request, application, state, la...
A authenticated used is trying to access an application.
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/plugins/kgapplications/views/common.py#L130-L134
Karaage-Cluster/karaage
karaage/plugins/kgapplications/views/common.py
application_unauthenticated
def application_unauthenticated(request, token, state=None, label=None): """ An somebody is trying to access an application. """ application = base.get_application(secret_token=token) if application.expires < datetime.datetime.now(): return render( template_name='kgapplications/common_ex...
python
def application_unauthenticated(request, token, state=None, label=None): """ An somebody is trying to access an application. """ application = base.get_application(secret_token=token) if application.expires < datetime.datetime.now(): return render( template_name='kgapplications/common_ex...
An somebody is trying to access an application.
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/plugins/kgapplications/views/common.py#L137-L157
Karaage-Cluster/karaage
karaage/plugins/kgusage/usage.py
get_institute_usage
def get_institute_usage(institute, start, end): """Return a tuple of cpu hours and number of jobs for an institute for a given period Keyword arguments: institute -- start -- start date end -- end date """ try: cache = InstituteCache.objects.get( institute=institute,...
python
def get_institute_usage(institute, start, end): """Return a tuple of cpu hours and number of jobs for an institute for a given period Keyword arguments: institute -- start -- start date end -- end date """ try: cache = InstituteCache.objects.get( institute=institute,...
Return a tuple of cpu hours and number of jobs for an institute for a given period Keyword arguments: institute -- start -- start date end -- end date
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/plugins/kgusage/usage.py#L35-L50
Karaage-Cluster/karaage
karaage/plugins/kgusage/usage.py
get_project_usage
def get_project_usage(project, start, end): """Return a tuple of cpu hours and number of jobs for a project for a given period Keyword arguments: project -- start -- start date end -- end date """ try: cache = ProjectCache.objects.get( project=project, date=datetime...
python
def get_project_usage(project, start, end): """Return a tuple of cpu hours and number of jobs for a project for a given period Keyword arguments: project -- start -- start date end -- end date """ try: cache = ProjectCache.objects.get( project=project, date=datetime...
Return a tuple of cpu hours and number of jobs for a project for a given period Keyword arguments: project -- start -- start date end -- end date
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/plugins/kgusage/usage.py#L53-L69
Karaage-Cluster/karaage
karaage/plugins/kgusage/usage.py
get_person_usage
def get_person_usage(person, project, start, end): """Return a tuple of cpu hours and number of jobs for a person in a specific project Keyword arguments: person -- project -- The project the usage is from start -- start date end -- end date """ try: cache = PersonCache.obje...
python
def get_person_usage(person, project, start, end): """Return a tuple of cpu hours and number of jobs for a person in a specific project Keyword arguments: person -- project -- The project the usage is from start -- start date end -- end date """ try: cache = PersonCache.obje...
Return a tuple of cpu hours and number of jobs for a person in a specific project Keyword arguments: person -- project -- The project the usage is from start -- start date end -- end date
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/plugins/kgusage/usage.py#L72-L88
Karaage-Cluster/karaage
karaage/plugins/kgusage/usage.py
get_machine_usage
def get_machine_usage(machine, start, end): """Return a tuple of cpu hours and number of jobs for a machine for a given period Keyword arguments: machine -- start -- start date end -- end date """ try: cache = MachineCache.objects.get( machine=machine, date=datetim...
python
def get_machine_usage(machine, start, end): """Return a tuple of cpu hours and number of jobs for a machine for a given period Keyword arguments: machine -- start -- start date end -- end date """ try: cache = MachineCache.objects.get( machine=machine, date=datetim...
Return a tuple of cpu hours and number of jobs for a machine for a given period Keyword arguments: machine -- start -- start date end -- end date
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/plugins/kgusage/usage.py#L91-L108
Karaage-Cluster/karaage
karaage/plugins/kgusage/usage.py
get_machine_category_usage
def get_machine_category_usage(start, end): """Return a tuple of cpu hours and number of jobs for a given period Keyword arguments: start -- start date end -- end date """ cache = MachineCategoryCache.objects.get( date=datetime.date.today(), start=start, end=end) retur...
python
def get_machine_category_usage(start, end): """Return a tuple of cpu hours and number of jobs for a given period Keyword arguments: start -- start date end -- end date """ cache = MachineCategoryCache.objects.get( date=datetime.date.today(), start=start, end=end) retur...
Return a tuple of cpu hours and number of jobs for a given period Keyword arguments: start -- start date end -- end date
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/plugins/kgusage/usage.py#L111-L124
Karaage-Cluster/karaage
karaage/plugins/kgapplications/views/project.py
get_applicant_from_email
def get_applicant_from_email(email): """ Get applicant from email address. If the person exists, return (person, True) If multiple matches, return (None, True) Otherwise create applicant and return (applicant, False) """ try: applicant = Person.active.get(email=email) exis...
python
def get_applicant_from_email(email): """ Get applicant from email address. If the person exists, return (person, True) If multiple matches, return (None, True) Otherwise create applicant and return (applicant, False) """ try: applicant = Person.active.get(email=email) exis...
Get applicant from email address. If the person exists, return (person, True) If multiple matches, return (None, True) Otherwise create applicant and return (applicant, False)
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/plugins/kgapplications/views/project.py#L48-L67
Karaage-Cluster/karaage
karaage/plugins/kgapplications/views/project.py
_send_invitation
def _send_invitation(request, project): """ The logged in project leader OR administrator wants to invite somebody. """ form = forms.InviteUserApplicationForm(request.POST or None) if request.method == 'POST': if form.is_valid(): email = form.cleaned_data['email'] applic...
python
def _send_invitation(request, project): """ The logged in project leader OR administrator wants to invite somebody. """ form = forms.InviteUserApplicationForm(request.POST or None) if request.method == 'POST': if form.is_valid(): email = form.cleaned_data['email'] applic...
The logged in project leader OR administrator wants to invite somebody.
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/plugins/kgapplications/views/project.py#L70-L106
Karaage-Cluster/karaage
karaage/plugins/kgapplications/views/project.py
send_invitation
def send_invitation(request, project_id=None): """ The logged in project leader wants to invite somebody to their project. """ project = None if project_id is not None: project = get_object_or_404(Project, id=project_id) if project is None: if not is_admin(request): re...
python
def send_invitation(request, project_id=None): """ The logged in project leader wants to invite somebody to their project. """ project = None if project_id is not None: project = get_object_or_404(Project, id=project_id) if project is None: if not is_admin(request): re...
The logged in project leader wants to invite somebody to their project.
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/plugins/kgapplications/views/project.py#L110-L128
Karaage-Cluster/karaage
karaage/plugins/kgapplications/views/project.py
new_application
def new_application(request): """ A new application by a user to start a new project. """ # Note default kgapplications/index.html will display error if user logged # in. if not settings.ALLOW_REGISTRATIONS: return render( template_name='kgapplications/project_common_disabled.html', ...
python
def new_application(request): """ A new application by a user to start a new project. """ # Note default kgapplications/index.html will display error if user logged # in. if not settings.ALLOW_REGISTRATIONS: return render( template_name='kgapplications/project_common_disabled.html', ...
A new application by a user to start a new project.
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/plugins/kgapplications/views/project.py#L131-L191
asottile/setuptools-golang
setuptools_golang.py
_get_ldflags
def _get_ldflags(): """Determine the correct link flags. This attempts dummy compiles similar to how autotools does feature detection. """ # windows gcc does not support linking with unresolved symbols if sys.platform == 'win32': # pragma: no cover (windows) prefix = getattr(sys, 'real_pre...
python
def _get_ldflags(): """Determine the correct link flags. This attempts dummy compiles similar to how autotools does feature detection. """ # windows gcc does not support linking with unresolved symbols if sys.platform == 'win32': # pragma: no cover (windows) prefix = getattr(sys, 'real_pre...
Determine the correct link flags. This attempts dummy compiles similar to how autotools does feature detection.
https://github.com/asottile/setuptools-golang/blob/a4951e05efc0cf6b9df42a6ff63ac45e0b7b664d/setuptools_golang.py#L42-L68
dwavesystems/penaltymodel
penaltymodel_maxgap/penaltymodel/maxgap/interface.py
get_penalty_model
def get_penalty_model(specification): """Factory function for penaltymodel_maxgap. Args: specification (penaltymodel.Specification): The specification for the desired penalty model. Returns: :class:`penaltymodel.PenaltyModel`: Penalty model with the given specification. Ra...
python
def get_penalty_model(specification): """Factory function for penaltymodel_maxgap. Args: specification (penaltymodel.Specification): The specification for the desired penalty model. Returns: :class:`penaltymodel.PenaltyModel`: Penalty model with the given specification. Ra...
Factory function for penaltymodel_maxgap. Args: specification (penaltymodel.Specification): The specification for the desired penalty model. Returns: :class:`penaltymodel.PenaltyModel`: Penalty model with the given specification. Raises: :class:`penaltymodel.Impossible...
https://github.com/dwavesystems/penaltymodel/blob/b9d343233aea8df0f59cea45a07f12d0b3b8d9b3/penaltymodel_maxgap/penaltymodel/maxgap/interface.py#L25-L66
dwavesystems/penaltymodel
penaltymodel_cache/penaltymodel/cache/database_manager.py
insert_feasible_configurations
def insert_feasible_configurations(cur, feasible_configurations, encoded_data=None): """Insert a group of feasible configurations into the cache. Args: cur (:class:`sqlite3.Cursor`): An sqlite3 cursor. This function is meant to be run within a :obj:`with` statement. feasible_configu...
python
def insert_feasible_configurations(cur, feasible_configurations, encoded_data=None): """Insert a group of feasible configurations into the cache. Args: cur (:class:`sqlite3.Cursor`): An sqlite3 cursor. This function is meant to be run within a :obj:`with` statement. feasible_configu...
Insert a group of feasible configurations into the cache. Args: cur (:class:`sqlite3.Cursor`): An sqlite3 cursor. This function is meant to be run within a :obj:`with` statement. feasible_configurations (dict[tuple[int]): The set of feasible configurations. Each key should b...
https://github.com/dwavesystems/penaltymodel/blob/b9d343233aea8df0f59cea45a07f12d0b3b8d9b3/penaltymodel_cache/penaltymodel/cache/database_manager.py#L147-L193
dwavesystems/penaltymodel
penaltymodel_cache/penaltymodel/cache/database_manager.py
iter_feasible_configurations
def iter_feasible_configurations(cur): """Iterate over all of the sets of feasible configurations in the cache. Args: cur (:class:`sqlite3.Cursor`): An sqlite3 cursor. This function is meant to be run within a :obj:`with` statement. Yields: dict[tuple(int): number]: The feasibl...
python
def iter_feasible_configurations(cur): """Iterate over all of the sets of feasible configurations in the cache. Args: cur (:class:`sqlite3.Cursor`): An sqlite3 cursor. This function is meant to be run within a :obj:`with` statement. Yields: dict[tuple(int): number]: The feasibl...
Iterate over all of the sets of feasible configurations in the cache. Args: cur (:class:`sqlite3.Cursor`): An sqlite3 cursor. This function is meant to be run within a :obj:`with` statement. Yields: dict[tuple(int): number]: The feasible_configurations.
https://github.com/dwavesystems/penaltymodel/blob/b9d343233aea8df0f59cea45a07f12d0b3b8d9b3/penaltymodel_cache/penaltymodel/cache/database_manager.py#L215-L236
dwavesystems/penaltymodel
penaltymodel_cache/penaltymodel/cache/database_manager.py
_decode_config
def _decode_config(c, num_variables): """inverse of _serialize_config, always converts to spin.""" def bits(c): n = 1 << (num_variables - 1) for __ in range(num_variables): yield 1 if c & n else -1 n >>= 1 return tuple(bits(c))
python
def _decode_config(c, num_variables): """inverse of _serialize_config, always converts to spin.""" def bits(c): n = 1 << (num_variables - 1) for __ in range(num_variables): yield 1 if c & n else -1 n >>= 1 return tuple(bits(c))
inverse of _serialize_config, always converts to spin.
https://github.com/dwavesystems/penaltymodel/blob/b9d343233aea8df0f59cea45a07f12d0b3b8d9b3/penaltymodel_cache/penaltymodel/cache/database_manager.py#L239-L246
dwavesystems/penaltymodel
penaltymodel_cache/penaltymodel/cache/database_manager.py
insert_ising_model
def insert_ising_model(cur, nodelist, edgelist, linear, quadratic, offset, encoded_data=None): """Insert an Ising model into the cache. Args: cur (:class:`sqlite3.Cursor`): An sqlite3 cursor. This function is meant to be run within a :obj:`with` statement. nodelist (list): The nodes...
python
def insert_ising_model(cur, nodelist, edgelist, linear, quadratic, offset, encoded_data=None): """Insert an Ising model into the cache. Args: cur (:class:`sqlite3.Cursor`): An sqlite3 cursor. This function is meant to be run within a :obj:`with` statement. nodelist (list): The nodes...
Insert an Ising model into the cache. Args: cur (:class:`sqlite3.Cursor`): An sqlite3 cursor. This function is meant to be run within a :obj:`with` statement. nodelist (list): The nodes in the graph. edgelist (list): The edges in the graph. linear (dict): The linear bias...
https://github.com/dwavesystems/penaltymodel/blob/b9d343233aea8df0f59cea45a07f12d0b3b8d9b3/penaltymodel_cache/penaltymodel/cache/database_manager.py#L249-L313
dwavesystems/penaltymodel
penaltymodel_cache/penaltymodel/cache/database_manager.py
_serialize_linear_biases
def _serialize_linear_biases(linear, nodelist): """Serializes the linear biases. Args: linear: a interable object where linear[v] is the bias associated with v. nodelist (list): an ordered iterable containing the nodes. Returns: str: base 64 encoded string of little end...
python
def _serialize_linear_biases(linear, nodelist): """Serializes the linear biases. Args: linear: a interable object where linear[v] is the bias associated with v. nodelist (list): an ordered iterable containing the nodes. Returns: str: base 64 encoded string of little end...
Serializes the linear biases. Args: linear: a interable object where linear[v] is the bias associated with v. nodelist (list): an ordered iterable containing the nodes. Returns: str: base 64 encoded string of little endian 8 byte floats, one for each of the bias...
https://github.com/dwavesystems/penaltymodel/blob/b9d343233aea8df0f59cea45a07f12d0b3b8d9b3/penaltymodel_cache/penaltymodel/cache/database_manager.py#L316-L337
dwavesystems/penaltymodel
penaltymodel_cache/penaltymodel/cache/database_manager.py
_serialize_quadratic_biases
def _serialize_quadratic_biases(quadratic, edgelist): """Serializes the quadratic biases. Args: quadratic (dict): a dict of the form {edge1: bias1, ...} where each edge is of the form (node1, node2). edgelist (list): a list of the form [(node1, node2), ...]. Returns: st...
python
def _serialize_quadratic_biases(quadratic, edgelist): """Serializes the quadratic biases. Args: quadratic (dict): a dict of the form {edge1: bias1, ...} where each edge is of the form (node1, node2). edgelist (list): a list of the form [(node1, node2), ...]. Returns: st...
Serializes the quadratic biases. Args: quadratic (dict): a dict of the form {edge1: bias1, ...} where each edge is of the form (node1, node2). edgelist (list): a list of the form [(node1, node2), ...]. Returns: str: base 64 encoded string of little endian 8 byte floats, ...
https://github.com/dwavesystems/penaltymodel/blob/b9d343233aea8df0f59cea45a07f12d0b3b8d9b3/penaltymodel_cache/penaltymodel/cache/database_manager.py#L340-L362
dwavesystems/penaltymodel
penaltymodel_cache/penaltymodel/cache/database_manager.py
iter_ising_model
def iter_ising_model(cur): """Iterate over all of the Ising models in the cache. Args: cur (:class:`sqlite3.Cursor`): An sqlite3 cursor. This function is meant to be run within a :obj:`with` statement. Yields: tuple: A 5-tuple consisting of: list: The nodelist for ...
python
def iter_ising_model(cur): """Iterate over all of the Ising models in the cache. Args: cur (:class:`sqlite3.Cursor`): An sqlite3 cursor. This function is meant to be run within a :obj:`with` statement. Yields: tuple: A 5-tuple consisting of: list: The nodelist for ...
Iterate over all of the Ising models in the cache. Args: cur (:class:`sqlite3.Cursor`): An sqlite3 cursor. This function is meant to be run within a :obj:`with` statement. Yields: tuple: A 5-tuple consisting of: list: The nodelist for a graph in the cache. ...
https://github.com/dwavesystems/penaltymodel/blob/b9d343233aea8df0f59cea45a07f12d0b3b8d9b3/penaltymodel_cache/penaltymodel/cache/database_manager.py#L365-L399
dwavesystems/penaltymodel
penaltymodel_cache/penaltymodel/cache/database_manager.py
_decode_linear_biases
def _decode_linear_biases(linear_string, nodelist): """Inverse of _serialize_linear_biases. Args: linear_string (str): base 64 encoded string of little endian 8 byte floats, one for each of the nodes in nodelist. nodelist (list): list of the form [node1, node2, ...]. Returns: ...
python
def _decode_linear_biases(linear_string, nodelist): """Inverse of _serialize_linear_biases. Args: linear_string (str): base 64 encoded string of little endian 8 byte floats, one for each of the nodes in nodelist. nodelist (list): list of the form [node1, node2, ...]. Returns: ...
Inverse of _serialize_linear_biases. Args: linear_string (str): base 64 encoded string of little endian 8 byte floats, one for each of the nodes in nodelist. nodelist (list): list of the form [node1, node2, ...]. Returns: dict: linear biases in a dict. Examples: ...
https://github.com/dwavesystems/penaltymodel/blob/b9d343233aea8df0f59cea45a07f12d0b3b8d9b3/penaltymodel_cache/penaltymodel/cache/database_manager.py#L402-L421
dwavesystems/penaltymodel
penaltymodel_cache/penaltymodel/cache/database_manager.py
_decode_quadratic_biases
def _decode_quadratic_biases(quadratic_string, edgelist): """Inverse of _serialize_quadratic_biases Args: quadratic_string (str) : base 64 encoded string of little endian 8 byte floats, one for each of the edges. edgelist (list): a list of edges of the form [(node1, node2), ...]. ...
python
def _decode_quadratic_biases(quadratic_string, edgelist): """Inverse of _serialize_quadratic_biases Args: quadratic_string (str) : base 64 encoded string of little endian 8 byte floats, one for each of the edges. edgelist (list): a list of edges of the form [(node1, node2), ...]. ...
Inverse of _serialize_quadratic_biases Args: quadratic_string (str) : base 64 encoded string of little endian 8 byte floats, one for each of the edges. edgelist (list): a list of edges of the form [(node1, node2), ...]. Returns: dict: J. A dict of the form {edge1: bias1, .....
https://github.com/dwavesystems/penaltymodel/blob/b9d343233aea8df0f59cea45a07f12d0b3b8d9b3/penaltymodel_cache/penaltymodel/cache/database_manager.py#L424-L444
dwavesystems/penaltymodel
penaltymodel_cache/penaltymodel/cache/database_manager.py
insert_penalty_model
def insert_penalty_model(cur, penalty_model): """Insert a penalty model into the database. Args: cur (:class:`sqlite3.Cursor`): An sqlite3 cursor. This function is meant to be run within a :obj:`with` statement. penalty_model (:class:`penaltymodel.PenaltyModel`): A penalty ...
python
def insert_penalty_model(cur, penalty_model): """Insert a penalty model into the database. Args: cur (:class:`sqlite3.Cursor`): An sqlite3 cursor. This function is meant to be run within a :obj:`with` statement. penalty_model (:class:`penaltymodel.PenaltyModel`): A penalty ...
Insert a penalty model into the database. Args: cur (:class:`sqlite3.Cursor`): An sqlite3 cursor. This function is meant to be run within a :obj:`with` statement. penalty_model (:class:`penaltymodel.PenaltyModel`): A penalty model to be stored in the database. Examples:...
https://github.com/dwavesystems/penaltymodel/blob/b9d343233aea8df0f59cea45a07f12d0b3b8d9b3/penaltymodel_cache/penaltymodel/cache/database_manager.py#L447-L514
dwavesystems/penaltymodel
penaltymodel_cache/penaltymodel/cache/database_manager.py
iter_penalty_model_from_specification
def iter_penalty_model_from_specification(cur, specification): """Iterate through all penalty models in the cache matching the given specification. Args: cur (:class:`sqlite3.Cursor`): An sqlite3 cursor. This function is meant to be run within a :obj:`with` statement. specificat...
python
def iter_penalty_model_from_specification(cur, specification): """Iterate through all penalty models in the cache matching the given specification. Args: cur (:class:`sqlite3.Cursor`): An sqlite3 cursor. This function is meant to be run within a :obj:`with` statement. specificat...
Iterate through all penalty models in the cache matching the given specification. Args: cur (:class:`sqlite3.Cursor`): An sqlite3 cursor. This function is meant to be run within a :obj:`with` statement. specification (:class:`penaltymodel.Specification`): A specification ...
https://github.com/dwavesystems/penaltymodel/blob/b9d343233aea8df0f59cea45a07f12d0b3b8d9b3/penaltymodel_cache/penaltymodel/cache/database_manager.py#L517-L583
dwavesystems/penaltymodel
penaltymodel_core/penaltymodel/core/classes/penaltymodel.py
PenaltyModel.from_specification
def from_specification(cls, specification, model, classical_gap, ground_energy): """Construct a PenaltyModel from a Specification. Args: specification (:class:`.Specification`): A specification that was used to generate the model. model (:class:`dimod.BinaryQuadr...
python
def from_specification(cls, specification, model, classical_gap, ground_energy): """Construct a PenaltyModel from a Specification. Args: specification (:class:`.Specification`): A specification that was used to generate the model. model (:class:`dimod.BinaryQuadr...
Construct a PenaltyModel from a Specification. Args: specification (:class:`.Specification`): A specification that was used to generate the model. model (:class:`dimod.BinaryQuadraticModel`): A binary quadratic model that has ground states that match the ...
https://github.com/dwavesystems/penaltymodel/blob/b9d343233aea8df0f59cea45a07f12d0b3b8d9b3/penaltymodel_core/penaltymodel/core/classes/penaltymodel.py#L175-L202
dwavesystems/penaltymodel
penaltymodel_core/penaltymodel/core/classes/penaltymodel.py
PenaltyModel.relabel_variables
def relabel_variables(self, mapping, inplace=True): """Relabel the variables and nodes according to the given mapping. Args: mapping (dict[hashable, hashable]): A dict with the current variable labels as keys and new labels as values. A partial mapping is all...
python
def relabel_variables(self, mapping, inplace=True): """Relabel the variables and nodes according to the given mapping. Args: mapping (dict[hashable, hashable]): A dict with the current variable labels as keys and new labels as values. A partial mapping is all...
Relabel the variables and nodes according to the given mapping. Args: mapping (dict[hashable, hashable]): A dict with the current variable labels as keys and new labels as values. A partial mapping is allowed. inplace (bool, optional, default=True): ...
https://github.com/dwavesystems/penaltymodel/blob/b9d343233aea8df0f59cea45a07f12d0b3b8d9b3/penaltymodel_core/penaltymodel/core/classes/penaltymodel.py#L213-L253
dwavesystems/penaltymodel
penaltymodel_cache/penaltymodel/cache/interface.py
get_penalty_model
def get_penalty_model(specification, database=None): """Factory function for penaltymodel_cache. Args: specification (penaltymodel.Specification): The specification for the desired penalty model. database (str, optional): The path to the desired sqlite database file. If ...
python
def get_penalty_model(specification, database=None): """Factory function for penaltymodel_cache. Args: specification (penaltymodel.Specification): The specification for the desired penalty model. database (str, optional): The path to the desired sqlite database file. If ...
Factory function for penaltymodel_cache. Args: specification (penaltymodel.Specification): The specification for the desired penalty model. database (str, optional): The path to the desired sqlite database file. If None, will use the default. Returns: :class:`pe...
https://github.com/dwavesystems/penaltymodel/blob/b9d343233aea8df0f59cea45a07f12d0b3b8d9b3/penaltymodel_cache/penaltymodel/cache/interface.py#L16-L68
dwavesystems/penaltymodel
penaltymodel_cache/penaltymodel/cache/interface.py
cache_penalty_model
def cache_penalty_model(penalty_model, database=None): """Caching function for penaltymodel_cache. Args: penalty_model (:class:`penaltymodel.PenaltyModel`): Penalty model to be cached. database (str, optional): The path to the desired sqlite database file. If None, will ...
python
def cache_penalty_model(penalty_model, database=None): """Caching function for penaltymodel_cache. Args: penalty_model (:class:`penaltymodel.PenaltyModel`): Penalty model to be cached. database (str, optional): The path to the desired sqlite database file. If None, will ...
Caching function for penaltymodel_cache. Args: penalty_model (:class:`penaltymodel.PenaltyModel`): Penalty model to be cached. database (str, optional): The path to the desired sqlite database file. If None, will use the default.
https://github.com/dwavesystems/penaltymodel/blob/b9d343233aea8df0f59cea45a07f12d0b3b8d9b3/penaltymodel_cache/penaltymodel/cache/interface.py#L71-L99
dwavesystems/penaltymodel
penaltymodel_core/penaltymodel/core/interface.py
get_penalty_model
def get_penalty_model(specification): """Retrieve a PenaltyModel from one of the available factories. Args: specification (:class:`.Specification`): The specification for the desired PenaltyModel. Returns: :class:`.PenaltyModel`/None: A PenaltyModel as returned by the h...
python
def get_penalty_model(specification): """Retrieve a PenaltyModel from one of the available factories. Args: specification (:class:`.Specification`): The specification for the desired PenaltyModel. Returns: :class:`.PenaltyModel`/None: A PenaltyModel as returned by the h...
Retrieve a PenaltyModel from one of the available factories. Args: specification (:class:`.Specification`): The specification for the desired PenaltyModel. Returns: :class:`.PenaltyModel`/None: A PenaltyModel as returned by the highest priority factory, or None if no factor...
https://github.com/dwavesystems/penaltymodel/blob/b9d343233aea8df0f59cea45a07f12d0b3b8d9b3/penaltymodel_core/penaltymodel/core/interface.py#L37-L74
dwavesystems/penaltymodel
penaltymodel_core/penaltymodel/core/interface.py
iter_factories
def iter_factories(): """Iterate through all factories identified by the factory entrypoint. Yields: function: A function that accepts a :class:`.Specification` and returns a :class:`.PenaltyModel`. """ # retrieve all of the factories with factories = (entry.load() for entry in ite...
python
def iter_factories(): """Iterate through all factories identified by the factory entrypoint. Yields: function: A function that accepts a :class:`.Specification` and returns a :class:`.PenaltyModel`. """ # retrieve all of the factories with factories = (entry.load() for entry in ite...
Iterate through all factories identified by the factory entrypoint. Yields: function: A function that accepts a :class:`.Specification` and returns a :class:`.PenaltyModel`.
https://github.com/dwavesystems/penaltymodel/blob/b9d343233aea8df0f59cea45a07f12d0b3b8d9b3/penaltymodel_core/penaltymodel/core/interface.py#L100-L114
dwavesystems/penaltymodel
penaltymodel_mip/penaltymodel/mip/generation.py
generate_bqm
def generate_bqm(graph, table, decision, linear_energy_ranges=None, quadratic_energy_ranges=None, min_classical_gap=2, precision=7, max_decision=8, max_variables=10, return_auxiliary=False): """Get a binary quadratic model with specific ground states. Args: ...
python
def generate_bqm(graph, table, decision, linear_energy_ranges=None, quadratic_energy_ranges=None, min_classical_gap=2, precision=7, max_decision=8, max_variables=10, return_auxiliary=False): """Get a binary quadratic model with specific ground states. Args: ...
Get a binary quadratic model with specific ground states. Args: graph (:obj:`~networkx.Graph`): Defines the structure of the generated binary quadratic model. table (iterable): Iterable of valid configurations (of spin-values). Each configuration is a tuple of v...
https://github.com/dwavesystems/penaltymodel/blob/b9d343233aea8df0f59cea45a07f12d0b3b8d9b3/penaltymodel_mip/penaltymodel/mip/generation.py#L14-L124
dwavesystems/penaltymodel
penaltymodel_lp/penaltymodel/lp/interface.py
get_penalty_model
def get_penalty_model(specification): """Factory function for penaltymodel-lp. Args: specification (penaltymodel.Specification): The specification for the desired penalty model. Returns: :class:`penaltymodel.PenaltyModel`: Penalty model with the given specification. Raises...
python
def get_penalty_model(specification): """Factory function for penaltymodel-lp. Args: specification (penaltymodel.Specification): The specification for the desired penalty model. Returns: :class:`penaltymodel.PenaltyModel`: Penalty model with the given specification. Raises...
Factory function for penaltymodel-lp. Args: specification (penaltymodel.Specification): The specification for the desired penalty model. Returns: :class:`penaltymodel.PenaltyModel`: Penalty model with the given specification. Raises: :class:`penaltymodel.ImpossiblePena...
https://github.com/dwavesystems/penaltymodel/blob/b9d343233aea8df0f59cea45a07f12d0b3b8d9b3/penaltymodel_lp/penaltymodel/lp/interface.py#L13-L49
dwavesystems/penaltymodel
penaltymodel_core/penaltymodel/core/classes/specification.py
Specification._check_ising_linear_ranges
def _check_ising_linear_ranges(linear_ranges, graph): """check correctness/populate defaults for ising_linear_ranges.""" if linear_ranges is None: linear_ranges = {} for v in graph: if v in linear_ranges: # check linear_ranges[v] = Specifi...
python
def _check_ising_linear_ranges(linear_ranges, graph): """check correctness/populate defaults for ising_linear_ranges.""" if linear_ranges is None: linear_ranges = {} for v in graph: if v in linear_ranges: # check linear_ranges[v] = Specifi...
check correctness/populate defaults for ising_linear_ranges.
https://github.com/dwavesystems/penaltymodel/blob/b9d343233aea8df0f59cea45a07f12d0b3b8d9b3/penaltymodel_core/penaltymodel/core/classes/specification.py#L194-L207
dwavesystems/penaltymodel
penaltymodel_core/penaltymodel/core/classes/specification.py
Specification._check_ising_quadratic_ranges
def _check_ising_quadratic_ranges(quad_ranges, graph): """check correctness/populate defaults for ising_quadratic_ranges.""" if quad_ranges is None: quad_ranges = {} # first just populate the top level so we can rely on the structure for u in graph: if u not in q...
python
def _check_ising_quadratic_ranges(quad_ranges, graph): """check correctness/populate defaults for ising_quadratic_ranges.""" if quad_ranges is None: quad_ranges = {} # first just populate the top level so we can rely on the structure for u in graph: if u not in q...
check correctness/populate defaults for ising_quadratic_ranges.
https://github.com/dwavesystems/penaltymodel/blob/b9d343233aea8df0f59cea45a07f12d0b3b8d9b3/penaltymodel_core/penaltymodel/core/classes/specification.py#L210-L237
dwavesystems/penaltymodel
penaltymodel_core/penaltymodel/core/classes/specification.py
Specification._check_range
def _check_range(range_): """Check that a range is in the format we expect [min, max] and return""" try: if not isinstance(range_, list): range_ = list(range_) min_, max_ = range_ except (ValueError, TypeError): raise TypeError("each range in i...
python
def _check_range(range_): """Check that a range is in the format we expect [min, max] and return""" try: if not isinstance(range_, list): range_ = list(range_) min_, max_ = range_ except (ValueError, TypeError): raise TypeError("each range in i...
Check that a range is in the format we expect [min, max] and return
https://github.com/dwavesystems/penaltymodel/blob/b9d343233aea8df0f59cea45a07f12d0b3b8d9b3/penaltymodel_core/penaltymodel/core/classes/specification.py#L240-L251
dwavesystems/penaltymodel
penaltymodel_core/penaltymodel/core/classes/specification.py
Specification.relabel_variables
def relabel_variables(self, mapping, inplace=True): """Relabel the variables and nodes according to the given mapping. Args: mapping (dict): a dict mapping the current variable/node labels to new ones. inplace (bool, optional, default=True): If Tr...
python
def relabel_variables(self, mapping, inplace=True): """Relabel the variables and nodes according to the given mapping. Args: mapping (dict): a dict mapping the current variable/node labels to new ones. inplace (bool, optional, default=True): If Tr...
Relabel the variables and nodes according to the given mapping. Args: mapping (dict): a dict mapping the current variable/node labels to new ones. inplace (bool, optional, default=True): If True, the specification is updated in-place; otherwise, a new spe...
https://github.com/dwavesystems/penaltymodel/blob/b9d343233aea8df0f59cea45a07f12d0b3b8d9b3/penaltymodel_core/penaltymodel/core/classes/specification.py#L270-L373
dwavesystems/penaltymodel
penaltymodel_lp/penaltymodel/lp/generation.py
get_item
def get_item(dictionary, tuple_key, default_value): """Grab values from a dictionary using an unordered tuple as a key. Dictionary should not contain None, 0, or False as dictionary values. Args: dictionary: Dictionary that uses two-element tuple as keys tuple_key: Unordered tuple of two e...
python
def get_item(dictionary, tuple_key, default_value): """Grab values from a dictionary using an unordered tuple as a key. Dictionary should not contain None, 0, or False as dictionary values. Args: dictionary: Dictionary that uses two-element tuple as keys tuple_key: Unordered tuple of two e...
Grab values from a dictionary using an unordered tuple as a key. Dictionary should not contain None, 0, or False as dictionary values. Args: dictionary: Dictionary that uses two-element tuple as keys tuple_key: Unordered tuple of two elements default_value: Value that is returned when ...
https://github.com/dwavesystems/penaltymodel/blob/b9d343233aea8df0f59cea45a07f12d0b3b8d9b3/penaltymodel_lp/penaltymodel/lp/generation.py#L14-L31
dwavesystems/penaltymodel
penaltymodel_lp/penaltymodel/lp/generation.py
_get_lp_matrix
def _get_lp_matrix(spin_states, nodes, edges, offset_weight, gap_weight): """Creates an linear programming matrix based on the spin states, graph, and scalars provided. LP matrix: [spin_states, corresponding states of edges, offset_weight, gap_weight] Args: spin_states: Numpy array of spin ...
python
def _get_lp_matrix(spin_states, nodes, edges, offset_weight, gap_weight): """Creates an linear programming matrix based on the spin states, graph, and scalars provided. LP matrix: [spin_states, corresponding states of edges, offset_weight, gap_weight] Args: spin_states: Numpy array of spin ...
Creates an linear programming matrix based on the spin states, graph, and scalars provided. LP matrix: [spin_states, corresponding states of edges, offset_weight, gap_weight] Args: spin_states: Numpy array of spin states nodes: Iterable edges: Iterable of tuples offset_w...
https://github.com/dwavesystems/penaltymodel/blob/b9d343233aea8df0f59cea45a07f12d0b3b8d9b3/penaltymodel_lp/penaltymodel/lp/generation.py#L34-L70
dwavesystems/penaltymodel
penaltymodel_lp/penaltymodel/lp/generation.py
generate_bqm
def generate_bqm(graph, table, decision_variables, linear_energy_ranges=None, quadratic_energy_ranges=None, min_classical_gap=2): """ Args: graph: A networkx.Graph table: An iterable of valid spin configurations. Each configuration is a tuple of variable assignments ...
python
def generate_bqm(graph, table, decision_variables, linear_energy_ranges=None, quadratic_energy_ranges=None, min_classical_gap=2): """ Args: graph: A networkx.Graph table: An iterable of valid spin configurations. Each configuration is a tuple of variable assignments ...
Args: graph: A networkx.Graph table: An iterable of valid spin configurations. Each configuration is a tuple of variable assignments ordered by `decision`. decision_variables: An ordered iterable of the variables in the binary quadratic model. linear_energy_ranges: Dictionary...
https://github.com/dwavesystems/penaltymodel/blob/b9d343233aea8df0f59cea45a07f12d0b3b8d9b3/penaltymodel_lp/penaltymodel/lp/generation.py#L75-L172
dwavesystems/penaltymodel
penaltymodel_maxgap/penaltymodel/maxgap/generation.py
generate
def generate(graph, feasible_configurations, decision_variables, linear_energy_ranges, quadratic_energy_ranges, min_classical_gap, smt_solver_name=None): """Generates the Ising model that induces the given feasible configurations. The code is based on the papers [#do]_ and [#mc]_. ...
python
def generate(graph, feasible_configurations, decision_variables, linear_energy_ranges, quadratic_energy_ranges, min_classical_gap, smt_solver_name=None): """Generates the Ising model that induces the given feasible configurations. The code is based on the papers [#do]_ and [#mc]_. ...
Generates the Ising model that induces the given feasible configurations. The code is based on the papers [#do]_ and [#mc]_. Args: graph (nx.Graph): The target graph on which the Ising model is to be built. feasible_configurations (dict): The set of feasible configurations of the de...
https://github.com/dwavesystems/penaltymodel/blob/b9d343233aea8df0f59cea45a07f12d0b3b8d9b3/penaltymodel_maxgap/penaltymodel/maxgap/generation.py#L30-L166
dwavesystems/penaltymodel
penaltymodel_maxgap/penaltymodel/maxgap/theta.py
limitReal
def limitReal(x, max_denominator=1000000): """Creates an pysmt Real constant from x. Args: x (number): A number to be cast to a pysmt constant. max_denominator (int, optional): The maximum size of the denominator. Default 1000000. Returns: A Real constant with the given...
python
def limitReal(x, max_denominator=1000000): """Creates an pysmt Real constant from x. Args: x (number): A number to be cast to a pysmt constant. max_denominator (int, optional): The maximum size of the denominator. Default 1000000. Returns: A Real constant with the given...
Creates an pysmt Real constant from x. Args: x (number): A number to be cast to a pysmt constant. max_denominator (int, optional): The maximum size of the denominator. Default 1000000. Returns: A Real constant with the given value and the denominator limited.
https://github.com/dwavesystems/penaltymodel/blob/b9d343233aea8df0f59cea45a07f12d0b3b8d9b3/penaltymodel_maxgap/penaltymodel/maxgap/theta.py#L26-L39
dwavesystems/penaltymodel
penaltymodel_maxgap/penaltymodel/maxgap/theta.py
Theta.from_graph
def from_graph(cls, graph, linear_energy_ranges, quadratic_energy_ranges): """Create Theta from a graph and energy ranges. Args: graph (:obj:`networkx.Graph`): Provides the structure for Theta. linear_energy_ranges (dict): A dict of the form {v: ...
python
def from_graph(cls, graph, linear_energy_ranges, quadratic_energy_ranges): """Create Theta from a graph and energy ranges. Args: graph (:obj:`networkx.Graph`): Provides the structure for Theta. linear_energy_ranges (dict): A dict of the form {v: ...
Create Theta from a graph and energy ranges. Args: graph (:obj:`networkx.Graph`): Provides the structure for Theta. linear_energy_ranges (dict): A dict of the form {v: (min, max), ...} where min and max are the range of values allowed to ...
https://github.com/dwavesystems/penaltymodel/blob/b9d343233aea8df0f59cea45a07f12d0b3b8d9b3/penaltymodel_maxgap/penaltymodel/maxgap/theta.py#L55-L112
dwavesystems/penaltymodel
penaltymodel_maxgap/penaltymodel/maxgap/theta.py
Theta.to_bqm
def to_bqm(self, model): """Given a pysmt model, return a bqm. Adds the values of the biases as determined by the SMT solver to a bqm. Args: model: A pysmt model. Returns: :obj:`dimod.BinaryQuadraticModel` """ linear = ((v, float(model.get_py_v...
python
def to_bqm(self, model): """Given a pysmt model, return a bqm. Adds the values of the biases as determined by the SMT solver to a bqm. Args: model: A pysmt model. Returns: :obj:`dimod.BinaryQuadraticModel` """ linear = ((v, float(model.get_py_v...
Given a pysmt model, return a bqm. Adds the values of the biases as determined by the SMT solver to a bqm. Args: model: A pysmt model. Returns: :obj:`dimod.BinaryQuadraticModel`
https://github.com/dwavesystems/penaltymodel/blob/b9d343233aea8df0f59cea45a07f12d0b3b8d9b3/penaltymodel_maxgap/penaltymodel/maxgap/theta.py#L114-L132
dwavesystems/penaltymodel
penaltymodel_maxgap/penaltymodel/maxgap/smt.py
SpinTimes
def SpinTimes(spin, bias): """Define our own multiplication for bias times spins. This allows for cleaner log code as well as value checking. Args: spin (int): -1 or 1 bias (:class:`pysmt.shortcuts.Symbol`): The bias Returns: spins * bias """ if not isinstance(spin, in...
python
def SpinTimes(spin, bias): """Define our own multiplication for bias times spins. This allows for cleaner log code as well as value checking. Args: spin (int): -1 or 1 bias (:class:`pysmt.shortcuts.Symbol`): The bias Returns: spins * bias """ if not isinstance(spin, in...
Define our own multiplication for bias times spins. This allows for cleaner log code as well as value checking. Args: spin (int): -1 or 1 bias (:class:`pysmt.shortcuts.Symbol`): The bias Returns: spins * bias
https://github.com/dwavesystems/penaltymodel/blob/b9d343233aea8df0f59cea45a07f12d0b3b8d9b3/penaltymodel_maxgap/penaltymodel/maxgap/smt.py#L33-L53
dwavesystems/penaltymodel
penaltymodel_maxgap/penaltymodel/maxgap/smt.py
_elimination_trees
def _elimination_trees(theta, decision_variables): """From Theta and the decision variables, determine the elimination order and the induced trees. """ # auxiliary variables are any variables that are not decision auxiliary_variables = set(n for n in theta.linear if n not in decision_variables) ...
python
def _elimination_trees(theta, decision_variables): """From Theta and the decision variables, determine the elimination order and the induced trees. """ # auxiliary variables are any variables that are not decision auxiliary_variables = set(n for n in theta.linear if n not in decision_variables) ...
From Theta and the decision variables, determine the elimination order and the induced trees.
https://github.com/dwavesystems/penaltymodel/blob/b9d343233aea8df0f59cea45a07f12d0b3b8d9b3/penaltymodel_maxgap/penaltymodel/maxgap/smt.py#L56-L98
dwavesystems/penaltymodel
penaltymodel_maxgap/penaltymodel/maxgap/smt.py
Table.energy_upperbound
def energy_upperbound(self, spins): """A formula for an upper bound on the energy of Theta with spins fixed. Args: spins (dict): Spin values for a subset of the variables in Theta. Returns: Formula that upper bounds the energy with spins fixed. """ subt...
python
def energy_upperbound(self, spins): """A formula for an upper bound on the energy of Theta with spins fixed. Args: spins (dict): Spin values for a subset of the variables in Theta. Returns: Formula that upper bounds the energy with spins fixed. """ subt...
A formula for an upper bound on the energy of Theta with spins fixed. Args: spins (dict): Spin values for a subset of the variables in Theta. Returns: Formula that upper bounds the energy with spins fixed.
https://github.com/dwavesystems/penaltymodel/blob/b9d343233aea8df0f59cea45a07f12d0b3b8d9b3/penaltymodel_maxgap/penaltymodel/maxgap/smt.py#L133-L157
dwavesystems/penaltymodel
penaltymodel_maxgap/penaltymodel/maxgap/smt.py
Table.energy
def energy(self, spins, break_aux_symmetry=True): """A formula for the exact energy of Theta with spins fixed. Args: spins (dict): Spin values for a subset of the variables in Theta. break_aux_symmetry (bool, optional): Default True. If True, break the aux variab...
python
def energy(self, spins, break_aux_symmetry=True): """A formula for the exact energy of Theta with spins fixed. Args: spins (dict): Spin values for a subset of the variables in Theta. break_aux_symmetry (bool, optional): Default True. If True, break the aux variab...
A formula for the exact energy of Theta with spins fixed. Args: spins (dict): Spin values for a subset of the variables in Theta. break_aux_symmetry (bool, optional): Default True. If True, break the aux variable symmetry by setting all aux variable to 1 ...
https://github.com/dwavesystems/penaltymodel/blob/b9d343233aea8df0f59cea45a07f12d0b3b8d9b3/penaltymodel_maxgap/penaltymodel/maxgap/smt.py#L159-L194
dwavesystems/penaltymodel
penaltymodel_maxgap/penaltymodel/maxgap/smt.py
Table.message
def message(self, tree, spins, subtheta, auxvars): """Determine the energy of the elimination tree. Args: tree (dict): The current elimination tree spins (dict): The current fixed spins subtheta (dict): Theta with spins fixed. auxvars (dict): The auxiliar...
python
def message(self, tree, spins, subtheta, auxvars): """Determine the energy of the elimination tree. Args: tree (dict): The current elimination tree spins (dict): The current fixed spins subtheta (dict): Theta with spins fixed. auxvars (dict): The auxiliar...
Determine the energy of the elimination tree. Args: tree (dict): The current elimination tree spins (dict): The current fixed spins subtheta (dict): Theta with spins fixed. auxvars (dict): The auxiliary variables for the given spins. Returns: ...
https://github.com/dwavesystems/penaltymodel/blob/b9d343233aea8df0f59cea45a07f12d0b3b8d9b3/penaltymodel_maxgap/penaltymodel/maxgap/smt.py#L196-L253
dwavesystems/penaltymodel
penaltymodel_maxgap/penaltymodel/maxgap/smt.py
Table.message_upperbound
def message_upperbound(self, tree, spins, subtheta): """Determine an upper bound on the energy of the elimination tree. Args: tree (dict): The current elimination tree spins (dict): The current fixed spins subtheta (dict): Theta with spins fixed. Returns: ...
python
def message_upperbound(self, tree, spins, subtheta): """Determine an upper bound on the energy of the elimination tree. Args: tree (dict): The current elimination tree spins (dict): The current fixed spins subtheta (dict): Theta with spins fixed. Returns: ...
Determine an upper bound on the energy of the elimination tree. Args: tree (dict): The current elimination tree spins (dict): The current fixed spins subtheta (dict): Theta with spins fixed. Returns: The formula for the energy of the tree.
https://github.com/dwavesystems/penaltymodel/blob/b9d343233aea8df0f59cea45a07f12d0b3b8d9b3/penaltymodel_maxgap/penaltymodel/maxgap/smt.py#L255-L303
dwavesystems/penaltymodel
penaltymodel_maxgap/penaltymodel/maxgap/smt.py
Table.set_energy
def set_energy(self, spins, target_energy): """Set the energy of Theta with spins fixed to target_energy. Args: spins (dict): Spin values for a subset of the variables in Theta. target_energy (float): The desired energy for Theta with spins fixed. Notes: Add...
python
def set_energy(self, spins, target_energy): """Set the energy of Theta with spins fixed to target_energy. Args: spins (dict): Spin values for a subset of the variables in Theta. target_energy (float): The desired energy for Theta with spins fixed. Notes: Add...
Set the energy of Theta with spins fixed to target_energy. Args: spins (dict): Spin values for a subset of the variables in Theta. target_energy (float): The desired energy for Theta with spins fixed. Notes: Add equality constraint to assertions.
https://github.com/dwavesystems/penaltymodel/blob/b9d343233aea8df0f59cea45a07f12d0b3b8d9b3/penaltymodel_maxgap/penaltymodel/maxgap/smt.py#L305-L317
dwavesystems/penaltymodel
penaltymodel_maxgap/penaltymodel/maxgap/smt.py
Table.set_energy_upperbound
def set_energy_upperbound(self, spins, offset=0): """Upper bound the energy of Theta with spins fixed to be greater than (gap + offset). Args: spins (dict): Spin values for a subset of the variables in Theta. offset (float): A value that is added to the upper bound. Default valu...
python
def set_energy_upperbound(self, spins, offset=0): """Upper bound the energy of Theta with spins fixed to be greater than (gap + offset). Args: spins (dict): Spin values for a subset of the variables in Theta. offset (float): A value that is added to the upper bound. Default valu...
Upper bound the energy of Theta with spins fixed to be greater than (gap + offset). Args: spins (dict): Spin values for a subset of the variables in Theta. offset (float): A value that is added to the upper bound. Default value is 0. Notes: Add equality constraint t...
https://github.com/dwavesystems/penaltymodel/blob/b9d343233aea8df0f59cea45a07f12d0b3b8d9b3/penaltymodel_maxgap/penaltymodel/maxgap/smt.py#L319-L331
dls-controls/pymalcolm
malcolm/modules/pandablocks/controllers/pandablocksmanagercontroller.py
PandABlocksManagerController._poll_loop
def _poll_loop(self): """At self.poll_period poll for changes""" next_poll = time.time() while True: next_poll += self._poll_period timeout = next_poll - time.time() if timeout < 0: timeout = 0 try: return self._stop...
python
def _poll_loop(self): """At self.poll_period poll for changes""" next_poll = time.time() while True: next_poll += self._poll_period timeout = next_poll - time.time() if timeout < 0: timeout = 0 try: return self._stop...
At self.poll_period poll for changes
https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/modules/pandablocks/controllers/pandablocksmanagercontroller.py#L101-L118
dls-controls/pymalcolm
malcolm/core/serializable.py
camel_to_title
def camel_to_title(name): """Takes a camelCaseFieldName and returns an Title Case Field Name Args: name (str): E.g. camelCaseFieldName Returns: str: Title Case converted name. E.g. Camel Case Field Name """ split = re.findall(r"[A-Z]?[a-z0-9]+|[A-Z]+(?=[A-Z]|$)", name) ret = " ...
python
def camel_to_title(name): """Takes a camelCaseFieldName and returns an Title Case Field Name Args: name (str): E.g. camelCaseFieldName Returns: str: Title Case converted name. E.g. Camel Case Field Name """ split = re.findall(r"[A-Z]?[a-z0-9]+|[A-Z]+(?=[A-Z]|$)", name) ret = " ...
Takes a camelCaseFieldName and returns an Title Case Field Name Args: name (str): E.g. camelCaseFieldName Returns: str: Title Case converted name. E.g. Camel Case Field Name
https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/core/serializable.py#L55-L67
dls-controls/pymalcolm
malcolm/core/serializable.py
snake_to_camel
def snake_to_camel(name): """Takes a snake_field_name and returns a camelCaseFieldName Args: name (str): E.g. snake_field_name or SNAKE_FIELD_NAME Returns: str: camelCase converted name. E.g. capsFieldName """ ret = "".join(x.title() for x in name.split("_")) ret = ret[0].lower...
python
def snake_to_camel(name): """Takes a snake_field_name and returns a camelCaseFieldName Args: name (str): E.g. snake_field_name or SNAKE_FIELD_NAME Returns: str: camelCase converted name. E.g. capsFieldName """ ret = "".join(x.title() for x in name.split("_")) ret = ret[0].lower...
Takes a snake_field_name and returns a camelCaseFieldName Args: name (str): E.g. snake_field_name or SNAKE_FIELD_NAME Returns: str: camelCase converted name. E.g. capsFieldName
https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/core/serializable.py#L70-L81
dls-controls/pymalcolm
malcolm/core/serializable.py
Serializable.to_dict
def to_dict(self): # type: () -> OrderedDict """Create a dictionary representation of object attributes Returns: OrderedDict serialised version of self """ d = OrderedDict() if self.typeid: d["typeid"] = self.typeid for k in self.call_ty...
python
def to_dict(self): # type: () -> OrderedDict """Create a dictionary representation of object attributes Returns: OrderedDict serialised version of self """ d = OrderedDict() if self.typeid: d["typeid"] = self.typeid for k in self.call_ty...
Create a dictionary representation of object attributes Returns: OrderedDict serialised version of self
https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/core/serializable.py#L143-L159
dls-controls/pymalcolm
malcolm/core/serializable.py
Serializable.from_dict
def from_dict(cls, d, ignore=()): """Create an instance from a serialized version of cls Args: d(dict): Endpoints of cls to set ignore(tuple): Keys to ignore Returns: Instance of this class """ filtered = {} for k, v in d.items(): ...
python
def from_dict(cls, d, ignore=()): """Create an instance from a serialized version of cls Args: d(dict): Endpoints of cls to set ignore(tuple): Keys to ignore Returns: Instance of this class """ filtered = {} for k, v in d.items(): ...
Create an instance from a serialized version of cls Args: d(dict): Endpoints of cls to set ignore(tuple): Keys to ignore Returns: Instance of this class
https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/core/serializable.py#L162-L184
dls-controls/pymalcolm
malcolm/core/serializable.py
Serializable.register_subclass
def register_subclass(cls, typeid): """Register a subclass so from_dict() works Args: typeid (str): Type identifier for subclass """ def decorator(subclass): cls._subcls_lookup[typeid] = subclass subclass.typeid = typeid return subclass ...
python
def register_subclass(cls, typeid): """Register a subclass so from_dict() works Args: typeid (str): Type identifier for subclass """ def decorator(subclass): cls._subcls_lookup[typeid] = subclass subclass.typeid = typeid return subclass ...
Register a subclass so from_dict() works Args: typeid (str): Type identifier for subclass
https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/core/serializable.py#L187-L197
dls-controls/pymalcolm
malcolm/core/serializable.py
Serializable.lookup_subclass
def lookup_subclass(cls, d): """Look up a class based on a serialized dictionary containing a typeid Args: d (dict): Dictionary with key "typeid" Returns: Serializable subclass """ try: typeid = d["typeid"] except KeyError: ...
python
def lookup_subclass(cls, d): """Look up a class based on a serialized dictionary containing a typeid Args: d (dict): Dictionary with key "typeid" Returns: Serializable subclass """ try: typeid = d["typeid"] except KeyError: ...
Look up a class based on a serialized dictionary containing a typeid Args: d (dict): Dictionary with key "typeid" Returns: Serializable subclass
https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/core/serializable.py#L200-L218
dls-controls/pymalcolm
malcolm/core/process.py
Process.start
def start(self, timeout=None): """Start the process going Args: timeout (float): Maximum amount of time to wait for each spawned process. None means forever """ assert self.state == STOPPED, "Process already started" self.state = STARTING shou...
python
def start(self, timeout=None): """Start the process going Args: timeout (float): Maximum amount of time to wait for each spawned process. None means forever """ assert self.state == STOPPED, "Process already started" self.state = STARTING shou...
Start the process going Args: timeout (float): Maximum amount of time to wait for each spawned process. None means forever
https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/core/process.py#L78-L91
dls-controls/pymalcolm
malcolm/core/process.py
Process.stop
def stop(self, timeout=None): """Stop the process and wait for it to finish Args: timeout (float): Maximum amount of time to wait for each spawned object. None means forever """ assert self.state == STARTED, "Process not started" self.state = STOPPING...
python
def stop(self, timeout=None): """Stop the process and wait for it to finish Args: timeout (float): Maximum amount of time to wait for each spawned object. None means forever """ assert self.state == STARTED, "Process not started" self.state = STOPPING...
Stop the process and wait for it to finish Args: timeout (float): Maximum amount of time to wait for each spawned object. None means forever
https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/core/process.py#L130-L150
dls-controls/pymalcolm
malcolm/core/process.py
Process.spawn
def spawn(self, function, *args, **kwargs): # type: (Callable[..., Any], *Any, **Any) -> Spawned """Runs the function in a worker thread, returning a Result object Args: function: Function to run args: Positional arguments to run the function with kwargs: Key...
python
def spawn(self, function, *args, **kwargs): # type: (Callable[..., Any], *Any, **Any) -> Spawned """Runs the function in a worker thread, returning a Result object Args: function: Function to run args: Positional arguments to run the function with kwargs: Key...
Runs the function in a worker thread, returning a Result object Args: function: Function to run args: Positional arguments to run the function with kwargs: Keyword arguments to run the function with Returns: Spawned: Something you can call wait(timeout) ...
https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/core/process.py#L152-L172
dls-controls/pymalcolm
malcolm/core/process.py
Process.add_controller
def add_controller(self, controller, timeout=None): # type: (Controller, float) -> None """Add a controller to be hosted by this process Args: controller (Controller): Its controller timeout (float): Maximum amount of time to wait for each spawned object....
python
def add_controller(self, controller, timeout=None): # type: (Controller, float) -> None """Add a controller to be hosted by this process Args: controller (Controller): Its controller timeout (float): Maximum amount of time to wait for each spawned object....
Add a controller to be hosted by this process Args: controller (Controller): Its controller timeout (float): Maximum amount of time to wait for each spawned object. None means forever
https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/core/process.py#L179-L195
dls-controls/pymalcolm
malcolm/core/process.py
Process.block_view
def block_view(self, mri): # type: (str) -> Block """Get a Block view from a Controller with given mri""" controller = self.get_controller(mri) block = controller.block_view() return block
python
def block_view(self, mri): # type: (str) -> Block """Get a Block view from a Controller with given mri""" controller = self.get_controller(mri) block = controller.block_view() return block
Get a Block view from a Controller with given mri
https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/core/process.py#L210-L215
dls-controls/pymalcolm
malcolm/modules/builtin/controllers/basiccontroller.py
BasicController.update_title
def update_title(self, _, info): # type: (object, TitleInfo) -> None """Set the label of the Block Meta object""" with self._lock: self._block.meta.set_label(info.title)
python
def update_title(self, _, info): # type: (object, TitleInfo) -> None """Set the label of the Block Meta object""" with self._lock: self._block.meta.set_label(info.title)
Set the label of the Block Meta object
https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/modules/builtin/controllers/basiccontroller.py#L18-L22
dls-controls/pymalcolm
malcolm/modules/builtin/controllers/basiccontroller.py
BasicController.update_health
def update_health(self, reporter, info): # type: (object, HealthInfo) -> None """Set the health attribute. Called from part""" with self.changes_squashed: alarm = info.alarm if alarm.is_ok(): self._faults.pop(reporter, None) else: ...
python
def update_health(self, reporter, info): # type: (object, HealthInfo) -> None """Set the health attribute. Called from part""" with self.changes_squashed: alarm = info.alarm if alarm.is_ok(): self._faults.pop(reporter, None) else: ...
Set the health attribute. Called from part
https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/modules/builtin/controllers/basiccontroller.py#L24-L42
dls-controls/pymalcolm
malcolm/modules/pandablocks/parts/pandablocksmaker.py
PandABlocksMaker.make_parts_for
def make_parts_for(self, field_name, field_data): """Create the relevant parts for this field Args: field_name (str): Short field name, e.g. VAL field_data (FieldData): Field data object """ typ = field_data.field_type subtyp = field_data.field_subtype ...
python
def make_parts_for(self, field_name, field_data): """Create the relevant parts for this field Args: field_name (str): Short field name, e.g. VAL field_data (FieldData): Field data object """ typ = field_data.field_type subtyp = field_data.field_subtype ...
Create the relevant parts for this field Args: field_name (str): Short field name, e.g. VAL field_data (FieldData): Field data object
https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/modules/pandablocks/parts/pandablocksmaker.py#L49-L86
dls-controls/pymalcolm
malcolm/core/context.py
Context.block_view
def block_view(self, mri): # type: (str) -> Block """Get a view of a block Args: mri: The mri of the controller hosting the block Returns: Block: The block we control """ controller = self.get_controller(mri) block = controller.block_view...
python
def block_view(self, mri): # type: (str) -> Block """Get a view of a block Args: mri: The mri of the controller hosting the block Returns: Block: The block we control """ controller = self.get_controller(mri) block = controller.block_view...
Get a view of a block Args: mri: The mri of the controller hosting the block Returns: Block: The block we control
https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/core/context.py#L97-L109
dls-controls/pymalcolm
malcolm/core/context.py
Context.set_notify_dispatch_request
def set_notify_dispatch_request(self, notify_dispatch_request, *args): """Set function to call just before requests are dispatched Args: notify_dispatch_request (callable): function will be called with request as single arg just before request is dispatched """ ...
python
def set_notify_dispatch_request(self, notify_dispatch_request, *args): """Set function to call just before requests are dispatched Args: notify_dispatch_request (callable): function will be called with request as single arg just before request is dispatched """ ...
Set function to call just before requests are dispatched Args: notify_dispatch_request (callable): function will be called with request as single arg just before request is dispatched
https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/core/context.py#L120-L128
dls-controls/pymalcolm
malcolm/core/context.py
Context.ignore_stops_before_now
def ignore_stops_before_now(self): """Ignore any stops received before this point""" self._sentinel_stop = object() self._q.put(self._sentinel_stop)
python
def ignore_stops_before_now(self): """Ignore any stops received before this point""" self._sentinel_stop = object() self._q.put(self._sentinel_stop)
Ignore any stops received before this point
https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/core/context.py#L145-L148
dls-controls/pymalcolm
malcolm/core/context.py
Context.put
def put(self, path, value, timeout=None, event_timeout=None): """"Puts a value to a path and returns when it completes Args: path (list): The path to put to value (object): The value to set timeout (float): time in seconds to wait for responses, wait forever ...
python
def put(self, path, value, timeout=None, event_timeout=None): """"Puts a value to a path and returns when it completes Args: path (list): The path to put to value (object): The value to set timeout (float): time in seconds to wait for responses, wait forever ...
Puts a value to a path and returns when it completes Args: path (list): The path to put to value (object): The value to set timeout (float): time in seconds to wait for responses, wait forever if None event_timeout: maximum time in seconds to wait...
https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/core/context.py#L154-L171
dls-controls/pymalcolm
malcolm/core/context.py
Context.put_async
def put_async(self, path, value): """"Puts a value to a path and returns immediately Args: path (list): The path to put to value (object): The value to set Returns: Future: A single Future which will resolve to the result """ request = Put(s...
python
def put_async(self, path, value): """"Puts a value to a path and returns immediately Args: path (list): The path to put to value (object): The value to set Returns: Future: A single Future which will resolve to the result """ request = Put(s...
Puts a value to a path and returns immediately Args: path (list): The path to put to value (object): The value to set Returns: Future: A single Future which will resolve to the result
https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/core/context.py#L173-L186
dls-controls/pymalcolm
malcolm/core/context.py
Context.post
def post(self, path, params=None, timeout=None, event_timeout=None): """Synchronously calls a method Args: path (list): The path to post to params (dict): parameters for the call timeout (float): time in seconds to wait for responses, wait forever if ...
python
def post(self, path, params=None, timeout=None, event_timeout=None): """Synchronously calls a method Args: path (list): The path to post to params (dict): parameters for the call timeout (float): time in seconds to wait for responses, wait forever if ...
Synchronously calls a method Args: path (list): The path to post to params (dict): parameters for the call timeout (float): time in seconds to wait for responses, wait forever if None event_timeout: maximum time in seconds to wait between each res...
https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/core/context.py#L188-L205
dls-controls/pymalcolm
malcolm/core/context.py
Context.post_async
def post_async(self, path, params=None): """Asynchronously calls a function on a child block Args: path (list): The path to post to params (dict): parameters for the call Returns: Future: as single Future that will resolve to the result """ ...
python
def post_async(self, path, params=None): """Asynchronously calls a function on a child block Args: path (list): The path to post to params (dict): parameters for the call Returns: Future: as single Future that will resolve to the result """ ...
Asynchronously calls a function on a child block Args: path (list): The path to post to params (dict): parameters for the call Returns: Future: as single Future that will resolve to the result
https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/core/context.py#L207-L220
dls-controls/pymalcolm
malcolm/core/context.py
Context.subscribe
def subscribe(self, path, callback, *args): """Subscribe to changes in a given attribute and call ``callback(future, value, *args)`` when it changes Returns: Future: A single Future which will resolve to the result """ request = Subscribe(self._get_next_id(), path, d...
python
def subscribe(self, path, callback, *args): """Subscribe to changes in a given attribute and call ``callback(future, value, *args)`` when it changes Returns: Future: A single Future which will resolve to the result """ request = Subscribe(self._get_next_id(), path, d...
Subscribe to changes in a given attribute and call ``callback(future, value, *args)`` when it changes Returns: Future: A single Future which will resolve to the result
https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/core/context.py#L222-L240
dls-controls/pymalcolm
malcolm/core/context.py
Context.unsubscribe
def unsubscribe(self, future): """Terminates the subscription given by a future Args: future (Future): The future of the original subscription """ assert future not in self._pending_unsubscribes, \ "%r has already been unsubscribed from" % \ self._pen...
python
def unsubscribe(self, future): """Terminates the subscription given by a future Args: future (Future): The future of the original subscription """ assert future not in self._pending_unsubscribes, \ "%r has already been unsubscribed from" % \ self._pen...
Terminates the subscription given by a future Args: future (Future): The future of the original subscription
https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/core/context.py#L242-L263
dls-controls/pymalcolm
malcolm/core/context.py
Context.unsubscribe_all
def unsubscribe_all(self, callback=False): """Send an unsubscribe for all active subscriptions""" futures = ((f, r) for f, r in self._requests.items() if isinstance(r, Subscribe) and f not in self._pending_unsubscribes) if futures: for future, re...
python
def unsubscribe_all(self, callback=False): """Send an unsubscribe for all active subscriptions""" futures = ((f, r) for f, r in self._requests.items() if isinstance(r, Subscribe) and f not in self._pending_unsubscribes) if futures: for future, re...
Send an unsubscribe for all active subscriptions
https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/core/context.py#L265-L276
dls-controls/pymalcolm
malcolm/core/context.py
Context.when_matches
def when_matches(self, path, good_value, bad_values=None, timeout=None, event_timeout=None): """Resolve when an path value equals value Args: path (list): The path to wait to good_value (object): the value to wait for bad_values (list): values to...
python
def when_matches(self, path, good_value, bad_values=None, timeout=None, event_timeout=None): """Resolve when an path value equals value Args: path (list): The path to wait to good_value (object): the value to wait for bad_values (list): values to...
Resolve when an path value equals value Args: path (list): The path to wait to good_value (object): the value to wait for bad_values (list): values to raise an error on timeout (float): time in seconds to wait for responses, wait forever if None ...
https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/core/context.py#L282-L297
dls-controls/pymalcolm
malcolm/core/context.py
Context.when_matches_async
def when_matches_async(self, path, good_value, bad_values=None): """Wait for an attribute to become a given value Args: path (list): The path to wait to good_value: If it is a callable then expect it to return True if we are satisfied and raise on error. If it is...
python
def when_matches_async(self, path, good_value, bad_values=None): """Wait for an attribute to become a given value Args: path (list): The path to wait to good_value: If it is a callable then expect it to return True if we are satisfied and raise on error. If it is...
Wait for an attribute to become a given value Args: path (list): The path to wait to good_value: If it is a callable then expect it to return True if we are satisfied and raise on error. If it is not callable then compare each value against this one and r...
https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/core/context.py#L299-L317
dls-controls/pymalcolm
malcolm/core/context.py
Context.wait_all_futures
def wait_all_futures(self, futures, timeout=None, event_timeout=None): # type: (Union[List[Future], Future, None], float, float) -> None """Services all futures until the list 'futures' are all done then returns. Calls relevant subscription callbacks as they come off the queue and raises...
python
def wait_all_futures(self, futures, timeout=None, event_timeout=None): # type: (Union[List[Future], Future, None], float, float) -> None """Services all futures until the list 'futures' are all done then returns. Calls relevant subscription callbacks as they come off the queue and raises...
Services all futures until the list 'futures' are all done then returns. Calls relevant subscription callbacks as they come off the queue and raises an exception on abort Args: futures: a `Future` or list of all futures that the caller wants to wait for t...
https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/core/context.py#L319-L360
dls-controls/pymalcolm
malcolm/core/context.py
Context.sleep
def sleep(self, seconds): """Services all futures while waiting Args: seconds (float): Time to wait """ until = time.time() + seconds try: while True: self._service_futures([], until) except TimeoutError: return
python
def sleep(self, seconds): """Services all futures while waiting Args: seconds (float): Time to wait """ until = time.time() + seconds try: while True: self._service_futures([], until) except TimeoutError: return
Services all futures while waiting Args: seconds (float): Time to wait
https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/core/context.py#L362-L373
dls-controls/pymalcolm
malcolm/core/context.py
Context._service_futures
def _service_futures(self, futures, until=None): """Args: futures (list): The futures to service until (float): Timestamp to wait until """ if until is None: timeout = None else: timeout = until - time.time() if timeout < 0: ...
python
def _service_futures(self, futures, until=None): """Args: futures (list): The futures to service until (float): Timestamp to wait until """ if until is None: timeout = None else: timeout = until - time.time() if timeout < 0: ...
Args: futures (list): The futures to service until (float): Timestamp to wait until
https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/core/context.py#L404-L451
dls-controls/pymalcolm
malcolm/core/concurrency.py
Spawned.get
def get(self, timeout=None): # type: (float) -> T """Return the result or raise the error the function has produced""" self.wait(timeout) if isinstance(self._result, Exception): raise self._result return self._result
python
def get(self, timeout=None): # type: (float) -> T """Return the result or raise the error the function has produced""" self.wait(timeout) if isinstance(self._result, Exception): raise self._result return self._result
Return the result or raise the error the function has produced
https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/core/concurrency.py#L61-L67
dls-controls/pymalcolm
setup.py
get_version
def get_version(): """Extracts the version number from the version.py file. """ VERSION_FILE = os.path.join(module_name, 'version.py') txt = open(VERSION_FILE).read() mo = re.search(r'^__version__ = [\'"]([^\'"]*)[\'"]', txt, re.M) if mo: version = mo.group(1) bs_version = os.env...
python
def get_version(): """Extracts the version number from the version.py file. """ VERSION_FILE = os.path.join(module_name, 'version.py') txt = open(VERSION_FILE).read() mo = re.search(r'^__version__ = [\'"]([^\'"]*)[\'"]', txt, re.M) if mo: version = mo.group(1) bs_version = os.env...
Extracts the version number from the version.py file.
https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/setup.py#L12-L27
dls-controls/pymalcolm
malcolm/modules/scanning/controllers/runnablecontroller.py
RunnableController.update_configure_params
def update_configure_params(self, part=None, info=None): # type: (Part, ConfigureParamsInfo) -> None """Tell controller part needs different things passed to Configure""" with self.changes_squashed: # Update the dict if part: self.part_configure_params[par...
python
def update_configure_params(self, part=None, info=None): # type: (Part, ConfigureParamsInfo) -> None """Tell controller part needs different things passed to Configure""" with self.changes_squashed: # Update the dict if part: self.part_configure_params[par...
Tell controller part needs different things passed to Configure
https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/modules/scanning/controllers/runnablecontroller.py#L132-L200
dls-controls/pymalcolm
malcolm/modules/scanning/controllers/runnablecontroller.py
RunnableController.validate
def validate(self, generator, axesToMove=None, **kwargs): # type: (AGenerator, AAxesToMove, **Any) -> AConfigureParams """Validate configuration parameters and return validated parameters. Doesn't take device state into account so can be run in any state """ iterations = 10 ...
python
def validate(self, generator, axesToMove=None, **kwargs): # type: (AGenerator, AAxesToMove, **Any) -> AConfigureParams """Validate configuration parameters and return validated parameters. Doesn't take device state into account so can be run in any state """ iterations = 10 ...
Validate configuration parameters and return validated parameters. Doesn't take device state into account so can be run in any state
https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/modules/scanning/controllers/runnablecontroller.py#L221-L257
dls-controls/pymalcolm
malcolm/modules/scanning/controllers/runnablecontroller.py
RunnableController.configure
def configure(self, generator, axesToMove=None, **kwargs): # type: (AGenerator, AAxesToMove, **Any) -> None """Validate the params then configure the device ready for run(). Try to prepare the device as much as possible so that run() is quick to start, this may involve potentially long ...
python
def configure(self, generator, axesToMove=None, **kwargs): # type: (AGenerator, AAxesToMove, **Any) -> None """Validate the params then configure the device ready for run(). Try to prepare the device as much as possible so that run() is quick to start, this may involve potentially long ...
Validate the params then configure the device ready for run(). Try to prepare the device as much as possible so that run() is quick to start, this may involve potentially long running activities like moving motors. Normally it will return in Armed state. If the user aborts then it will...
https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/modules/scanning/controllers/runnablecontroller.py#L271-L293
dls-controls/pymalcolm
malcolm/modules/scanning/controllers/runnablecontroller.py
RunnableController.run
def run(self): # type: () -> None """Run a device where configure() has already be called Normally it will return in Ready state. If setup for multiple-runs with a single configure() then it will return in Armed state. If the user aborts then it will return in Aborted state. If ...
python
def run(self): # type: () -> None """Run a device where configure() has already be called Normally it will return in Ready state. If setup for multiple-runs with a single configure() then it will return in Armed state. If the user aborts then it will return in Aborted state. If ...
Run a device where configure() has already be called Normally it will return in Ready state. If setup for multiple-runs with a single configure() then it will return in Armed state. If the user aborts then it will return in Aborted state. If something goes wrong it will return in Fault ...
https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/modules/scanning/controllers/runnablecontroller.py#L337-L376
dls-controls/pymalcolm
malcolm/modules/scanning/controllers/runnablecontroller.py
RunnableController.abort
def abort(self): # type: () -> None """Abort the current operation and block until aborted Normally it will return in Aborted state. If something goes wrong it will return in Fault state. If the user disables then it will return in Disabled state. """ # Tell _cal...
python
def abort(self): # type: () -> None """Abort the current operation and block until aborted Normally it will return in Aborted state. If something goes wrong it will return in Fault state. If the user disables then it will return in Disabled state. """ # Tell _cal...
Abort the current operation and block until aborted Normally it will return in Aborted state. If something goes wrong it will return in Fault state. If the user disables then it will return in Disabled state.
https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/modules/scanning/controllers/runnablecontroller.py#L407-L418
dls-controls/pymalcolm
malcolm/modules/scanning/controllers/runnablecontroller.py
RunnableController.pause
def pause(self, lastGoodStep=0): # type: (ALastGoodStep) -> None """Pause a run() so that resume() can be called later, or seek within an Armed or Paused state. The original call to run() will not be interrupted by pause(), it will wait until the scan completes or is aborted. ...
python
def pause(self, lastGoodStep=0): # type: (ALastGoodStep) -> None """Pause a run() so that resume() can be called later, or seek within an Armed or Paused state. The original call to run() will not be interrupted by pause(), it will wait until the scan completes or is aborted. ...
Pause a run() so that resume() can be called later, or seek within an Armed or Paused state. The original call to run() will not be interrupted by pause(), it will wait until the scan completes or is aborted. Normally it will return in Paused state. If the user aborts then it will ...
https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/modules/scanning/controllers/runnablecontroller.py#L462-L486
dls-controls/pymalcolm
malcolm/modules/scanning/controllers/runnablecontroller.py
RunnableController.resume
def resume(self): # type: () -> None """Resume a paused scan. Normally it will return in Running state. If something goes wrong it will return in Fault state. """ self.transition(ss.RUNNING) self.resume_queue.put(True)
python
def resume(self): # type: () -> None """Resume a paused scan. Normally it will return in Running state. If something goes wrong it will return in Fault state. """ self.transition(ss.RUNNING) self.resume_queue.put(True)
Resume a paused scan. Normally it will return in Running state. If something goes wrong it will return in Fault state.
https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/modules/scanning/controllers/runnablecontroller.py#L503-L511
dls-controls/pymalcolm
malcolm/modules/scanning/hooks.py
ConfigureHook.create_info
def create_info(cls, configure_func): # type: (Callable) -> ConfigureParamsInfo """Create a `ConfigureParamsInfo` describing the extra parameters that should be passed at configure""" call_types = getattr(configure_func, "call_types", {}) # type: Dict[str, A...
python
def create_info(cls, configure_func): # type: (Callable) -> ConfigureParamsInfo """Create a `ConfigureParamsInfo` describing the extra parameters that should be passed at configure""" call_types = getattr(configure_func, "call_types", {}) # type: Dict[str, A...
Create a `ConfigureParamsInfo` describing the extra parameters that should be passed at configure
https://github.com/dls-controls/pymalcolm/blob/80ea667e4da26365a6cebc0249f52fdc744bd983/malcolm/modules/scanning/hooks.py#L92-L109