repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
dagwieers/vmguestlib | vmguestlib.py | VMGuestLib.GetMemActiveMB | def GetMemActiveMB(self):
'''Retrieves the amount of memory the virtual machine is actively using its
estimated working set size.'''
counter = c_uint()
ret = vmGuestLib.VMGuestLib_GetMemActiveMB(self.handle.value, byref(counter))
if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGue... | python | def GetMemActiveMB(self):
'''Retrieves the amount of memory the virtual machine is actively using its
estimated working set size.'''
counter = c_uint()
ret = vmGuestLib.VMGuestLib_GetMemActiveMB(self.handle.value, byref(counter))
if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGue... | [
"def",
"GetMemActiveMB",
"(",
"self",
")",
":",
"counter",
"=",
"c_uint",
"(",
")",
"ret",
"=",
"vmGuestLib",
".",
"VMGuestLib_GetMemActiveMB",
"(",
"self",
".",
"handle",
".",
"value",
",",
"byref",
"(",
"counter",
")",
")",
"if",
"ret",
"!=",
"VMGUESTL... | Retrieves the amount of memory the virtual machine is actively using its
estimated working set size. | [
"Retrieves",
"the",
"amount",
"of",
"memory",
"the",
"virtual",
"machine",
"is",
"actively",
"using",
"its",
"estimated",
"working",
"set",
"size",
"."
] | train | https://github.com/dagwieers/vmguestlib/blob/2ba9333a745628cf9e6b4c767427a5bd997a71ad/vmguestlib.py#L307-L313 |
dagwieers/vmguestlib | vmguestlib.py | VMGuestLib.GetMemBalloonedMB | def GetMemBalloonedMB(self):
'''Retrieves the amount of memory that has been reclaimed from this virtual
machine by the vSphere memory balloon driver (also referred to as the
"vmmemctl" driver).'''
counter = c_uint()
ret = vmGuestLib.VMGuestLib_GetMemBalloonedMB(self.handle... | python | def GetMemBalloonedMB(self):
'''Retrieves the amount of memory that has been reclaimed from this virtual
machine by the vSphere memory balloon driver (also referred to as the
"vmmemctl" driver).'''
counter = c_uint()
ret = vmGuestLib.VMGuestLib_GetMemBalloonedMB(self.handle... | [
"def",
"GetMemBalloonedMB",
"(",
"self",
")",
":",
"counter",
"=",
"c_uint",
"(",
")",
"ret",
"=",
"vmGuestLib",
".",
"VMGuestLib_GetMemBalloonedMB",
"(",
"self",
".",
"handle",
".",
"value",
",",
"byref",
"(",
"counter",
")",
")",
"if",
"ret",
"!=",
"VM... | Retrieves the amount of memory that has been reclaimed from this virtual
machine by the vSphere memory balloon driver (also referred to as the
"vmmemctl" driver). | [
"Retrieves",
"the",
"amount",
"of",
"memory",
"that",
"has",
"been",
"reclaimed",
"from",
"this",
"virtual",
"machine",
"by",
"the",
"vSphere",
"memory",
"balloon",
"driver",
"(",
"also",
"referred",
"to",
"as",
"the",
"vmmemctl",
"driver",
")",
"."
] | train | https://github.com/dagwieers/vmguestlib/blob/2ba9333a745628cf9e6b4c767427a5bd997a71ad/vmguestlib.py#L315-L322 |
dagwieers/vmguestlib | vmguestlib.py | VMGuestLib.GetMemBalloonMaxMB | def GetMemBalloonMaxMB(self):
'''Undocumented.'''
counter = c_uint()
ret = vmGuestLib.VMGuestLib_GetMemBalloonMaxMB(self.handle.value, byref(counter))
if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
return counter.value | python | def GetMemBalloonMaxMB(self):
'''Undocumented.'''
counter = c_uint()
ret = vmGuestLib.VMGuestLib_GetMemBalloonMaxMB(self.handle.value, byref(counter))
if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
return counter.value | [
"def",
"GetMemBalloonMaxMB",
"(",
"self",
")",
":",
"counter",
"=",
"c_uint",
"(",
")",
"ret",
"=",
"vmGuestLib",
".",
"VMGuestLib_GetMemBalloonMaxMB",
"(",
"self",
".",
"handle",
".",
"value",
",",
"byref",
"(",
"counter",
")",
")",
"if",
"ret",
"!=",
"... | Undocumented. | [
"Undocumented",
"."
] | train | https://github.com/dagwieers/vmguestlib/blob/2ba9333a745628cf9e6b4c767427a5bd997a71ad/vmguestlib.py#L325-L330 |
dagwieers/vmguestlib | vmguestlib.py | VMGuestLib.GetMemBalloonTargetMB | def GetMemBalloonTargetMB(self):
'''Undocumented.'''
counter = c_uint()
ret = vmGuestLib.VMGuestLib_GetMemBalloonTargetMB(self.handle.value, byref(counter))
if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
return counter.value | python | def GetMemBalloonTargetMB(self):
'''Undocumented.'''
counter = c_uint()
ret = vmGuestLib.VMGuestLib_GetMemBalloonTargetMB(self.handle.value, byref(counter))
if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
return counter.value | [
"def",
"GetMemBalloonTargetMB",
"(",
"self",
")",
":",
"counter",
"=",
"c_uint",
"(",
")",
"ret",
"=",
"vmGuestLib",
".",
"VMGuestLib_GetMemBalloonTargetMB",
"(",
"self",
".",
"handle",
".",
"value",
",",
"byref",
"(",
"counter",
")",
")",
"if",
"ret",
"!=... | Undocumented. | [
"Undocumented",
"."
] | train | https://github.com/dagwieers/vmguestlib/blob/2ba9333a745628cf9e6b4c767427a5bd997a71ad/vmguestlib.py#L333-L338 |
dagwieers/vmguestlib | vmguestlib.py | VMGuestLib.GetMemLimitMB | def GetMemLimitMB(self):
'''Retrieves the upper limit of memory that is available to the virtual
machine. For information about setting a memory limit, see "Limits and
Reservations" on page 14.'''
counter = c_uint()
ret = vmGuestLib.VMGuestLib_GetMemLimitMB(self.handle.valu... | python | def GetMemLimitMB(self):
'''Retrieves the upper limit of memory that is available to the virtual
machine. For information about setting a memory limit, see "Limits and
Reservations" on page 14.'''
counter = c_uint()
ret = vmGuestLib.VMGuestLib_GetMemLimitMB(self.handle.valu... | [
"def",
"GetMemLimitMB",
"(",
"self",
")",
":",
"counter",
"=",
"c_uint",
"(",
")",
"ret",
"=",
"vmGuestLib",
".",
"VMGuestLib_GetMemLimitMB",
"(",
"self",
".",
"handle",
".",
"value",
",",
"byref",
"(",
"counter",
")",
")",
"if",
"ret",
"!=",
"VMGUESTLIB... | Retrieves the upper limit of memory that is available to the virtual
machine. For information about setting a memory limit, see "Limits and
Reservations" on page 14. | [
"Retrieves",
"the",
"upper",
"limit",
"of",
"memory",
"that",
"is",
"available",
"to",
"the",
"virtual",
"machine",
".",
"For",
"information",
"about",
"setting",
"a",
"memory",
"limit",
"see",
"Limits",
"and",
"Reservations",
"on",
"page",
"14",
"."
] | train | https://github.com/dagwieers/vmguestlib/blob/2ba9333a745628cf9e6b4c767427a5bd997a71ad/vmguestlib.py#L340-L347 |
dagwieers/vmguestlib | vmguestlib.py | VMGuestLib.GetMemLLSwappedMB | def GetMemLLSwappedMB(self):
'''Undocumented.'''
counter = c_uint()
ret = vmGuestLib.VMGuestLib_GetMemLLSwappedMB(self.handle.value, byref(counter))
if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
return counter.value | python | def GetMemLLSwappedMB(self):
'''Undocumented.'''
counter = c_uint()
ret = vmGuestLib.VMGuestLib_GetMemLLSwappedMB(self.handle.value, byref(counter))
if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
return counter.value | [
"def",
"GetMemLLSwappedMB",
"(",
"self",
")",
":",
"counter",
"=",
"c_uint",
"(",
")",
"ret",
"=",
"vmGuestLib",
".",
"VMGuestLib_GetMemLLSwappedMB",
"(",
"self",
".",
"handle",
".",
"value",
",",
"byref",
"(",
"counter",
")",
")",
"if",
"ret",
"!=",
"VM... | Undocumented. | [
"Undocumented",
"."
] | train | https://github.com/dagwieers/vmguestlib/blob/2ba9333a745628cf9e6b4c767427a5bd997a71ad/vmguestlib.py#L350-L355 |
dagwieers/vmguestlib | vmguestlib.py | VMGuestLib.GetMemMappedMB | def GetMemMappedMB(self):
'''Retrieves the amount of memory that is allocated to the virtual machine.
Memory that is ballooned, swapped, or has never been accessed is
excluded.'''
counter = c_uint()
ret = vmGuestLib.VMGuestLib_GetMemMappedMB(self.handle.value, byref(counter... | python | def GetMemMappedMB(self):
'''Retrieves the amount of memory that is allocated to the virtual machine.
Memory that is ballooned, swapped, or has never been accessed is
excluded.'''
counter = c_uint()
ret = vmGuestLib.VMGuestLib_GetMemMappedMB(self.handle.value, byref(counter... | [
"def",
"GetMemMappedMB",
"(",
"self",
")",
":",
"counter",
"=",
"c_uint",
"(",
")",
"ret",
"=",
"vmGuestLib",
".",
"VMGuestLib_GetMemMappedMB",
"(",
"self",
".",
"handle",
".",
"value",
",",
"byref",
"(",
"counter",
")",
")",
"if",
"ret",
"!=",
"VMGUESTL... | Retrieves the amount of memory that is allocated to the virtual machine.
Memory that is ballooned, swapped, or has never been accessed is
excluded. | [
"Retrieves",
"the",
"amount",
"of",
"memory",
"that",
"is",
"allocated",
"to",
"the",
"virtual",
"machine",
".",
"Memory",
"that",
"is",
"ballooned",
"swapped",
"or",
"has",
"never",
"been",
"accessed",
"is",
"excluded",
"."
] | train | https://github.com/dagwieers/vmguestlib/blob/2ba9333a745628cf9e6b4c767427a5bd997a71ad/vmguestlib.py#L357-L364 |
dagwieers/vmguestlib | vmguestlib.py | VMGuestLib.GetMemOverheadMB | def GetMemOverheadMB(self):
'''Retrieves the amount of "overhead" memory associated with this virtual
machine that is currently consumed on the host system. Overhead
memory is additional memory that is reserved for data structures required
by the virtualization layer.'''
... | python | def GetMemOverheadMB(self):
'''Retrieves the amount of "overhead" memory associated with this virtual
machine that is currently consumed on the host system. Overhead
memory is additional memory that is reserved for data structures required
by the virtualization layer.'''
... | [
"def",
"GetMemOverheadMB",
"(",
"self",
")",
":",
"counter",
"=",
"c_uint",
"(",
")",
"ret",
"=",
"vmGuestLib",
".",
"VMGuestLib_GetMemOverheadMB",
"(",
"self",
".",
"handle",
".",
"value",
",",
"byref",
"(",
"counter",
")",
")",
"if",
"ret",
"!=",
"VMGU... | Retrieves the amount of "overhead" memory associated with this virtual
machine that is currently consumed on the host system. Overhead
memory is additional memory that is reserved for data structures required
by the virtualization layer. | [
"Retrieves",
"the",
"amount",
"of",
"overhead",
"memory",
"associated",
"with",
"this",
"virtual",
"machine",
"that",
"is",
"currently",
"consumed",
"on",
"the",
"host",
"system",
".",
"Overhead",
"memory",
"is",
"additional",
"memory",
"that",
"is",
"reserved",... | train | https://github.com/dagwieers/vmguestlib/blob/2ba9333a745628cf9e6b4c767427a5bd997a71ad/vmguestlib.py#L366-L374 |
dagwieers/vmguestlib | vmguestlib.py | VMGuestLib.GetMemReservationMB | def GetMemReservationMB(self):
'''Retrieves the minimum amount of memory that is reserved for the virtual
machine. For information about setting a memory reservation, see "Limits
and Reservations" on page 14.'''
counter = c_uint()
ret = vmGuestLib.VMGuestLib_GetMemReservati... | python | def GetMemReservationMB(self):
'''Retrieves the minimum amount of memory that is reserved for the virtual
machine. For information about setting a memory reservation, see "Limits
and Reservations" on page 14.'''
counter = c_uint()
ret = vmGuestLib.VMGuestLib_GetMemReservati... | [
"def",
"GetMemReservationMB",
"(",
"self",
")",
":",
"counter",
"=",
"c_uint",
"(",
")",
"ret",
"=",
"vmGuestLib",
".",
"VMGuestLib_GetMemReservationMB",
"(",
"self",
".",
"handle",
".",
"value",
",",
"byref",
"(",
"counter",
")",
")",
"if",
"ret",
"!=",
... | Retrieves the minimum amount of memory that is reserved for the virtual
machine. For information about setting a memory reservation, see "Limits
and Reservations" on page 14. | [
"Retrieves",
"the",
"minimum",
"amount",
"of",
"memory",
"that",
"is",
"reserved",
"for",
"the",
"virtual",
"machine",
".",
"For",
"information",
"about",
"setting",
"a",
"memory",
"reservation",
"see",
"Limits",
"and",
"Reservations",
"on",
"page",
"14",
"."
... | train | https://github.com/dagwieers/vmguestlib/blob/2ba9333a745628cf9e6b4c767427a5bd997a71ad/vmguestlib.py#L376-L383 |
dagwieers/vmguestlib | vmguestlib.py | VMGuestLib.GetMemSharedMB | def GetMemSharedMB(self):
'''Retrieves the amount of physical memory associated with this virtual
machine that is copy-on-write (COW) shared on the host.'''
counter = c_uint()
ret = vmGuestLib.VMGuestLib_GetMemSharedMB(self.handle.value, byref(counter))
if ret != VMGUESTLIB_ER... | python | def GetMemSharedMB(self):
'''Retrieves the amount of physical memory associated with this virtual
machine that is copy-on-write (COW) shared on the host.'''
counter = c_uint()
ret = vmGuestLib.VMGuestLib_GetMemSharedMB(self.handle.value, byref(counter))
if ret != VMGUESTLIB_ER... | [
"def",
"GetMemSharedMB",
"(",
"self",
")",
":",
"counter",
"=",
"c_uint",
"(",
")",
"ret",
"=",
"vmGuestLib",
".",
"VMGuestLib_GetMemSharedMB",
"(",
"self",
".",
"handle",
".",
"value",
",",
"byref",
"(",
"counter",
")",
")",
"if",
"ret",
"!=",
"VMGUESTL... | Retrieves the amount of physical memory associated with this virtual
machine that is copy-on-write (COW) shared on the host. | [
"Retrieves",
"the",
"amount",
"of",
"physical",
"memory",
"associated",
"with",
"this",
"virtual",
"machine",
"that",
"is",
"copy",
"-",
"on",
"-",
"write",
"(",
"COW",
")",
"shared",
"on",
"the",
"host",
"."
] | train | https://github.com/dagwieers/vmguestlib/blob/2ba9333a745628cf9e6b4c767427a5bd997a71ad/vmguestlib.py#L385-L391 |
dagwieers/vmguestlib | vmguestlib.py | VMGuestLib.GetMemSharedSavedMB | def GetMemSharedSavedMB(self):
'''Retrieves the estimated amount of physical memory on the host saved
from copy-on-write (COW) shared guest physical memory.'''
counter = c_uint()
ret = vmGuestLib.VMGuestLib_GetMemSharedSavedMB(self.handle.value, byref(counter))
if ret != VMGUE... | python | def GetMemSharedSavedMB(self):
'''Retrieves the estimated amount of physical memory on the host saved
from copy-on-write (COW) shared guest physical memory.'''
counter = c_uint()
ret = vmGuestLib.VMGuestLib_GetMemSharedSavedMB(self.handle.value, byref(counter))
if ret != VMGUE... | [
"def",
"GetMemSharedSavedMB",
"(",
"self",
")",
":",
"counter",
"=",
"c_uint",
"(",
")",
"ret",
"=",
"vmGuestLib",
".",
"VMGuestLib_GetMemSharedSavedMB",
"(",
"self",
".",
"handle",
".",
"value",
",",
"byref",
"(",
"counter",
")",
")",
"if",
"ret",
"!=",
... | Retrieves the estimated amount of physical memory on the host saved
from copy-on-write (COW) shared guest physical memory. | [
"Retrieves",
"the",
"estimated",
"amount",
"of",
"physical",
"memory",
"on",
"the",
"host",
"saved",
"from",
"copy",
"-",
"on",
"-",
"write",
"(",
"COW",
")",
"shared",
"guest",
"physical",
"memory",
"."
] | train | https://github.com/dagwieers/vmguestlib/blob/2ba9333a745628cf9e6b4c767427a5bd997a71ad/vmguestlib.py#L393-L399 |
dagwieers/vmguestlib | vmguestlib.py | VMGuestLib.GetMemShares | def GetMemShares(self):
'''Retrieves the number of memory shares allocated to the virtual machine.
For information about how an ESX server uses memory shares to manage
virtual machine priority, see the vSphere Resource Management Guide.'''
counter = c_uint()
ret = vmGuestLi... | python | def GetMemShares(self):
'''Retrieves the number of memory shares allocated to the virtual machine.
For information about how an ESX server uses memory shares to manage
virtual machine priority, see the vSphere Resource Management Guide.'''
counter = c_uint()
ret = vmGuestLi... | [
"def",
"GetMemShares",
"(",
"self",
")",
":",
"counter",
"=",
"c_uint",
"(",
")",
"ret",
"=",
"vmGuestLib",
".",
"VMGuestLib_GetMemShares",
"(",
"self",
".",
"handle",
".",
"value",
",",
"byref",
"(",
"counter",
")",
")",
"if",
"ret",
"!=",
"VMGUESTLIB_E... | Retrieves the number of memory shares allocated to the virtual machine.
For information about how an ESX server uses memory shares to manage
virtual machine priority, see the vSphere Resource Management Guide. | [
"Retrieves",
"the",
"number",
"of",
"memory",
"shares",
"allocated",
"to",
"the",
"virtual",
"machine",
".",
"For",
"information",
"about",
"how",
"an",
"ESX",
"server",
"uses",
"memory",
"shares",
"to",
"manage",
"virtual",
"machine",
"priority",
"see",
"the"... | train | https://github.com/dagwieers/vmguestlib/blob/2ba9333a745628cf9e6b4c767427a5bd997a71ad/vmguestlib.py#L401-L408 |
dagwieers/vmguestlib | vmguestlib.py | VMGuestLib.GetMemSwappedMB | def GetMemSwappedMB(self):
'''Retrieves the amount of memory that has been reclaimed from this virtual
machine by transparently swapping guest memory to disk.'''
counter = c_uint()
ret = vmGuestLib.VMGuestLib_GetMemSwappedMB(self.handle.value, byref(counter))
if ret != VMGUEST... | python | def GetMemSwappedMB(self):
'''Retrieves the amount of memory that has been reclaimed from this virtual
machine by transparently swapping guest memory to disk.'''
counter = c_uint()
ret = vmGuestLib.VMGuestLib_GetMemSwappedMB(self.handle.value, byref(counter))
if ret != VMGUEST... | [
"def",
"GetMemSwappedMB",
"(",
"self",
")",
":",
"counter",
"=",
"c_uint",
"(",
")",
"ret",
"=",
"vmGuestLib",
".",
"VMGuestLib_GetMemSwappedMB",
"(",
"self",
".",
"handle",
".",
"value",
",",
"byref",
"(",
"counter",
")",
")",
"if",
"ret",
"!=",
"VMGUES... | Retrieves the amount of memory that has been reclaimed from this virtual
machine by transparently swapping guest memory to disk. | [
"Retrieves",
"the",
"amount",
"of",
"memory",
"that",
"has",
"been",
"reclaimed",
"from",
"this",
"virtual",
"machine",
"by",
"transparently",
"swapping",
"guest",
"memory",
"to",
"disk",
"."
] | train | https://github.com/dagwieers/vmguestlib/blob/2ba9333a745628cf9e6b4c767427a5bd997a71ad/vmguestlib.py#L410-L416 |
dagwieers/vmguestlib | vmguestlib.py | VMGuestLib.GetMemSwapTargetMB | def GetMemSwapTargetMB(self):
'''Undocumented.'''
counter = c_uint()
ret = vmGuestLib.VMGuestLib_GetMemSwapTargetMB(self.handle.value, byref(counter))
if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
return counter.value | python | def GetMemSwapTargetMB(self):
'''Undocumented.'''
counter = c_uint()
ret = vmGuestLib.VMGuestLib_GetMemSwapTargetMB(self.handle.value, byref(counter))
if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
return counter.value | [
"def",
"GetMemSwapTargetMB",
"(",
"self",
")",
":",
"counter",
"=",
"c_uint",
"(",
")",
"ret",
"=",
"vmGuestLib",
".",
"VMGuestLib_GetMemSwapTargetMB",
"(",
"self",
".",
"handle",
".",
"value",
",",
"byref",
"(",
"counter",
")",
")",
"if",
"ret",
"!=",
"... | Undocumented. | [
"Undocumented",
"."
] | train | https://github.com/dagwieers/vmguestlib/blob/2ba9333a745628cf9e6b4c767427a5bd997a71ad/vmguestlib.py#L419-L424 |
dagwieers/vmguestlib | vmguestlib.py | VMGuestLib.GetMemTargetSizeMB | def GetMemTargetSizeMB(self):
'''Retrieves the size of the target memory allocation for this virtual machine.'''
counter = c_uint()
ret = vmGuestLib.VMGuestLib_GetMemTargetSizeMB(self.handle.value, byref(counter))
if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
... | python | def GetMemTargetSizeMB(self):
'''Retrieves the size of the target memory allocation for this virtual machine.'''
counter = c_uint()
ret = vmGuestLib.VMGuestLib_GetMemTargetSizeMB(self.handle.value, byref(counter))
if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
... | [
"def",
"GetMemTargetSizeMB",
"(",
"self",
")",
":",
"counter",
"=",
"c_uint",
"(",
")",
"ret",
"=",
"vmGuestLib",
".",
"VMGuestLib_GetMemTargetSizeMB",
"(",
"self",
".",
"handle",
".",
"value",
",",
"byref",
"(",
"counter",
")",
")",
"if",
"ret",
"!=",
"... | Retrieves the size of the target memory allocation for this virtual machine. | [
"Retrieves",
"the",
"size",
"of",
"the",
"target",
"memory",
"allocation",
"for",
"this",
"virtual",
"machine",
"."
] | train | https://github.com/dagwieers/vmguestlib/blob/2ba9333a745628cf9e6b4c767427a5bd997a71ad/vmguestlib.py#L426-L431 |
dagwieers/vmguestlib | vmguestlib.py | VMGuestLib.GetMemUsedMB | def GetMemUsedMB(self):
'''Retrieves the estimated amount of physical host memory currently
consumed for this virtual machine's physical memory.'''
counter = c_uint()
ret = vmGuestLib.VMGuestLib_GetMemUsedMB(self.handle.value, byref(counter))
if ret != VMGUESTLIB_ERROR_SUCCESS... | python | def GetMemUsedMB(self):
'''Retrieves the estimated amount of physical host memory currently
consumed for this virtual machine's physical memory.'''
counter = c_uint()
ret = vmGuestLib.VMGuestLib_GetMemUsedMB(self.handle.value, byref(counter))
if ret != VMGUESTLIB_ERROR_SUCCESS... | [
"def",
"GetMemUsedMB",
"(",
"self",
")",
":",
"counter",
"=",
"c_uint",
"(",
")",
"ret",
"=",
"vmGuestLib",
".",
"VMGuestLib_GetMemUsedMB",
"(",
"self",
".",
"handle",
".",
"value",
",",
"byref",
"(",
"counter",
")",
")",
"if",
"ret",
"!=",
"VMGUESTLIB_E... | Retrieves the estimated amount of physical host memory currently
consumed for this virtual machine's physical memory. | [
"Retrieves",
"the",
"estimated",
"amount",
"of",
"physical",
"host",
"memory",
"currently",
"consumed",
"for",
"this",
"virtual",
"machine",
"s",
"physical",
"memory",
"."
] | train | https://github.com/dagwieers/vmguestlib/blob/2ba9333a745628cf9e6b4c767427a5bd997a71ad/vmguestlib.py#L433-L439 |
dagwieers/vmguestlib | vmguestlib.py | VMGuestLib.GetMemZippedMB | def GetMemZippedMB(self):
'''Undocumented.'''
counter = c_uint()
ret = vmGuestLib.VMGuestLib_GetMemZippedMB(self.handle.value, byref(counter))
if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
return counter.value | python | def GetMemZippedMB(self):
'''Undocumented.'''
counter = c_uint()
ret = vmGuestLib.VMGuestLib_GetMemZippedMB(self.handle.value, byref(counter))
if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
return counter.value | [
"def",
"GetMemZippedMB",
"(",
"self",
")",
":",
"counter",
"=",
"c_uint",
"(",
")",
"ret",
"=",
"vmGuestLib",
".",
"VMGuestLib_GetMemZippedMB",
"(",
"self",
".",
"handle",
".",
"value",
",",
"byref",
"(",
"counter",
")",
")",
"if",
"ret",
"!=",
"VMGUESTL... | Undocumented. | [
"Undocumented",
"."
] | train | https://github.com/dagwieers/vmguestlib/blob/2ba9333a745628cf9e6b4c767427a5bd997a71ad/vmguestlib.py#L442-L447 |
dagwieers/vmguestlib | vmguestlib.py | VMGuestLib.GetMemZipSavedMB | def GetMemZipSavedMB(self):
'''Undocumented.'''
counter = c_uint()
ret = vmGuestLib.VMGuestLib_GetMemZipSavedMB(self.handle.value, byref(counter))
if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
return counter.value | python | def GetMemZipSavedMB(self):
'''Undocumented.'''
counter = c_uint()
ret = vmGuestLib.VMGuestLib_GetMemZipSavedMB(self.handle.value, byref(counter))
if ret != VMGUESTLIB_ERROR_SUCCESS: raise VMGuestLibException(ret)
return counter.value | [
"def",
"GetMemZipSavedMB",
"(",
"self",
")",
":",
"counter",
"=",
"c_uint",
"(",
")",
"ret",
"=",
"vmGuestLib",
".",
"VMGuestLib_GetMemZipSavedMB",
"(",
"self",
".",
"handle",
".",
"value",
",",
"byref",
"(",
"counter",
")",
")",
"if",
"ret",
"!=",
"VMGU... | Undocumented. | [
"Undocumented",
"."
] | train | https://github.com/dagwieers/vmguestlib/blob/2ba9333a745628cf9e6b4c767427a5bd997a71ad/vmguestlib.py#L450-L455 |
markchil/gptools | gptools/splines.py | spev | def spev(t_int, C, deg, x, cov_C=None, M_spline=False, I_spline=False, n=0):
"""Evaluate a B-, M- or I-spline with the specified internal knots, order and coefficients.
`deg` boundary knots are appended at both sides of the domain.
The zeroth order basis functions are modified to ensure continuity... | python | def spev(t_int, C, deg, x, cov_C=None, M_spline=False, I_spline=False, n=0):
"""Evaluate a B-, M- or I-spline with the specified internal knots, order and coefficients.
`deg` boundary knots are appended at both sides of the domain.
The zeroth order basis functions are modified to ensure continuity... | [
"def",
"spev",
"(",
"t_int",
",",
"C",
",",
"deg",
",",
"x",
",",
"cov_C",
"=",
"None",
",",
"M_spline",
"=",
"False",
",",
"I_spline",
"=",
"False",
",",
"n",
"=",
"0",
")",
":",
"C",
"=",
"scipy",
".",
"asarray",
"(",
"C",
",",
"dtype",
"="... | Evaluate a B-, M- or I-spline with the specified internal knots, order and coefficients.
`deg` boundary knots are appended at both sides of the domain.
The zeroth order basis functions are modified to ensure continuity at the
right-hand boundary.
Note that the I-splines include the :math:... | [
"Evaluate",
"a",
"B",
"-",
"M",
"-",
"or",
"I",
"-",
"spline",
"with",
"the",
"specified",
"internal",
"knots",
"order",
"and",
"coefficients",
".",
"deg",
"boundary",
"knots",
"are",
"appended",
"at",
"both",
"sides",
"of",
"the",
"domain",
".",
"The",
... | train | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/splines.py#L5-L146 |
coursera/courseraoauth2client | courseraoauth2client/commands/version.py | parser | def parser(subparsers):
"Build an argparse argument parser to parse the command line."
# create the parser for the version subcommand.
parser_version = subparsers.add_parser(
'version',
help="Output the version of %(prog)s to the console.")
parser_version.set_defaults(func=command_versi... | python | def parser(subparsers):
"Build an argparse argument parser to parse the command line."
# create the parser for the version subcommand.
parser_version = subparsers.add_parser(
'version',
help="Output the version of %(prog)s to the console.")
parser_version.set_defaults(func=command_versi... | [
"def",
"parser",
"(",
"subparsers",
")",
":",
"# create the parser for the version subcommand.",
"parser_version",
"=",
"subparsers",
".",
"add_parser",
"(",
"'version'",
",",
"help",
"=",
"\"Output the version of %(prog)s to the console.\"",
")",
"parser_version",
".",
"se... | Build an argparse argument parser to parse the command line. | [
"Build",
"an",
"argparse",
"argument",
"parser",
"to",
"parse",
"the",
"command",
"line",
"."
] | train | https://github.com/coursera/courseraoauth2client/blob/4edd991defe26bfc768ab28a30368cace40baf44/courseraoauth2client/commands/version.py#L53-L62 |
CTPUG/wafer | wafer/registration/templatetags/wafer_crispy.py | wafer_form_helper | def wafer_form_helper(context, helper_name):
'''
Find the specified Crispy FormHelper and instantiate it.
Handy when you are crispyifying other apps' forms.
'''
request = context.request
module, class_name = helper_name.rsplit('.', 1)
if module not in sys.modules:
__import__(module)
... | python | def wafer_form_helper(context, helper_name):
'''
Find the specified Crispy FormHelper and instantiate it.
Handy when you are crispyifying other apps' forms.
'''
request = context.request
module, class_name = helper_name.rsplit('.', 1)
if module not in sys.modules:
__import__(module)
... | [
"def",
"wafer_form_helper",
"(",
"context",
",",
"helper_name",
")",
":",
"request",
"=",
"context",
".",
"request",
"module",
",",
"class_name",
"=",
"helper_name",
".",
"rsplit",
"(",
"'.'",
",",
"1",
")",
"if",
"module",
"not",
"in",
"sys",
".",
"modu... | Find the specified Crispy FormHelper and instantiate it.
Handy when you are crispyifying other apps' forms. | [
"Find",
"the",
"specified",
"Crispy",
"FormHelper",
"and",
"instantiate",
"it",
".",
"Handy",
"when",
"you",
"are",
"crispyifying",
"other",
"apps",
"forms",
"."
] | train | https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/registration/templatetags/wafer_crispy.py#L8-L19 |
CTPUG/wafer | wafer/pages/models.py | page_menus | def page_menus(root_menu):
"""Add page menus."""
for page in Page.objects.filter(include_in_menu=True):
path = page.get_path()
menu = path[0] if len(path) > 1 else None
try:
root_menu.add_item(page.name, page.get_absolute_url(), menu=menu)
except MenuError as e:
... | python | def page_menus(root_menu):
"""Add page menus."""
for page in Page.objects.filter(include_in_menu=True):
path = page.get_path()
menu = path[0] if len(path) > 1 else None
try:
root_menu.add_item(page.name, page.get_absolute_url(), menu=menu)
except MenuError as e:
... | [
"def",
"page_menus",
"(",
"root_menu",
")",
":",
"for",
"page",
"in",
"Page",
".",
"objects",
".",
"filter",
"(",
"include_in_menu",
"=",
"True",
")",
":",
"path",
"=",
"page",
".",
"get_path",
"(",
")",
"menu",
"=",
"path",
"[",
"0",
"]",
"if",
"l... | Add page menus. | [
"Add",
"page",
"menus",
"."
] | train | https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/pages/models.py#L162-L171 |
CTPUG/wafer | wafer/registration/views.py | redirect_profile | def redirect_profile(request):
'''
The default destination from logging in, redirect to the actual profile URL
'''
if request.user.is_authenticated:
return HttpResponseRedirect(reverse('wafer_user_profile',
args=(request.user.username,)))
else:
... | python | def redirect_profile(request):
'''
The default destination from logging in, redirect to the actual profile URL
'''
if request.user.is_authenticated:
return HttpResponseRedirect(reverse('wafer_user_profile',
args=(request.user.username,)))
else:
... | [
"def",
"redirect_profile",
"(",
"request",
")",
":",
"if",
"request",
".",
"user",
".",
"is_authenticated",
":",
"return",
"HttpResponseRedirect",
"(",
"reverse",
"(",
"'wafer_user_profile'",
",",
"args",
"=",
"(",
"request",
".",
"user",
".",
"username",
",",... | The default destination from logging in, redirect to the actual profile URL | [
"The",
"default",
"destination",
"from",
"logging",
"in",
"redirect",
"to",
"the",
"actual",
"profile",
"URL"
] | train | https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/registration/views.py#L12-L20 |
CTPUG/wafer | wafer/talks/templatetags/review.py | reviewed_badge | def reviewed_badge(user, talk):
"""Returns a badge for the user's reviews of the talk"""
context = {
'reviewed': False,
}
review = None
if user and not user.is_anonymous():
review = talk.reviews.filter(reviewer=user).first()
if review:
context['reviewed'] = True
... | python | def reviewed_badge(user, talk):
"""Returns a badge for the user's reviews of the talk"""
context = {
'reviewed': False,
}
review = None
if user and not user.is_anonymous():
review = talk.reviews.filter(reviewer=user).first()
if review:
context['reviewed'] = True
... | [
"def",
"reviewed_badge",
"(",
"user",
",",
"talk",
")",
":",
"context",
"=",
"{",
"'reviewed'",
":",
"False",
",",
"}",
"review",
"=",
"None",
"if",
"user",
"and",
"not",
"user",
".",
"is_anonymous",
"(",
")",
":",
"review",
"=",
"talk",
".",
"review... | Returns a badge for the user's reviews of the talk | [
"Returns",
"a",
"badge",
"for",
"the",
"user",
"s",
"reviews",
"of",
"the",
"talk"
] | train | https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/talks/templatetags/review.py#L7-L21 |
markchil/gptools | gptools/kernel/warping.py | beta_cdf_warp | def beta_cdf_warp(X, d, n, *args):
r"""Warp inputs that are confined to the unit hypercube using the regularized incomplete beta function.
Applies separately to each dimension, designed for use with
:py:class:`WarpingFunction`.
Assumes that your inputs `X` lie entirely within the unit hypercub... | python | def beta_cdf_warp(X, d, n, *args):
r"""Warp inputs that are confined to the unit hypercube using the regularized incomplete beta function.
Applies separately to each dimension, designed for use with
:py:class:`WarpingFunction`.
Assumes that your inputs `X` lie entirely within the unit hypercub... | [
"def",
"beta_cdf_warp",
"(",
"X",
",",
"d",
",",
"n",
",",
"*",
"args",
")",
":",
"X",
"=",
"scipy",
".",
"asarray",
"(",
"X",
")",
"a",
"=",
"args",
"[",
"2",
"*",
"d",
"]",
"b",
"=",
"args",
"[",
"2",
"*",
"d",
"+",
"1",
"]",
"if",
"n... | r"""Warp inputs that are confined to the unit hypercube using the regularized incomplete beta function.
Applies separately to each dimension, designed for use with
:py:class:`WarpingFunction`.
Assumes that your inputs `X` lie entirely within the unit hypercube [0, 1].
Note that you may ex... | [
"r",
"Warp",
"inputs",
"that",
"are",
"confined",
"to",
"the",
"unit",
"hypercube",
"using",
"the",
"regularized",
"incomplete",
"beta",
"function",
".",
"Applies",
"separately",
"to",
"each",
"dimension",
"designed",
"for",
"use",
"with",
":",
"py",
":",
"c... | train | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/kernel/warping.py#L315-L365 |
markchil/gptools | gptools/kernel/warping.py | linear_warp | def linear_warp(X, d, n, *args):
r"""Warp inputs with a linear transformation.
Applies the warping
.. math::
w(x) = \frac{x-a}{b-a}
to each dimension. If you set `a=min(X)` and `b=max(X)` then this is a
convenient way to map your inputs to the unit hypercube.
... | python | def linear_warp(X, d, n, *args):
r"""Warp inputs with a linear transformation.
Applies the warping
.. math::
w(x) = \frac{x-a}{b-a}
to each dimension. If you set `a=min(X)` and `b=max(X)` then this is a
convenient way to map your inputs to the unit hypercube.
... | [
"def",
"linear_warp",
"(",
"X",
",",
"d",
",",
"n",
",",
"*",
"args",
")",
":",
"X",
"=",
"scipy",
".",
"asarray",
"(",
"X",
",",
"dtype",
"=",
"float",
")",
"a",
"=",
"args",
"[",
"2",
"*",
"d",
"]",
"b",
"=",
"args",
"[",
"2",
"*",
"d",... | r"""Warp inputs with a linear transformation.
Applies the warping
.. math::
w(x) = \frac{x-a}{b-a}
to each dimension. If you set `a=min(X)` and `b=max(X)` then this is a
convenient way to map your inputs to the unit hypercube.
Parameters
----------
X : ar... | [
"r",
"Warp",
"inputs",
"with",
"a",
"linear",
"transformation",
".",
"Applies",
"the",
"warping",
"..",
"math",
"::",
"w",
"(",
"x",
")",
"=",
"\\",
"frac",
"{",
"x",
"-",
"a",
"}",
"{",
"b",
"-",
"a",
"}",
"to",
"each",
"dimension",
".",
"If",
... | train | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/kernel/warping.py#L367-L402 |
markchil/gptools | gptools/kernel/warping.py | WarpedKernel.w_func | def w_func(self, X, d, n):
"""Evaluate the (possibly recursive) warping function and its derivatives.
Parameters
----------
X : array, (`M`,)
The points (from dimension `d`) to evaluate the warping function at.
d : int
The dimension to warp.
... | python | def w_func(self, X, d, n):
"""Evaluate the (possibly recursive) warping function and its derivatives.
Parameters
----------
X : array, (`M`,)
The points (from dimension `d`) to evaluate the warping function at.
d : int
The dimension to warp.
... | [
"def",
"w_func",
"(",
"self",
",",
"X",
",",
"d",
",",
"n",
")",
":",
"if",
"n",
"==",
"0",
":",
"wX",
"=",
"self",
".",
"w",
"(",
"X",
",",
"d",
",",
"0",
")",
"if",
"isinstance",
"(",
"self",
".",
"k",
",",
"WarpedKernel",
")",
":",
"wX... | Evaluate the (possibly recursive) warping function and its derivatives.
Parameters
----------
X : array, (`M`,)
The points (from dimension `d`) to evaluate the warping function at.
d : int
The dimension to warp.
n : int
The derivative ... | [
"Evaluate",
"the",
"(",
"possibly",
"recursive",
")",
"warping",
"function",
"and",
"its",
"derivatives",
".",
"Parameters",
"----------",
"X",
":",
"array",
"(",
"M",
")",
"The",
"points",
"(",
"from",
"dimension",
"d",
")",
"to",
"evaluate",
"the",
"warp... | train | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/kernel/warping.py#L507-L531 |
markchil/gptools | gptools/kernel/warping.py | WarpedKernel.enforce_bounds | def enforce_bounds(self, v):
"""Set `enforce_bounds` for both of the kernels to a new value.
"""
self._enforce_bounds = v
self.k.enforce_bounds = v
self.w.enforce_bounds = v | python | def enforce_bounds(self, v):
"""Set `enforce_bounds` for both of the kernels to a new value.
"""
self._enforce_bounds = v
self.k.enforce_bounds = v
self.w.enforce_bounds = v | [
"def",
"enforce_bounds",
"(",
"self",
",",
"v",
")",
":",
"self",
".",
"_enforce_bounds",
"=",
"v",
"self",
".",
"k",
".",
"enforce_bounds",
"=",
"v",
"self",
".",
"w",
".",
"enforce_bounds",
"=",
"v"
] | Set `enforce_bounds` for both of the kernels to a new value. | [
"Set",
"enforce_bounds",
"for",
"both",
"of",
"the",
"kernels",
"to",
"a",
"new",
"value",
"."
] | train | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/kernel/warping.py#L540-L545 |
markchil/gptools | gptools/kernel/warping.py | WarpedKernel.free_params | def free_params(self, value):
"""Set the free parameters. Note that this bypasses enforce_bounds.
"""
value = scipy.asarray(value, dtype=float)
self.K_up_to_date = False
self.k.free_params = value[:self.k.num_free_params]
self.w.free_params = value[self.k.num_free_params:... | python | def free_params(self, value):
"""Set the free parameters. Note that this bypasses enforce_bounds.
"""
value = scipy.asarray(value, dtype=float)
self.K_up_to_date = False
self.k.free_params = value[:self.k.num_free_params]
self.w.free_params = value[self.k.num_free_params:... | [
"def",
"free_params",
"(",
"self",
",",
"value",
")",
":",
"value",
"=",
"scipy",
".",
"asarray",
"(",
"value",
",",
"dtype",
"=",
"float",
")",
"self",
".",
"K_up_to_date",
"=",
"False",
"self",
".",
"k",
".",
"free_params",
"=",
"value",
"[",
":",
... | Set the free parameters. Note that this bypasses enforce_bounds. | [
"Set",
"the",
"free",
"parameters",
".",
"Note",
"that",
"this",
"bypasses",
"enforce_bounds",
"."
] | train | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/kernel/warping.py#L582-L588 |
markchil/gptools | gptools/kernel/warping.py | WarpedKernel.set_hyperparams | def set_hyperparams(self, new_params):
"""Set the (free) hyperparameters.
Parameters
----------
new_params : :py:class:`Array` or other Array-like
New values of the free parameters.
Raises
------
ValueError
If the length o... | python | def set_hyperparams(self, new_params):
"""Set the (free) hyperparameters.
Parameters
----------
new_params : :py:class:`Array` or other Array-like
New values of the free parameters.
Raises
------
ValueError
If the length o... | [
"def",
"set_hyperparams",
"(",
"self",
",",
"new_params",
")",
":",
"new_params",
"=",
"scipy",
".",
"asarray",
"(",
"new_params",
",",
"dtype",
"=",
"float",
")",
"if",
"len",
"(",
"new_params",
")",
"==",
"len",
"(",
"self",
".",
"free_params",
")",
... | Set the (free) hyperparameters.
Parameters
----------
new_params : :py:class:`Array` or other Array-like
New values of the free parameters.
Raises
------
ValueError
If the length of `new_params` is not consistent with :py:attr:`se... | [
"Set",
"the",
"(",
"free",
")",
"hyperparameters",
".",
"Parameters",
"----------",
"new_params",
":",
":",
"py",
":",
"class",
":",
"Array",
"or",
"other",
"Array",
"-",
"like",
"New",
"values",
"of",
"the",
"free",
"parameters",
".",
"Raises",
"------",
... | train | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/kernel/warping.py#L611-L631 |
codenerix/django-codenerix | codenerix/multiforms.py | MultiForm.get | def get(self, request, *args, **kwargs):
"""
Handles GET requests and instantiates blank versions of the form and its inline formsets.
"""
# Prepare base
if 'pk' in kwargs:
self.object = self.get_object()
else:
self.object = None
form_clas... | python | def get(self, request, *args, **kwargs):
"""
Handles GET requests and instantiates blank versions of the form and its inline formsets.
"""
# Prepare base
if 'pk' in kwargs:
self.object = self.get_object()
else:
self.object = None
form_clas... | [
"def",
"get",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# Prepare base",
"if",
"'pk'",
"in",
"kwargs",
":",
"self",
".",
"object",
"=",
"self",
".",
"get_object",
"(",
")",
"else",
":",
"self",
".",
"object"... | Handles GET requests and instantiates blank versions of the form and its inline formsets. | [
"Handles",
"GET",
"requests",
"and",
"instantiates",
"blank",
"versions",
"of",
"the",
"form",
"and",
"its",
"inline",
"formsets",
"."
] | train | https://github.com/codenerix/django-codenerix/blob/1f5527b352141caaee902b37b2648791a06bd57d/codenerix/multiforms.py#L51-L160 |
codenerix/django-codenerix | codenerix/multiforms.py | MultiForm.post | def post(self, request, *args, **kwargs):
"""
andles POST requests, instantiating a form instance and its inline formsets with the passed POST variables and then checking them for validity.
"""
# Prepare base
if 'pk' in kwargs:
self.object = self.get_object()
... | python | def post(self, request, *args, **kwargs):
"""
andles POST requests, instantiating a form instance and its inline formsets with the passed POST variables and then checking them for validity.
"""
# Prepare base
if 'pk' in kwargs:
self.object = self.get_object()
... | [
"def",
"post",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# Prepare base",
"if",
"'pk'",
"in",
"kwargs",
":",
"self",
".",
"object",
"=",
"self",
".",
"get_object",
"(",
")",
"else",
":",
"self",
".",
"object... | andles POST requests, instantiating a form instance and its inline formsets with the passed POST variables and then checking them for validity. | [
"andles",
"POST",
"requests",
"instantiating",
"a",
"form",
"instance",
"and",
"its",
"inline",
"formsets",
"with",
"the",
"passed",
"POST",
"variables",
"and",
"then",
"checking",
"them",
"for",
"validity",
"."
] | train | https://github.com/codenerix/django-codenerix/blob/1f5527b352141caaee902b37b2648791a06bd57d/codenerix/multiforms.py#L162-L309 |
codenerix/django-codenerix | codenerix/multiforms.py | MultiForm.form_valid | def form_valid(self, form, forms):
"""
Called if all forms are valid. Creates a Recipe instance along with associated Ingredients and Instructions and then redirects to a success page.
"""
if self.object:
form.save()
for (formobj, linkerfield) in forms:
... | python | def form_valid(self, form, forms):
"""
Called if all forms are valid. Creates a Recipe instance along with associated Ingredients and Instructions and then redirects to a success page.
"""
if self.object:
form.save()
for (formobj, linkerfield) in forms:
... | [
"def",
"form_valid",
"(",
"self",
",",
"form",
",",
"forms",
")",
":",
"if",
"self",
".",
"object",
":",
"form",
".",
"save",
"(",
")",
"for",
"(",
"formobj",
",",
"linkerfield",
")",
"in",
"forms",
":",
"if",
"form",
"!=",
"formobj",
":",
"formobj... | Called if all forms are valid. Creates a Recipe instance along with associated Ingredients and Instructions and then redirects to a success page. | [
"Called",
"if",
"all",
"forms",
"are",
"valid",
".",
"Creates",
"a",
"Recipe",
"instance",
"along",
"with",
"associated",
"Ingredients",
"and",
"Instructions",
"and",
"then",
"redirects",
"to",
"a",
"success",
"page",
"."
] | train | https://github.com/codenerix/django-codenerix/blob/1f5527b352141caaee902b37b2648791a06bd57d/codenerix/multiforms.py#L312-L327 |
codenerix/django-codenerix | codenerix/multiforms.py | MultiForm.form_invalid | def form_invalid(self, form, forms, open_tabs, position_form_default):
"""
Called if a form is invalid. Re-renders the context data with the data-filled forms and errors.
"""
# return self.render_to_response( self.get_context_data( form = form, forms = forms ) )
return self.rende... | python | def form_invalid(self, form, forms, open_tabs, position_form_default):
"""
Called if a form is invalid. Re-renders the context data with the data-filled forms and errors.
"""
# return self.render_to_response( self.get_context_data( form = form, forms = forms ) )
return self.rende... | [
"def",
"form_invalid",
"(",
"self",
",",
"form",
",",
"forms",
",",
"open_tabs",
",",
"position_form_default",
")",
":",
"# return self.render_to_response( self.get_context_data( form = form, forms = forms ) )",
"return",
"self",
".",
"render_to_response",
"(",
"self",
".",... | Called if a form is invalid. Re-renders the context data with the data-filled forms and errors. | [
"Called",
"if",
"a",
"form",
"is",
"invalid",
".",
"Re",
"-",
"renders",
"the",
"context",
"data",
"with",
"the",
"data",
"-",
"filled",
"forms",
"and",
"errors",
"."
] | train | https://github.com/codenerix/django-codenerix/blob/1f5527b352141caaee902b37b2648791a06bd57d/codenerix/multiforms.py#L329-L334 |
markchil/gptools | gptools/utils.py | wrap_fmin_slsqp | def wrap_fmin_slsqp(fun, guess, opt_kwargs={}):
"""Wrapper for :py:func:`fmin_slsqp` to allow it to be called with :py:func:`minimize`-like syntax.
This is included to enable the code to run with :py:mod:`scipy` versions
older than 0.11.0.
Accepts `opt_kwargs` in the same format as used by
:py:fun... | python | def wrap_fmin_slsqp(fun, guess, opt_kwargs={}):
"""Wrapper for :py:func:`fmin_slsqp` to allow it to be called with :py:func:`minimize`-like syntax.
This is included to enable the code to run with :py:mod:`scipy` versions
older than 0.11.0.
Accepts `opt_kwargs` in the same format as used by
:py:fun... | [
"def",
"wrap_fmin_slsqp",
"(",
"fun",
",",
"guess",
",",
"opt_kwargs",
"=",
"{",
"}",
")",
":",
"opt_kwargs",
"=",
"dict",
"(",
"opt_kwargs",
")",
"opt_kwargs",
".",
"pop",
"(",
"'method'",
",",
"None",
")",
"eqcons",
"=",
"[",
"]",
"ieqcons",
"=",
"... | Wrapper for :py:func:`fmin_slsqp` to allow it to be called with :py:func:`minimize`-like syntax.
This is included to enable the code to run with :py:mod:`scipy` versions
older than 0.11.0.
Accepts `opt_kwargs` in the same format as used by
:py:func:`scipy.optimize.minimize`, with the additional precon... | [
"Wrapper",
"for",
":",
"py",
":",
"func",
":",
"fmin_slsqp",
"to",
"allow",
"it",
"to",
"be",
"called",
"with",
":",
"py",
":",
"func",
":",
"minimize",
"-",
"like",
"syntax",
"."
] | train | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L1269-L1367 |
markchil/gptools | gptools/utils.py | fixed_poch | def fixed_poch(a, n):
"""Implementation of the Pochhammer symbol :math:`(a)_n` which handles negative integer arguments properly.
Need conditional statement because scipy's impelementation of the Pochhammer
symbol is wrong for negative integer arguments. This function uses the
definition from
h... | python | def fixed_poch(a, n):
"""Implementation of the Pochhammer symbol :math:`(a)_n` which handles negative integer arguments properly.
Need conditional statement because scipy's impelementation of the Pochhammer
symbol is wrong for negative integer arguments. This function uses the
definition from
h... | [
"def",
"fixed_poch",
"(",
"a",
",",
"n",
")",
":",
"# Old form, calls gamma function:",
"# if a < 0.0 and a % 1 == 0 and n <= -a:",
"# p = (-1.0)**n * scipy.misc.factorial(-a) / scipy.misc.factorial(-a - n)",
"# else:",
"# p = scipy.special.poch(a, n)",
"# return p",
"if",
"(",... | Implementation of the Pochhammer symbol :math:`(a)_n` which handles negative integer arguments properly.
Need conditional statement because scipy's impelementation of the Pochhammer
symbol is wrong for negative integer arguments. This function uses the
definition from
http://functions.wolfram.com/G... | [
"Implementation",
"of",
"the",
"Pochhammer",
"symbol",
":",
"math",
":",
"(",
"a",
")",
"_n",
"which",
"handles",
"negative",
"integer",
"arguments",
"properly",
".",
"Need",
"conditional",
"statement",
"because",
"scipy",
"s",
"impelementation",
"of",
"the",
... | train | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L1369-L1395 |
markchil/gptools | gptools/utils.py | Kn2Der | def Kn2Der(nu, y, n=0):
r"""Find the derivatives of :math:`K_\nu(y^{1/2})`.
Parameters
----------
nu : float
The order of the modified Bessel function of the second kind.
y : array of float
The values to evaluate at.
n : nonnegative int, optional
The order of derivat... | python | def Kn2Der(nu, y, n=0):
r"""Find the derivatives of :math:`K_\nu(y^{1/2})`.
Parameters
----------
nu : float
The order of the modified Bessel function of the second kind.
y : array of float
The values to evaluate at.
n : nonnegative int, optional
The order of derivat... | [
"def",
"Kn2Der",
"(",
"nu",
",",
"y",
",",
"n",
"=",
"0",
")",
":",
"n",
"=",
"int",
"(",
"n",
")",
"y",
"=",
"scipy",
".",
"asarray",
"(",
"y",
",",
"dtype",
"=",
"float",
")",
"sqrty",
"=",
"scipy",
".",
"sqrt",
"(",
"y",
")",
"if",
"n"... | r"""Find the derivatives of :math:`K_\nu(y^{1/2})`.
Parameters
----------
nu : float
The order of the modified Bessel function of the second kind.
y : array of float
The values to evaluate at.
n : nonnegative int, optional
The order of derivative to take. | [
"r",
"Find",
"the",
"derivatives",
"of",
":",
"math",
":",
"K_",
"\\",
"nu",
"(",
"y^",
"{",
"1",
"/",
"2",
"}",
")",
".",
"Parameters",
"----------",
"nu",
":",
"float",
"The",
"order",
"of",
"the",
"modified",
"Bessel",
"function",
"of",
"the",
"... | train | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L1397-L1427 |
markchil/gptools | gptools/utils.py | yn2Kn2Der | def yn2Kn2Der(nu, y, n=0, tol=5e-4, nterms=1, nu_step=0.001):
r"""Computes the function :math:`y^{\nu/2} K_{\nu}(y^{1/2})` and its derivatives.
Care has been taken to handle the conditions at :math:`y=0`.
For `n=0`, uses a direct evaluation of the expression, replacing points
where `y=0` with ... | python | def yn2Kn2Der(nu, y, n=0, tol=5e-4, nterms=1, nu_step=0.001):
r"""Computes the function :math:`y^{\nu/2} K_{\nu}(y^{1/2})` and its derivatives.
Care has been taken to handle the conditions at :math:`y=0`.
For `n=0`, uses a direct evaluation of the expression, replacing points
where `y=0` with ... | [
"def",
"yn2Kn2Der",
"(",
"nu",
",",
"y",
",",
"n",
"=",
"0",
",",
"tol",
"=",
"5e-4",
",",
"nterms",
"=",
"1",
",",
"nu_step",
"=",
"0.001",
")",
":",
"n",
"=",
"int",
"(",
"n",
")",
"y",
"=",
"scipy",
".",
"asarray",
"(",
"y",
",",
"dtype"... | r"""Computes the function :math:`y^{\nu/2} K_{\nu}(y^{1/2})` and its derivatives.
Care has been taken to handle the conditions at :math:`y=0`.
For `n=0`, uses a direct evaluation of the expression, replacing points
where `y=0` with the appropriate value. For `n>0`, uses a general sum
expressio... | [
"r",
"Computes",
"the",
"function",
":",
"math",
":",
"y^",
"{",
"\\",
"nu",
"/",
"2",
"}",
"K_",
"{",
"\\",
"nu",
"}",
"(",
"y^",
"{",
"1",
"/",
"2",
"}",
")",
"and",
"its",
"derivatives",
".",
"Care",
"has",
"been",
"taken",
"to",
"handle",
... | train | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L1429-L1518 |
markchil/gptools | gptools/utils.py | incomplete_bell_poly | def incomplete_bell_poly(n, k, x):
r"""Recursive evaluation of the incomplete Bell polynomial :math:`B_{n, k}(x)`.
Evaluates the incomplete Bell polynomial :math:`B_{n, k}(x_1, x_2, \dots, x_{n-k+1})`,
also known as the partial Bell polynomial or the Bell polynomial of the
second kind. This polynom... | python | def incomplete_bell_poly(n, k, x):
r"""Recursive evaluation of the incomplete Bell polynomial :math:`B_{n, k}(x)`.
Evaluates the incomplete Bell polynomial :math:`B_{n, k}(x_1, x_2, \dots, x_{n-k+1})`,
also known as the partial Bell polynomial or the Bell polynomial of the
second kind. This polynom... | [
"def",
"incomplete_bell_poly",
"(",
"n",
",",
"k",
",",
"x",
")",
":",
"if",
"n",
"==",
"0",
"and",
"k",
"==",
"0",
":",
"return",
"scipy",
".",
"ones",
"(",
"x",
".",
"shape",
"[",
"0",
"]",
",",
"dtype",
"=",
"float",
")",
"elif",
"k",
"=="... | r"""Recursive evaluation of the incomplete Bell polynomial :math:`B_{n, k}(x)`.
Evaluates the incomplete Bell polynomial :math:`B_{n, k}(x_1, x_2, \dots, x_{n-k+1})`,
also known as the partial Bell polynomial or the Bell polynomial of the
second kind. This polynomial is useful in the evaluation of (the... | [
"r",
"Recursive",
"evaluation",
"of",
"the",
"incomplete",
"Bell",
"polynomial",
":",
"math",
":",
"B_",
"{",
"n",
"k",
"}",
"(",
"x",
")",
".",
"Evaluates",
"the",
"incomplete",
"Bell",
"polynomial",
":",
"math",
":",
"B_",
"{",
"n",
"k",
"}",
"(",
... | train | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L1520-L1570 |
markchil/gptools | gptools/utils.py | generate_set_partition_strings | def generate_set_partition_strings(n):
"""Generate the restricted growth strings for all of the partitions of an `n`-member set.
Uses Algorithm H from page 416 of volume 4A of Knuth's `The Art of Computer
Programming`. Returns the partitions in lexicographical order.
Parameters
----------
... | python | def generate_set_partition_strings(n):
"""Generate the restricted growth strings for all of the partitions of an `n`-member set.
Uses Algorithm H from page 416 of volume 4A of Knuth's `The Art of Computer
Programming`. Returns the partitions in lexicographical order.
Parameters
----------
... | [
"def",
"generate_set_partition_strings",
"(",
"n",
")",
":",
"# Handle edge cases:",
"if",
"n",
"==",
"0",
":",
"return",
"[",
"]",
"elif",
"n",
"==",
"1",
":",
"return",
"[",
"scipy",
".",
"array",
"(",
"[",
"0",
"]",
")",
"]",
"partitions",
"=",
"[... | Generate the restricted growth strings for all of the partitions of an `n`-member set.
Uses Algorithm H from page 416 of volume 4A of Knuth's `The Art of Computer
Programming`. Returns the partitions in lexicographical order.
Parameters
----------
n : scalar int, non-negative
Numbe... | [
"Generate",
"the",
"restricted",
"growth",
"strings",
"for",
"all",
"of",
"the",
"partitions",
"of",
"an",
"n",
"-",
"member",
"set",
".",
"Uses",
"Algorithm",
"H",
"from",
"page",
"416",
"of",
"volume",
"4A",
"of",
"Knuth",
"s",
"The",
"Art",
"of",
"C... | train | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L1572-L1624 |
markchil/gptools | gptools/utils.py | generate_set_partitions | def generate_set_partitions(set_):
"""Generate all of the partitions of a set.
This is a helper function that utilizes the restricted growth strings from
:py:func:`generate_set_partition_strings`. The partitions are returned in
lexicographic order.
Parameters
----------
set_ : :py:... | python | def generate_set_partitions(set_):
"""Generate all of the partitions of a set.
This is a helper function that utilizes the restricted growth strings from
:py:func:`generate_set_partition_strings`. The partitions are returned in
lexicographic order.
Parameters
----------
set_ : :py:... | [
"def",
"generate_set_partitions",
"(",
"set_",
")",
":",
"set_",
"=",
"scipy",
".",
"asarray",
"(",
"set_",
")",
"strings",
"=",
"generate_set_partition_strings",
"(",
"len",
"(",
"set_",
")",
")",
"partitions",
"=",
"[",
"]",
"for",
"string",
"in",
"strin... | Generate all of the partitions of a set.
This is a helper function that utilizes the restricted growth strings from
:py:func:`generate_set_partition_strings`. The partitions are returned in
lexicographic order.
Parameters
----------
set_ : :py:class:`Array` or other Array-like, (`m`,)
... | [
"Generate",
"all",
"of",
"the",
"partitions",
"of",
"a",
"set",
".",
"This",
"is",
"a",
"helper",
"function",
"that",
"utilizes",
"the",
"restricted",
"growth",
"strings",
"from",
":",
"py",
":",
"func",
":",
"generate_set_partition_strings",
".",
"The",
"pa... | train | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L1626-L1656 |
markchil/gptools | gptools/utils.py | unique_rows | def unique_rows(arr, return_index=False, return_inverse=False):
"""Returns a copy of arr with duplicate rows removed.
From Stackoverflow "Find unique rows in numpy.array."
Parameters
----------
arr : :py:class:`Array`, (`m`, `n`)
The array to find the unique rows of.
return_ind... | python | def unique_rows(arr, return_index=False, return_inverse=False):
"""Returns a copy of arr with duplicate rows removed.
From Stackoverflow "Find unique rows in numpy.array."
Parameters
----------
arr : :py:class:`Array`, (`m`, `n`)
The array to find the unique rows of.
return_ind... | [
"def",
"unique_rows",
"(",
"arr",
",",
"return_index",
"=",
"False",
",",
"return_inverse",
"=",
"False",
")",
":",
"b",
"=",
"scipy",
".",
"ascontiguousarray",
"(",
"arr",
")",
".",
"view",
"(",
"scipy",
".",
"dtype",
"(",
"(",
"scipy",
".",
"void",
... | Returns a copy of arr with duplicate rows removed.
From Stackoverflow "Find unique rows in numpy.array."
Parameters
----------
arr : :py:class:`Array`, (`m`, `n`)
The array to find the unique rows of.
return_index : bool, optional
If True, the indices of the unique rows in ... | [
"Returns",
"a",
"copy",
"of",
"arr",
"with",
"duplicate",
"rows",
"removed",
".",
"From",
"Stackoverflow",
"Find",
"unique",
"rows",
"in",
"numpy",
".",
"array",
".",
"Parameters",
"----------",
"arr",
":",
":",
"py",
":",
"class",
":",
"Array",
"(",
"m"... | train | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L1666-L1721 |
markchil/gptools | gptools/utils.py | compute_stats | def compute_stats(vals, check_nan=False, robust=False, axis=1, plot_QQ=False, bins=15, name=''):
"""Compute the average statistics (mean, std dev) for the given values.
Parameters
----------
vals : array-like, (`M`, `D`)
Values to compute the average statistics along the specified axis of.
... | python | def compute_stats(vals, check_nan=False, robust=False, axis=1, plot_QQ=False, bins=15, name=''):
"""Compute the average statistics (mean, std dev) for the given values.
Parameters
----------
vals : array-like, (`M`, `D`)
Values to compute the average statistics along the specified axis of.
... | [
"def",
"compute_stats",
"(",
"vals",
",",
"check_nan",
"=",
"False",
",",
"robust",
"=",
"False",
",",
"axis",
"=",
"1",
",",
"plot_QQ",
"=",
"False",
",",
"bins",
"=",
"15",
",",
"name",
"=",
"''",
")",
":",
"if",
"axis",
"!=",
"1",
"and",
"robu... | Compute the average statistics (mean, std dev) for the given values.
Parameters
----------
vals : array-like, (`M`, `D`)
Values to compute the average statistics along the specified axis of.
check_nan : bool, optional
Whether or not to check for (and exclude) NaN's. Default is False... | [
"Compute",
"the",
"average",
"statistics",
"(",
"mean",
"std",
"dev",
")",
"for",
"the",
"given",
"values",
".",
"Parameters",
"----------",
"vals",
":",
"array",
"-",
"like",
"(",
"M",
"D",
")",
"Values",
"to",
"compute",
"the",
"average",
"statistics",
... | train | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L1767-L1899 |
markchil/gptools | gptools/utils.py | univariate_envelope_plot | def univariate_envelope_plot(x, mean, std, ax=None, base_alpha=0.375, envelopes=[1, 3], lb=None, ub=None, expansion=10, **kwargs):
"""Make a plot of a mean curve with uncertainty envelopes.
"""
if ax is None:
f = plt.figure()
ax = f.add_subplot(1, 1, 1)
elif ax == 'gca':
ax = plt... | python | def univariate_envelope_plot(x, mean, std, ax=None, base_alpha=0.375, envelopes=[1, 3], lb=None, ub=None, expansion=10, **kwargs):
"""Make a plot of a mean curve with uncertainty envelopes.
"""
if ax is None:
f = plt.figure()
ax = f.add_subplot(1, 1, 1)
elif ax == 'gca':
ax = plt... | [
"def",
"univariate_envelope_plot",
"(",
"x",
",",
"mean",
",",
"std",
",",
"ax",
"=",
"None",
",",
"base_alpha",
"=",
"0.375",
",",
"envelopes",
"=",
"[",
"1",
",",
"3",
"]",
",",
"lb",
"=",
"None",
",",
"ub",
"=",
"None",
",",
"expansion",
"=",
... | Make a plot of a mean curve with uncertainty envelopes. | [
"Make",
"a",
"plot",
"of",
"a",
"mean",
"curve",
"with",
"uncertainty",
"envelopes",
"."
] | train | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L1901-L1936 |
markchil/gptools | gptools/utils.py | summarize_sampler | def summarize_sampler(sampler, weights=None, burn=0, ci=0.95, chain_mask=None):
r"""Create summary statistics of the flattened chain of the sampler.
The confidence regions are computed from the quantiles of the data.
Parameters
----------
sampler : :py:class:`emcee.Sampler` instance or arr... | python | def summarize_sampler(sampler, weights=None, burn=0, ci=0.95, chain_mask=None):
r"""Create summary statistics of the flattened chain of the sampler.
The confidence regions are computed from the quantiles of the data.
Parameters
----------
sampler : :py:class:`emcee.Sampler` instance or arr... | [
"def",
"summarize_sampler",
"(",
"sampler",
",",
"weights",
"=",
"None",
",",
"burn",
"=",
"0",
",",
"ci",
"=",
"0.95",
",",
"chain_mask",
"=",
"None",
")",
":",
"try",
":",
"k",
"=",
"sampler",
".",
"flatchain",
".",
"shape",
"[",
"-",
"1",
"]",
... | r"""Create summary statistics of the flattened chain of the sampler.
The confidence regions are computed from the quantiles of the data.
Parameters
----------
sampler : :py:class:`emcee.Sampler` instance or array, (`n_temps`, `n_chains`, `n_samp`, `n_dim`), (`n_chains`, `n_samp`, `n_dim`) or (... | [
"r",
"Create",
"summary",
"statistics",
"of",
"the",
"flattened",
"chain",
"of",
"the",
"sampler",
".",
"The",
"confidence",
"regions",
"are",
"computed",
"from",
"the",
"quantiles",
"of",
"the",
"data",
".",
"Parameters",
"----------",
"sampler",
":",
":",
... | train | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L1938-L2030 |
markchil/gptools | gptools/utils.py | plot_sampler | def plot_sampler(
sampler, suptitle=None, labels=None, bins=50,
plot_samples=False, plot_hist=True, plot_chains=True,
burn=0, chain_mask=None, temp_idx=0, weights=None, cutoff_weight=None,
cmap='gray_r', hist_color='k', chain_alpha=0.1,
points=None, covs=None, colors=None, ci=[0.... | python | def plot_sampler(
sampler, suptitle=None, labels=None, bins=50,
plot_samples=False, plot_hist=True, plot_chains=True,
burn=0, chain_mask=None, temp_idx=0, weights=None, cutoff_weight=None,
cmap='gray_r', hist_color='k', chain_alpha=0.1,
points=None, covs=None, colors=None, ci=[0.... | [
"def",
"plot_sampler",
"(",
"sampler",
",",
"suptitle",
"=",
"None",
",",
"labels",
"=",
"None",
",",
"bins",
"=",
"50",
",",
"plot_samples",
"=",
"False",
",",
"plot_hist",
"=",
"True",
",",
"plot_chains",
"=",
"True",
",",
"burn",
"=",
"0",
",",
"c... | Plot the results of MCMC sampler (posterior and chains).
Loosely based on triangle.py. Provides extensive options to format the plot.
Parameters
----------
sampler : :py:class:`emcee.Sampler` instance or array, (`n_temps`, `n_chains`, `n_samp`, `n_dim`), (`n_chains`, `n_samp`, `n_dim`) or (`n_... | [
"Plot",
"the",
"results",
"of",
"MCMC",
"sampler",
"(",
"posterior",
"and",
"chains",
")",
".",
"Loosely",
"based",
"on",
"triangle",
".",
"py",
".",
"Provides",
"extensive",
"options",
"to",
"format",
"the",
"plot",
".",
"Parameters",
"----------",
"sampler... | train | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L2032-L2439 |
markchil/gptools | gptools/utils.py | plot_sampler_fingerprint | def plot_sampler_fingerprint(
sampler, hyperprior, weights=None, cutoff_weight=None, nbins=None,
labels=None, burn=0, chain_mask=None, temp_idx=0, points=None,
plot_samples=False, sample_color='k', point_color=None, point_lw=3,
title='', rot_x_labels=False, figsize=None
):
"""Mak... | python | def plot_sampler_fingerprint(
sampler, hyperprior, weights=None, cutoff_weight=None, nbins=None,
labels=None, burn=0, chain_mask=None, temp_idx=0, points=None,
plot_samples=False, sample_color='k', point_color=None, point_lw=3,
title='', rot_x_labels=False, figsize=None
):
"""Mak... | [
"def",
"plot_sampler_fingerprint",
"(",
"sampler",
",",
"hyperprior",
",",
"weights",
"=",
"None",
",",
"cutoff_weight",
"=",
"None",
",",
"nbins",
"=",
"None",
",",
"labels",
"=",
"None",
",",
"burn",
"=",
"0",
",",
"chain_mask",
"=",
"None",
",",
"temp... | Make a plot of the sampler's "fingerprint": univariate marginal histograms for all hyperparameters.
The hyperparameters are mapped to [0, 1] using
:py:meth:`hyperprior.elementwise_cdf`, so this can only be used with prior
distributions which implement this function.
Returns the figure and axis... | [
"Make",
"a",
"plot",
"of",
"the",
"sampler",
"s",
"fingerprint",
":",
"univariate",
"marginal",
"histograms",
"for",
"all",
"hyperparameters",
".",
"The",
"hyperparameters",
"are",
"mapped",
"to",
"[",
"0",
"1",
"]",
"using",
":",
"py",
":",
"meth",
":",
... | train | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L2441-L2614 |
markchil/gptools | gptools/utils.py | plot_sampler_cov | def plot_sampler_cov(
sampler, method='corr', weights=None, cutoff_weight=None, labels=None,
burn=0, chain_mask=None, temp_idx=0, cbar_label=None, title='',
rot_x_labels=False, figsize=None, xlabel_on_top=True
):
"""Make a plot of the sampler's correlation or covariance matrix.
... | python | def plot_sampler_cov(
sampler, method='corr', weights=None, cutoff_weight=None, labels=None,
burn=0, chain_mask=None, temp_idx=0, cbar_label=None, title='',
rot_x_labels=False, figsize=None, xlabel_on_top=True
):
"""Make a plot of the sampler's correlation or covariance matrix.
... | [
"def",
"plot_sampler_cov",
"(",
"sampler",
",",
"method",
"=",
"'corr'",
",",
"weights",
"=",
"None",
",",
"cutoff_weight",
"=",
"None",
",",
"labels",
"=",
"None",
",",
"burn",
"=",
"0",
",",
"chain_mask",
"=",
"None",
",",
"temp_idx",
"=",
"0",
",",
... | Make a plot of the sampler's correlation or covariance matrix.
Returns the figure and axis created.
Parameters
----------
sampler : :py:class:`emcee.Sampler` instance or array, (`n_temps`, `n_chains`, `n_samp`, `n_dim`), (`n_chains`, `n_samp`, `n_dim`) or (`n_samp`, `n_dim`)
The sample... | [
"Make",
"a",
"plot",
"of",
"the",
"sampler",
"s",
"correlation",
"or",
"covariance",
"matrix",
".",
"Returns",
"the",
"figure",
"and",
"axis",
"created",
".",
"Parameters",
"----------",
"sampler",
":",
":",
"py",
":",
"class",
":",
"emcee",
".",
"Sampler"... | train | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L2616-L2752 |
markchil/gptools | gptools/utils.py | ProductJointPrior.sample_u | def sample_u(self, q):
r"""Extract a sample from random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the inverse
CDF. To facilitate efficient sampling, this function returns a *vector*
of PPF values, one value for each variable. Ba... | python | def sample_u(self, q):
r"""Extract a sample from random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the inverse
CDF. To facilitate efficient sampling, this function returns a *vector*
of PPF values, one value for each variable. Ba... | [
"def",
"sample_u",
"(",
"self",
",",
"q",
")",
":",
"p1_num_params",
"=",
"len",
"(",
"self",
".",
"p1",
".",
"bounds",
")",
"return",
"scipy",
".",
"concatenate",
"(",
"(",
"self",
".",
"p1",
".",
"sample_u",
"(",
"q",
"[",
":",
"p1_num_params",
"... | r"""Extract a sample from random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the inverse
CDF. To facilitate efficient sampling, this function returns a *vector*
of PPF values, one value for each variable. Basically, the idea is that,
... | [
"r",
"Extract",
"a",
"sample",
"from",
"random",
"variates",
"uniform",
"on",
":",
"math",
":",
"[",
"0",
"1",
"]",
".",
"For",
"a",
"univariate",
"distribution",
"this",
"is",
"simply",
"evaluating",
"the",
"inverse",
"CDF",
".",
"To",
"facilitate",
"ef... | train | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L285-L306 |
markchil/gptools | gptools/utils.py | ProductJointPrior.elementwise_cdf | def elementwise_cdf(self, p):
r"""Convert a sample to random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the CDF. To
facilitate efficient sampling, this function returns a *vector* of CDF
values, one value for each variable. Basic... | python | def elementwise_cdf(self, p):
r"""Convert a sample to random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the CDF. To
facilitate efficient sampling, this function returns a *vector* of CDF
values, one value for each variable. Basic... | [
"def",
"elementwise_cdf",
"(",
"self",
",",
"p",
")",
":",
"p1_num_params",
"=",
"len",
"(",
"self",
".",
"p1",
".",
"bounds",
")",
"return",
"scipy",
".",
"concatenate",
"(",
"(",
"self",
".",
"p1",
".",
"elementwise_cdf",
"(",
"p",
"[",
":",
"p1_nu... | r"""Convert a sample to random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the CDF. To
facilitate efficient sampling, this function returns a *vector* of CDF
values, one value for each variable. Basically, the idea is that, given
... | [
"r",
"Convert",
"a",
"sample",
"to",
"random",
"variates",
"uniform",
"on",
":",
"math",
":",
"[",
"0",
"1",
"]",
".",
"For",
"a",
"univariate",
"distribution",
"this",
"is",
"simply",
"evaluating",
"the",
"CDF",
".",
"To",
"facilitate",
"efficient",
"sa... | train | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L308-L330 |
markchil/gptools | gptools/utils.py | ProductJointPrior.random_draw | def random_draw(self, size=None):
"""Draw random samples of the hyperparameters.
The outputs of the two priors are stacked vertically.
Parameters
----------
size : None, int or array-like, optional
The number/shape of samples to draw. If None, only o... | python | def random_draw(self, size=None):
"""Draw random samples of the hyperparameters.
The outputs of the two priors are stacked vertically.
Parameters
----------
size : None, int or array-like, optional
The number/shape of samples to draw. If None, only o... | [
"def",
"random_draw",
"(",
"self",
",",
"size",
"=",
"None",
")",
":",
"draw_1",
"=",
"self",
".",
"p1",
".",
"random_draw",
"(",
"size",
"=",
"size",
")",
"draw_2",
"=",
"self",
".",
"p2",
".",
"random_draw",
"(",
"size",
"=",
"size",
")",
"if",
... | Draw random samples of the hyperparameters.
The outputs of the two priors are stacked vertically.
Parameters
----------
size : None, int or array-like, optional
The number/shape of samples to draw. If None, only one sample is
returned. Default is... | [
"Draw",
"random",
"samples",
"of",
"the",
"hyperparameters",
".",
"The",
"outputs",
"of",
"the",
"two",
"priors",
"are",
"stacked",
"vertically",
".",
"Parameters",
"----------",
"size",
":",
"None",
"int",
"or",
"array",
"-",
"like",
"optional",
"The",
"num... | train | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L332-L349 |
markchil/gptools | gptools/utils.py | UniformJointPrior.sample_u | def sample_u(self, q):
r"""Extract a sample from random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the inverse
CDF. To facilitate efficient sampling, this function returns a *vector*
of PPF values, one value for each variable. Ba... | python | def sample_u(self, q):
r"""Extract a sample from random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the inverse
CDF. To facilitate efficient sampling, this function returns a *vector*
of PPF values, one value for each variable. Ba... | [
"def",
"sample_u",
"(",
"self",
",",
"q",
")",
":",
"q",
"=",
"scipy",
".",
"atleast_1d",
"(",
"q",
")",
"if",
"len",
"(",
"q",
")",
"!=",
"len",
"(",
"self",
".",
"bounds",
")",
":",
"raise",
"ValueError",
"(",
"\"length of q must equal the number of ... | r"""Extract a sample from random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the inverse
CDF. To facilitate efficient sampling, this function returns a *vector*
of PPF values, one value for each variable. Basically, the idea is that,
... | [
"r",
"Extract",
"a",
"sample",
"from",
"random",
"variates",
"uniform",
"on",
":",
"math",
":",
"[",
"0",
"1",
"]",
".",
"For",
"a",
"univariate",
"distribution",
"this",
"is",
"simply",
"evaluating",
"the",
"inverse",
"CDF",
".",
"To",
"facilitate",
"ef... | train | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L392-L414 |
markchil/gptools | gptools/utils.py | UniformJointPrior.elementwise_cdf | def elementwise_cdf(self, p):
r"""Convert a sample to random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the CDF. To
facilitate efficient sampling, this function returns a *vector* of CDF
values, one value for each variable. Basic... | python | def elementwise_cdf(self, p):
r"""Convert a sample to random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the CDF. To
facilitate efficient sampling, this function returns a *vector* of CDF
values, one value for each variable. Basic... | [
"def",
"elementwise_cdf",
"(",
"self",
",",
"p",
")",
":",
"p",
"=",
"scipy",
".",
"atleast_1d",
"(",
"p",
")",
"if",
"len",
"(",
"p",
")",
"!=",
"len",
"(",
"self",
".",
"bounds",
")",
":",
"raise",
"ValueError",
"(",
"\"length of p must equal the num... | r"""Convert a sample to random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the CDF. To
facilitate efficient sampling, this function returns a *vector* of CDF
values, one value for each variable. Basically, the idea is that, given
... | [
"r",
"Convert",
"a",
"sample",
"to",
"random",
"variates",
"uniform",
"on",
":",
"math",
":",
"[",
"0",
"1",
"]",
".",
"For",
"a",
"univariate",
"distribution",
"this",
"is",
"simply",
"evaluating",
"the",
"CDF",
".",
"To",
"facilitate",
"efficient",
"sa... | train | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L416-L445 |
markchil/gptools | gptools/utils.py | UniformJointPrior.random_draw | def random_draw(self, size=None):
"""Draw random samples of the hyperparameters.
Parameters
----------
size : None, int or array-like, optional
The number/shape of samples to draw. If None, only one sample is
returned. Default is None.
"""
... | python | def random_draw(self, size=None):
"""Draw random samples of the hyperparameters.
Parameters
----------
size : None, int or array-like, optional
The number/shape of samples to draw. If None, only one sample is
returned. Default is None.
"""
... | [
"def",
"random_draw",
"(",
"self",
",",
"size",
"=",
"None",
")",
":",
"return",
"scipy",
".",
"asarray",
"(",
"[",
"numpy",
".",
"random",
".",
"uniform",
"(",
"low",
"=",
"b",
"[",
"0",
"]",
",",
"high",
"=",
"b",
"[",
"1",
"]",
",",
"size",
... | Draw random samples of the hyperparameters.
Parameters
----------
size : None, int or array-like, optional
The number/shape of samples to draw. If None, only one sample is
returned. Default is None. | [
"Draw",
"random",
"samples",
"of",
"the",
"hyperparameters",
".",
"Parameters",
"----------",
"size",
":",
"None",
"int",
"or",
"array",
"-",
"like",
"optional",
"The",
"number",
"/",
"shape",
"of",
"samples",
"to",
"draw",
".",
"If",
"None",
"only",
"one"... | train | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L447-L456 |
markchil/gptools | gptools/utils.py | CoreEdgeJointPrior.random_draw | def random_draw(self, size=None):
"""Draw random samples of the hyperparameters.
Parameters
----------
size : None, int or array-like, optional
The number/shape of samples to draw. If None, only one sample is
returned. Default is None.
"""
... | python | def random_draw(self, size=None):
"""Draw random samples of the hyperparameters.
Parameters
----------
size : None, int or array-like, optional
The number/shape of samples to draw. If None, only one sample is
returned. Default is None.
"""
... | [
"def",
"random_draw",
"(",
"self",
",",
"size",
"=",
"None",
")",
":",
"if",
"size",
"is",
"None",
":",
"size",
"=",
"1",
"single_val",
"=",
"True",
"else",
":",
"single_val",
"=",
"False",
"out_shape",
"=",
"[",
"len",
"(",
"self",
".",
"bounds",
... | Draw random samples of the hyperparameters.
Parameters
----------
size : None, int or array-like, optional
The number/shape of samples to draw. If None, only one sample is
returned. Default is None. | [
"Draw",
"random",
"samples",
"of",
"the",
"hyperparameters",
".",
"Parameters",
"----------",
"size",
":",
"None",
"int",
"or",
"array",
"-",
"like",
"optional",
"The",
"number",
"/",
"shape",
"of",
"samples",
"to",
"draw",
".",
"If",
"None",
"only",
"one"... | train | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L520-L554 |
markchil/gptools | gptools/utils.py | IndependentJointPrior.sample_u | def sample_u(self, q):
r"""Extract a sample from random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the inverse
CDF. To facilitate efficient sampling, this function returns a *vector*
of PPF values, one value for each variable. Ba... | python | def sample_u(self, q):
r"""Extract a sample from random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the inverse
CDF. To facilitate efficient sampling, this function returns a *vector*
of PPF values, one value for each variable. Ba... | [
"def",
"sample_u",
"(",
"self",
",",
"q",
")",
":",
"q",
"=",
"scipy",
".",
"atleast_1d",
"(",
"q",
")",
"if",
"len",
"(",
"q",
")",
"!=",
"len",
"(",
"self",
".",
"univariate_priors",
")",
":",
"raise",
"ValueError",
"(",
"\"length of q must equal the... | r"""Extract a sample from random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the inverse
CDF. To facilitate efficient sampling, this function returns a *vector*
of PPF values, one value for each variable. Basically, the idea is that,
... | [
"r",
"Extract",
"a",
"sample",
"from",
"random",
"variates",
"uniform",
"on",
":",
"math",
":",
"[",
"0",
"1",
"]",
".",
"For",
"a",
"univariate",
"distribution",
"this",
"is",
"simply",
"evaluating",
"the",
"inverse",
"CDF",
".",
"To",
"facilitate",
"ef... | train | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L708-L730 |
markchil/gptools | gptools/utils.py | IndependentJointPrior.elementwise_cdf | def elementwise_cdf(self, p):
r"""Convert a sample to random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the CDF. To
facilitate efficient sampling, this function returns a *vector* of CDF
values, one value for each variable. Basic... | python | def elementwise_cdf(self, p):
r"""Convert a sample to random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the CDF. To
facilitate efficient sampling, this function returns a *vector* of CDF
values, one value for each variable. Basic... | [
"def",
"elementwise_cdf",
"(",
"self",
",",
"p",
")",
":",
"p",
"=",
"scipy",
".",
"atleast_1d",
"(",
"p",
")",
"if",
"len",
"(",
"p",
")",
"!=",
"len",
"(",
"self",
".",
"univariate_priors",
")",
":",
"raise",
"ValueError",
"(",
"\"length of p must eq... | r"""Convert a sample to random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the CDF. To
facilitate efficient sampling, this function returns a *vector* of CDF
values, one value for each variable. Basically, the idea is that, given
... | [
"r",
"Convert",
"a",
"sample",
"to",
"random",
"variates",
"uniform",
"on",
":",
"math",
":",
"[",
"0",
"1",
"]",
".",
"For",
"a",
"univariate",
"distribution",
"this",
"is",
"simply",
"evaluating",
"the",
"CDF",
".",
"To",
"facilitate",
"efficient",
"sa... | train | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L732-L753 |
markchil/gptools | gptools/utils.py | IndependentJointPrior.random_draw | def random_draw(self, size=None):
"""Draw random samples of the hyperparameters.
Parameters
----------
size : None, int or array-like, optional
The number/shape of samples to draw. If None, only one sample is
returned. Default is None.
"""
... | python | def random_draw(self, size=None):
"""Draw random samples of the hyperparameters.
Parameters
----------
size : None, int or array-like, optional
The number/shape of samples to draw. If None, only one sample is
returned. Default is None.
"""
... | [
"def",
"random_draw",
"(",
"self",
",",
"size",
"=",
"None",
")",
":",
"return",
"scipy",
".",
"asarray",
"(",
"[",
"p",
".",
"rvs",
"(",
"size",
"=",
"size",
")",
"for",
"p",
"in",
"self",
".",
"univariate_priors",
"]",
")"
] | Draw random samples of the hyperparameters.
Parameters
----------
size : None, int or array-like, optional
The number/shape of samples to draw. If None, only one sample is
returned. Default is None. | [
"Draw",
"random",
"samples",
"of",
"the",
"hyperparameters",
".",
"Parameters",
"----------",
"size",
":",
"None",
"int",
"or",
"array",
"-",
"like",
"optional",
"The",
"number",
"/",
"shape",
"of",
"samples",
"to",
"draw",
".",
"If",
"None",
"only",
"one"... | train | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L755-L764 |
markchil/gptools | gptools/utils.py | NormalJointPrior.bounds | def bounds(self):
"""The bounds of the random variable.
Set `self.i=0.95` to return the 95% interval if this is used for setting
bounds on optimizers/etc. where infinite bounds may not be useful.
"""
return [scipy.stats.norm.interval(self.i, loc=m, scale=s) for s, m in z... | python | def bounds(self):
"""The bounds of the random variable.
Set `self.i=0.95` to return the 95% interval if this is used for setting
bounds on optimizers/etc. where infinite bounds may not be useful.
"""
return [scipy.stats.norm.interval(self.i, loc=m, scale=s) for s, m in z... | [
"def",
"bounds",
"(",
"self",
")",
":",
"return",
"[",
"scipy",
".",
"stats",
".",
"norm",
".",
"interval",
"(",
"self",
".",
"i",
",",
"loc",
"=",
"m",
",",
"scale",
"=",
"s",
")",
"for",
"s",
",",
"m",
"in",
"zip",
"(",
"self",
".",
"sigma"... | The bounds of the random variable.
Set `self.i=0.95` to return the 95% interval if this is used for setting
bounds on optimizers/etc. where infinite bounds may not be useful. | [
"The",
"bounds",
"of",
"the",
"random",
"variable",
".",
"Set",
"self",
".",
"i",
"=",
"0",
".",
"95",
"to",
"return",
"the",
"95%",
"interval",
"if",
"this",
"is",
"used",
"for",
"setting",
"bounds",
"on",
"optimizers",
"/",
"etc",
".",
"where",
"in... | train | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L803-L809 |
markchil/gptools | gptools/utils.py | NormalJointPrior.sample_u | def sample_u(self, q):
r"""Extract a sample from random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the inverse
CDF. To facilitate efficient sampling, this function returns a *vector*
of PPF values, one value for each variable. Ba... | python | def sample_u(self, q):
r"""Extract a sample from random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the inverse
CDF. To facilitate efficient sampling, this function returns a *vector*
of PPF values, one value for each variable. Ba... | [
"def",
"sample_u",
"(",
"self",
",",
"q",
")",
":",
"q",
"=",
"scipy",
".",
"atleast_1d",
"(",
"q",
")",
"if",
"len",
"(",
"q",
")",
"!=",
"len",
"(",
"self",
".",
"sigma",
")",
":",
"raise",
"ValueError",
"(",
"\"length of q must equal the number of p... | r"""Extract a sample from random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the inverse
CDF. To facilitate efficient sampling, this function returns a *vector*
of PPF values, one value for each variable. Basically, the idea is that,
... | [
"r",
"Extract",
"a",
"sample",
"from",
"random",
"variates",
"uniform",
"on",
":",
"math",
":",
"[",
"0",
"1",
"]",
".",
"For",
"a",
"univariate",
"distribution",
"this",
"is",
"simply",
"evaluating",
"the",
"inverse",
"CDF",
".",
"To",
"facilitate",
"ef... | train | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L811-L833 |
markchil/gptools | gptools/utils.py | NormalJointPrior.elementwise_cdf | def elementwise_cdf(self, p):
r"""Convert a sample to random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the CDF. To
facilitate efficient sampling, this function returns a *vector* of CDF
values, one value for each variable. Basic... | python | def elementwise_cdf(self, p):
r"""Convert a sample to random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the CDF. To
facilitate efficient sampling, this function returns a *vector* of CDF
values, one value for each variable. Basic... | [
"def",
"elementwise_cdf",
"(",
"self",
",",
"p",
")",
":",
"p",
"=",
"scipy",
".",
"atleast_1d",
"(",
"p",
")",
"if",
"len",
"(",
"p",
")",
"!=",
"len",
"(",
"self",
".",
"sigma",
")",
":",
"raise",
"ValueError",
"(",
"\"length of p must equal the numb... | r"""Convert a sample to random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the CDF. To
facilitate efficient sampling, this function returns a *vector* of CDF
values, one value for each variable. Basically, the idea is that, given
... | [
"r",
"Convert",
"a",
"sample",
"to",
"random",
"variates",
"uniform",
"on",
":",
"math",
":",
"[",
"0",
"1",
"]",
".",
"For",
"a",
"univariate",
"distribution",
"this",
"is",
"simply",
"evaluating",
"the",
"CDF",
".",
"To",
"facilitate",
"efficient",
"sa... | train | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L835-L856 |
markchil/gptools | gptools/utils.py | NormalJointPrior.random_draw | def random_draw(self, size=None):
"""Draw random samples of the hyperparameters.
Parameters
----------
size : None, int or array-like, optional
The number/shape of samples to draw. If None, only one sample is
returned. Default is None.
"""
... | python | def random_draw(self, size=None):
"""Draw random samples of the hyperparameters.
Parameters
----------
size : None, int or array-like, optional
The number/shape of samples to draw. If None, only one sample is
returned. Default is None.
"""
... | [
"def",
"random_draw",
"(",
"self",
",",
"size",
"=",
"None",
")",
":",
"return",
"scipy",
".",
"asarray",
"(",
"[",
"scipy",
".",
"stats",
".",
"norm",
".",
"rvs",
"(",
"loc",
"=",
"m",
",",
"scale",
"=",
"s",
",",
"size",
"=",
"size",
")",
"fo... | Draw random samples of the hyperparameters.
Parameters
----------
size : None, int or array-like, optional
The number/shape of samples to draw. If None, only one sample is
returned. Default is None. | [
"Draw",
"random",
"samples",
"of",
"the",
"hyperparameters",
".",
"Parameters",
"----------",
"size",
":",
"None",
"int",
"or",
"array",
"-",
"like",
"optional",
"The",
"number",
"/",
"shape",
"of",
"samples",
"to",
"draw",
".",
"If",
"None",
"only",
"one"... | train | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L858-L867 |
markchil/gptools | gptools/utils.py | LogNormalJointPrior.bounds | def bounds(self):
"""The bounds of the random variable.
Set `self.i=0.95` to return the 95% interval if this is used for setting
bounds on optimizers/etc. where infinite bounds may not be useful.
"""
return [scipy.stats.lognorm.interval(self.i, s, loc=0, scale=em) for s,... | python | def bounds(self):
"""The bounds of the random variable.
Set `self.i=0.95` to return the 95% interval if this is used for setting
bounds on optimizers/etc. where infinite bounds may not be useful.
"""
return [scipy.stats.lognorm.interval(self.i, s, loc=0, scale=em) for s,... | [
"def",
"bounds",
"(",
"self",
")",
":",
"return",
"[",
"scipy",
".",
"stats",
".",
"lognorm",
".",
"interval",
"(",
"self",
".",
"i",
",",
"s",
",",
"loc",
"=",
"0",
",",
"scale",
"=",
"em",
")",
"for",
"s",
",",
"em",
"in",
"zip",
"(",
"self... | The bounds of the random variable.
Set `self.i=0.95` to return the 95% interval if this is used for setting
bounds on optimizers/etc. where infinite bounds may not be useful. | [
"The",
"bounds",
"of",
"the",
"random",
"variable",
".",
"Set",
"self",
".",
"i",
"=",
"0",
".",
"95",
"to",
"return",
"the",
"95%",
"interval",
"if",
"this",
"is",
"used",
"for",
"setting",
"bounds",
"on",
"optimizers",
"/",
"etc",
".",
"where",
"in... | train | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L909-L915 |
markchil/gptools | gptools/utils.py | LogNormalJointPrior.sample_u | def sample_u(self, q):
r"""Extract a sample from random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the inverse
CDF. To facilitate efficient sampling, this function returns a *vector*
of PPF values, one value for each variable. Ba... | python | def sample_u(self, q):
r"""Extract a sample from random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the inverse
CDF. To facilitate efficient sampling, this function returns a *vector*
of PPF values, one value for each variable. Ba... | [
"def",
"sample_u",
"(",
"self",
",",
"q",
")",
":",
"q",
"=",
"scipy",
".",
"atleast_1d",
"(",
"q",
")",
"if",
"len",
"(",
"q",
")",
"!=",
"len",
"(",
"self",
".",
"sigma",
")",
":",
"raise",
"ValueError",
"(",
"\"length of q must equal the number of p... | r"""Extract a sample from random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the inverse
CDF. To facilitate efficient sampling, this function returns a *vector*
of PPF values, one value for each variable. Basically, the idea is that,
... | [
"r",
"Extract",
"a",
"sample",
"from",
"random",
"variates",
"uniform",
"on",
":",
"math",
":",
"[",
"0",
"1",
"]",
".",
"For",
"a",
"univariate",
"distribution",
"this",
"is",
"simply",
"evaluating",
"the",
"inverse",
"CDF",
".",
"To",
"facilitate",
"ef... | train | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L917-L939 |
markchil/gptools | gptools/utils.py | LogNormalJointPrior.elementwise_cdf | def elementwise_cdf(self, p):
r"""Convert a sample to random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the CDF. To
facilitate efficient sampling, this function returns a *vector* of CDF
values, one value for each variable. Basic... | python | def elementwise_cdf(self, p):
r"""Convert a sample to random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the CDF. To
facilitate efficient sampling, this function returns a *vector* of CDF
values, one value for each variable. Basic... | [
"def",
"elementwise_cdf",
"(",
"self",
",",
"p",
")",
":",
"p",
"=",
"scipy",
".",
"atleast_1d",
"(",
"p",
")",
"if",
"len",
"(",
"p",
")",
"!=",
"len",
"(",
"self",
".",
"sigma",
")",
":",
"raise",
"ValueError",
"(",
"\"length of p must equal the numb... | r"""Convert a sample to random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the CDF. To
facilitate efficient sampling, this function returns a *vector* of CDF
values, one value for each variable. Basically, the idea is that, given
... | [
"r",
"Convert",
"a",
"sample",
"to",
"random",
"variates",
"uniform",
"on",
":",
"math",
":",
"[",
"0",
"1",
"]",
".",
"For",
"a",
"univariate",
"distribution",
"this",
"is",
"simply",
"evaluating",
"the",
"CDF",
".",
"To",
"facilitate",
"efficient",
"sa... | train | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L941-L962 |
markchil/gptools | gptools/utils.py | LogNormalJointPrior.random_draw | def random_draw(self, size=None):
"""Draw random samples of the hyperparameters.
Parameters
----------
size : None, int or array-like, optional
The number/shape of samples to draw. If None, only one sample is
returned. Default is None.
"""
... | python | def random_draw(self, size=None):
"""Draw random samples of the hyperparameters.
Parameters
----------
size : None, int or array-like, optional
The number/shape of samples to draw. If None, only one sample is
returned. Default is None.
"""
... | [
"def",
"random_draw",
"(",
"self",
",",
"size",
"=",
"None",
")",
":",
"return",
"scipy",
".",
"asarray",
"(",
"[",
"scipy",
".",
"stats",
".",
"lognorm",
".",
"rvs",
"(",
"s",
",",
"loc",
"=",
"0",
",",
"scale",
"=",
"em",
",",
"size",
"=",
"s... | Draw random samples of the hyperparameters.
Parameters
----------
size : None, int or array-like, optional
The number/shape of samples to draw. If None, only one sample is
returned. Default is None. | [
"Draw",
"random",
"samples",
"of",
"the",
"hyperparameters",
".",
"Parameters",
"----------",
"size",
":",
"None",
"int",
"or",
"array",
"-",
"like",
"optional",
"The",
"number",
"/",
"shape",
"of",
"samples",
"to",
"draw",
".",
"If",
"None",
"only",
"one"... | train | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L964-L973 |
markchil/gptools | gptools/utils.py | GammaJointPrior.bounds | def bounds(self):
"""The bounds of the random variable.
Set `self.i=0.95` to return the 95% interval if this is used for setting
bounds on optimizers/etc. where infinite bounds may not be useful.
"""
return [scipy.stats.gamma.interval(self.i, a, loc=0, scale=1.0 / b) for... | python | def bounds(self):
"""The bounds of the random variable.
Set `self.i=0.95` to return the 95% interval if this is used for setting
bounds on optimizers/etc. where infinite bounds may not be useful.
"""
return [scipy.stats.gamma.interval(self.i, a, loc=0, scale=1.0 / b) for... | [
"def",
"bounds",
"(",
"self",
")",
":",
"return",
"[",
"scipy",
".",
"stats",
".",
"gamma",
".",
"interval",
"(",
"self",
".",
"i",
",",
"a",
",",
"loc",
"=",
"0",
",",
"scale",
"=",
"1.0",
"/",
"b",
")",
"for",
"a",
",",
"b",
"in",
"zip",
... | The bounds of the random variable.
Set `self.i=0.95` to return the 95% interval if this is used for setting
bounds on optimizers/etc. where infinite bounds may not be useful. | [
"The",
"bounds",
"of",
"the",
"random",
"variable",
".",
"Set",
"self",
".",
"i",
"=",
"0",
".",
"95",
"to",
"return",
"the",
"95%",
"interval",
"if",
"this",
"is",
"used",
"for",
"setting",
"bounds",
"on",
"optimizers",
"/",
"etc",
".",
"where",
"in... | train | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L1015-L1021 |
markchil/gptools | gptools/utils.py | GammaJointPrior.sample_u | def sample_u(self, q):
r"""Extract a sample from random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the inverse
CDF. To facilitate efficient sampling, this function returns a *vector*
of PPF values, one value for each variable. Ba... | python | def sample_u(self, q):
r"""Extract a sample from random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the inverse
CDF. To facilitate efficient sampling, this function returns a *vector*
of PPF values, one value for each variable. Ba... | [
"def",
"sample_u",
"(",
"self",
",",
"q",
")",
":",
"q",
"=",
"scipy",
".",
"atleast_1d",
"(",
"q",
")",
"if",
"len",
"(",
"q",
")",
"!=",
"len",
"(",
"self",
".",
"a",
")",
":",
"raise",
"ValueError",
"(",
"\"length of q must equal the number of param... | r"""Extract a sample from random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the inverse
CDF. To facilitate efficient sampling, this function returns a *vector*
of PPF values, one value for each variable. Basically, the idea is that,
... | [
"r",
"Extract",
"a",
"sample",
"from",
"random",
"variates",
"uniform",
"on",
":",
"math",
":",
"[",
"0",
"1",
"]",
".",
"For",
"a",
"univariate",
"distribution",
"this",
"is",
"simply",
"evaluating",
"the",
"inverse",
"CDF",
".",
"To",
"facilitate",
"ef... | train | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L1023-L1045 |
markchil/gptools | gptools/utils.py | GammaJointPrior.elementwise_cdf | def elementwise_cdf(self, p):
r"""Convert a sample to random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the CDF. To
facilitate efficient sampling, this function returns a *vector* of CDF
values, one value for each variable. Basic... | python | def elementwise_cdf(self, p):
r"""Convert a sample to random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the CDF. To
facilitate efficient sampling, this function returns a *vector* of CDF
values, one value for each variable. Basic... | [
"def",
"elementwise_cdf",
"(",
"self",
",",
"p",
")",
":",
"p",
"=",
"scipy",
".",
"atleast_1d",
"(",
"p",
")",
"if",
"len",
"(",
"p",
")",
"!=",
"len",
"(",
"self",
".",
"a",
")",
":",
"raise",
"ValueError",
"(",
"\"length of p must equal the number o... | r"""Convert a sample to random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the CDF. To
facilitate efficient sampling, this function returns a *vector* of CDF
values, one value for each variable. Basically, the idea is that, given
... | [
"r",
"Convert",
"a",
"sample",
"to",
"random",
"variates",
"uniform",
"on",
":",
"math",
":",
"[",
"0",
"1",
"]",
".",
"For",
"a",
"univariate",
"distribution",
"this",
"is",
"simply",
"evaluating",
"the",
"CDF",
".",
"To",
"facilitate",
"efficient",
"sa... | train | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L1047-L1068 |
markchil/gptools | gptools/utils.py | GammaJointPrior.random_draw | def random_draw(self, size=None):
"""Draw random samples of the hyperparameters.
Parameters
----------
size : None, int or array-like, optional
The number/shape of samples to draw. If None, only one sample is
returned. Default is None.
"""
... | python | def random_draw(self, size=None):
"""Draw random samples of the hyperparameters.
Parameters
----------
size : None, int or array-like, optional
The number/shape of samples to draw. If None, only one sample is
returned. Default is None.
"""
... | [
"def",
"random_draw",
"(",
"self",
",",
"size",
"=",
"None",
")",
":",
"return",
"scipy",
".",
"asarray",
"(",
"[",
"scipy",
".",
"stats",
".",
"gamma",
".",
"rvs",
"(",
"a",
",",
"loc",
"=",
"0",
",",
"scale",
"=",
"1.0",
"/",
"b",
",",
"size"... | Draw random samples of the hyperparameters.
Parameters
----------
size : None, int or array-like, optional
The number/shape of samples to draw. If None, only one sample is
returned. Default is None. | [
"Draw",
"random",
"samples",
"of",
"the",
"hyperparameters",
".",
"Parameters",
"----------",
"size",
":",
"None",
"int",
"or",
"array",
"-",
"like",
"optional",
"The",
"number",
"/",
"shape",
"of",
"samples",
"to",
"draw",
".",
"If",
"None",
"only",
"one"... | train | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L1070-L1079 |
markchil/gptools | gptools/utils.py | SortedUniformJointPrior.sample_u | def sample_u(self, q):
r"""Extract a sample from random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the inverse
CDF. To facilitate efficient sampling, this function returns a *vector*
of PPF values, one value for each variable. Ba... | python | def sample_u(self, q):
r"""Extract a sample from random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the inverse
CDF. To facilitate efficient sampling, this function returns a *vector*
of PPF values, one value for each variable. Ba... | [
"def",
"sample_u",
"(",
"self",
",",
"q",
")",
":",
"q",
"=",
"scipy",
".",
"atleast_1d",
"(",
"q",
")",
"if",
"len",
"(",
"q",
")",
"!=",
"self",
".",
"num_var",
":",
"raise",
"ValueError",
"(",
"\"length of q must equal the number of parameters!\"",
")",... | r"""Extract a sample from random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the inverse
CDF. To facilitate efficient sampling, this function returns a *vector*
of PPF values, one value for each variable. Basically, the idea is that,
... | [
"r",
"Extract",
"a",
"sample",
"from",
"random",
"variates",
"uniform",
"on",
":",
"math",
":",
"[",
"0",
"1",
"]",
".",
"For",
"a",
"univariate",
"distribution",
"this",
"is",
"simply",
"evaluating",
"the",
"inverse",
"CDF",
".",
"To",
"facilitate",
"ef... | train | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L1154-L1189 |
markchil/gptools | gptools/utils.py | SortedUniformJointPrior.elementwise_cdf | def elementwise_cdf(self, p):
r"""Convert a sample to random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the CDF. To
facilitate efficient sampling, this function returns a *vector* of CDF
values, one value for each variable. Basic... | python | def elementwise_cdf(self, p):
r"""Convert a sample to random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the CDF. To
facilitate efficient sampling, this function returns a *vector* of CDF
values, one value for each variable. Basic... | [
"def",
"elementwise_cdf",
"(",
"self",
",",
"p",
")",
":",
"p",
"=",
"scipy",
".",
"atleast_1d",
"(",
"p",
")",
"if",
"len",
"(",
"p",
")",
"!=",
"len",
"(",
"self",
".",
"bounds",
")",
":",
"raise",
"ValueError",
"(",
"\"length of p must equal the num... | r"""Convert a sample to random variates uniform on :math:`[0, 1]`.
For a univariate distribution, this is simply evaluating the CDF. To
facilitate efficient sampling, this function returns a *vector* of CDF
values, one value for each variable. Basically, the idea is that, given
... | [
"r",
"Convert",
"a",
"sample",
"to",
"random",
"variates",
"uniform",
"on",
":",
"math",
":",
"[",
"0",
"1",
"]",
".",
"For",
"a",
"univariate",
"distribution",
"this",
"is",
"simply",
"evaluating",
"the",
"CDF",
".",
"To",
"facilitate",
"efficient",
"sa... | train | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L1191-L1233 |
markchil/gptools | gptools/utils.py | SortedUniformJointPrior.random_draw | def random_draw(self, size=None):
"""Draw random samples of the hyperparameters.
Parameters
----------
size : None, int or array-like, optional
The number/shape of samples to draw. If None, only one sample is
returned. Default is None.
"""
... | python | def random_draw(self, size=None):
"""Draw random samples of the hyperparameters.
Parameters
----------
size : None, int or array-like, optional
The number/shape of samples to draw. If None, only one sample is
returned. Default is None.
"""
... | [
"def",
"random_draw",
"(",
"self",
",",
"size",
"=",
"None",
")",
":",
"if",
"size",
"is",
"None",
":",
"size",
"=",
"1",
"single_val",
"=",
"True",
"else",
":",
"single_val",
"=",
"False",
"out_shape",
"=",
"[",
"self",
".",
"num_var",
"]",
"try",
... | Draw random samples of the hyperparameters.
Parameters
----------
size : None, int or array-like, optional
The number/shape of samples to draw. If None, only one sample is
returned. Default is None. | [
"Draw",
"random",
"samples",
"of",
"the",
"hyperparameters",
".",
"Parameters",
"----------",
"size",
":",
"None",
"int",
"or",
"array",
"-",
"like",
"optional",
"The",
"number",
"/",
"shape",
"of",
"samples",
"to",
"draw",
".",
"If",
"None",
"only",
"one"... | train | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/utils.py#L1235-L1267 |
CTPUG/wafer | wafer/tickets/views.py | zapier_cancel_hook | def zapier_cancel_hook(request):
'''
Zapier can post something like this when tickets are cancelled
{
"ticket_type": "Individual (Regular)",
"barcode": "12345678",
"email": "demo@example.com"
}
'''
if request.META.get('HTTP_X_ZAPIER_SECRET', None) != settings.WAFER_TICKET... | python | def zapier_cancel_hook(request):
'''
Zapier can post something like this when tickets are cancelled
{
"ticket_type": "Individual (Regular)",
"barcode": "12345678",
"email": "demo@example.com"
}
'''
if request.META.get('HTTP_X_ZAPIER_SECRET', None) != settings.WAFER_TICKET... | [
"def",
"zapier_cancel_hook",
"(",
"request",
")",
":",
"if",
"request",
".",
"META",
".",
"get",
"(",
"'HTTP_X_ZAPIER_SECRET'",
",",
"None",
")",
"!=",
"settings",
".",
"WAFER_TICKETS_SECRET",
":",
"raise",
"PermissionDenied",
"(",
"'Incorrect secret'",
")",
"# ... | Zapier can post something like this when tickets are cancelled
{
"ticket_type": "Individual (Regular)",
"barcode": "12345678",
"email": "demo@example.com"
} | [
"Zapier",
"can",
"post",
"something",
"like",
"this",
"when",
"tickets",
"are",
"cancelled",
"{",
"ticket_type",
":",
"Individual",
"(",
"Regular",
")",
"barcode",
":",
"12345678",
"email",
":",
"demo"
] | train | https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/tickets/views.py#L55-L73 |
CTPUG/wafer | wafer/tickets/views.py | zapier_guest_hook | def zapier_guest_hook(request):
'''
Zapier can POST something like this when tickets are bought:
{
"ticket_type": "Individual (Regular)",
"barcode": "12345678",
"email": "demo@example.com"
}
'''
if request.META.get('HTTP_X_ZAPIER_SECRET', None) != settings.WAFER_TICKETS_... | python | def zapier_guest_hook(request):
'''
Zapier can POST something like this when tickets are bought:
{
"ticket_type": "Individual (Regular)",
"barcode": "12345678",
"email": "demo@example.com"
}
'''
if request.META.get('HTTP_X_ZAPIER_SECRET', None) != settings.WAFER_TICKETS_... | [
"def",
"zapier_guest_hook",
"(",
"request",
")",
":",
"if",
"request",
".",
"META",
".",
"get",
"(",
"'HTTP_X_ZAPIER_SECRET'",
",",
"None",
")",
"!=",
"settings",
".",
"WAFER_TICKETS_SECRET",
":",
"raise",
"PermissionDenied",
"(",
"'Incorrect secret'",
")",
"# T... | Zapier can POST something like this when tickets are bought:
{
"ticket_type": "Individual (Regular)",
"barcode": "12345678",
"email": "demo@example.com"
} | [
"Zapier",
"can",
"POST",
"something",
"like",
"this",
"when",
"tickets",
"are",
"bought",
":",
"{"
] | train | https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/tickets/views.py#L81-L99 |
cocaine/cocaine-framework-python | cocaine/detail/secadaptor.py | TVM.fetch_token | def fetch_token(self):
"""Gains token from secure backend service.
:return: Token formatted for Cocaine protocol header.
"""
grant_type = 'client_credentials'
channel = yield self._tvm.ticket_full(
self._client_id, self._client_secret, grant_type, {})
ticket... | python | def fetch_token(self):
"""Gains token from secure backend service.
:return: Token formatted for Cocaine protocol header.
"""
grant_type = 'client_credentials'
channel = yield self._tvm.ticket_full(
self._client_id, self._client_secret, grant_type, {})
ticket... | [
"def",
"fetch_token",
"(",
"self",
")",
":",
"grant_type",
"=",
"'client_credentials'",
"channel",
"=",
"yield",
"self",
".",
"_tvm",
".",
"ticket_full",
"(",
"self",
".",
"_client_id",
",",
"self",
".",
"_client_secret",
",",
"grant_type",
",",
"{",
"}",
... | Gains token from secure backend service.
:return: Token formatted for Cocaine protocol header. | [
"Gains",
"token",
"from",
"secure",
"backend",
"service",
"."
] | train | https://github.com/cocaine/cocaine-framework-python/blob/d8a30074b6338bac4389eb996e00d404338115e4/cocaine/detail/secadaptor.py#L54-L65 |
cocaine/cocaine-framework-python | cocaine/detail/secadaptor.py | SecureServiceFabric.make_secure_adaptor | def make_secure_adaptor(service, mod, client_id, client_secret, tok_update_sec=None):
"""
:param service: Service to wrap in.
:param mod: Name (type) of token refresh backend.
:param client_id: Client identifier.
:param client_secret: Client secret.
:param tok_update_sec:... | python | def make_secure_adaptor(service, mod, client_id, client_secret, tok_update_sec=None):
"""
:param service: Service to wrap in.
:param mod: Name (type) of token refresh backend.
:param client_id: Client identifier.
:param client_secret: Client secret.
:param tok_update_sec:... | [
"def",
"make_secure_adaptor",
"(",
"service",
",",
"mod",
",",
"client_id",
",",
"client_secret",
",",
"tok_update_sec",
"=",
"None",
")",
":",
"if",
"mod",
"==",
"'TVM'",
":",
"return",
"SecureServiceAdaptor",
"(",
"service",
",",
"TVM",
"(",
"client_id",
"... | :param service: Service to wrap in.
:param mod: Name (type) of token refresh backend.
:param client_id: Client identifier.
:param client_secret: Client secret.
:param tok_update_sec: Token update interval in seconds. | [
":",
"param",
"service",
":",
"Service",
"to",
"wrap",
"in",
".",
":",
"param",
"mod",
":",
"Name",
"(",
"type",
")",
"of",
"token",
"refresh",
"backend",
".",
":",
"param",
"client_id",
":",
"Client",
"identifier",
".",
":",
"param",
"client_secret",
... | train | https://github.com/cocaine/cocaine-framework-python/blob/d8a30074b6338bac4389eb996e00d404338115e4/cocaine/detail/secadaptor.py#L131-L142 |
wdecoster/nanoget | nanoget/extraction_functions.py | process_summary | def process_summary(summaryfile, **kwargs):
"""Extracting information from an albacore summary file.
Only reads which have a >0 length are returned.
The fields below may or may not exist, depending on the type of sequencing performed.
Fields 1-14 are for 1D sequencing.
Fields 1-23 for 2D sequencin... | python | def process_summary(summaryfile, **kwargs):
"""Extracting information from an albacore summary file.
Only reads which have a >0 length are returned.
The fields below may or may not exist, depending on the type of sequencing performed.
Fields 1-14 are for 1D sequencing.
Fields 1-23 for 2D sequencin... | [
"def",
"process_summary",
"(",
"summaryfile",
",",
"*",
"*",
"kwargs",
")",
":",
"logging",
".",
"info",
"(",
"\"Nanoget: Collecting metrics from summary file {} for {} sequencing\"",
".",
"format",
"(",
"summaryfile",
",",
"kwargs",
"[",
"\"readtype\"",
"]",
")",
"... | Extracting information from an albacore summary file.
Only reads which have a >0 length are returned.
The fields below may or may not exist, depending on the type of sequencing performed.
Fields 1-14 are for 1D sequencing.
Fields 1-23 for 2D sequencing.
Fields 24-27, 2-5, 22-23 for 1D^2 (1D2) sequ... | [
"Extracting",
"information",
"from",
"an",
"albacore",
"summary",
"file",
"."
] | train | https://github.com/wdecoster/nanoget/blob/fb7306220e261849b96785fab02dd2f35a0e3b60/nanoget/extraction_functions.py#L12-L90 |
wdecoster/nanoget | nanoget/extraction_functions.py | check_bam | def check_bam(bam, samtype="bam"):
"""Check if bam file is valid.
Bam file should:
- exists
- has an index (create if necessary)
- is sorted by coordinate
- has at least one mapped read
"""
ut.check_existance(bam)
samfile = pysam.AlignmentFile(bam, "rb")
if not samfile.has_index... | python | def check_bam(bam, samtype="bam"):
"""Check if bam file is valid.
Bam file should:
- exists
- has an index (create if necessary)
- is sorted by coordinate
- has at least one mapped read
"""
ut.check_existance(bam)
samfile = pysam.AlignmentFile(bam, "rb")
if not samfile.has_index... | [
"def",
"check_bam",
"(",
"bam",
",",
"samtype",
"=",
"\"bam\"",
")",
":",
"ut",
".",
"check_existance",
"(",
"bam",
")",
"samfile",
"=",
"pysam",
".",
"AlignmentFile",
"(",
"bam",
",",
"\"rb\"",
")",
"if",
"not",
"samfile",
".",
"has_index",
"(",
")",
... | Check if bam file is valid.
Bam file should:
- exists
- has an index (create if necessary)
- is sorted by coordinate
- has at least one mapped read | [
"Check",
"if",
"bam",
"file",
"is",
"valid",
"."
] | train | https://github.com/wdecoster/nanoget/blob/fb7306220e261849b96785fab02dd2f35a0e3b60/nanoget/extraction_functions.py#L93-L117 |
wdecoster/nanoget | nanoget/extraction_functions.py | process_ubam | def process_ubam(bam, **kwargs):
"""Extracting metrics from unaligned bam format
Extracting lengths
"""
logging.info("Nanoget: Starting to collect statistics from ubam file {}.".format(bam))
samfile = pysam.AlignmentFile(bam, "rb", check_sq=False)
if not samfile.has_index():
pysam.index(... | python | def process_ubam(bam, **kwargs):
"""Extracting metrics from unaligned bam format
Extracting lengths
"""
logging.info("Nanoget: Starting to collect statistics from ubam file {}.".format(bam))
samfile = pysam.AlignmentFile(bam, "rb", check_sq=False)
if not samfile.has_index():
pysam.index(... | [
"def",
"process_ubam",
"(",
"bam",
",",
"*",
"*",
"kwargs",
")",
":",
"logging",
".",
"info",
"(",
"\"Nanoget: Starting to collect statistics from ubam file {}.\"",
".",
"format",
"(",
"bam",
")",
")",
"samfile",
"=",
"pysam",
".",
"AlignmentFile",
"(",
"bam",
... | Extracting metrics from unaligned bam format
Extracting lengths | [
"Extracting",
"metrics",
"from",
"unaligned",
"bam",
"format",
"Extracting",
"lengths"
] | train | https://github.com/wdecoster/nanoget/blob/fb7306220e261849b96785fab02dd2f35a0e3b60/nanoget/extraction_functions.py#L120-L139 |
wdecoster/nanoget | nanoget/extraction_functions.py | process_bam | def process_bam(bam, **kwargs):
"""Combines metrics from bam after extraction.
Processing function: calls pool of worker functions
to extract from a bam file the following metrics:
-lengths
-aligned lengths
-qualities
-aligned qualities
-mapping qualities
-edit distances to the refe... | python | def process_bam(bam, **kwargs):
"""Combines metrics from bam after extraction.
Processing function: calls pool of worker functions
to extract from a bam file the following metrics:
-lengths
-aligned lengths
-qualities
-aligned qualities
-mapping qualities
-edit distances to the refe... | [
"def",
"process_bam",
"(",
"bam",
",",
"*",
"*",
"kwargs",
")",
":",
"logging",
".",
"info",
"(",
"\"Nanoget: Starting to collect statistics from bam file {}.\"",
".",
"format",
"(",
"bam",
")",
")",
"samfile",
"=",
"check_bam",
"(",
"bam",
")",
"chromosomes",
... | Combines metrics from bam after extraction.
Processing function: calls pool of worker functions
to extract from a bam file the following metrics:
-lengths
-aligned lengths
-qualities
-aligned qualities
-mapping qualities
-edit distances to the reference genome scaled by read length
... | [
"Combines",
"metrics",
"from",
"bam",
"after",
"extraction",
"."
] | train | https://github.com/wdecoster/nanoget/blob/fb7306220e261849b96785fab02dd2f35a0e3b60/nanoget/extraction_functions.py#L142-L168 |
wdecoster/nanoget | nanoget/extraction_functions.py | extract_from_bam | def extract_from_bam(params):
"""Extracts metrics from bam.
Worker function per chromosome
loop over a bam file and create list with tuples containing metrics:
-qualities
-aligned qualities
-lengths
-aligned lengths
-mapping qualities
-edit distances to the reference genome scaled b... | python | def extract_from_bam(params):
"""Extracts metrics from bam.
Worker function per chromosome
loop over a bam file and create list with tuples containing metrics:
-qualities
-aligned qualities
-lengths
-aligned lengths
-mapping qualities
-edit distances to the reference genome scaled b... | [
"def",
"extract_from_bam",
"(",
"params",
")",
":",
"bam",
",",
"chromosome",
"=",
"params",
"samfile",
"=",
"pysam",
".",
"AlignmentFile",
"(",
"bam",
",",
"\"rb\"",
")",
"return",
"[",
"(",
"read",
".",
"query_name",
",",
"nanomath",
".",
"ave_qual",
"... | Extracts metrics from bam.
Worker function per chromosome
loop over a bam file and create list with tuples containing metrics:
-qualities
-aligned qualities
-lengths
-aligned lengths
-mapping qualities
-edit distances to the reference genome scaled by read length | [
"Extracts",
"metrics",
"from",
"bam",
"."
] | train | https://github.com/wdecoster/nanoget/blob/fb7306220e261849b96785fab02dd2f35a0e3b60/nanoget/extraction_functions.py#L200-L223 |
wdecoster/nanoget | nanoget/extraction_functions.py | get_pID | def get_pID(read):
"""Return the percent identity of a read.
based on the NM tag if present,
if not calculate from MD tag and CIGAR string
read.query_alignment_length can be zero in the case of ultra long reads aligned with minimap2 -L
"""
try:
return 100 * (1 - read.get_tag("NM") / re... | python | def get_pID(read):
"""Return the percent identity of a read.
based on the NM tag if present,
if not calculate from MD tag and CIGAR string
read.query_alignment_length can be zero in the case of ultra long reads aligned with minimap2 -L
"""
try:
return 100 * (1 - read.get_tag("NM") / re... | [
"def",
"get_pID",
"(",
"read",
")",
":",
"try",
":",
"return",
"100",
"*",
"(",
"1",
"-",
"read",
".",
"get_tag",
"(",
"\"NM\"",
")",
"/",
"read",
".",
"query_alignment_length",
")",
"except",
"KeyError",
":",
"try",
":",
"return",
"100",
"*",
"(",
... | Return the percent identity of a read.
based on the NM tag if present,
if not calculate from MD tag and CIGAR string
read.query_alignment_length can be zero in the case of ultra long reads aligned with minimap2 -L | [
"Return",
"the",
"percent",
"identity",
"of",
"a",
"read",
"."
] | train | https://github.com/wdecoster/nanoget/blob/fb7306220e261849b96785fab02dd2f35a0e3b60/nanoget/extraction_functions.py#L226-L243 |
wdecoster/nanoget | nanoget/extraction_functions.py | handle_compressed_input | def handle_compressed_input(inputfq, file_type="fastq"):
"""Return handles from compressed files according to extension.
Check for which fastq input is presented and open a handle accordingly
Can read from compressed files (gz, bz2, bgz) or uncompressed
Relies on file extensions to recognize compressio... | python | def handle_compressed_input(inputfq, file_type="fastq"):
"""Return handles from compressed files according to extension.
Check for which fastq input is presented and open a handle accordingly
Can read from compressed files (gz, bz2, bgz) or uncompressed
Relies on file extensions to recognize compressio... | [
"def",
"handle_compressed_input",
"(",
"inputfq",
",",
"file_type",
"=",
"\"fastq\"",
")",
":",
"ut",
".",
"check_existance",
"(",
"inputfq",
")",
"if",
"inputfq",
".",
"endswith",
"(",
"(",
"'.gz'",
",",
"'bgz'",
")",
")",
":",
"import",
"gzip",
"logging"... | Return handles from compressed files according to extension.
Check for which fastq input is presented and open a handle accordingly
Can read from compressed files (gz, bz2, bgz) or uncompressed
Relies on file extensions to recognize compression | [
"Return",
"handles",
"from",
"compressed",
"files",
"according",
"to",
"extension",
"."
] | train | https://github.com/wdecoster/nanoget/blob/fb7306220e261849b96785fab02dd2f35a0e3b60/nanoget/extraction_functions.py#L256-L277 |
wdecoster/nanoget | nanoget/extraction_functions.py | process_fasta | def process_fasta(fasta, **kwargs):
"""Combine metrics extracted from a fasta file."""
logging.info("Nanoget: Starting to collect statistics from a fasta file.")
inputfasta = handle_compressed_input(fasta, file_type="fasta")
return ut.reduce_memory_usage(pd.DataFrame(
data=[len(rec) for rec in S... | python | def process_fasta(fasta, **kwargs):
"""Combine metrics extracted from a fasta file."""
logging.info("Nanoget: Starting to collect statistics from a fasta file.")
inputfasta = handle_compressed_input(fasta, file_type="fasta")
return ut.reduce_memory_usage(pd.DataFrame(
data=[len(rec) for rec in S... | [
"def",
"process_fasta",
"(",
"fasta",
",",
"*",
"*",
"kwargs",
")",
":",
"logging",
".",
"info",
"(",
"\"Nanoget: Starting to collect statistics from a fasta file.\"",
")",
"inputfasta",
"=",
"handle_compressed_input",
"(",
"fasta",
",",
"file_type",
"=",
"\"fasta\"",... | Combine metrics extracted from a fasta file. | [
"Combine",
"metrics",
"extracted",
"from",
"a",
"fasta",
"file",
"."
] | train | https://github.com/wdecoster/nanoget/blob/fb7306220e261849b96785fab02dd2f35a0e3b60/nanoget/extraction_functions.py#L280-L287 |
wdecoster/nanoget | nanoget/extraction_functions.py | process_fastq_plain | def process_fastq_plain(fastq, **kwargs):
"""Combine metrics extracted from a fastq file."""
logging.info("Nanoget: Starting to collect statistics from plain fastq file.")
inputfastq = handle_compressed_input(fastq)
return ut.reduce_memory_usage(pd.DataFrame(
data=[res for res in extract_from_fa... | python | def process_fastq_plain(fastq, **kwargs):
"""Combine metrics extracted from a fastq file."""
logging.info("Nanoget: Starting to collect statistics from plain fastq file.")
inputfastq = handle_compressed_input(fastq)
return ut.reduce_memory_usage(pd.DataFrame(
data=[res for res in extract_from_fa... | [
"def",
"process_fastq_plain",
"(",
"fastq",
",",
"*",
"*",
"kwargs",
")",
":",
"logging",
".",
"info",
"(",
"\"Nanoget: Starting to collect statistics from plain fastq file.\"",
")",
"inputfastq",
"=",
"handle_compressed_input",
"(",
"fastq",
")",
"return",
"ut",
".",... | Combine metrics extracted from a fastq file. | [
"Combine",
"metrics",
"extracted",
"from",
"a",
"fastq",
"file",
"."
] | train | https://github.com/wdecoster/nanoget/blob/fb7306220e261849b96785fab02dd2f35a0e3b60/nanoget/extraction_functions.py#L290-L297 |
wdecoster/nanoget | nanoget/extraction_functions.py | extract_from_fastq | def extract_from_fastq(fq):
"""Extract metrics from a fastq file.
Return average quality and read length
"""
for rec in SeqIO.parse(fq, "fastq"):
yield nanomath.ave_qual(rec.letter_annotations["phred_quality"]), len(rec) | python | def extract_from_fastq(fq):
"""Extract metrics from a fastq file.
Return average quality and read length
"""
for rec in SeqIO.parse(fq, "fastq"):
yield nanomath.ave_qual(rec.letter_annotations["phred_quality"]), len(rec) | [
"def",
"extract_from_fastq",
"(",
"fq",
")",
":",
"for",
"rec",
"in",
"SeqIO",
".",
"parse",
"(",
"fq",
",",
"\"fastq\"",
")",
":",
"yield",
"nanomath",
".",
"ave_qual",
"(",
"rec",
".",
"letter_annotations",
"[",
"\"phred_quality\"",
"]",
")",
",",
"len... | Extract metrics from a fastq file.
Return average quality and read length | [
"Extract",
"metrics",
"from",
"a",
"fastq",
"file",
"."
] | train | https://github.com/wdecoster/nanoget/blob/fb7306220e261849b96785fab02dd2f35a0e3b60/nanoget/extraction_functions.py#L300-L306 |
wdecoster/nanoget | nanoget/extraction_functions.py | stream_fastq_full | def stream_fastq_full(fastq, threads):
"""Generator for returning metrics extracted from fastq.
Extract from a fastq file:
-readname
-average and median quality
-read_lenght
"""
logging.info("Nanoget: Starting to collect full metrics from plain fastq file.")
inputfastq = handle_compress... | python | def stream_fastq_full(fastq, threads):
"""Generator for returning metrics extracted from fastq.
Extract from a fastq file:
-readname
-average and median quality
-read_lenght
"""
logging.info("Nanoget: Starting to collect full metrics from plain fastq file.")
inputfastq = handle_compress... | [
"def",
"stream_fastq_full",
"(",
"fastq",
",",
"threads",
")",
":",
"logging",
".",
"info",
"(",
"\"Nanoget: Starting to collect full metrics from plain fastq file.\"",
")",
"inputfastq",
"=",
"handle_compressed_input",
"(",
"fastq",
")",
"with",
"cfutures",
".",
"Proce... | Generator for returning metrics extracted from fastq.
Extract from a fastq file:
-readname
-average and median quality
-read_lenght | [
"Generator",
"for",
"returning",
"metrics",
"extracted",
"from",
"fastq",
"."
] | train | https://github.com/wdecoster/nanoget/blob/fb7306220e261849b96785fab02dd2f35a0e3b60/nanoget/extraction_functions.py#L309-L322 |
wdecoster/nanoget | nanoget/extraction_functions.py | extract_all_from_fastq | def extract_all_from_fastq(rec):
"""Extract metrics from a fastq file.
Return identifier, read length, average quality and median quality
"""
return (rec.id,
len(rec),
nanomath.ave_qual(rec.letter_annotations["phred_quality"]),
nanomath.median_qual(rec.letter_annotat... | python | def extract_all_from_fastq(rec):
"""Extract metrics from a fastq file.
Return identifier, read length, average quality and median quality
"""
return (rec.id,
len(rec),
nanomath.ave_qual(rec.letter_annotations["phred_quality"]),
nanomath.median_qual(rec.letter_annotat... | [
"def",
"extract_all_from_fastq",
"(",
"rec",
")",
":",
"return",
"(",
"rec",
".",
"id",
",",
"len",
"(",
"rec",
")",
",",
"nanomath",
".",
"ave_qual",
"(",
"rec",
".",
"letter_annotations",
"[",
"\"phred_quality\"",
"]",
")",
",",
"nanomath",
".",
"media... | Extract metrics from a fastq file.
Return identifier, read length, average quality and median quality | [
"Extract",
"metrics",
"from",
"a",
"fastq",
"file",
"."
] | train | https://github.com/wdecoster/nanoget/blob/fb7306220e261849b96785fab02dd2f35a0e3b60/nanoget/extraction_functions.py#L325-L333 |
wdecoster/nanoget | nanoget/extraction_functions.py | process_fastq_rich | def process_fastq_rich(fastq, **kwargs):
"""Extract metrics from a richer fastq file.
Extract information from fastq files generated by albacore or MinKNOW,
containing richer information in the header (key-value pairs)
read=<int> [72]
ch=<int> [159]
start_time=<timestamp> [2016-07-15T14:23:22Z]... | python | def process_fastq_rich(fastq, **kwargs):
"""Extract metrics from a richer fastq file.
Extract information from fastq files generated by albacore or MinKNOW,
containing richer information in the header (key-value pairs)
read=<int> [72]
ch=<int> [159]
start_time=<timestamp> [2016-07-15T14:23:22Z]... | [
"def",
"process_fastq_rich",
"(",
"fastq",
",",
"*",
"*",
"kwargs",
")",
":",
"logging",
".",
"info",
"(",
"\"Nanoget: Starting to collect statistics from rich fastq file.\"",
")",
"inputfastq",
"=",
"handle_compressed_input",
"(",
"fastq",
")",
"res",
"=",
"[",
"]"... | Extract metrics from a richer fastq file.
Extract information from fastq files generated by albacore or MinKNOW,
containing richer information in the header (key-value pairs)
read=<int> [72]
ch=<int> [159]
start_time=<timestamp> [2016-07-15T14:23:22Z] # UTC ISO 8601 ISO 3339 timestamp
Z indica... | [
"Extract",
"metrics",
"from",
"a",
"richer",
"fastq",
"file",
"."
] | train | https://github.com/wdecoster/nanoget/blob/fb7306220e261849b96785fab02dd2f35a0e3b60/nanoget/extraction_functions.py#L341-L374 |
wdecoster/nanoget | nanoget/extraction_functions.py | readfq | def readfq(fp):
"""Generator function adapted from https://github.com/lh3/readfq."""
last = None # this is a buffer keeping the last unprocessed line
while True: # mimic closure; is it a bad idea?
if not last: # the first record or a record following a fastq
for l in fp: # search for... | python | def readfq(fp):
"""Generator function adapted from https://github.com/lh3/readfq."""
last = None # this is a buffer keeping the last unprocessed line
while True: # mimic closure; is it a bad idea?
if not last: # the first record or a record following a fastq
for l in fp: # search for... | [
"def",
"readfq",
"(",
"fp",
")",
":",
"last",
"=",
"None",
"# this is a buffer keeping the last unprocessed line",
"while",
"True",
":",
"# mimic closure; is it a bad idea?",
"if",
"not",
"last",
":",
"# the first record or a record following a fastq",
"for",
"l",
"in",
"... | Generator function adapted from https://github.com/lh3/readfq. | [
"Generator",
"function",
"adapted",
"from",
"https",
":",
"//",
"github",
".",
"com",
"/",
"lh3",
"/",
"readfq",
"."
] | train | https://github.com/wdecoster/nanoget/blob/fb7306220e261849b96785fab02dd2f35a0e3b60/nanoget/extraction_functions.py#L377-L409 |
wdecoster/nanoget | nanoget/extraction_functions.py | fq_minimal | def fq_minimal(fq):
"""Minimal fastq metrics extractor.
Quickly parse a fasta/fastq file - but makes expectations on the file format
There will be dragons if unexpected format is used
Expects a fastq_rich format, but extracts only timestamp and length
"""
try:
while True:
ti... | python | def fq_minimal(fq):
"""Minimal fastq metrics extractor.
Quickly parse a fasta/fastq file - but makes expectations on the file format
There will be dragons if unexpected format is used
Expects a fastq_rich format, but extracts only timestamp and length
"""
try:
while True:
ti... | [
"def",
"fq_minimal",
"(",
"fq",
")",
":",
"try",
":",
"while",
"True",
":",
"time",
"=",
"next",
"(",
"fq",
")",
"[",
"1",
":",
"]",
".",
"split",
"(",
"\" \"",
")",
"[",
"4",
"]",
"[",
"11",
":",
"-",
"1",
"]",
"length",
"=",
"len",
"(",
... | Minimal fastq metrics extractor.
Quickly parse a fasta/fastq file - but makes expectations on the file format
There will be dragons if unexpected format is used
Expects a fastq_rich format, but extracts only timestamp and length | [
"Minimal",
"fastq",
"metrics",
"extractor",
"."
] | train | https://github.com/wdecoster/nanoget/blob/fb7306220e261849b96785fab02dd2f35a0e3b60/nanoget/extraction_functions.py#L412-L427 |
wdecoster/nanoget | nanoget/extraction_functions.py | process_fastq_minimal | def process_fastq_minimal(fastq, **kwargs):
"""Swiftly extract minimal features (length and timestamp) from a rich fastq file"""
infastq = handle_compressed_input(fastq)
try:
df = pd.DataFrame(
data=[rec for rec in fq_minimal(infastq) if rec],
columns=["timestamp", "lengths"]... | python | def process_fastq_minimal(fastq, **kwargs):
"""Swiftly extract minimal features (length and timestamp) from a rich fastq file"""
infastq = handle_compressed_input(fastq)
try:
df = pd.DataFrame(
data=[rec for rec in fq_minimal(infastq) if rec],
columns=["timestamp", "lengths"]... | [
"def",
"process_fastq_minimal",
"(",
"fastq",
",",
"*",
"*",
"kwargs",
")",
":",
"infastq",
"=",
"handle_compressed_input",
"(",
"fastq",
")",
"try",
":",
"df",
"=",
"pd",
".",
"DataFrame",
"(",
"data",
"=",
"[",
"rec",
"for",
"rec",
"in",
"fq_minimal",
... | Swiftly extract minimal features (length and timestamp) from a rich fastq file | [
"Swiftly",
"extract",
"minimal",
"features",
"(",
"length",
"and",
"timestamp",
")",
"from",
"a",
"rich",
"fastq",
"file"
] | train | https://github.com/wdecoster/nanoget/blob/fb7306220e261849b96785fab02dd2f35a0e3b60/nanoget/extraction_functions.py#L430-L441 |
LordDarkula/chess_py | chess_py/core/algebraic/converter.py | _get_piece | def _get_piece(string, index):
"""
Returns Piece subclass given index of piece.
:type: index: int
:type: loc Location
:raise: KeyError
"""
piece = string[index].strip()
piece = piece.upper()
piece_dict = {'R': Rook,
'P': Pawn,
'B': Bishop,
... | python | def _get_piece(string, index):
"""
Returns Piece subclass given index of piece.
:type: index: int
:type: loc Location
:raise: KeyError
"""
piece = string[index].strip()
piece = piece.upper()
piece_dict = {'R': Rook,
'P': Pawn,
'B': Bishop,
... | [
"def",
"_get_piece",
"(",
"string",
",",
"index",
")",
":",
"piece",
"=",
"string",
"[",
"index",
"]",
".",
"strip",
"(",
")",
"piece",
"=",
"piece",
".",
"upper",
"(",
")",
"piece_dict",
"=",
"{",
"'R'",
":",
"Rook",
",",
"'P'",
":",
"Pawn",
","... | Returns Piece subclass given index of piece.
:type: index: int
:type: loc Location
:raise: KeyError | [
"Returns",
"Piece",
"subclass",
"given",
"index",
"of",
"piece",
"."
] | train | https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/core/algebraic/converter.py#L24-L44 |
LordDarkula/chess_py | chess_py/core/algebraic/converter.py | incomplete_alg | def incomplete_alg(alg_str, input_color, position):
"""
Converts a string written in short algebraic form into an incomplete move.
These incomplete moves do not have the initial location specified and
therefore cannot be used to update the board. IN order to fully utilize
incomplete move, it must be... | python | def incomplete_alg(alg_str, input_color, position):
"""
Converts a string written in short algebraic form into an incomplete move.
These incomplete moves do not have the initial location specified and
therefore cannot be used to update the board. IN order to fully utilize
incomplete move, it must be... | [
"def",
"incomplete_alg",
"(",
"alg_str",
",",
"input_color",
",",
"position",
")",
":",
"edge_rank",
"=",
"0",
"if",
"input_color",
"==",
"color",
".",
"white",
"else",
"7",
"if",
"alg_str",
"is",
"None",
"or",
"len",
"(",
"alg_str",
")",
"<=",
"1",
":... | Converts a string written in short algebraic form into an incomplete move.
These incomplete moves do not have the initial location specified and
therefore cannot be used to update the board. IN order to fully utilize
incomplete move, it must be run through ``make_legal()`` with
the corresponding positio... | [
"Converts",
"a",
"string",
"written",
"in",
"short",
"algebraic",
"form",
"into",
"an",
"incomplete",
"move",
".",
"These",
"incomplete",
"moves",
"do",
"not",
"have",
"the",
"initial",
"location",
"specified",
"and",
"therefore",
"cannot",
"be",
"used",
"to",... | train | https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/core/algebraic/converter.py#L105-L305 |
LordDarkula/chess_py | chess_py/core/algebraic/converter.py | make_legal | def make_legal(move, position):
"""
Converts an incomplete move (initial ``Location`` not specified)
and the corresponding position into the a complete move
with the most likely starting point specified. If no moves match, ``None``
is returned.
:type: move: Move
:type: position: Board
:... | python | def make_legal(move, position):
"""
Converts an incomplete move (initial ``Location`` not specified)
and the corresponding position into the a complete move
with the most likely starting point specified. If no moves match, ``None``
is returned.
:type: move: Move
:type: position: Board
:... | [
"def",
"make_legal",
"(",
"move",
",",
"position",
")",
":",
"assert",
"isinstance",
"(",
"move",
",",
"Move",
")",
"for",
"legal_move",
"in",
"position",
".",
"all_possible_moves",
"(",
"move",
".",
"color",
")",
":",
"if",
"move",
".",
"status",
"==",
... | Converts an incomplete move (initial ``Location`` not specified)
and the corresponding position into the a complete move
with the most likely starting point specified. If no moves match, ``None``
is returned.
:type: move: Move
:type: position: Board
:rtype: Move | [
"Converts",
"an",
"incomplete",
"move",
"(",
"initial",
"Location",
"not",
"specified",
")",
"and",
"the",
"corresponding",
"position",
"into",
"the",
"a",
"complete",
"move",
"with",
"the",
"most",
"likely",
"starting",
"point",
"specified",
".",
"If",
"no",
... | train | https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/core/algebraic/converter.py#L308-L330 |
LordDarkula/chess_py | chess_py/core/algebraic/converter.py | short_alg | def short_alg(algebraic_string, input_color, position):
"""
Converts a string written in short algebraic form, the color
of the side whose turn it is, and the corresponding position
into a complete move that can be played. If no moves match,
None is returned.
Examples: e4, Nf3, exd5, Qxf3, 00, ... | python | def short_alg(algebraic_string, input_color, position):
"""
Converts a string written in short algebraic form, the color
of the side whose turn it is, and the corresponding position
into a complete move that can be played. If no moves match,
None is returned.
Examples: e4, Nf3, exd5, Qxf3, 00, ... | [
"def",
"short_alg",
"(",
"algebraic_string",
",",
"input_color",
",",
"position",
")",
":",
"return",
"make_legal",
"(",
"incomplete_alg",
"(",
"algebraic_string",
",",
"input_color",
",",
"position",
")",
",",
"position",
")"
] | Converts a string written in short algebraic form, the color
of the side whose turn it is, and the corresponding position
into a complete move that can be played. If no moves match,
None is returned.
Examples: e4, Nf3, exd5, Qxf3, 00, 000, e8=Q
:type: algebraic_string: str
:type: input_color: ... | [
"Converts",
"a",
"string",
"written",
"in",
"short",
"algebraic",
"form",
"the",
"color",
"of",
"the",
"side",
"whose",
"turn",
"it",
"is",
"and",
"the",
"corresponding",
"position",
"into",
"a",
"complete",
"move",
"that",
"can",
"be",
"played",
".",
"If"... | train | https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/core/algebraic/converter.py#L333-L346 |
LordDarkula/chess_py | chess_py/core/algebraic/converter.py | long_alg | def long_alg(alg_str, position):
"""
Converts a string written in long algebraic form
and the corresponding position into a complete move
(initial location specified). Used primarily for
UCI, but can be used for other purposes.
:type: alg_str: str
:type: position: Board
:rtype: Move
... | python | def long_alg(alg_str, position):
"""
Converts a string written in long algebraic form
and the corresponding position into a complete move
(initial location specified). Used primarily for
UCI, but can be used for other purposes.
:type: alg_str: str
:type: position: Board
:rtype: Move
... | [
"def",
"long_alg",
"(",
"alg_str",
",",
"position",
")",
":",
"if",
"alg_str",
"is",
"None",
"or",
"len",
"(",
"alg_str",
")",
"<",
"4",
"or",
"len",
"(",
"alg_str",
")",
">",
"6",
":",
"raise",
"ValueError",
"(",
"\"Invalid string input {}\"",
".",
"f... | Converts a string written in long algebraic form
and the corresponding position into a complete move
(initial location specified). Used primarily for
UCI, but can be used for other purposes.
:type: alg_str: str
:type: position: Board
:rtype: Move | [
"Converts",
"a",
"string",
"written",
"in",
"long",
"algebraic",
"form",
"and",
"the",
"corresponding",
"position",
"into",
"a",
"complete",
"move",
"(",
"initial",
"location",
"specified",
")",
".",
"Used",
"primarily",
"for",
"UCI",
"but",
"can",
"be",
"us... | train | https://github.com/LordDarkula/chess_py/blob/14bebc2f8c49ae25c59375cc83d0b38d8ff7281d/chess_py/core/algebraic/converter.py#L349-L383 |
cimm-kzn/CGRtools | CGRtools/containers/molecule.py | MoleculeContainer.reset_query_marks | def reset_query_marks(self):
"""
set or reset hyb and neighbors marks to atoms.
"""
for i, atom in self.atoms():
neighbors = 0
hybridization = 1
# hybridization 1- sp3; 2- sp2; 3- sp1; 4- aromatic
for j, bond in self._adj[i].items():
... | python | def reset_query_marks(self):
"""
set or reset hyb and neighbors marks to atoms.
"""
for i, atom in self.atoms():
neighbors = 0
hybridization = 1
# hybridization 1- sp3; 2- sp2; 3- sp1; 4- aromatic
for j, bond in self._adj[i].items():
... | [
"def",
"reset_query_marks",
"(",
"self",
")",
":",
"for",
"i",
",",
"atom",
"in",
"self",
".",
"atoms",
"(",
")",
":",
"neighbors",
"=",
"0",
"hybridization",
"=",
"1",
"# hybridization 1- sp3; 2- sp2; 3- sp1; 4- aromatic",
"for",
"j",
",",
"bond",
"in",
"se... | set or reset hyb and neighbors marks to atoms. | [
"set",
"or",
"reset",
"hyb",
"and",
"neighbors",
"marks",
"to",
"atoms",
"."
] | train | https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/containers/molecule.py#L38-L65 |
cimm-kzn/CGRtools | CGRtools/containers/molecule.py | MoleculeContainer.implicify_hydrogens | def implicify_hydrogens(self):
"""
remove explicit hydrogen if possible
:return: number of removed hydrogens
"""
explicit = defaultdict(list)
c = 0
for n, atom in self.atoms():
if atom.element == 'H':
for m in self.neighbors(n):
... | python | def implicify_hydrogens(self):
"""
remove explicit hydrogen if possible
:return: number of removed hydrogens
"""
explicit = defaultdict(list)
c = 0
for n, atom in self.atoms():
if atom.element == 'H':
for m in self.neighbors(n):
... | [
"def",
"implicify_hydrogens",
"(",
"self",
")",
":",
"explicit",
"=",
"defaultdict",
"(",
"list",
")",
"c",
"=",
"0",
"for",
"n",
",",
"atom",
"in",
"self",
".",
"atoms",
"(",
")",
":",
"if",
"atom",
".",
"element",
"==",
"'H'",
":",
"for",
"m",
... | remove explicit hydrogen if possible
:return: number of removed hydrogens | [
"remove",
"explicit",
"hydrogen",
"if",
"possible"
] | train | https://github.com/cimm-kzn/CGRtools/blob/15a19b04f6e4e1d0dab8e0d32a0877c7f7d70f34/CGRtools/containers/molecule.py#L67-L93 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.