input stringlengths 11 7.65k | target stringlengths 22 8.26k |
|---|---|
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def start_tls(self, read_server_info=True):
self.start_tls_called = True |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def system_error(self,
error_msg,
error_code="",
reviewing_user=None,
reviewing_service=""):
"""
Mark that this attempt could not be completed because of a system error.
Status should be moved to `must_retry`. Fo... |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def add(self, dn, object_class=None, attributes=None):
self.result = { 'dn' : '',
'referrals' : None,
'description' : 'success',
'result' : 0,
'message' : '',
'type' : 'addResponse'}
... |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def retire_user(cls, user_id):
"""
Retire user as part of GDPR Phase I
Returns 'True' if records found
:param user_id: int
:return: bool
"""
try:
user_obj = User.objects.get(id=user_id)
except User.DoesNotExist:
return False
... |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def delete(self, dn, controls=None):
self.result = { 'dn' : '',
'referrals' : None,
'description' : 'success',
'result' : 0,
'message' : '',
'type' : 'addResponse'}
# Check to see if... |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def approve(self, user_id=None, service=""):
"""
Approve the verification attempt for user
Valid attempt statuses when calling this method:
`submitted`, `approved`, `denied`
After method completes:
status is set to `approved`
expiry_date is set to on... |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def modify(self, dn, changes, controls=None):
self.result = { 'dn' : '',
'referrals' : None,
'description' : 'success',
'result' : 0,
'message' : '',
'type' : 'modifyResponse'}
# Che... |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def get_initial_verification(cls, user, earliest_allowed_date=None):
"""Get initial verification for a user with the 'photo_id_key'.
Arguments:
user(User): user object
earliest_allowed_date(datetime): override expiration date for initial verification
Return:
... |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def _match_greater_than_or_equal(search_base, attribute, value, candidates):
matches = list()
for entry in candidates:
dn = entry.get("dn")
if not dn.endswith(search_base):
continue
value_from_directory = entry.get("attributes").get(attribute)
... |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def upload_face_image(self, img_data):
"""
Upload an image of the user's face. `img_data` should be a raw
bytestream of a PNG image. This method will take the data, encrypt it
using our FACE_IMAGE_AES_KEY, encode it with base64 and save it to the
storage backend.
Yes, en... |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def _match_greater_than(search_base, attribute, value, candidates):
matches = list()
for entry in candidates:
dn = entry.get("dn")
if not dn.endswith(search_base):
continue
value_from_directory = entry.get("attributes").get(attribute)
if s... |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def upload_photo_id_image(self, img_data):
"""
Upload an the user's photo ID image. `img_data` should be a raw
bytestream of a PNG image. This method will take the data, encrypt it
using a randomly generated AES key, encode it with base64 and save it
to the storage backend. The r... |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def _match_less_than_or_equal(search_base, attribute, value, candidates):
matches = list()
for entry in candidates:
dn = entry.get("dn")
if not dn.endswith(search_base):
continue
value_from_directory = entry.get("attributes").get(attribute)
... |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def submit(self, copy_id_photo_from=None):
"""
Submit our verification attempt to Software Secure for validation. This
will set our status to "submitted" if the post is successful, and
"must_retry" if the post fails.
Keyword Arguments:
copy_id_photo_from (SoftwareSec... |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def _match_less_than(search_base, attribute, value, candidates):
matches = list()
for entry in candidates:
dn = entry.get("dn")
if not dn.endswith(search_base):
continue
value_from_directory = entry.get("attributes").get(attribute)
if str(... |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def parsed_error_msg(self):
"""
Parse the error messages we receive from SoftwareSecure
Error messages are written in the form:
`[{"photoIdReasons": ["Not provided"]}]`
Returns:
str[]: List of error messages.
"""
parsed_errors = []
error... |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def _match_equal_to(search_base, attribute, value, candidates):
matches = list()
match_using_regex = False
if "*" in value:
match_using_regex = True
#regex = check_escape(value)
regex = value.replace('*', '.*')
regex = "^{0}$".format(regex)
... |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def image_url(self, name, override_receipt_id=None):
"""
We dynamically generate this, since we want it the expiration clock to
start when the message is created, not when the record is created.
Arguments:
name (str): Name of the image (e.g. "photo_id" or "face")
Ke... |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def _match_notequal_to(search_base, attribute, value, candidates):
matches = list()
match_using_regex = False
if "*" in value:
match_using_regex = True
#regex = check_escape(value)
regex = value.replace('*', '.*')
regex = "^{0}$".format(regex)
... |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def _storage(self):
"""
Return the configured django storage backend.
"""
config = settings.VERIFY_STUDENT["SOFTWARE_SECURE"]
# Default to the S3 backend for backward compatibility
storage_class = config.get("STORAGE_CLASS", "storages.backends.s3boto.S3BotoStorage")
... |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def _parse_filter():
op = pyparsing.oneOf('! & |')
lpar = pyparsing.Literal('(').suppress()
rpar = pyparsing.Literal(')').suppress()
k = pyparsing.Word(pyparsing.alphanums)
# NOTE: We may need to expand on this list, but as this is not a real
# LDAP server we should be... |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def _get_path(self, prefix, override_receipt_id=None):
"""
Returns the path to a resource with this instance's `receipt_id`.
If `override_receipt_id` is given, the path to that resource will be
retrieved instead. This allows us to retrieve images submitted in
previous attempts (... |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def _deDuplicate(results):
found = dict()
deDuped = list()
for entry in results:
dn = entry.get("dn")
if not dn in found:
found[dn] = 1
deDuped.append(entry)
return deDuped |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def _encrypted_user_photo_key_str(self):
"""
Software Secure needs to have both UserPhoto and PhotoID decrypted in
the same manner. So even though this is going to be the same for every
request, we're also using RSA encryption to encrypt the AES key for
faces.
"""
... |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def _invert_results(self, candidates):
inverted_candidates = list(self.directory)
for candidate in candidates:
try:
inverted_candidates.remove(candidate)
except ValueError:
pass
return inverted_candidates |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def create_request(self, copy_id_photo_from=None):
"""
Construct the HTTP request to the photo verification service.
Keyword Arguments:
copy_id_photo_from (SoftwareSecurePhotoVerification): If provided, re-send the ID photo
data from this attempt. This is used for r... |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def _search_not(self, base, search_filter, candidates=None):
# Create empty candidates list as we need to use self.directory for
# each search
candidates = list()
this_filter = list()
index = 0
search_filter.remove("!")
for condition in search_filter:
... |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def request_message_txt(self):
"""
This is the body of the request we send across. This is never actually
used in the code, but exists for debugging purposes -- you can call
`print attempt.request_message_txt()` on the console and get a readable
rendering of the request that woul... |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def _search_and(self, base, search_filter, candidates=None):
# Load the data from the directory, if we aren't passed any
if candidates == [] or candidates is None:
candidates = self.directory
this_filter = list()
index = 0
search_filter.remove("&")
for condit... |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def send_request(self, copy_id_photo_from=None):
"""
Assembles a submission to Software Secure and sends it via HTTPS.
Keyword Arguments:
copy_id_photo_from (SoftwareSecurePhotoVerification): If provided, re-send the ID photo
data from this attempt. This is used for... |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def _search_or(self, base, search_filter, candidates=None):
# Create empty candidates list as we need to use self.directory for
# each search
candidates = list()
this_filter = list()
index = 0
search_filter.remove("|")
for condition in search_filter:
... |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def search(self, search_base=None, search_scope=None,
search_filter=None, attributes=None, paged_size=5,
size_limit=0, paged_cookie=None):
s_filter = list()
candidates = list()
self.response = list()
self.result = dict()
try:
if isinstan... |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def set_deadline(cls, course_key, deadline, is_explicit=False):
"""
Configure the verification deadline for a course.
If `deadline` is `None`, then the course will have no verification
deadline. In this case, users will be able to verify for the course
at any time.
Arg... |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def unbind(self):
return True |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def deadlines_for_courses(cls, course_keys):
"""
Retrieve verification deadlines for particular courses.
Arguments:
course_keys (list): List of `CourseKey`s.
Returns:
dict: Map of course keys to datetimes (verification deadlines)
"""
all_deadlin... |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def __init__(self):
self._calls = CallList()
self._server_mock = None
self.directory = []
self.exception = None
self.reset() |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def deadline_for_course(cls, course_key):
"""
Retrieve the verification deadline for a particular course.
Arguments:
course_key (CourseKey): The identifier for the course.
Returns:
datetime or None
"""
try:
deadline = cls.objects.get... |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def reset(self):
self._calls.reset() |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def setLDAPDirectory(self, directory=None):
if directory is None:
self.directory = []
else:
try:
with open(DIRECTORY, 'w+') as f:
f.write(str(directory))
self.directory = directory
except OSError as e:
... |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def set_exception(self, exc=True):
self.exception = exc |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def _load_data(self, directory):
try:
with open(directory, 'r') as f:
data = f.read()
return literal_eval(data)
except OSError as e:
raise |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def calls(self):
return self._calls |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def __enter__(self):
self.start() |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def __exit__(self, *args):
self.stop()
self.reset() |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def activate(self, func):
evaldict = {'ldap3mock': self, 'func': func}
return get_wrapped(func, _wrapper_template, evaldict) |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def _on_Server(self, host, port, use_ssl, connect_timeout, get_info=None,
tls=None):
# mangle request packet
return "FakeServerObject" |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def _on_Connection(self, server, user, password,
auto_bind=None, client_strategy=None,
authentication=None, check_names=None,
auto_referrals=None, receive_timeout=None):
"""
We need to create a Connection object with
methods:
... |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def unbound_on_Server(host, port,
use_ssl,
connect_timeout, *a, **kwargs):
return self._on_Server(host, port,
use_ssl,
connect_timeout, *a, **kwargs) |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def unbound_on_Connection(server, user,
password,
auto_bind,
client_strategy,
authentication,
check_names,
auto_refe... |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def stop(self):
self._patcher.stop()
self._patcher2.stop()
self._server_mock = None |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def get_server_mock(self):
return self._server_mock |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def setUp(self):
entry_Li = ComputedEntry("Li", -1.90753119)
with open(os.path.join(PymatgenTest.TEST_FILES_DIR, "LiTiO2_batt.json")) as f:
entries_LTO = json.load(f, cls=MontyDecoder)
self.ie_LTO = InsertionElectrode.from_entries(entries_LTO, entry_Li)
with open(os.pat... |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def __init__(self):
"""
Every authenticator has to have a name
:param name:
"""
super().__init__() |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def testName(self):
plotter = VoltageProfilePlotter(xaxis="frac_x")
plotter.add_electrode(self.ie_LTO, "LTO insertion")
plotter.add_electrode(self.ce_FF, "FeF3 conversion")
self.assertIsNotNone(plotter.get_plot_data(self.ie_LTO))
self.assertIsNotNone(plotter.get_plot_data(self.ce... |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def testPlotly(self):
plotter = VoltageProfilePlotter(xaxis="frac_x")
plotter.add_electrode(self.ie_LTO, "LTO insertion")
plotter.add_electrode(self.ce_FF, "FeF3 conversion")
fig = plotter.get_plotly_figure()
self.assertEqual(fig.layout.xaxis.title.text, "Atomic Fraction of Li")
... |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def _no_ssl_required_on_debug(app, **kwargs):
if app.debug or app.testing:
os.environ['AUTHLIB_INSECURE_TRANSPORT'] = '1' |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def __init__(self, head):
self.head = head
self.lsize = 0
while head.next:
head = head.next
self.lsize += 1
self.m1_idx = None
self.m2_idx = None
if self.lsize > self._largesize:
self.m1_idx = self.lsize / 3 # start from 1/3
... |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def _getN(self, n):
n -= 1
p = self.head
while n:
p = p.next
n -= 1
return p |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def _get(delta, start):
p = start
while delta:
p = p.next
delta -= 1
return p.val |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def main():
parser = argparse.ArgumentParser()
parser.add_argument("day", help="The day of the results, with format yyyymmdd")
args = parser.parse_args()
install_autopkgtest_results_formatter()
with tempfile.TemporaryDirectory(dir=os.environ.get("HOME")) as temp_dir:
clone_results_repo(temp_... |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def __init__(self, parent, window):
self._parent = parent
self._window = window
self._application = self._parent._application
# create user interface
self._container = gtk.VBox(False, 5)
self._controls = gtk.HBox(False, 5)
separator = gtk.HSeparator()
# pack interface
self._container.pack_end(separ... |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def install_autopkgtest_results_formatter():
subprocess.check_call(
["sudo", "snap", "install", "autopkgtest-results-formatter", "--edge"]
) |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def can_handle(self, uri):
"""Returns boolean denoting if specified URI can be handled by this extension"""
return False |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def clone_results_repo(dest_dir):
subprocess.check_call(
["git", "clone", "https://github.com/elopio/autopkgtest-results.git", dest_dir]
) |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def get_container(self):
"""Return container widget"""
return self._container |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def format_results(dest_dir, distros, day):
subprocess.check_call(
[
"/snap/bin/autopkgtest-results-formatter",
"--destination",
dest_dir,
"--distros",
*distros,
"--day",
day,
]
) |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def get_information(self):
"""Returns information about extension"""
icon = None
name = None
return icon, name |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def commit_and_push(repo_dir, day):
subprocess.check_call(
["git", "config", "--global", "user.email", "u1test+m-o@canonical.com"]
)
subprocess.check_call(["git", "config", "--global", "user.name", "snappy-m-o"])
subprocess.check_call(["git", "-C", repo_dir, "add", "--all"])
subprocess.chec... |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def unmount(self, uri):
"""Method called by the mount manager for unmounting the selected URI"""
pass |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def focus_object(self):
"""Method called by the mount manager for focusing main object"""
pass |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def __init__(self, gan=None, config=None, trainer=None):
super().__init__(config=config, gan=gan, trainer=trainer)
self.d_grads = None
self.g_grads = None |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def main():
# Contingency Table from Wilks (2011) Table 8.3
table = np.array([[50, 91, 71],
[47, 2364, 170],
[54, 205, 3288]])
mct = MulticlassContingencyTable(table, n_classes=table.shape[0],
class_names=np.arange(table.shape[... |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def gradients(self, d_grads, g_grads):
if self.d_grads is None:
self.d_grads = [torch.zeros_like(_g) for _g in d_grads]
self.g_grads = [torch.zeros_like(_g) for _g in g_grads] |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def __init__(self, table=None, n_classes=2, class_names=("1", "0")):
self.table = table
self.n_classes = n_classes
self.class_names = class_names
if table is None:
self.table = np.zeros((self.n_classes, self.n_classes), dtype=int) |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def __add__(self, other):
assert self.n_classes == other.n_classes, "Number of classes does not match"
return MulticlassContingencyTable(self.table + other.table,
n_classes=self.n_classes,
class_names=self.class_names) |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def peirce_skill_score(self):
"""
Multiclass Peirce Skill Score (also Hanssen and Kuipers score, True Skill Score)
"""
n = float(self.table.sum())
nf = self.table.sum(axis=1)
no = self.table.sum(axis=0)
correct = float(self.table.trace())
return (correct /... |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def gerrity_score(self):
"""
Gerrity Score, which weights each cell in the contingency table by its observed relative frequency.
:return:
"""
k = self.table.shape[0]
n = float(self.table.sum())
p_o = self.table.sum(axis=0) / n
p_sum = np.cumsum(p_o)[:-1]
... |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def heidke_skill_score(self):
n = float(self.table.sum())
nf = self.table.sum(axis=1)
no = self.table.sum(axis=0)
correct = float(self.table.trace())
return (correct / n - (nf * no).sum() / n ** 2) / (1 - (nf * no).sum() / n ** 2) |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def git_checkout(git_url, git_branch=None, git_tag=None, git_hash=None):
git_dst = tempfile.mkdtemp()
g = GitManager(url=git_url, git_dst=git_dst, git_branch=git_branch, git_tag=git_tag, git_hash=git_hash)
g.run()
shutil.rmtree(git_dst) |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def test_git_tag():
""" Test checkout w/ Tag """
git_checkout(git_url='https://github.com/voltgrid/voltgrid-pie.git', git_branch=None, git_tag='v0.1.0') |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def test_git_branch():
""" Test checkout w/ Branch """
git_checkout(git_url='https://github.com/voltgrid/voltgrid-pie.git', git_branch='master', git_tag=None) |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def test_make_gym_venv_nostack(name, num_envs, state_shape, reward_scale):
seed = 0
frame_op = None
frame_op_len = None
venv = make_gym_venv(name, num_envs, seed, frame_op=frame_op, frame_op_len=frame_op_len, reward_scale=reward_scale)
venv.reset()
for i in range(5):
state, reward, done,... |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def compute_rbf_kernel_matrix(X):
"""Compute the RBF kernel matrix with sigma2 as the median pairwise
distance.
"""
sigma2 = np.median(pairwise_distances(X, metric='euclidean'))**2
K = pairwise_kernels(X, X, metric='rbf', gamma=1.0/sigma2, n_jobs=-1)
return K |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def test_make_gym_concat(name, num_envs, state_shape, reward_scale):
seed = 0
frame_op = 'concat' # used for image, or for concat vector
frame_op_len = 4
venv = make_gym_venv(name, num_envs, seed, frame_op=frame_op, frame_op_len=frame_op_len, reward_scale=reward_scale)
venv.reset()
for i in ran... |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def balanced_accuracy_scoring(clf, X, y):
"""Scoring function that computes the balanced accuracy to be used
internally in the cross-validation procedure.
"""
y_pred = clf.predict(X)
conf_mat = confusion_matrix(y, y_pred)
bal_acc = 0.
for i in range(len(conf_mat)):
bal_acc += (float(... |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def test_make_gym_stack(name, num_envs, state_shape, reward_scale):
seed = 0
frame_op = 'stack' # used for rnn
frame_op_len = 4
venv = make_gym_venv(name, num_envs, seed, frame_op=frame_op, frame_op_len=frame_op_len, reward_scale=reward_scale)
venv.reset()
for i in range(5):
state, rewa... |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def compute_svm_cv(K, y, C=100.0, n_folds=5,
scoring=balanced_accuracy_scoring):
"""Compute cross-validated score of SVM with given precomputed kernel.
"""
cv = StratifiedKFold(y, n_folds=n_folds)
clf = SVC(C=C, kernel='precomputed', class_weight='auto')
scores = cross_val_score(c... |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def compute_svm_subjects(K, y, n_folds=5):
"""
"""
cv = KFold(len(K)/2, n_folds)
scores = np.zeros(n_folds)
for i, (train, test) in enumerate(cv):
train_ids = np.concatenate((train, len(K)/2+train))
test_ids = np.concatenate((test, len(K)/2+test))
clf = SVC(kernel='precompute... |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def permutation_subjects(y):
"""Permute class labels of Contextual Disorder dataset.
"""
y_perm = np.random.randint(0, 2, len(y)/2)
y_perm = np.concatenate((y_perm, np.logical_not(y_perm).astype(int)))
return y_perm |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def permutation_subjects_ktst(y):
"""Permute class labels of Contextual Disorder dataset for KTST.
"""
yp = np.random.randint(0, 2, len(y)/2)
yp = np.concatenate((yp, np.logical_not(yp).astype(int)))
y_perm = np.arange(len(y))
for i in range(len(y)/2):
if yp[i] == 1:
y_perm[i... |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def compute_svm_score_nestedCV(K, y, n_folds,
scoring=balanced_accuracy_scoring,
random_state=None,
param_grid=[{'C': np.logspace(-5, 5, 25)}]):
"""Compute cross-validated score of SVM using precomputed kernel.
"""
... |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def apply_svm(K, y, n_folds=5, iterations=10000, subjects=False, verbose=True,
random_state=None):
"""
Compute the balanced accuracy, its null distribution and the p-value.
Parameters:
----------
K: array-like
Kernel matrix
y: array_like
class labels
cv: Number... |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def apply_ktst(K, y, iterations=10000, subjects=False, verbose=True):
"""
Compute MMD^2_u, its null distribution and the p-value of the
kernel two-sample test.
Parameters:
----------
K: array-like
Kernel matrix
y: array_like
class labels
verbose: bool
Verbosity
... |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def test_login(self, mock_login_with_token, mock_input, mock_open_url):
quilt3.login()
url = quilt3.session.get_registry_url()
mock_open_url.assert_called_with(f'{url}/login')
mock_login_with_token.assert_called_with('123456') |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def decode(value):
if isinstance(value, bytes):
value = value.decode(errors="surrogateescape")
for char in ("\\", "\n", "\t"):
value = value.replace(
char.encode(encoding="unicode-escape").decode(), char
)
return value |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def test_login_with_token(self, mock_save_credentials, mock_save_auth):
url = quilt3.session.get_registry_url()
mock_auth = dict(
refresh_token='refresh-token',
access_token='access-token',
expires_at=123456789
)
self.requests_mock.add(
r... |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def encode(value):
if isinstance(value, bytes):
value = value.decode(errors="surrogateescape")
for char in ("\\", "\n", "\t"):
value = value.replace(
char, char.encode(encoding="unicode-escape").decode()
)
return value |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def format_date(date):
return date.replace(tzinfo=datetime.timezone.utc, microsecond=0).isoformat() |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def deserialize(self, value):
"""Cast raw string to appropriate type."""
return decode(value) |
def place_bonds_inner(self, state):
"""Place bonds corresponding to `state`.
No validity checking is done, the calling function is responsible
for that.
Args:
state: for each pair of atoms, the kind of bond to be placed.
Returns:
If successful, a BondTopology.
"""
self._curren... | def serialize(self, value, display=False):
"""Convert value back to string for saving."""
if value is None:
return ""
return str(value) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.