FlatSolutionDict¶

class FlatSolutionDict¶

Bases: dict[str, bool | int | float]

Solution dictionary type with a FlatSolution compatible structure.

Methods

__init__

clear

copy

fromkeys

Create a new dictionary with keys from iterable and values set to value.

get

Return the value for key if key is in the dictionary, else default.

items

keys

pop

If the key is not found, return the default if given; otherwise, raise a KeyError.

popitem

Remove and return a (key, value) pair as a 2-tuple.

setdefault

Insert key with a value of default if key is not in the dictionary.

to_list

Convert to a FlatSolution-compatible list (drop the names of variables).

to_solution

Convert this solution dictionary to a FlatSolution class instance.

update

If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

values

__class_getitem__()¶

See PEP 585

__contains__(key, /)¶

True if the dictionary has the specified key, else False.

__delitem__(key, /)¶

Delete self[key].

__eq__(value, /)¶

Return self==value.

__ge__(value, /)¶

Return self>=value.

__getattribute__(name, /)¶

Return getattr(self, name).

__getitem__()¶

x.__getitem__(y) <==> x[y]

__gt__(value, /)¶

Return self>value.

__init__(*args, **kwargs)¶
__ior__(value, /)¶

Return self|=value.

__iter__()¶

Implement iter(self).

__le__(value, /)¶

Return self<=value.

__len__()¶

Return len(self).

__lt__(value, /)¶

Return self<value.

__ne__(value, /)¶

Return self!=value.

__or__(value, /)¶

Return self|value.

__repr__()¶

Return repr(self).

__reversed__()¶

Return a reverse iterator over the dict keys.

__ror__(value, /)¶

Return value|self.

__setitem__(key: str, value: bool | int | float) None¶

Set item.

Parameters:
Raises:

TypeError – If a solution element has a StructuredSolution element form.

__sizeof__() size of D in memory, in bytes¶
clear() None.  Remove all items from D.¶
copy() a shallow copy of D¶
fromkeys(value=None, /)¶

Create a new dictionary with keys from iterable and values set to value.

get(key, default=None, /)¶

Return the value for key if key is in the dictionary, else default.

items() a set-like object providing a view on D's items¶
keys() a set-like object providing a view on D's keys¶
pop(k[, d]) v, remove specified key and return the corresponding value.¶

If the key is not found, return the default if given; otherwise, raise a KeyError.

popitem()¶

Remove and return a (key, value) pair as a 2-tuple.

Pairs are returned in LIFO (last-in, first-out) order. Raises KeyError if the dict is empty.

setdefault(key, default=None, /)¶

Insert key with a value of default if key is not in the dictionary.

Return the value for key if key is in the dictionary, else default.

to_list() list[bool | int | float]¶

Convert to a FlatSolution-compatible list (drop the names of variables).

Returns:

The solution.

Return type:

list[bool | int | float]

to_solution(variables: Variables) FlatSolution¶

Convert this solution dictionary to a FlatSolution class instance.

Parameters:

variables (Variables) – Variables relevant to this solution.

Returns:

The converted solution.

Return type:

FlatSolution

update([E, ]**F) None.  Update D from dict/iterable E and F.¶

If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

values() an object providing a view on D's values¶
__dict__ = mappingproxy({'__module__': 'amplify_bbopt.solution_type', '__doc__': 'Solution dictionary type with a :obj:`FlatSolution` compatible structure.', '__setitem__': <function FlatSolutionDict.__setitem__>, 'to_solution': <function FlatSolutionDict.to_solution>, 'to_list': <function FlatSolutionDict.to_list>, '__orig_bases__': (dict[str, typing.Union[bool, int, float]],), '__dict__': <attribute '__dict__' of 'FlatSolutionDict' objects>, '__weakref__': <attribute '__weakref__' of 'FlatSolutionDict' objects>, '__annotations__': {}})¶
__hash__ = None¶
__orig_bases__ = (dict[str, typing.Union[bool, int, float]],)¶
__weakref__¶

list of weak references to the object (if defined)