sentence1
stringlengths
52
3.87M
sentence2
stringlengths
1
47.2k
label
stringclasses
1 value
def find_ips_by_equip(self, id_equip): """ Get Ips related to equipment by its identifier :param id_equip: Equipment identifier. Integer value and greater than zero. :return: Dictionary with the following structure: { ips: { ipv4:[ id: <id_ip4>, oct...
Get Ips related to equipment by its identifier :param id_equip: Equipment identifier. Integer value and greater than zero. :return: Dictionary with the following structure: { ips: { ipv4:[ id: <id_ip4>, oct1: <oct1>, oct2: <oct2>, oct3: <oct...
entailment
def find_ip6_by_id(self, id_ip): """ Get an IP6 by ID :param id_ip: IP6 identifier. Integer value and greater than zero. :return: Dictionary with the following structure: :: {'ip': {'id': < id >, 'block1': <block1>, 'block2': <block2>, ...
Get an IP6 by ID :param id_ip: IP6 identifier. Integer value and greater than zero. :return: Dictionary with the following structure: :: {'ip': {'id': < id >, 'block1': <block1>, 'block2': <block2>, 'block3': <block3>, 'block4': <bl...
entailment
def save_ipv6(self, ip6, id_equip, descricao, id_net): """ Save an IP6 and associate with equipment :param ip6: An IP6 available to save in format xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx. :param id_equip: Equipment identifier. Integer value and greater than zero. :param descrica...
Save an IP6 and associate with equipment :param ip6: An IP6 available to save in format xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx. :param id_equip: Equipment identifier. Integer value and greater than zero. :param descricao: IPv6 description. :param id_net: Network identifier. Integer val...
entailment
def delete_ip4(self, id_ip): """ Delete an IP4 :param id_ip: Ipv4 identifier. Integer value and greater than zero. :return: None :raise IpNotFoundError: IP is not registered. :raise DataBaseError: Networkapi failed to access the database. """ if not i...
Delete an IP4 :param id_ip: Ipv4 identifier. Integer value and greater than zero. :return: None :raise IpNotFoundError: IP is not registered. :raise DataBaseError: Networkapi failed to access the database.
entailment
def find_ip6_by_network(self, id_network): """List IPv6 from network. :param id_network: Network ipv6 identifier. Integer value and greater than zero. :return: Dictionary with the following structure: :: {'ip': {'id': < id >, 'id_vlan': < id_vlan >, ...
List IPv6 from network. :param id_network: Network ipv6 identifier. Integer value and greater than zero. :return: Dictionary with the following structure: :: {'ip': {'id': < id >, 'id_vlan': < id_vlan >, 'block1': <block1>, 'block2': <block2>, ...
entailment
def search_ipv6_environment(self, ipv6, id_environment): """Get IPv6 with an associated environment. :param ipv6: IPv6 address in the format x1:x2:x3:x4:x5:x6:x7:x8. :param id_environment: Environment identifier. Integer value and greater than zero. :return: Dictionary with the followi...
Get IPv6 with an associated environment. :param ipv6: IPv6 address in the format x1:x2:x3:x4:x5:x6:x7:x8. :param id_environment: Environment identifier. Integer value and greater than zero. :return: Dictionary with the following structure: :: {'ipv6': {'id': < id >, ...
entailment
def assoc_ipv4(self, id_ip, id_equip, id_net): """ Associate an IP4 with equipment. :param id_ip: IPv4 identifier. :param id_equip: Equipment identifier. Integer value and greater than zero. :param id_net: Network identifier. Integer value and greater than zero. :return...
Associate an IP4 with equipment. :param id_ip: IPv4 identifier. :param id_equip: Equipment identifier. Integer value and greater than zero. :param id_net: Network identifier. Integer value and greater than zero. :return: None :raise InvalidParameterError: IPv4, Equipment or Ne...
entailment
def assoc_ipv6(self, id_ip, id_equip, id_net): """ Associate an IP6 with equipment. :param id_ip: IPv6 identifier. :param id_equip: Equipment identifier. Integer value and greater than zero. :param id_net: Network identifier. Integer value and greater than zero. :return...
Associate an IP6 with equipment. :param id_ip: IPv6 identifier. :param id_equip: Equipment identifier. Integer value and greater than zero. :param id_net: Network identifier. Integer value and greater than zero. :return: None :raise InvalidParameterError: IPv6, Equipment or Ne...
entailment
def listar(self): """List all network types. :return: Following dictionary: :: {'net_type': [{'id': < id_tipo_rede >, 'name': < nome_tipo_rede >}, ... other network types ...]} :raise DataBaseError: Networkapi failed to access the database. :raise XMLE...
List all network types. :return: Following dictionary: :: {'net_type': [{'id': < id_tipo_rede >, 'name': < nome_tipo_rede >}, ... other network types ...]} :raise DataBaseError: Networkapi failed to access the database. :raise XMLError: Networkapi failed to ge...
entailment
def inserir(self, name): """Insert new network type and return its identifier. :param name: Network type name. :return: Following dictionary: {'net_type': {'id': < id >}} :raise InvalidParameterError: Network type is none or invalid. :raise NomeTipoRedeDuplicadoError: A networ...
Insert new network type and return its identifier. :param name: Network type name. :return: Following dictionary: {'net_type': {'id': < id >}} :raise InvalidParameterError: Network type is none or invalid. :raise NomeTipoRedeDuplicadoError: A network type with this name already exists...
entailment
def alterar(self, id_net_type, name): """Edit network type by its identifier. :param id_net_type: Network type identifier. :param name: Network type name. :return: None :raise InvalidParameterError: Network type identifier and/or name is(are) none or invalid. :raise Ti...
Edit network type by its identifier. :param id_net_type: Network type identifier. :param name: Network type name. :return: None :raise InvalidParameterError: Network type identifier and/or name is(are) none or invalid. :raise TipoRedeNaoExisteError: Network type does not exist...
entailment
def remover(self, id_net_type): """Remove network type by its identifier. :param id_net_type: Network type identifier. :return: None :raise TipoRedeNaoExisteError: Network type does not exist. :raise TipoRedeError: Network type is associated with network. :raise Invali...
Remove network type by its identifier. :param id_net_type: Network type identifier. :return: None :raise TipoRedeNaoExisteError: Network type does not exist. :raise TipoRedeError: Network type is associated with network. :raise InvalidParameterError: Network type is none or in...
entailment
def cc(filename: 'input source file', output: 'output file name. default to be replacing input file\'s suffix with ".py"' = None, name: 'name of language' = 'unname'): """ rbnf source code compiler. """ lang = Language(name) with Path(filename).open('r') as fr: build_l...
rbnf source code compiler.
entailment
def run(filename: 'python file generated by `rbnf` command, or rbnf sour file', opt: 'optimize switch' = False): """ You can apply immediate tests on your parser. P.S: use `--opt` option takes longer starting time. """ from rbnf.easy import build_parser import importlib.util import t...
You can apply immediate tests on your parser. P.S: use `--opt` option takes longer starting time.
entailment
def rbnf_lexing(text: str): """Read loudly for documentation.""" cast_map: const = _cast_map lexer_table: const = _lexer_table keyword: const = _keyword drop_table: const = _DropTable end: const = _END unknown: const = _UNKNOWN text_length = len(text) colno ...
Read loudly for documentation.
entailment
def recover_codes(tokens: Iterator[Tokenizer]) -> str: """ from a series of tokenizers to code string. (preserve the indentation) """ tokens = iter(tokens) s = [] try: head = next(tokens) except StopIteration: return s append = s.append lineno = head.lineno ...
from a series of tokenizers to code string. (preserve the indentation)
entailment
def str_lexer(mode): """ generate token strings' cache """ cast_to_const = ConstStrPool.cast_to_const def f_raw(inp_str, pos): return cast_to_const(mode) if inp_str.startswith(mode, pos) else None def f_collection(inp_str, pos): for each in mode: if inp_str.startswi...
generate token strings' cache
entailment
def regex_lexer(regex_pat): """ generate token names' cache """ if isinstance(regex_pat, str): regex_pat = re.compile(regex_pat) def f(inp_str, pos): m = regex_pat.match(inp_str, pos) return m.group() if m else None elif hasattr(regex_pat, 'match'): ...
generate token names' cache
entailment
def dispatch(self, tree): "Dispatcher function, dispatching tree type T to method _T." if isinstance(tree, list): for t in tree: self.dispatch(t) return meth = getattr(self, "_" + tree.__class__.__name__) meth(tree)
Dispatcher function, dispatching tree type T to method _T.
entailment
def process(fn, bound_names): """ process automatic context variable capturing. return the transformed function and its ast. """ if isinstance(fn, _AutoContext): fn = fn.fn # noinspection PyArgumentList,PyArgumentList if isinstance(fn, _FnCodeStr): if bound_names: ...
process automatic context variable capturing. return the transformed function and its ast.
entailment
def ignore(self, *ignore_lst: str): """ ignore a set of tokens with specific names """ def stream(): for each in ignore_lst: each = ConstStrPool.cast_to_const(each) yield id(each), each self.ignore_lst.update(stream())
ignore a set of tokens with specific names
entailment
def build_language(source_code: str, lang: Language, filename: str): """ lang: language object represents your language. """ state = MetaState(rbnf.implementation, requires=_Wild(), filename=filename) state.data = lang _build_language(source_code, state) lang.build()
lang: language object represents your language.
entailment
def _decode_POST_value(request, field_name, default=None): """Helper to decode a request field into unicode based on charsets encoding. Args: request: the HttpRequest object. field_name: the field expected in the request.POST Kwargs: default: if passed in then field is optional and...
Helper to decode a request field into unicode based on charsets encoding. Args: request: the HttpRequest object. field_name: the field expected in the request.POST Kwargs: default: if passed in then field is optional and default is used if not found; if None, then assume fi...
entailment
def _get_addresses(self, address_data, retain_name=False): """ Takes RFC-compliant email addresses in both terse (email only) and verbose (name + email) forms and returns a list of email address strings (TODO: breaking change that returns a tuple of (name, email) per string) ...
Takes RFC-compliant email addresses in both terse (email only) and verbose (name + email) forms and returns a list of email address strings (TODO: breaking change that returns a tuple of (name, email) per string)
entailment
def parse(self, request): """Parse incoming request and return an email instance. Args: request: an HttpRequest object, containing the forwarded email, as per the SendGrid specification for inbound emails. Returns: an EmailMultiAlternatives instance, con...
Parse incoming request and return an email instance. Args: request: an HttpRequest object, containing the forwarded email, as per the SendGrid specification for inbound emails. Returns: an EmailMultiAlternatives instance, containing the parsed contents ...
entailment
def parse(self, request): """Parse incoming request and return an email instance. Mailgun does a lot of the heavy lifting at their end - requests come in from them UTF-8 encoded, and with the message reply and signature stripped out for you. Args: request: an HttpRe...
Parse incoming request and return an email instance. Mailgun does a lot of the heavy lifting at their end - requests come in from them UTF-8 encoded, and with the message reply and signature stripped out for you. Args: request: an HttpRequest object, containing the forwarde...
entailment
def _get_recipients(self, array): """Returns an iterator of objects in the form ["Name <address@example.com", ...] from the array [["address@example.com", "Name"]] """ for address, name in array: if not name: yield address else: ...
Returns an iterator of objects in the form ["Name <address@example.com", ...] from the array [["address@example.com", "Name"]]
entailment
def parse(self, request): """Parse incoming request and return an email instance. Args: request: an HttpRequest object, containing a list of forwarded emails, as per Mandrill specification for inbound emails. Returns: a list of EmailMultiAlternatives ins...
Parse incoming request and return an email instance. Args: request: an HttpRequest object, containing a list of forwarded emails, as per Mandrill specification for inbound emails. Returns: a list of EmailMultiAlternatives instances
entailment
def _log_request(request): """Helper function to dump out debug info.""" logger.debug("Inbound email received") for k, v in list(request.POST.items()): logger.debug("- POST['%s']='%s'" % (k, v)) for n, f in list(request.FILES.items()): logger.debug("- FILES['%s']: '%s', %sB", n, f.cont...
Helper function to dump out debug info.
entailment
def receive_inbound_email(request): """Receives inbound email from SendGrid. This view receives the email from SendGrid, parses the contents, logs the message and the fires the inbound_email signal. """ # log the request.POST and request.FILES contents if log_requests is True: _log_req...
Receives inbound email from SendGrid. This view receives the email from SendGrid, parses the contents, logs the message and the fires the inbound_email signal.
entailment
def get_backend_class(): """Return reference to the configured backed class.""" # this will (intentionally) blow up if the setting does not exist assert hasattr(settings, 'INBOUND_EMAIL_PARSER') assert getattr(settings, 'INBOUND_EMAIL_PARSER') is not None package, klass = settings.INBOUND_EMAIL_PAR...
Return reference to the configured backed class.
entailment
def sorted_exists(values, x): """ For list, values, returns the insert position for item x and whether the item already exists in the list. This allows one function call to return either the index to overwrite an existing value in the list, or the index to insert a new item in the list and keep the list...
For list, values, returns the insert position for item x and whether the item already exists in the list. This allows one function call to return either the index to overwrite an existing value in the list, or the index to insert a new item in the list and keep the list in sorted order. :param values: list...
entailment
def sorted_index(values, x): """ For list, values, returns the index location of element x. If x does not exist will raise an error. :param values: list :param x: item :return: integer index """ i = bisect_left(values, x) j = bisect_right(values, x) return values[i:j].index(x) + i
For list, values, returns the index location of element x. If x does not exist will raise an error. :param values: list :param x: item :return: integer index
entailment
def sorted_list_indexes(list_to_sort, key=None, reverse=False): """ Sorts a list but returns the order of the index values of the list for the sort and not the values themselves. For example is the list provided is ['b', 'a', 'c'] then the result will be [2, 1, 3] :param list_to_sort: list to sort ...
Sorts a list but returns the order of the index values of the list for the sort and not the values themselves. For example is the list provided is ['b', 'a', 'c'] then the result will be [2, 1, 3] :param list_to_sort: list to sort :param key: if not None then a function of one argument that is used to extr...
entailment
def runDia(diagram): """Generate the diagrams using Dia.""" ifname = '{}.dia'.format(diagram) ofname = '{}.png'.format(diagram) cmd = 'dia -t png-libart -e {} {}'.format(ofname, ifname) print(' {}'.format(cmd)) subprocess.call(cmd, shell=True) return True
Generate the diagrams using Dia.
entailment
def init2( self, input_tube, # Read task from the input tube. output_tubes, # Send result on all the output tubes. num_workers, # Total number of workers in the stage. disable_result, # Whether to override any result with None. do_stop_task, # Whether to ...
Create *num_workers* worker objects with *input_tube* and an iterable of *output_tubes*. The worker reads a task from *input_tube* and writes the result to *output_tubes*.
entailment
def assemble( cls, args, input_tube, output_tubes, size, disable_result=False, do_stop_task=False, ): """Create, assemble and start workers. Workers are created of class *cls*, initialized with *args*, and given task/result com...
Create, assemble and start workers. Workers are created of class *cls*, initialized with *args*, and given task/result communication channels *input_tube* and *output_tubes*. The number of workers created is according to *size* parameter. *do_stop_task* indicates whether doTask() will be...
entailment
def _link(self, next_worker, next_is_first=False): """Link the worker to the given next worker object, connecting the two workers with communication tubes.""" lock = multiprocessing.Lock() next_worker._lock_prev_input = lock self._lock_next_input = lock lock.acquire() ...
Link the worker to the given next worker object, connecting the two workers with communication tubes.
entailment
def putResult(self, result): """Register the *result* by putting it on all the output tubes.""" self._lock_prev_output.acquire() for tube in self._tubes_result_output: tube.put((result, 0)) self._lock_next_output.release()
Register the *result* by putting it on all the output tubes.
entailment
def init2( self, input_tube, # Read task from the input tube. output_tubes, # Send result on all the output tubes. num_workers, # Total number of workers in the stage. disable_result, # Whether to override any result with None. do_stop_task, # Whether to ...
Create *num_workers* worker objects with *input_tube* and an iterable of *output_tubes*. The worker reads a task from *input_tube* and writes the result to *output_tubes*.
entailment
def assemble( cls, args, input_tube, output_tubes, size, disable_result, do_stop_task, ): """Create, assemble and start workers. Workers are created of class *cls*, initialized with *args*, and given task/result communication c...
Create, assemble and start workers. Workers are created of class *cls*, initialized with *args*, and given task/result communication channels *input_tube* and *output_tubes*. The number of workers created is according to *size* parameter. *do_stop_task* indicates whether doTask() will be...
entailment
def show(self, index=True, **kwargs): """ Print the contents of the Series. This method uses the tabulate function from the tabulate package. Use the kwargs to pass along any arguments to the tabulate function. :param index: If True then include the indexes as a column in the output, if...
Print the contents of the Series. This method uses the tabulate function from the tabulate package. Use the kwargs to pass along any arguments to the tabulate function. :param index: If True then include the indexes as a column in the output, if False ignore the index :param kwargs: Parameters ...
entailment
def get(self, indexes, as_list=False): """ Given indexes will return a sub-set of the Series. This method will direct to the specific methods based on what types are passed in for the indexes. The type of the return is determined by the types of the parameters. :param indexes: i...
Given indexes will return a sub-set of the Series. This method will direct to the specific methods based on what types are passed in for the indexes. The type of the return is determined by the types of the parameters. :param indexes: index value, list of index values, or a list of booleans. ...
entailment
def get_cell(self, index): """ For a single index and return the value :param index: index value :return: value """ i = sorted_index(self._index, index) if self._sort else self._index.index(index) return self._data[i]
For a single index and return the value :param index: index value :return: value
entailment
def get_rows(self, indexes, as_list=False): """ For a list of indexes return the values of the indexes in that column. :param indexes: either a list of index values or a list of booleans with same length as all indexes :param as_list: if True return a list, if False return Series ...
For a list of indexes return the values of the indexes in that column. :param indexes: either a list of index values or a list of booleans with same length as all indexes :param as_list: if True return a list, if False return Series :return: Series if as_list if False, a list if as_list is True
entailment
def get_location(self, location): """ For an index location return a dict of the index and value. This is optimized for speed because it does not need to lookup the index location with a search. Also can accept relative indexing from the end of the SEries in standard python notation [-3,...
For an index location return a dict of the index and value. This is optimized for speed because it does not need to lookup the index location with a search. Also can accept relative indexing from the end of the SEries in standard python notation [-3, -2, -1] :param location: index location in s...
entailment
def get_locations(self, locations, as_list=False): """ For list of locations return a Series or list of the values. :param locations: list of index locations :param as_list: True to return a list of values :return: Series or list """ indexes = [self._index[x] fo...
For list of locations return a Series or list of the values. :param locations: list of index locations :param as_list: True to return a list of values :return: Series or list
entailment
def get_slice(self, start_index=None, stop_index=None, as_list=False): """ For sorted Series will return either a Series or list of all of the rows where the index is greater than or equal to the start_index if provided and less than or equal to the stop_index if provided. If either the ...
For sorted Series will return either a Series or list of all of the rows where the index is greater than or equal to the start_index if provided and less than or equal to the stop_index if provided. If either the start or stop index is None then will include from the first or last element, similar to st...
entailment
def to_dict(self, index=True, ordered=False): """ Returns a dict where the keys are the data and index names and the values are list of the data and index. :param index: If True then include the index in the dict with the index_name as the key :param ordered: If True then return an Orde...
Returns a dict where the keys are the data and index names and the values are list of the data and index. :param index: If True then include the index in the dict with the index_name as the key :param ordered: If True then return an OrderedDict() to preserve the order of the columns in the Series ...
entailment
def head(self, rows): """ Return a Series of the first N rows :param rows: number of rows :return: Series """ rows_bool = [True] * min(rows, len(self._index)) rows_bool.extend([False] * max(0, len(self._index) - rows)) return self.get(indexes=rows_bool)
Return a Series of the first N rows :param rows: number of rows :return: Series
entailment
def select_index(self, compare, result='boolean'): """ Finds the elements in the index that match the compare parameter and returns either a list of the values that match, of a boolean list the length of the index with True to each index that matches. If the indexes are tuples then the c...
Finds the elements in the index that match the compare parameter and returns either a list of the values that match, of a boolean list the length of the index with True to each index that matches. If the indexes are tuples then the compare is a tuple where None in any field of the tuple will be treated ...
entailment
def equality(self, indexes=None, value=None): """ Math helper method. Given a column and optional indexes will return a list of booleans on the equality of the value for that index in the DataFrame to the value parameter. :param indexes: list of index values or list of booleans. If a li...
Math helper method. Given a column and optional indexes will return a list of booleans on the equality of the value for that index in the DataFrame to the value parameter. :param indexes: list of index values or list of booleans. If a list of booleans then the list must be the same\ length as t...
entailment
def _pad_data(self, index_len): """ Pad the data in Series with [None] to ensure that data is the same length as index :param index_len: length of index to extend data to :return: nothing """ self._data.extend([None] * (index_len - len(self._data)))
Pad the data in Series with [None] to ensure that data is the same length as index :param index_len: length of index to extend data to :return: nothing
entailment
def sort_index(self): """ Sort the Series by the index. The sort modifies the Series inplace :return: nothing """ sort = sorted_list_indexes(self._index) # sort index self._index = blist([self._index[x] for x in sort]) if self._blist else [self._index[x] for x in...
Sort the Series by the index. The sort modifies the Series inplace :return: nothing
entailment
def set(self, indexes, values=None): """ Given indexes will set a sub-set of the Series to the values provided. This method will direct to the below methods based on what types are passed in for the indexes. If the indexes contains values not in the Series then new rows or columns will...
Given indexes will set a sub-set of the Series to the values provided. This method will direct to the below methods based on what types are passed in for the indexes. If the indexes contains values not in the Series then new rows or columns will be added. :param indexes: indexes value, list o...
entailment
def _add_row(self, index): """ Add a new row to the Series :param index: index of the new row :return: nothing """ self._index.append(index) self._data.append(None)
Add a new row to the Series :param index: index of the new row :return: nothing
entailment
def _insert_row(self, i, index): """ Insert a new row in the Series. :param i: index location to insert :param index: index value to insert into the index list :return: nothing """ if i == len(self._index): self._add_row(index) else: ...
Insert a new row in the Series. :param i: index location to insert :param index: index value to insert into the index list :return: nothing
entailment
def _add_missing_rows(self, indexes): """ Given a list of indexes, find all the indexes that are not currently in the Series and make a new row for that index by appending to the Series. This does not maintain sorted order for the index. :param indexes: list of indexes :return: ...
Given a list of indexes, find all the indexes that are not currently in the Series and make a new row for that index by appending to the Series. This does not maintain sorted order for the index. :param indexes: list of indexes :return: nothing
entailment
def _insert_missing_rows(self, indexes): """ Given a list of indexes, find all the indexes that are not currently in the Series and make a new row for that index, inserting into the index. This requires the Series to be sorted=True :param indexes: list of indexes :return: nothin...
Given a list of indexes, find all the indexes that are not currently in the Series and make a new row for that index, inserting into the index. This requires the Series to be sorted=True :param indexes: list of indexes :return: nothing
entailment
def set_cell(self, index, value): """ Sets the value of a single cell. If the index is not in the current index then a new index will be created. :param index: index value :param value: value to set :return: nothing """ if self._sort: exists, i = sort...
Sets the value of a single cell. If the index is not in the current index then a new index will be created. :param index: index value :param value: value to set :return: nothing
entailment
def set_rows(self, index, values=None): """ Set rows to a single value or list of values. If any of the index values are not in the current indexes then a new row will be created. :param index: list of index values or list of booleans. If a list of booleans then the list must be the sam...
Set rows to a single value or list of values. If any of the index values are not in the current indexes then a new row will be created. :param index: list of index values or list of booleans. If a list of booleans then the list must be the same\ length as the Series :param values: eithe...
entailment
def set_locations(self, locations, values): """ For a list of locations set the values. :param locations: list of index locations :param values: list of values or a single value :return: nothing """ indexes = [self._index[x] for x in locations] self.set(...
For a list of locations set the values. :param locations: list of index locations :param values: list of values or a single value :return: nothing
entailment
def append_row(self, index, value): """ Appends a row of value to the end of the data. Be very careful with this function as for sorted Series it will not enforce sort order. Use this only for speed when needed, be careful. :param index: index :param value: value :retur...
Appends a row of value to the end of the data. Be very careful with this function as for sorted Series it will not enforce sort order. Use this only for speed when needed, be careful. :param index: index :param value: value :return: nothing
entailment
def append_rows(self, indexes, values): """ Appends values to the end of the data. Be very careful with this function as for sort DataFrames it will not enforce sort order. Use this only for speed when needed, be careful. :param indexes: list of indexes to append :param values:...
Appends values to the end of the data. Be very careful with this function as for sort DataFrames it will not enforce sort order. Use this only for speed when needed, be careful. :param indexes: list of indexes to append :param values: list of values to append :return: nothing
entailment
def delete(self, indexes): """ Delete rows from the DataFrame :param indexes: either a list of values or list of booleans for the rows to delete :return: nothing """ indexes = [indexes] if not isinstance(indexes, (list, blist)) else indexes if all([isinstance(i, ...
Delete rows from the DataFrame :param indexes: either a list of values or list of booleans for the rows to delete :return: nothing
entailment
def reset_index(self): """ Resets the index of the Series to simple integer list and the index name to 'index'. :return: nothing """ self.index = list(range(self.__len__())) self.index_name = 'index'
Resets the index of the Series to simple integer list and the index name to 'index'. :return: nothing
entailment
def value(self, indexes, int_as_index=False): """ Wrapper function for get. It will return a list, no index. If the indexes are integers it will be assumed that they are locations unless int_as_index = True. If the indexes are locations then they will be rotated to the left by offset nu...
Wrapper function for get. It will return a list, no index. If the indexes are integers it will be assumed that they are locations unless int_as_index = True. If the indexes are locations then they will be rotated to the left by offset number of locations. :param indexes: integer location, sing...
entailment
def from_dataframe(cls, dataframe, column, offset=0): """ Creates and return a Series from a DataFrame and specific column :param dataframe: raccoon DataFrame :param column: column name :param offset: offset value must be provided as there is no equivalent for a DataFrame ...
Creates and return a Series from a DataFrame and specific column :param dataframe: raccoon DataFrame :param column: column name :param offset: offset value must be provided as there is no equivalent for a DataFrame :return: Series
entailment
def from_series(cls, series, offset=0): """ Creates and return a Series from a Series :param series: raccoon Series :param offset: offset value must be provided as there is no equivalent for a DataFrame :return: Series """ return cls(data=series.data, index=serie...
Creates and return a Series from a Series :param series: raccoon Series :param offset: offset value must be provided as there is no equivalent for a DataFrame :return: Series
entailment
def get(self, timeout=None): """Return the next available item from the tube. Blocks if tube is empty, until a producer for the tube puts an item on it.""" if timeout: try: result = self._queue.get(True, timeout) except multiprocessing.Queue.Empty: ...
Return the next available item from the tube. Blocks if tube is empty, until a producer for the tube puts an item on it.
entailment
def get(self, timeout=None): """Retrieve results from all the output tubes.""" valid = False result = None for tube in self._output_tubes: if timeout: valid, result = tube.get(timeout) if valid: result = result[0] ...
Retrieve results from all the output tubes.
entailment
def link(self, next_stage): """Link to the given downstream stage *next_stage* by adding its input tube to the list of this stage's output tubes. Return this stage.""" if next_stage is self: raise ValueError('cannot link stage to itself') self._output_tubes.append(next_stage._inp...
Link to the given downstream stage *next_stage* by adding its input tube to the list of this stage's output tubes. Return this stage.
entailment
def getLeaves(self): """Return the downstream leaf stages of this stage.""" result = list() if not self._next_stages: result.append(self) else: for stage in self._next_stages: leaves = stage.getLeaves() result += leaves retu...
Return the downstream leaf stages of this stage.
entailment
def build(self): """Create and start up the internal workers.""" # If there's no output tube, it means that this stage # is at the end of a fork (hasn't been linked to any stage downstream). # Therefore, create one output tube. if not self._output_tubes: self._output...
Create and start up the internal workers.
entailment
def get(self, timeout=None): """Return the next available item from the tube. Blocks if tube is empty, until a producer for the tube puts an item on it.""" if timeout: # Todo: Consider locking the poll/recv block. # Otherwise, this method is not thread safe. ...
Return the next available item from the tube. Blocks if tube is empty, until a producer for the tube puts an item on it.
entailment
def _sort_columns(self, columns_list): """ Given a list of column names will sort the DataFrame columns to match the given order :param columns_list: list of column names. Must include all column names :return: nothing """ if not (all([x in columns_list for x in self._co...
Given a list of column names will sort the DataFrame columns to match the given order :param columns_list: list of column names. Must include all column names :return: nothing
entailment
def _pad_data(self, max_len=None): """ Pad the data in DataFrame with [None} to ensure that all columns have the same length. :param max_len: If provided will extend all columns to this length, if not then will use the longest column :return: nothing """ if not max_len: ...
Pad the data in DataFrame with [None} to ensure that all columns have the same length. :param max_len: If provided will extend all columns to this length, if not then will use the longest column :return: nothing
entailment
def get(self, indexes=None, columns=None, as_list=False, as_dict=False): """ Given indexes and columns will return a sub-set of the DataFrame. This method will direct to the below methods based on what types are passed in for the indexes and columns. The type of the return is determined by the ...
Given indexes and columns will return a sub-set of the DataFrame. This method will direct to the below methods based on what types are passed in for the indexes and columns. The type of the return is determined by the types of the parameters. :param indexes: index value, list of index values, o...
entailment
def get_cell(self, index, column): """ For a single index and column value return the value of the cell :param index: index value :param column: column name :return: value """ i = sorted_index(self._index, index) if self._sort else self._index.index(index) ...
For a single index and column value return the value of the cell :param index: index value :param column: column name :return: value
entailment
def get_rows(self, indexes, column, as_list=False): """ For a list of indexes and a single column name return the values of the indexes in that column. :param indexes: either a list of index values or a list of booleans with same length as all indexes :param column: single column name ...
For a list of indexes and a single column name return the values of the indexes in that column. :param indexes: either a list of index values or a list of booleans with same length as all indexes :param column: single column name :param as_list: if True return a list, if False return DataFrame ...
entailment
def get_columns(self, index, columns=None, as_dict=False): """ For a single index and list of column names return a DataFrame of the values in that index as either a dict or a DataFrame :param index: single index value :param columns: list of column names :param as_dict:...
For a single index and list of column names return a DataFrame of the values in that index as either a dict or a DataFrame :param index: single index value :param columns: list of column names :param as_dict: if True then return the result as a dictionary :return: DataFrame or d...
entailment
def get_entire_column(self, column, as_list=False): """ Shortcut method to retrieve a single column all rows. Since this is a common use case this method will be faster than the more general method. :param column: single column name :param as_list: if True return a list, if Fals...
Shortcut method to retrieve a single column all rows. Since this is a common use case this method will be faster than the more general method. :param column: single column name :param as_list: if True return a list, if False return DataFrame :return: DataFrame is as_list if False, a lis...
entailment
def get_matrix(self, indexes, columns): """ For a list of indexes and list of columns return a DataFrame of the values. :param indexes: either a list of index values or a list of booleans with same length as all indexes :param columns: list of column names :return: DataFrame ...
For a list of indexes and list of columns return a DataFrame of the values. :param indexes: either a list of index values or a list of booleans with same length as all indexes :param columns: list of column names :return: DataFrame
entailment
def get_location(self, location, columns=None, as_dict=False, index=True): """ For an index location and either (1) list of columns return a DataFrame or dictionary of the values or (2) single column name and return the value of that cell. This is optimized for speed because it does not need ...
For an index location and either (1) list of columns return a DataFrame or dictionary of the values or (2) single column name and return the value of that cell. This is optimized for speed because it does not need to lookup the index location with a search. Also can accept relative indexing from the end...
entailment
def get_locations(self, locations, columns=None, **kwargs): """ For list of locations and list of columns return a DataFrame of the values. :param locations: list of index locations :param columns: list of column names :param kwargs: will pass along these parameters to the get()...
For list of locations and list of columns return a DataFrame of the values. :param locations: list of index locations :param columns: list of column names :param kwargs: will pass along these parameters to the get() method :return: DataFrame
entailment
def get_slice(self, start_index=None, stop_index=None, columns=None, as_dict=False): """ For sorted DataFrames will return either a DataFrame or dict of all of the rows where the index is greater than or equal to the start_index if provided and less than or equal to the stop_index if provided. I...
For sorted DataFrames will return either a DataFrame or dict of all of the rows where the index is greater than or equal to the start_index if provided and less than or equal to the stop_index if provided. If either the start or stop index is None then will include from the first or last element, simila...
entailment
def _insert_row(self, i, index): """ Insert a new row in the DataFrame. :param i: index location to insert :param index: index value to insert into the index list :return: nothing """ if i == len(self._index): self._add_row(index) else: ...
Insert a new row in the DataFrame. :param i: index location to insert :param index: index value to insert into the index list :return: nothing
entailment
def _add_row(self, index): """ Add a new row to the DataFrame :param index: index of the new row :return: nothing """ self._index.append(index) for c, _ in enumerate(self._columns): self._data[c].append(None)
Add a new row to the DataFrame :param index: index of the new row :return: nothing
entailment
def _add_column(self, column): """ Add a new column to the DataFrame :param column: column name :return: nothing """ self._columns.append(column) if self._blist: self._data.append(blist([None] * len(self._index))) else: self._data....
Add a new column to the DataFrame :param column: column name :return: nothing
entailment
def set(self, indexes=None, columns=None, values=None): """ Given indexes and columns will set a sub-set of the DataFrame to the values provided. This method will direct to the below methods based on what types are passed in for the indexes and columns. If the indexes or columns contains...
Given indexes and columns will set a sub-set of the DataFrame to the values provided. This method will direct to the below methods based on what types are passed in for the indexes and columns. If the indexes or columns contains values not in the DataFrame then new rows or columns will be added. ...
entailment
def set_cell(self, index, column, value): """ Sets the value of a single cell. If the index and/or column is not in the current index/columns then a new index and/or column will be created. :param index: index value :param column: column name :param value: value to set ...
Sets the value of a single cell. If the index and/or column is not in the current index/columns then a new index and/or column will be created. :param index: index value :param column: column name :param value: value to set :return: nothing
entailment
def set_row(self, index, values): """ Sets the values of the columns in a single row. :param index: index value :param values: dict with the keys as the column names and the values what to set that column to :return: nothing """ if self._sort: exists,...
Sets the values of the columns in a single row. :param index: index value :param values: dict with the keys as the column names and the values what to set that column to :return: nothing
entailment
def set_column(self, index=None, column=None, values=None): """ Set a column to a single value or list of values. If any of the index values are not in the current indexes then a new row will be created. :param index: list of index values or list of booleans. If a list of booleans then ...
Set a column to a single value or list of values. If any of the index values are not in the current indexes then a new row will be created. :param index: list of index values or list of booleans. If a list of booleans then the list must be the same\ length as the DataFrame :param column...
entailment
def set_location(self, location, values, missing_to_none=False): """ Sets the column values, as given by the keys of the values dict, for the row at location to the values of the values dict. If missing_to_none is False then columns not in the values dict will be left unchanged, if it is ...
Sets the column values, as given by the keys of the values dict, for the row at location to the values of the values dict. If missing_to_none is False then columns not in the values dict will be left unchanged, if it is True then they are set to None. This method does not add new columns and raises an e...
entailment
def append_row(self, index, values, new_cols=True): """ Appends a row of values to the end of the data. If there are new columns in the values and new_cols is True they will be added. Be very careful with this function as for sort DataFrames it will not enforce sort order. Use this only...
Appends a row of values to the end of the data. If there are new columns in the values and new_cols is True they will be added. Be very careful with this function as for sort DataFrames it will not enforce sort order. Use this only for speed when needed, be careful. :param index: value of the ...
entailment
def append_rows(self, indexes, values, new_cols=True): """ Appends rows of values to the end of the data. If there are new columns in the values and new_cols is True they will be added. Be very careful with this function as for sort DataFrames it will not enforce sort order. Use this on...
Appends rows of values to the end of the data. If there are new columns in the values and new_cols is True they will be added. Be very careful with this function as for sort DataFrames it will not enforce sort order. Use this only for speed when needed, be careful. :param indexes: list of inde...
entailment
def to_dict(self, index=True, ordered=False): """ Returns a dict where the keys are the column names and the values are lists of the values for that column. :param index: If True then include the index in the dict with the index_name as the key :param ordered: If True then return an Ord...
Returns a dict where the keys are the column names and the values are lists of the values for that column. :param index: If True then include the index in the dict with the index_name as the key :param ordered: If True then return an OrderedDict() to preserve the order of the columns in the DataFrame ...
entailment
def to_json(self): """ Returns a JSON of the entire DataFrame that can be reconstructed back with raccoon.from_json(input). Any object that cannot be serialized will be replaced with the representation of the object using repr(). In that instance the DataFrame will have a string represen...
Returns a JSON of the entire DataFrame that can be reconstructed back with raccoon.from_json(input). Any object that cannot be serialized will be replaced with the representation of the object using repr(). In that instance the DataFrame will have a string representation in place of the object and will ...
entailment
def rename_columns(self, rename_dict): """ Renames the columns :param rename_dict: dict where the keys are the current column names and the values are the new names :return: nothing """ if not all([x in self._columns for x in rename_dict.keys()]): raise Value...
Renames the columns :param rename_dict: dict where the keys are the current column names and the values are the new names :return: nothing
entailment
def delete_all_rows(self): """ Deletes the contents of all rows in the DataFrame. This function is faster than delete_rows() to remove all information, and at the same time it keeps the container lists for the columns and index so if there is another object that references this DataFrame...
Deletes the contents of all rows in the DataFrame. This function is faster than delete_rows() to remove all information, and at the same time it keeps the container lists for the columns and index so if there is another object that references this DataFrame, like a ViewSeries, the reference remains in t...
entailment