sentence1 stringlengths 52 3.87M | sentence2 stringlengths 1 47.2k | label stringclasses 1
value |
|---|---|---|
def splitPolygon(self, polygon, coplanarFront, coplanarBack, front, back):
"""
Split `polygon` by this plane if needed, then put the polygon or polygon
fragments in the appropriate lists. Coplanar polygons go into either
`coplanarFront` or `coplanarBack` depending on their orientation wi... | Split `polygon` by this plane if needed, then put the polygon or polygon
fragments in the appropriate lists. Coplanar polygons go into either
`coplanarFront` or `coplanarBack` depending on their orientation with
respect to this plane. Polygons in front or in back of this plane go into
ei... | entailment |
def invert(self):
"""
Convert solid space to empty space and empty space to solid space.
"""
for poly in self.polygons:
poly.flip()
self.plane.flip()
if self.front:
self.front.invert()
if self.back:
self.back.invert()
... | Convert solid space to empty space and empty space to solid space. | entailment |
def clipPolygons(self, polygons):
"""
Recursively remove all polygons in `polygons` that are inside this BSP
tree.
"""
if not self.plane:
return polygons[:]
front = []
back = []
for poly in polygons:
self.plane.splitPolygon(poly,... | Recursively remove all polygons in `polygons` that are inside this BSP
tree. | entailment |
def clipTo(self, bsp):
"""
Remove all polygons in this BSP tree that are inside the other BSP tree
`bsp`.
"""
self.polygons = bsp.clipPolygons(self.polygons)
if self.front:
self.front.clipTo(bsp)
if self.back:
self.back.clipTo(bsp) | Remove all polygons in this BSP tree that are inside the other BSP tree
`bsp`. | entailment |
def allPolygons(self):
"""
Return a list of all polygons in this BSP tree.
"""
polygons = self.polygons[:]
if self.front:
polygons.extend(self.front.allPolygons())
if self.back:
polygons.extend(self.back.allPolygons())
return polygons | Return a list of all polygons in this BSP tree. | entailment |
def build(self, polygons):
"""
Build a BSP tree out of `polygons`. When called on an existing tree, the
new polygons are filtered down to the bottom of the tree and become new
nodes there. Each set of polygons is partitioned using the first polygon
(no heuristic is used to pick a... | Build a BSP tree out of `polygons`. When called on an existing tree, the
new polygons are filtered down to the bottom of the tree and become new
nodes there. Each set of polygons is partitioned using the first polygon
(no heuristic is used to pick a good split). | entailment |
def get_rate(currency):
"""Returns the rate from the default currency to `currency`."""
source = get_rate_source()
try:
return Rate.objects.get(source=source, currency=currency).value
except Rate.DoesNotExist:
raise CurrencyConversionException(
"Rate for %s in %s do not exist... | Returns the rate from the default currency to `currency`. | entailment |
def get_rate_source():
"""Get the default Rate Source and return it."""
backend = money_rates_settings.DEFAULT_BACKEND()
try:
return RateSource.objects.get(name=backend.get_source_name())
except RateSource.DoesNotExist:
raise CurrencyConversionException(
"Rate for %s source d... | Get the default Rate Source and return it. | entailment |
def base_convert_money(amount, currency_from, currency_to):
"""
Convert 'amount' from 'currency_from' to 'currency_to'
"""
source = get_rate_source()
# Get rate for currency_from.
if source.base_currency != currency_from:
rate_from = get_rate(currency_from)
else:
# If curren... | Convert 'amount' from 'currency_from' to 'currency_to' | entailment |
def convert_money(amount, currency_from, currency_to):
"""
Convert 'amount' from 'currency_from' to 'currency_to' and return a Money
instance of the converted amount.
"""
new_amount = base_convert_money(amount, currency_from, currency_to)
return moneyed.Money(new_amount, currency_to) | Convert 'amount' from 'currency_from' to 'currency_to' and return a Money
instance of the converted amount. | entailment |
def format_date(format_string=None, datetime_obj=None):
"""
Format a datetime object with Java SimpleDateFormat's-like string.
If datetime_obj is not given - use current datetime.
If format_string is not given - return number of millisecond since epoch.
:param format_string:
:param datetime_ob... | Format a datetime object with Java SimpleDateFormat's-like string.
If datetime_obj is not given - use current datetime.
If format_string is not given - return number of millisecond since epoch.
:param format_string:
:param datetime_obj:
:return:
:rtype string | entailment |
def allZero(buffer):
"""
Tries to determine if a buffer is empty.
@type buffer: str
@param buffer: Buffer to test if it is empty.
@rtype: bool
@return: C{True} if the given buffer is empty, i.e. full of zeros,
C{False} if it doesn't.
"""
allZero = True
for byte ... | Tries to determine if a buffer is empty.
@type buffer: str
@param buffer: Buffer to test if it is empty.
@rtype: bool
@return: C{True} if the given buffer is empty, i.e. full of zeros,
C{False} if it doesn't. | entailment |
def writeByte(self, byte):
"""
Writes a byte into the L{WriteData} stream object.
@type byte: int
@param byte: Byte value to write into the stream.
"""
self.data.write(pack("B" if not self.signed else "b", byte)) | Writes a byte into the L{WriteData} stream object.
@type byte: int
@param byte: Byte value to write into the stream. | entailment |
def writeWord(self, word):
"""
Writes a word value into the L{WriteData} stream object.
@type word: int
@param word: Word value to write into the stream.
"""
self.data.write(pack(self.endianness + ("H" if not self.signed else "h"), word)) | Writes a word value into the L{WriteData} stream object.
@type word: int
@param word: Word value to write into the stream. | entailment |
def writeDword(self, dword):
"""
Writes a dword value into the L{WriteData} stream object.
@type dword: int
@param dword: Dword value to write into the stream.
"""
self.data.write(pack(self.endianness + ("L" if not self.signed else "l"), dword)) | Writes a dword value into the L{WriteData} stream object.
@type dword: int
@param dword: Dword value to write into the stream. | entailment |
def writeQword(self, qword):
"""
Writes a qword value into the L{WriteData} stream object.
@type qword: int
@param qword: Qword value to write into the stream.
"""
self.data.write(pack(self.endianness + ("Q" if not self.signed else "q"), qword)) | Writes a qword value into the L{WriteData} stream object.
@type qword: int
@param qword: Qword value to write into the stream. | entailment |
def setOffset(self, value):
"""
Sets the offset of the L{WriteData} stream object in wich the data is written.
@type value: int
@param value: Integer value that represent the offset we want to start writing in the L{WriteData} stream.
@raise WrongOffsetValue... | Sets the offset of the L{WriteData} stream object in wich the data is written.
@type value: int
@param value: Integer value that represent the offset we want to start writing in the L{WriteData} stream.
@raise WrongOffsetValueException: The value is beyond the total length ... | entailment |
def skipBytes(self, nroBytes):
"""
Skips the specified number as parameter to the current value of the L{WriteData} stream.
@type nroBytes: int
@param nroBytes: The number of bytes to skip.
"""
self.data.seek(nroBytes + self.data.tell()) | Skips the specified number as parameter to the current value of the L{WriteData} stream.
@type nroBytes: int
@param nroBytes: The number of bytes to skip. | entailment |
def readDword(self):
"""
Reads a dword value from the L{ReadData} stream object.
@rtype: int
@return: The dword value read from the L{ReadData} stream.
"""
dword = unpack(self.endianness + ('L' if not self.signed else 'l'), self.readAt(self.offset, 4))[0]
... | Reads a dword value from the L{ReadData} stream object.
@rtype: int
@return: The dword value read from the L{ReadData} stream. | entailment |
def readWord(self):
"""
Reads a word value from the L{ReadData} stream object.
@rtype: int
@return: The word value read from the L{ReadData} stream.
"""
word = unpack(self.endianness + ('H' if not self.signed else 'h'), self.readAt(self.offset, 2))[0]
sel... | Reads a word value from the L{ReadData} stream object.
@rtype: int
@return: The word value read from the L{ReadData} stream. | entailment |
def readByte(self):
"""
Reads a byte value from the L{ReadData} stream object.
@rtype: int
@return: The byte value read from the L{ReadData} stream.
"""
byte = unpack('B' if not self.signed else 'b', self.readAt(self.offset, 1))[0]
self.offset += 1
... | Reads a byte value from the L{ReadData} stream object.
@rtype: int
@return: The byte value read from the L{ReadData} stream. | entailment |
def readQword(self):
"""
Reads a qword value from the L{ReadData} stream object.
@rtype: int
@return: The qword value read from the L{ReadData} stream.
"""
qword = unpack(self.endianness + ('Q' if not self.signed else 'b'), self.readAt(self.offset, 8))[0]
... | Reads a qword value from the L{ReadData} stream object.
@rtype: int
@return: The qword value read from the L{ReadData} stream. | entailment |
def readString(self):
"""
Reads an ASCII string from the L{ReadData} stream object.
@rtype: str
@return: An ASCII string read form the stream.
"""
resultStr = ""
while self.data[self.offset] != "\x00":
resultStr += self.data[self.offset]
... | Reads an ASCII string from the L{ReadData} stream object.
@rtype: str
@return: An ASCII string read form the stream. | entailment |
def readAlignedString(self, align = 4):
"""
Reads an ASCII string aligned to the next align-bytes boundary.
@type align: int
@param align: (Optional) The value we want the ASCII string to be aligned.
@rtype: str
@return: A 4-bytes aligned (default) ASCI... | Reads an ASCII string aligned to the next align-bytes boundary.
@type align: int
@param align: (Optional) The value we want the ASCII string to be aligned.
@rtype: str
@return: A 4-bytes aligned (default) ASCII string. | entailment |
def read(self, nroBytes):
"""
Reads data from the L{ReadData} stream object.
@type nroBytes: int
@param nroBytes: The number of bytes to read.
@rtype: str
@return: A string containing the read data from the L{ReadData} stream object.
@ra... | Reads data from the L{ReadData} stream object.
@type nroBytes: int
@param nroBytes: The number of bytes to read.
@rtype: str
@return: A string containing the read data from the L{ReadData} stream object.
@raise DataLengthException: The number of bytes t... | entailment |
def readAt(self, offset, size):
"""
Reads as many bytes indicated in the size parameter at the specific offset.
@type offset: int
@param offset: Offset of the value to be read.
@type size: int
@param size: This parameter indicates how many bytes are going to be read fro... | Reads as many bytes indicated in the size parameter at the specific offset.
@type offset: int
@param offset: Offset of the value to be read.
@type size: int
@param size: This parameter indicates how many bytes are going to be read from a given offset.
@rtype: str
@retu... | entailment |
def send(self, message, channel_name=None, fail_silently=False,
options=None):
# type: (Text, Optional[str], bool, Optional[SendOptions]) -> None
"""Send a notification to channels
:param message: A message
"""
if channel_name is None:
channels = self.se... | Send a notification to channels
:param message: A message | entailment |
def request(self, method, path,
params=None, headers=None, cookies=None, data=None, json=None, allow_redirects=None, timeout=None):
"""
Prepares and sends an HTTP request. Returns the HTTPResponse object.
:param method: str
:param path: str
:return: response
... | Prepares and sends an HTTP request. Returns the HTTPResponse object.
:param method: str
:param path: str
:return: response
:rtype: HTTPResponse | entailment |
def load_genomic_CDR3_anchor_pos_and_functionality(anchor_pos_file_name):
"""Read anchor position and functionality from file.
Parameters
----------
anchor_pos_file_name : str
File name for the functionality and position of a conserved residue
that defines the CDR3 region for each V or... | Read anchor position and functionality from file.
Parameters
----------
anchor_pos_file_name : str
File name for the functionality and position of a conserved residue
that defines the CDR3 region for each V or J germline sequence.
Returns
-------
anchor_pos_and_functio... | entailment |
def read_igor_V_gene_parameters(params_file_name):
"""Load raw genV from file.
genV is a list of genomic V information. Each element is a list of three
elements. The first is the name of the V allele, the second is the genomic
sequence trimmed to the CDR3 region for productive sequences, and the ... | Load raw genV from file.
genV is a list of genomic V information. Each element is a list of three
elements. The first is the name of the V allele, the second is the genomic
sequence trimmed to the CDR3 region for productive sequences, and the last
is the full germline sequence. For this 'raw gen... | entailment |
def read_igor_D_gene_parameters(params_file_name):
"""Load genD from file.
genD is a list of genomic D information. Each element is a list of the name
of the D allele and the germline sequence.
Parameters
----------
params_file_name : str
File name for a IGOR parameter file.
R... | Load genD from file.
genD is a list of genomic D information. Each element is a list of the name
of the D allele and the germline sequence.
Parameters
----------
params_file_name : str
File name for a IGOR parameter file.
Returns
-------
genD : list
List of genomic... | entailment |
def read_igor_J_gene_parameters(params_file_name):
"""Load raw genJ from file.
genJ is a list of genomic J information. Each element is a list of three
elements. The first is the name of the J allele, the second is the genomic
sequence trimmed to the CDR3 region for productive sequences, and the ... | Load raw genJ from file.
genJ is a list of genomic J information. Each element is a list of three
elements. The first is the name of the J allele, the second is the genomic
sequence trimmed to the CDR3 region for productive sequences, and the last
is the full germline sequence. For this 'raw gen... | entailment |
def read_igor_marginals_txt(marginals_file_name , dim_names=False):
"""Load raw IGoR model marginals.
Parameters
----------
marginals_file_name : str
File name for a IGOR model marginals file.
Returns
-------
model_dict : dict
Dictionary with model marginals.
dimens... | Load raw IGoR model marginals.
Parameters
----------
marginals_file_name : str
File name for a IGOR model marginals file.
Returns
-------
model_dict : dict
Dictionary with model marginals.
dimension_names_dict : dict
Dictionary that defines IGoR model dependecie... | entailment |
def anchor_and_curate_genV_and_genJ(self, V_anchor_pos_file, J_anchor_pos_file):
"""Trim V and J germline sequences to the CDR3 region.
Unproductive sequences have an empty string '' for the CDR3 region
sequence.
Edits the attributes genV and genJ
Param... | Trim V and J germline sequences to the CDR3 region.
Unproductive sequences have an empty string '' for the CDR3 region
sequence.
Edits the attributes genV and genJ
Parameters
----------
V_anchor_pos_file_name : str
File name for the ... | entailment |
def generate_cutV_genomic_CDR3_segs(self):
"""Add palindromic inserted nucleotides to germline V sequences.
The maximum number of palindromic insertions are appended to the
germline V segments so that delV can index directly for number of
nucleotides to delete from a segment.
... | Add palindromic inserted nucleotides to germline V sequences.
The maximum number of palindromic insertions are appended to the
germline V segments so that delV can index directly for number of
nucleotides to delete from a segment.
Sets the attribute cutV_genomic_CDR3_se... | entailment |
def generate_cutJ_genomic_CDR3_segs(self):
"""Add palindromic inserted nucleotides to germline J sequences.
The maximum number of palindromic insertions are appended to the
germline J segments so that delJ can index directly for number of
nucleotides to delete from a segment.
... | Add palindromic inserted nucleotides to germline J sequences.
The maximum number of palindromic insertions are appended to the
germline J segments so that delJ can index directly for number of
nucleotides to delete from a segment.
Sets the attribute cutJ_genomic_CDR3_se... | entailment |
def load_igor_genomic_data(self, params_file_name, V_anchor_pos_file, J_anchor_pos_file):
"""Set attributes by loading in genomic data from IGoR parameter file.
Sets attributes genV, max_delV_palindrome, cutV_genomic_CDR3_segs,
genD, max_delDl_palindrome, max_delDr_palindrome,
... | Set attributes by loading in genomic data from IGoR parameter file.
Sets attributes genV, max_delV_palindrome, cutV_genomic_CDR3_segs,
genD, max_delDl_palindrome, max_delDr_palindrome,
cutD_genomic_CDR3_segs, genJ, max_delJ_palindrome, and
cutJ_genomic_CDR3_segs.
... | entailment |
def generate_cutD_genomic_CDR3_segs(self):
"""Add palindromic inserted nucleotides to germline V sequences.
The maximum number of palindromic insertions are appended to the
germline D segments so that delDl and delDr can index directly for number
of nucleotides to delete from a... | Add palindromic inserted nucleotides to germline V sequences.
The maximum number of palindromic insertions are appended to the
germline D segments so that delDl and delDr can index directly for number
of nucleotides to delete from a segment.
Sets the attribute cutV_gen... | entailment |
def read_VDJ_palindrome_parameters(self, params_file_name):
"""Read V, D, and J palindrome parameters from file.
Sets the attributes max_delV_palindrome, max_delDl_palindrome,
max_delDr_palindrome, and max_delJ_palindrome.
Parameters
----------
params_file_n... | Read V, D, and J palindrome parameters from file.
Sets the attributes max_delV_palindrome, max_delDl_palindrome,
max_delDr_palindrome, and max_delJ_palindrome.
Parameters
----------
params_file_name : str
File name for an IGoR parameter file of a VDJ gen... | entailment |
def load_igor_genomic_data(self, params_file_name, V_anchor_pos_file, J_anchor_pos_file):
"""Set attributes by loading in genomic data from IGoR parameter file.
Sets attributes genV, genJ, max_delV_palindrome, max_delJ_palindrome,
cutV_genomic_CDR3_segs, and cutJ_genomic_CDR3_segs.
... | Set attributes by loading in genomic data from IGoR parameter file.
Sets attributes genV, genJ, max_delV_palindrome, max_delJ_palindrome,
cutV_genomic_CDR3_segs, and cutJ_genomic_CDR3_segs.
Parameters
----------
params_file_name : str
File name for a... | entailment |
def read_igor_VJ_palindrome_parameters(self, params_file_name):
"""Read V and J palindrome parameters from file.
Sets the attributes max_delV_palindrome and max_delJ_palindrome.
Parameters
----------
params_file_name : str
File name for an IGoR parameter... | Read V and J palindrome parameters from file.
Sets the attributes max_delV_palindrome and max_delJ_palindrome.
Parameters
----------
params_file_name : str
File name for an IGoR parameter file of a VJ generative model. | entailment |
def load_and_process_igor_model(self, marginals_file_name):
"""Set attributes by reading a generative model from IGoR marginal file.
Sets attributes PV, PdelV_given_V, PDJ, PdelJ_given_J,
PdelDldelDr_given_D, PinsVD, PinsDJ, Rvd, and Rdj.
Parameters
----------
... | Set attributes by reading a generative model from IGoR marginal file.
Sets attributes PV, PdelV_given_V, PDJ, PdelJ_given_J,
PdelDldelDr_given_D, PinsVD, PinsDJ, Rvd, and Rdj.
Parameters
----------
marginals_file_name : str
File name for a IGoR mode... | entailment |
def load_and_process_igor_model(self, marginals_file_name):
"""Set attributes by reading a generative model from IGoR marginal file.
Sets attributes PVJ, PdelV_given_V, PdelJ_given_J, PinsVJ, and Rvj.
Parameters
----------
marginals_file_name : str
F... | Set attributes by reading a generative model from IGoR marginal file.
Sets attributes PVJ, PdelV_given_V, PdelJ_given_J, PinsVJ, and Rvj.
Parameters
----------
marginals_file_name : str
File name for a IGoR model marginals file. | entailment |
def parse(readDataInstance):
"""
Returns a new L{ImageBoundForwarderRefEntry} object.
@type readDataInstance: L{ReadData}
@param readDataInstance: A L{ReadData} object with the corresponding data to generate a new L{ImageBoundForwarderRefEntry} object.
@rtype: L... | Returns a new L{ImageBoundForwarderRefEntry} object.
@type readDataInstance: L{ReadData}
@param readDataInstance: A L{ReadData} object with the corresponding data to generate a new L{ImageBoundForwarderRefEntry} object.
@rtype: L{ImageBoundForwarderRefEntry}
@return: A ... | entailment |
def parse(readDataInstance, numberOfEntries):
"""
Returns a L{ImageBoundForwarderRef} array where every element is a L{ImageBoundForwarderRefEntry} object.
@type readDataInstance: L{ReadData}
@param readDataInstance: A L{ReadData} object with the corresponding data to generate ... | Returns a L{ImageBoundForwarderRef} array where every element is a L{ImageBoundForwarderRefEntry} object.
@type readDataInstance: L{ReadData}
@param readDataInstance: A L{ReadData} object with the corresponding data to generate a new L{ImageBoundForwarderRef} object.
@type numb... | entailment |
def parse(readDataInstance):
"""
Returns a new L{ImageBoundImportDescriptor} object.
@type readDataInstance: L{ReadData}
@param readDataInstance: A L{ReadData} object containing the data to create a new L{ImageBoundImportDescriptor} object.
@rtype: L{ImageBoundI... | Returns a new L{ImageBoundImportDescriptor} object.
@type readDataInstance: L{ReadData}
@param readDataInstance: A L{ReadData} object containing the data to create a new L{ImageBoundImportDescriptor} object.
@rtype: L{ImageBoundImportDescriptor}
@return: A new {ImageBou... | entailment |
def parse(readDataInstance):
"""
Returns a new L{ImageBoundImportDescriptorEntry} object.
@type readDataInstance: L{ReadData}
@param readDataInstance: A L{ReadData} object containing data to create a new L{ImageBoundImportDescriptorEntry}.
@rtype: L{ImageBoundIm... | Returns a new L{ImageBoundImportDescriptorEntry} object.
@type readDataInstance: L{ReadData}
@param readDataInstance: A L{ReadData} object containing data to create a new L{ImageBoundImportDescriptorEntry}.
@rtype: L{ImageBoundImportDescriptorEntry}
@return: A new {Imag... | entailment |
def parse(readDataInstance):
"""
Returns a new L{TLSDirectory} object.
@type readDataInstance: L{ReadData}
@param readDataInstance: A L{ReadData} object containing data to create a new L{TLSDirectory} object.
@rtype: L{TLSDirectory}
@return: A new {TLSDi... | Returns a new L{TLSDirectory} object.
@type readDataInstance: L{ReadData}
@param readDataInstance: A L{ReadData} object containing data to create a new L{TLSDirectory} object.
@rtype: L{TLSDirectory}
@return: A new {TLSDirectory} object. | entailment |
def parse(readDataInstance):
"""
Returns a new L{TLSDirectory64} object.
@type readDataInstance: L{ReadData}
@param readDataInstance: A L{ReadData} object containing data to create a new L{TLSDirectory64} object.
@rtype: L{TLSDirectory64}
@return: A new ... | Returns a new L{TLSDirectory64} object.
@type readDataInstance: L{ReadData}
@param readDataInstance: A L{ReadData} object containing data to create a new L{TLSDirectory64} object.
@rtype: L{TLSDirectory64}
@return: A new L{TLSDirectory64} object. | entailment |
def parse(readDataInstance):
"""
Returns a new L{ImageLoadConfigDirectory64} object.
@type readDataInstance: L{ReadData}
@param readDataInstance: A L{ReadData} object containing data to create a new L{ImageLoadConfigDirectory64} object.
@rtype: L{ImageLoadConfig... | Returns a new L{ImageLoadConfigDirectory64} object.
@type readDataInstance: L{ReadData}
@param readDataInstance: A L{ReadData} object containing data to create a new L{ImageLoadConfigDirectory64} object.
@rtype: L{ImageLoadConfigDirectory64}
@return: A new L{ImageLoadCo... | entailment |
def parse(readDataInstance):
"""
Returns a new L{ImageBaseRelocationEntry} object.
@type readDataInstance: L{ReadData}
@param readDataInstance: A L{ReadData} object with data to parse as a L{ImageBaseRelocationEntry} object.
@rtype: L{ImageBaseRelocationEntry}
... | Returns a new L{ImageBaseRelocationEntry} object.
@type readDataInstance: L{ReadData}
@param readDataInstance: A L{ReadData} object with data to parse as a L{ImageBaseRelocationEntry} object.
@rtype: L{ImageBaseRelocationEntry}
@return: A new L{ImageBaseRelocationEntry}... | entailment |
def parse(readDataInstance):
"""
Returns a new L{ImageDebugDirectory} object.
@type readDataInstance: L{ReadData}
@param readDataInstance: A new L{ReadData} object with data to be parsed as a L{ImageDebugDirectory} object.
@rtype: L{ImageDebugDirectory}
... | Returns a new L{ImageDebugDirectory} object.
@type readDataInstance: L{ReadData}
@param readDataInstance: A new L{ReadData} object with data to be parsed as a L{ImageDebugDirectory} object.
@rtype: L{ImageDebugDirectory}
@return: A new L{ImageDebugDirectory} object. | entailment |
def parse(readDataInstance, nDebugEntries):
"""
Returns a new L{ImageDebugDirectories} object.
@type readDataInstance: L{ReadData}
@param readDataInstance: A L{ReadData} object with data to be parsed as a L{ImageDebugDirectories} object.
@type nDebugEntries: in... | Returns a new L{ImageDebugDirectories} object.
@type readDataInstance: L{ReadData}
@param readDataInstance: A L{ReadData} object with data to be parsed as a L{ImageDebugDirectories} object.
@type nDebugEntries: int
@param nDebugEntries: Number of L{ImageDebugDirectory} ... | entailment |
def parse(readDataInstance):
"""
Returns a new L{ImageImportDescriptorEntry} object.
@type readDataInstance: L{ReadData}
@param readDataInstance: A L{ReadData} object with data to be parsed as a L{ImageImportDescriptorEntry}.
@rtype: L{ImageImportDescriptorEntry... | Returns a new L{ImageImportDescriptorEntry} object.
@type readDataInstance: L{ReadData}
@param readDataInstance: A L{ReadData} object with data to be parsed as a L{ImageImportDescriptorEntry}.
@rtype: L{ImageImportDescriptorEntry}
@return: A new L{ImageImportDescriptorE... | entailment |
def parse(readDataInstance, nEntries):
"""
Returns a new L{ImageImportDescriptor} object.
@type readDataInstance: L{ReadData}
@param readDataInstance: A L{ReadData} object with data to be parsed as a L{ImageImportDescriptor} object.
@type nEntries: int
... | Returns a new L{ImageImportDescriptor} object.
@type readDataInstance: L{ReadData}
@param readDataInstance: A L{ReadData} object with data to be parsed as a L{ImageImportDescriptor} object.
@type nEntries: int
@param nEntries: The number of L{ImageImportDescriptorEntry}... | entailment |
def parse(readDataInstance):
"""
Returns a new L{ExportTableEntry} object.
@type readDataInstance: L{ReadData}
@param readDataInstance: A L{ReadData} object with data to be parsed as a L{ExportTableEntry} object.
@rtype: L{ExportTableEntry}
@return: A ne... | Returns a new L{ExportTableEntry} object.
@type readDataInstance: L{ReadData}
@param readDataInstance: A L{ReadData} object with data to be parsed as a L{ExportTableEntry} object.
@rtype: L{ExportTableEntry}
@return: A new L{ExportTableEntry} object. | entailment |
def parse(readDataInstance):
"""
Returns a new L{ImageExportTable} object.
@type readDataInstance: L{ReadData}
@param readDataInstance: A L{ReadData} object with data to be parsed as a L{ImageExportTable} object.
@rtype: L{ImageExportTable}
@return: A ne... | Returns a new L{ImageExportTable} object.
@type readDataInstance: L{ReadData}
@param readDataInstance: A L{ReadData} object with data to be parsed as a L{ImageExportTable} object.
@rtype: L{ImageExportTable}
@return: A new L{ImageExportTable} object. | entailment |
def parse(readDataInstance):
"""
Returns a new L{NETDirectory} object.
@type readDataInstance: L{ReadData}
@param readDataInstance: A L{ReadData} object with data to be parsed as a L{NETDirectory} object.
@rtype: L{NETDirectory}
@return: A new L{NETDirec... | Returns a new L{NETDirectory} object.
@type readDataInstance: L{ReadData}
@param readDataInstance: A L{ReadData} object with data to be parsed as a L{NETDirectory} object.
@rtype: L{NETDirectory}
@return: A new L{NETDirectory} object. | entailment |
def parse(readDataInstance):
"""
Returns a new L{NetDirectory} object.
@type readDataInstance: L{ReadData}
@param readDataInstance: A L{ReadData} object with data to be parsed as a L{NetDirectory} object.
@rtype: L{NetDirectory}
@return: A new L{NetDirec... | Returns a new L{NetDirectory} object.
@type readDataInstance: L{ReadData}
@param readDataInstance: A L{ReadData} object with data to be parsed as a L{NetDirectory} object.
@rtype: L{NetDirectory}
@return: A new L{NetDirectory} object. | entailment |
def parse(readDataInstance):
"""
Returns a new L{NetMetaDataHeader} object.
@type readDataInstance: L{ReadData}
@param readDataInstance: A L{ReadData} object with data to be parsed as a L{NetMetaDataHeader} object.
@rtype: L{NetMetaDataHeader}
@return: A... | Returns a new L{NetMetaDataHeader} object.
@type readDataInstance: L{ReadData}
@param readDataInstance: A L{ReadData} object with data to be parsed as a L{NetMetaDataHeader} object.
@rtype: L{NetMetaDataHeader}
@return: A new L{NetMetaDataHeader} object. | entailment |
def parse(readDataInstance):
"""
Returns a new L{NetMetaDataStreamEntry} object.
@type readDataInstance: L{ReadData}
@param readDataInstance: A L{ReadData} object with data to be parsed as a L{NetMetaDataStreamEntry}.
@rtype: L{NetMetaDataStreamEntry}
@r... | Returns a new L{NetMetaDataStreamEntry} object.
@type readDataInstance: L{ReadData}
@param readDataInstance: A L{ReadData} object with data to be parsed as a L{NetMetaDataStreamEntry}.
@rtype: L{NetMetaDataStreamEntry}
@return: A new L{NetMetaDataStreamEntry} object. | entailment |
def parse(readDataInstance, nStreams):
"""
Returns a new L{NetMetaDataStreams} object.
@type readDataInstance: L{ReadData}
@param readDataInstance: A L{ReadData} object with data to be parsed as a L{NetMetaDataStreams} object.
@type nStreams: int
@param... | Returns a new L{NetMetaDataStreams} object.
@type readDataInstance: L{ReadData}
@param readDataInstance: A L{ReadData} object with data to be parsed as a L{NetMetaDataStreams} object.
@type nStreams: int
@param nStreams: The number of L{NetMetaDataStreamEntry} objects i... | entailment |
def parse(readDataInstance):
"""
Returns a new L{NetMetaDataTableHeader} object.
@type readDataInstance: L{ReadData}
@param readDataInstance: A L{ReadData} object with data to be parsed as a L{NetMetaDataTableHeader} object.
@rtype: L{NetMetaDataTableHeader}
... | Returns a new L{NetMetaDataTableHeader} object.
@type readDataInstance: L{ReadData}
@param readDataInstance: A L{ReadData} object with data to be parsed as a L{NetMetaDataTableHeader} object.
@rtype: L{NetMetaDataTableHeader}
@return: A new L{NetMetaDataTableHeader} obj... | entailment |
def parse(readDataInstance, netMetaDataStreams):
"""
Returns a new L{NetMetaDataTables} object.
@type readDataInstance: L{ReadData}
@param readDataInstance: A L{ReadData} object with data to be parsed as a L{NetMetaDataTables} object.
@rtype: L{NetMetaDataTables... | Returns a new L{NetMetaDataTables} object.
@type readDataInstance: L{ReadData}
@param readDataInstance: A L{ReadData} object with data to be parsed as a L{NetMetaDataTables} object.
@rtype: L{NetMetaDataTables}
@return: A new L{NetMetaDataTables} object. | entailment |
def parse(readDataInstance):
"""
Returns a new L{NetResources} object.
@type readDataInstance: L{ReadData}
@param readDataInstance: A L{ReadData} object with data to be parsed as a L{NetResources} object.
@rtype: L{NetResources}
@return: A new L{NetResources} object.
... | Returns a new L{NetResources} object.
@type readDataInstance: L{ReadData}
@param readDataInstance: A L{ReadData} object with data to be parsed as a L{NetResources} object.
@rtype: L{NetResources}
@return: A new L{NetResources} object. | entailment |
def verify_and_fill_address_paths_from_bip32key(address_paths, master_key, network):
'''
Take address paths and verifies their accuracy client-side.
Also fills in all the available metadata (WIF, public key, etc)
'''
assert network, network
wallet_obj = Wallet.deserialize(master_key, network=... | Take address paths and verifies their accuracy client-side.
Also fills in all the available metadata (WIF, public key, etc) | entailment |
def solution_path(self):
'''Follows the solution path of the generalized lasso to find the best lambda value.'''
lambda_grid = np.exp(np.linspace(np.log(self.max_lambda), np.log(self.min_lambda), self.lambda_bins))
aic_trace = np.zeros((len(self.bins),lambda_grid.shape[0])) # The AIC score for e... | Follows the solution path of the generalized lasso to find the best lambda value. | entailment |
def run(self, lam, initial_values=None):
'''Run the graph-fused logit lasso with a fixed lambda penalty.'''
if initial_values is not None:
if self.k == 0 and self.trails is not None:
betas, zs, us = initial_values
else:
betas, us = initial_values
... | Run the graph-fused logit lasso with a fixed lambda penalty. | entailment |
def data_log_likelihood(self, successes, trials, beta):
'''Calculates the log-likelihood of a Polya tree bin given the beta values.'''
return binom.logpmf(successes, trials, 1.0 / (1 + np.exp(-beta))).sum() | Calculates the log-likelihood of a Polya tree bin given the beta values. | entailment |
def spawn_worker(params):
"""
This method has to be module level function
:type params: Params
"""
setup_logging(params)
log.info("Adding worker: idx=%s\tconcurrency=%s\tresults=%s", params.worker_index, params.concurrency,
params.report)
worker = Worker(params)
worker.star... | This method has to be module level function
:type params: Params | entailment |
def run_nose(self, params):
"""
:type params: Params
"""
thread.set_index(params.thread_index)
log.debug("[%s] Starting nose iterations: %s", params.worker_index, params)
assert isinstance(params.tests, list)
# argv.extend(['--with-apiritif', '--nocapture', '--exe... | :type params: Params | entailment |
def _write_single_sample(self, sample):
"""
:type sample: Sample
"""
bytes = sample.extras.get("responseHeadersSize", 0) + 2 + sample.extras.get("responseBodySize", 0)
message = sample.error_msg
if not message:
message = sample.extras.get("responseMessage")
... | :type sample: Sample | entailment |
def addError(self, test, error):
"""
when a test raises an uncaught exception
:param test:
:param error:
:return:
"""
# test_dict will be None if startTest wasn't called (i.e. exception in setUp/setUpClass)
# status=BROKEN
if self.current_sample is... | when a test raises an uncaught exception
:param test:
:param error:
:return: | entailment |
def parse(readDataInstance):
"""
Returns a L{Directory}-like object.
@type readDataInstance: L{ReadData}
@param readDataInstance: L{ReadData} object to read from.
@rtype: L{Directory}
@return: L{Directory} object.
"""
d = Directory()
... | Returns a L{Directory}-like object.
@type readDataInstance: L{ReadData}
@param readDataInstance: L{ReadData} object to read from.
@rtype: L{Directory}
@return: L{Directory} object. | entailment |
def parse(readDataInstance):
"""Returns a L{DataDirectory}-like object.
@type readDataInstance: L{ReadData}
@param readDataInstance: L{ReadData} object to read from.
@rtype: L{DataDirectory}
@return: The L{DataDirectory} object containing L{consts.IMAGE_NUMBEROF... | Returns a L{DataDirectory}-like object.
@type readDataInstance: L{ReadData}
@param readDataInstance: L{ReadData} object to read from.
@rtype: L{DataDirectory}
@return: The L{DataDirectory} object containing L{consts.IMAGE_NUMBEROF_DIRECTORY_ENTRIES} L{Directory} objects... | entailment |
def main():
"""Compute Pgens from a file and output to another file."""
parser = OptionParser(conflict_handler="resolve")
parser.add_option('--humanTRA', '--human_T_alpha', action='store_true', dest='humanTRA', default=False, help='use default human TRA model (T cell alpha chain)')
parser.add_option('... | Compute Pgens from a file and output to another file. | entailment |
def create_plateaus(data, edges, plateau_size, plateau_vals, plateaus=None):
'''Creates plateaus of constant value in the data.'''
nodes = set(edges.keys())
if plateaus is None:
plateaus = []
for i in range(len(plateau_vals)):
if len(nodes) == 0:
break
... | Creates plateaus of constant value in the data. | entailment |
def pretty_str(p, decimal_places=2, print_zero=True, label_columns=False):
'''Pretty-print a matrix or vector.'''
if len(p.shape) == 1:
return vector_str(p, decimal_places, print_zero)
if len(p.shape) == 2:
return matrix_str(p, decimal_places, print_zero, label_columns)
raise Exception('... | Pretty-print a matrix or vector. | entailment |
def matrix_str(p, decimal_places=2, print_zero=True, label_columns=False):
'''Pretty-print the matrix.'''
return '[{0}]'.format("\n ".join([(str(i) if label_columns else '') + vector_str(a, decimal_places, print_zero) for i, a in enumerate(p)])) | Pretty-print the matrix. | entailment |
def vector_str(p, decimal_places=2, print_zero=True):
'''Pretty-print the vector values.'''
style = '{0:.' + str(decimal_places) + 'f}'
return '[{0}]'.format(", ".join([' ' if not print_zero and a == 0 else style.format(a) for a in p])) | Pretty-print the vector values. | entailment |
def calc_plateaus(beta, edges, rel_tol=1e-4, verbose=0):
'''Calculate the plateaus (degrees of freedom) of a graph of beta values in linear time.'''
if not isinstance(edges, dict):
raise Exception('Edges must be a map from each node to a list of neighbors.')
to_check = deque(range(len(beta)))
ch... | Calculate the plateaus (degrees of freedom) of a graph of beta values in linear time. | entailment |
def nearly_unique(arr, rel_tol=1e-4, verbose=0):
'''Heuristic method to return the uniques within some precision in a numpy array'''
results = np.array([arr[0]])
for x in arr:
if np.abs(results - x).min() > rel_tol:
results = np.append(results, x)
return results | Heuristic method to return the uniques within some precision in a numpy array | entailment |
def hypercube_edges(dims, use_map=False):
'''Create edge lists for an arbitrary hypercube. TODO: this is probably not the fastest way.'''
edges = []
nodes = np.arange(np.product(dims)).reshape(dims)
for i,d in enumerate(dims):
for j in range(d-1):
for n1, n2 in zip(np.take(nodes, [j]... | Create edge lists for an arbitrary hypercube. TODO: this is probably not the fastest way. | entailment |
def get_delta(D, k):
'''Calculate the k-th order trend filtering matrix given the oriented edge
incidence matrix and the value of k.'''
if k < 0:
raise Exception('k must be at least 0th order.')
result = D
for i in range(k):
result = D.T.dot(result) if i % 2 == 0 else D.dot(result)
... | Calculate the k-th order trend filtering matrix given the oriented edge
incidence matrix and the value of k. | entailment |
def decompose_delta(deltak):
'''Decomposes the k-th order trend filtering matrix into a c-compatible set
of arrays.'''
if not isspmatrix_coo(deltak):
deltak = coo_matrix(deltak)
dk_rows = deltak.shape[0]
dk_rowbreaks = np.cumsum(deltak.getnnz(1), dtype="int32")
dk_cols = deltak.col.astyp... | Decomposes the k-th order trend filtering matrix into a c-compatible set
of arrays. | entailment |
def matrix_from_edges(edges):
'''Returns a sparse penalty matrix (D) from a list of edge pairs. Each edge
can have an optional weight associated with it.'''
max_col = 0
cols = []
rows = []
vals = []
if type(edges) is defaultdict:
edge_list = []
for i, neighbors in edges.items... | Returns a sparse penalty matrix (D) from a list of edge pairs. Each edge
can have an optional weight associated with it. | entailment |
def ks_distance(a, b):
'''Get the Kolmogorov-Smirnov (KS) distance between two densities a and b.'''
if len(a.shape) == 1:
return np.max(np.abs(a.cumsum() - b.cumsum()))
return np.max(np.abs(a.cumsum(axis=1) - b.cumsum(axis=1)), axis=1) | Get the Kolmogorov-Smirnov (KS) distance between two densities a and b. | entailment |
def tv_distance(a, b):
'''Get the Total Variation (TV) distance between two densities a and b.'''
if len(a.shape) == 1:
return np.sum(np.abs(a - b))
return np.sum(np.abs(a - b), axis=1) | Get the Total Variation (TV) distance between two densities a and b. | entailment |
def jdFromDate(dd, mm, yy):
'''def jdFromDate(dd, mm, yy): Compute the (integral) Julian day number of
day dd/mm/yyyy, i.e., the number of days between 1/1/4713 BC
(Julian calendar) and dd/mm/yyyy.'''
a = int((14 - mm) / 12.)
y = yy + 4800 - a
m = mm + 12 * a - 3
jd = dd + int((153 * m + 2) ... | def jdFromDate(dd, mm, yy): Compute the (integral) Julian day number of
day dd/mm/yyyy, i.e., the number of days between 1/1/4713 BC
(Julian calendar) and dd/mm/yyyy. | entailment |
def jdToDate(jd):
'''def jdToDate(jd): Convert a Julian day number to day/month/year.
jd is an integer.'''
if (jd > 2299160):
# After 5/10/1582, Gregorian calendar
a = jd + 32044
b = int((4 * a + 3) / 146097.)
c = a - int((b * 146097) / 4.)
else:
... | def jdToDate(jd): Convert a Julian day number to day/month/year.
jd is an integer. | entailment |
def NewMoon(k):
'''def NewMoon(k): Compute the time of the k-th new moon after
the new moon of 1/1/1900 13:52 UCT (measured as the number of
days since 1/1/4713 BC noon UCT, e.g., 2451545.125 is 1/1/2000 15:00 UTC.
Returns a floating number, e.g., 2415079.9758617813 for k=2 or
2414961.935157746 for ... | def NewMoon(k): Compute the time of the k-th new moon after
the new moon of 1/1/1900 13:52 UCT (measured as the number of
days since 1/1/4713 BC noon UCT, e.g., 2451545.125 is 1/1/2000 15:00 UTC.
Returns a floating number, e.g., 2415079.9758617813 for k=2 or
2414961.935157746 for k=-2. | entailment |
def SunLongitude(jdn):
'''def SunLongitude(jdn): Compute the longitude of the sun at any time.
Parameter: floating number jdn, the number of days since 1/1/4713 BC noon.
'''
T = (jdn - 2451545.0) / 36525.
# Time in Julian centuries
# from 2000-01-01 12:00:00 GMT
T2 = T * T
dr = math.pi /... | def SunLongitude(jdn): Compute the longitude of the sun at any time.
Parameter: floating number jdn, the number of days since 1/1/4713 BC noon. | entailment |
def getLunarMonth11(yy, timeZone):
'''def getLunarMonth11(yy, timeZone): Find the day that starts the luner month
11of the given year for the given time zone.'''
# off = jdFromDate(31, 12, yy) \
# - 2415021.076998695
off = jdFromDate(31, 12, yy) - 2415021.
k = int(off / 29.530588853)... | def getLunarMonth11(yy, timeZone): Find the day that starts the luner month
11of the given year for the given time zone. | entailment |
def getLeapMonthOffset(a11, timeZone):
'''def getLeapMonthOffset(a11, timeZone): Find the index of the leap month
after the month starting on the day a11.'''
k = int((a11 - 2415021.076998695) / 29.530588853 + 0.5)
last = 0
i = 1 # start with month following lunar month 11
arc = getSunLongitude(... | def getLeapMonthOffset(a11, timeZone): Find the index of the leap month
after the month starting on the day a11. | entailment |
def S2L(dd, mm, yy, timeZone=7):
'''def S2L(dd, mm, yy, timeZone = 7): Convert solar date dd/mm/yyyy to
the corresponding lunar date.'''
dayNumber = jdFromDate(dd, mm, yy)
k = int((dayNumber - 2415021.076998695) / 29.530588853)
monthStart = getNewMoonDay(k + 1, timeZone)
if (monthStart > dayNumb... | def S2L(dd, mm, yy, timeZone = 7): Convert solar date dd/mm/yyyy to
the corresponding lunar date. | entailment |
def L2S(lunarD, lunarM, lunarY, lunarLeap, tZ=7):
'''def L2S(lunarD, lunarM, lunarY, lunarLeap, tZ = 7): Convert a lunar date
to the corresponding solar date.'''
if (lunarM < 11):
a11 = getLunarMonth11(lunarY - 1, tZ)
b11 = getLunarMonth11(lunarY, tZ)
else:
a11 = getLunarMonth11(... | def L2S(lunarD, lunarM, lunarY, lunarLeap, tZ = 7): Convert a lunar date
to the corresponding solar date. | entailment |
def hasMZSignature(self, rd):
"""
Check for MZ signature.
@type rd: L{ReadData}
@param rd: A L{ReadData} object.
@rtype: bool
@return: True is the given L{ReadData} stream has the MZ signature. Otherwise, False.
"""
rd.setOffset(0)
sign = rd.rea... | Check for MZ signature.
@type rd: L{ReadData}
@param rd: A L{ReadData} object.
@rtype: bool
@return: True is the given L{ReadData} stream has the MZ signature. Otherwise, False. | entailment |
def hasPESignature(self, rd):
"""
Check for PE signature.
@type rd: L{ReadData}
@param rd: A L{ReadData} object.
@rtype: bool
@return: True is the given L{ReadData} stream has the PE signature. Otherwise, False.
"""
rd.setOffset(0)
e_lfanew_offse... | Check for PE signature.
@type rd: L{ReadData}
@param rd: A L{ReadData} object.
@rtype: bool
@return: True is the given L{ReadData} stream has the PE signature. Otherwise, False. | entailment |
def validate(self):
"""
Performs validations over some fields of the PE structure to determine if the loaded file has a valid PE format.
@raise PEException: If an invalid value is found into the PE instance.
"""
# Ange Albertini (@angie4771) can kill me for this! :)
... | Performs validations over some fields of the PE structure to determine if the loaded file has a valid PE format.
@raise PEException: If an invalid value is found into the PE instance. | entailment |
def readFile(self, pathToFile):
"""
Returns data from a file.
@type pathToFile: str
@param pathToFile: Path to the file.
@rtype: str
@return: The data from file.
"""
fd = open(pathToFile, "rb")
data = fd.read()
fd.close()... | Returns data from a file.
@type pathToFile: str
@param pathToFile: Path to the file.
@rtype: str
@return: The data from file. | entailment |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.