_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
75
19.8k
language
stringclasses
1 value
meta_information
dict
q275600
Checklist.update_checklist
test
def update_checklist(self, name): ''' Update the current checklist. Returns a new Checklist object. ''' checklist_json = self.fetch_json( uri_path=self.base_uri, http_method='PUT', query_params={'name': name} ) return self.create_check...
python
{ "resource": "" }
q275601
Checklist.add_item
test
def add_item(self, query_params=None): ''' Add an item to this checklist. Returns a dictionary of values of new item. ''' return self.fetch_json( uri_path=self.base_uri + '/checkItems', http_method='POST', query_params=query_params or {} ...
python
{ "resource": "" }
q275602
Checklist.remove_item
test
def remove_item(self, item_id): ''' Deletes an item from this checklist. ''' return self.fetch_json( uri_path=self.base_uri + '/checkItems/' + item_id, http_method='DELETE' )
python
{ "resource": "" }
q275603
ChecklistItem.update_name
test
def update_name( self, name ): """ Rename the current checklist item. Returns a new ChecklistItem object. """ checklistitem_json = self.fetch_json( uri_path = self.base_uri + '/name', http_method = 'PUT', query_params = {'value': name} ) ...
python
{ "resource": "" }
q275604
ChecklistItem.update_state
test
def update_state(self, state): """ Set the state of the current checklist item. Returns a new ChecklistItem object. """ checklistitem_json = self.fetch_json( uri_path = self.base_uri + '/state', http_method = 'PUT', query_params = {'value': 'complete' ...
python
{ "resource": "" }
q275605
Client.add_authorisation
test
def add_authorisation(self, query_params): ''' Adds the API key and user auth token to the query parameters ''' query_params['key'] = self.api_key if self.user_auth_token: query_params['token'] = self.user_auth_token return query_params
python
{ "resource": "" }
q275606
Client.check_errors
test
def check_errors(self, uri, response): ''' Check HTTP reponse for known errors ''' if response.status == 401: raise trolly.Unauthorised(uri, response) if response.status != 200: raise trolly.ResourceUnavailable(uri, response)
python
{ "resource": "" }
q275607
Client.build_uri
test
def build_uri(self, path, query_params): ''' Build the URI for the API call. ''' url = 'https://api.trello.com/1' + self.clean_path(path) url += '?' + urlencode(query_params) return url
python
{ "resource": "" }
q275608
Client.fetch_json
test
def fetch_json(self, uri_path, http_method='GET', query_params=None, body=None, headers=None): ''' Make a call to Trello API and capture JSON response. Raises an error when it fails. Returns: dict: Dictionary with the JSON data ''' query_pa...
python
{ "resource": "" }
q275609
Client.create_organisation
test
def create_organisation(self, organisation_json): ''' Create an Organisation object from a JSON object Returns: Organisation: The organisation from the given `organisation_json`. ''' return trolly.organisation.Organisation( trello_client=self, ...
python
{ "resource": "" }
q275610
Client.create_board
test
def create_board(self, board_json): ''' Create Board object from a JSON object Returns: Board: The board from the given `board_json`. ''' return trolly.board.Board( trello_client=self, board_id=board_json['id'], name=board_json['na...
python
{ "resource": "" }
q275611
Client.create_label
test
def create_label(self, label_json): ''' Create Label object from JSON object Returns: Label: The label from the given `label_json`. ''' return trolly.label.Label( trello_client=self, label_id=label_json['id'], name=label_json['name...
python
{ "resource": "" }
q275612
Client.create_list
test
def create_list(self, list_json): ''' Create List object from JSON object Returns: List: The list from the given `list_json`. ''' return trolly.list.List( trello_client=self, list_id=list_json['id'], name=list_json['name'], ...
python
{ "resource": "" }
q275613
Client.create_card
test
def create_card(self, card_json): ''' Create a Card object from JSON object Returns: Card: The card from the given `card_json`. ''' return trolly.card.Card( trello_client=self, card_id=card_json['id'], name=card_json['name'], ...
python
{ "resource": "" }
q275614
Client.create_checklist
test
def create_checklist(self, checklist_json): ''' Create a Checklist object from JSON object Returns: Checklist: The checklist from the given `checklist_json`. ''' return trolly.checklist.Checklist( trello_client=self, checklist_id=checklist_jso...
python
{ "resource": "" }
q275615
Client.create_member
test
def create_member(self, member_json): ''' Create a Member object from JSON object Returns: Member: The member from the given `member_json`. ''' return trolly.member.Member( trello_client=self, member_id=member_json['id'], name=memb...
python
{ "resource": "" }
q275616
Client.get_organisation
test
def get_organisation(self, id, name=None): ''' Get an organisation Returns: Organisation: The organisation with the given `id` ''' return self.create_organisation(dict(id=id, name=name))
python
{ "resource": "" }
q275617
Client.get_board
test
def get_board(self, id, name=None): ''' Get a board Returns: Board: The board with the given `id` ''' return self.create_board(dict(id=id, name=name))
python
{ "resource": "" }
q275618
Client.get_list
test
def get_list(self, id, name=None): ''' Get a list Returns: List: The list with the given `id` ''' return self.create_list(dict(id=id, name=name))
python
{ "resource": "" }
q275619
Client.get_card
test
def get_card(self, id, name=None): ''' Get a card Returns: Card: The card with the given `id` ''' return self.create_card(dict(id=id, name=name))
python
{ "resource": "" }
q275620
Client.get_checklist
test
def get_checklist(self, id, name=None): ''' Get a checklist Returns: Checklist: The checklist with the given `id` ''' return self.create_checklist(dict(id=id, name=name))
python
{ "resource": "" }
q275621
Client.get_member
test
def get_member(self, id='me', name=None): ''' Get a member or your current member if `id` wasn't given. Returns: Member: The member with the given `id`, defaults to the logged in member. ''' return self.create_member(dict(id=id, fullName=name))
python
{ "resource": "" }
q275622
domain_from_url
test
def domain_from_url(url): """ Get root domain from url. Will prune away query strings, url paths, protocol prefix and sub-domains Exceptions will be raised on invalid urls """ ext = tldextract.extract(url) if not ext.suffix: raise InvalidURLException() new_url = ext.domain + "." ...
python
{ "resource": "" }
q275623
to_raw_text_markupless
test
def to_raw_text_markupless(text, keep_whitespace=False, normalize_ascii=True): """ A generator to convert raw text segments, without xml to a list of words without any markup. Additionally dates are replaced by `7777` for normalization. Arguments --------- text: str, input text to token...
python
{ "resource": "" }
q275624
to_raw_text
test
def to_raw_text(text, keep_whitespace=False, normalize_ascii=True): """ A generator to convert raw text segments, with xml, and other non-textual content to a list of words without any markup. Additionally dates are replaced by `7777` for normalization. Arguments --------- text: str, inp...
python
{ "resource": "" }
q275625
to_raw_text_pairings
test
def to_raw_text_pairings(text, keep_whitespace=False, normalize_ascii=True): """ A generator to convert raw text segments, with xml, and other non-textual content to a list of words without any markup. Additionally dates are replaced by `7777` for normalization, along with wikipedia anchors kept. ...
python
{ "resource": "" }
q275626
Keyring.set_password
test
def set_password(self, service, username, password): """Write the password in the file. """ assoc = self._generate_assoc(service, username) # encrypt the password password_encrypted = self.encrypt(password.encode('utf-8'), assoc) # encode with base64 and add line break to...
python
{ "resource": "" }
q275627
split_with_locations
test
def split_with_locations(text, locations): """ Use an integer list to split the string contained in `text`. Arguments: ---------- text : str, same length as locations. locations : list<int>, contains values 'SHOULD_SPLIT', 'UNDECIDED', and 'SHOULD_NOT_SPLIT'....
python
{ "resource": "" }
q275628
mark_regex
test
def mark_regex(regex, text, split_locations): """ Regex that adds a 'SHOULD_SPLIT' marker at the end location of each matching group of the given regex. Arguments --------- regex : re.Expression text : str, same length as split_locations split_locations : list<int>, split de...
python
{ "resource": "" }
q275629
mark_begin_end_regex
test
def mark_begin_end_regex(regex, text, split_locations): """ Regex that adds a 'SHOULD_SPLIT' marker at the end location of each matching group of the given regex, and adds a 'SHOULD_SPLIT' at the beginning of the matching group. Each character within the matching group will be marked as 'SHOULD_...
python
{ "resource": "" }
q275630
main
test
def main(argv=None): """Main command line interface.""" if argv is None: argv = sys.argv[1:] cli = CommandLineTool() try: return cli.run(argv) except KeyboardInterrupt: print('Canceled') return 3
python
{ "resource": "" }
q275631
ArgonAESEncryption._create_cipher
test
def _create_cipher(self, password, salt, nonce = None): """ Create the cipher object to encrypt or decrypt a payload. """ from argon2.low_level import hash_secret_raw, Type from Crypto.Cipher import AES aesmode = self._get_mode(self.aesmode) if aesmode is None: ...
python
{ "resource": "" }
q275632
ArgonAESEncryption._get_mode
test
def _get_mode(mode = None): """ Return the AES mode, or a list of valid AES modes, if mode == None """ from Crypto.Cipher import AES AESModeMap = { 'CCM': AES.MODE_CCM, 'EAX': AES.MODE_EAX, 'GCM': AES.MODE_GCM, 'OCB': AES.MODE_OCB,...
python
{ "resource": "" }
q275633
CryptFileKeyring.priority
test
def priority(self): """ Applicable for all platforms, where the schemes, that are integrated with your environment, does not fit. """ try: __import__('argon2.low_level') except ImportError: # pragma: no cover raise RuntimeError("argon2_cffi pac...
python
{ "resource": "" }
q275634
CryptFileKeyring._check_scheme
test
def _check_scheme(self, config): """ check for a valid scheme raise AttributeError if missing raise ValueError if not valid """ try: scheme = config.get( escape_for_ini('keyring-setting'), escape_for_ini('scheme'), ...
python
{ "resource": "" }
q275635
MQTTService.onPublish
test
def onPublish(self, topic, payload, qos, dup, retain, msgId): ''' Callback Receiving messages from publisher ''' log.debug("msg={payload}", payload=payload)
python
{ "resource": "" }
q275636
MQTTFactory.makeId
test
def makeId(self): '''Produce ids for Protocol packets, outliving their sessions''' self.id = (self.id + 1) % 65536 self.id = self.id or 1 # avoid id 0 return self.id
python
{ "resource": "" }
q275637
BaseState.connect
test
def connect(self, request): ''' Send a CONNECT control packet. ''' state = self.__class__.__name__ return defer.fail(MQTTStateError("Unexpected connect() operation", state))
python
{ "resource": "" }
q275638
BaseState.handleCONNACK
test
def handleCONNACK(self, response): ''' Handles CONNACK packet from the server ''' state = self.__class__.__name__ log.error("Unexpected {packet:7} packet received in {log_source}", packet="CONNACK")
python
{ "resource": "" }
q275639
encodeString
test
def encodeString(string): ''' Encode an UTF-8 string into MQTT format. Returns a bytearray ''' encoded = bytearray(2) encoded.extend(bytearray(string, encoding='utf-8')) l = len(encoded)-2 if(l > 65535): raise StringValueError(l) encoded[0] = l >> 8 encoded[1] = l & 0xFF...
python
{ "resource": "" }
q275640
decodeString
test
def decodeString(encoded): ''' Decodes an UTF-8 string from an encoded MQTT bytearray. Returns the decoded string and renaining bytearray to be parsed ''' length = encoded[0]*256 + encoded[1] return (encoded[2:2+length].decode('utf-8'), encoded[2+length:])
python
{ "resource": "" }
q275641
encode16Int
test
def encode16Int(value): ''' Encodes a 16 bit unsigned integer into MQTT format. Returns a bytearray ''' value = int(value) encoded = bytearray(2) encoded[0] = value >> 8 encoded[1] = value & 0xFF return encoded
python
{ "resource": "" }
q275642
encodeLength
test
def encodeLength(value): ''' Encodes value into a multibyte sequence defined by MQTT protocol. Used to encode packet length fields. ''' encoded = bytearray() while True: digit = value % 128 value //= 128 if value > 0: digit |= 128 encoded.append(digit)...
python
{ "resource": "" }
q275643
decodeLength
test
def decodeLength(encoded): ''' Decodes a variable length value defined in the MQTT protocol. This value typically represents remaining field lengths ''' value = 0 multiplier = 1 for i in encoded: value += (i & 0x7F) * multiplier multiplier *= 0x80 if (i & 0x80) !...
python
{ "resource": "" }
q275644
DISCONNECT.encode
test
def encode(self): ''' Encode and store a DISCONNECT control packet. ''' header = bytearray(2) header[0] = 0xE0 self.encoded = header return str(header) if PY2 else bytes(header)
python
{ "resource": "" }
q275645
CONNECT.encode
test
def encode(self): ''' Encode and store a CONNECT control packet. @raise e: C{ValueError} if any encoded topic string exceeds 65535 bytes. @raise e: C{ValueError} if encoded username string exceeds 65535 bytes. ''' header = bytearray(1) varHeader = bytearray() ...
python
{ "resource": "" }
q275646
CONNECT.decode
test
def decode(self, packet): ''' Decode a CONNECT control packet. ''' self.encoded = packet # Strip the fixed header plus variable length field lenLen = 1 while packet[lenLen] & 0x80: lenLen += 1 packet_remaining = packet[lenLen+1:] # Var...
python
{ "resource": "" }
q275647
CONNACK.encode
test
def encode(self): ''' Encode and store a CONNACK control packet. ''' header = bytearray(1) varHeader = bytearray(2) header[0] = 0x20 varHeader[0] = self.session varHeader[1] = self.resultCode header.extend(encodeLength(len(varHe...
python
{ "resource": "" }
q275648
CONNACK.decode
test
def decode(self, packet): ''' Decode a CONNACK control packet. ''' self.encoded = packet # Strip the fixed header plus variable length field lenLen = 1 while packet[lenLen] & 0x80: lenLen += 1 packet_remaining = packet[lenLen+1:] self....
python
{ "resource": "" }
q275649
SUBSCRIBE.decode
test
def decode(self, packet): ''' Decode a SUBSCRIBE control packet. ''' self.encoded = packet lenLen = 1 while packet[lenLen] & 0x80: lenLen += 1 packet_remaining = packet[lenLen+1:] self.msgId = decode16Int(packet_remaining[0:2]) self....
python
{ "resource": "" }
q275650
SUBACK.encode
test
def encode(self): ''' Encode and store a SUBACK control packet. ''' header = bytearray(1) payload = bytearray() varHeader = encode16Int(self.msgId) header[0] = 0x90 for code in self.granted: payload.append(code[0] | (0x80 if code[1] == Tru...
python
{ "resource": "" }
q275651
UNSUBSCRIBE.encode
test
def encode(self): ''' Encode and store an UNSUBCRIBE control packet @raise e: C{ValueError} if any encoded topic string exceeds 65535 bytes ''' header = bytearray(1) payload = bytearray() varHeader = encode16Int(self.msgId) header[0] = 0xA2 # packe...
python
{ "resource": "" }
q275652
UNSUBSCRIBE.decode
test
def decode(self, packet): ''' Decode a UNSUBACK control packet. ''' self.encoded = packet lenLen = 1 while packet[lenLen] & 0x80: lenLen += 1 packet_remaining = packet[lenLen+1:] self.msgId = decode16Int(packet_remaining[0:2]) self.t...
python
{ "resource": "" }
q275653
UNSUBACK.encode
test
def encode(self): ''' Encode and store an UNSUBACK control packet ''' header = bytearray(1) varHeader = encode16Int(self.msgId) header[0] = 0xB0 header.extend(encodeLength(len(varHeader))) header.extend(varHeader) self.encoded = header ...
python
{ "resource": "" }
q275654
PUBLISH.encode
test
def encode(self): ''' Encode and store a PUBLISH control packet. @raise e: C{ValueError} if encoded topic string exceeds 65535 bytes. @raise e: C{ValueError} if encoded packet size exceeds 268435455 bytes. @raise e: C{TypeError} if C{data} is not a string, bytearray, int, boolean...
python
{ "resource": "" }
q275655
PUBLISH.decode
test
def decode(self, packet): ''' Decode a PUBLISH control packet. ''' self.encoded = packet lenLen = 1 while packet[lenLen] & 0x80: lenLen += 1 packet_remaining = packet[lenLen+1:] self.dup = (packet[0] & 0x08) == 0x08 self.qos = (p...
python
{ "resource": "" }
q275656
PUBREL.decode
test
def decode(self, packet): ''' Decode a PUBREL control packet. ''' self.encoded = packet lenLen = 1 while packet[lenLen] & 0x80: lenLen += 1 packet_remaining = packet[lenLen+1:] self.msgId = decode16Int(packet_remaining) self.dup = (pa...
python
{ "resource": "" }
q275657
API.get_url
test
def get_url(self, method=None, **kwargs): """Return url for call method. :param method (optional): `str` method name. :returns: `str` URL. """ kwargs.setdefault('v', self.__version) if self.__token is not None: kwargs.setdefault('access_token', self.__token)...
python
{ "resource": "" }
q275658
API.request
test
def request(self, method, **kwargs): """ Send request to API. :param method: `str` method name. :returns: `dict` response. """ kwargs.setdefault('v', self.__version) if self.__token is not None: kwargs.setdefault('access_token', self.__token) ...
python
{ "resource": "" }
q275659
FileMPI.refresh
test
def refresh(self): """ Refresh the list of blocks to the disk, collectively """ if self.comm.rank == 0: self._blocks = self.list_blocks() else: self._blocks = None self._blocks = self.comm.bcast(self._blocks)
python
{ "resource": "" }
q275660
classifier.format_data
test
def format_data(self, data, scale=True): """ Function for converting a dict to an array suitable for sklearn. Parameters ---------- data : dict A dict of data, containing all elements of `analytes` as items. scale : bool Whether or not...
python
{ "resource": "" }
q275661
classifier.fitting_data
test
def fitting_data(self, data): """ Function to format data for cluster fitting. Parameters ---------- data : dict A dict of data, containing all elements of `analytes` as items. Returns ------- A data array for initial cluster fitt...
python
{ "resource": "" }
q275662
classifier.fit_kmeans
test
def fit_kmeans(self, data, n_clusters, **kwargs): """ Fit KMeans clustering algorithm to data. Parameters ---------- data : array-like A dataset formatted by `classifier.fitting_data`. n_clusters : int The number of clusters in the data. *...
python
{ "resource": "" }
q275663
classifier.fit_meanshift
test
def fit_meanshift(self, data, bandwidth=None, bin_seeding=False, **kwargs): """ Fit MeanShift clustering algorithm to data. Parameters ---------- data : array-like A dataset formatted by `classifier.fitting_data`. bandwidth : float The bandwidth v...
python
{ "resource": "" }
q275664
classifier.fit
test
def fit(self, data, method='kmeans', **kwargs): """ fit classifiers from large dataset. Parameters ---------- data : dict A dict of data for clustering. Must contain items with the same name as analytes used for clustering. method : st...
python
{ "resource": "" }
q275665
classifier.predict
test
def predict(self, data): """ Label new data with cluster identities. Parameters ---------- data : dict A data dict containing the same analytes used to fit the classifier. sort_by : str The name of an analyte used to sort the resulting...
python
{ "resource": "" }
q275666
classifier.map_clusters
test
def map_clusters(self, size, sampled, clusters): """ Translate cluster identity back to original data size. Parameters ---------- size : int size of original dataset sampled : array-like integer array describing location of finite values ...
python
{ "resource": "" }
q275667
classifier.sort_clusters
test
def sort_clusters(self, data, cs, sort_by): """ Sort clusters by the concentration of a particular analyte. Parameters ---------- data : dict A dataset containing sort_by as a key. cs : array-like An array of clusters, the same length as values of...
python
{ "resource": "" }
q275668
get_date
test
def get_date(datetime, time_format=None): """ Return a datetime oject from a string, with optional time format. Parameters ---------- datetime : str Date-time as string in any sensible format. time_format : datetime str (optional) String describing the datetime format. If missin...
python
{ "resource": "" }
q275669
get_total_n_points
test
def get_total_n_points(d): """ Returns the total number of data points in values of dict. Paramters --------- d : dict """ n = 0 for di in d.values(): n += len(di) return n
python
{ "resource": "" }
q275670
get_total_time_span
test
def get_total_time_span(d): """ Returns total length of analysis. """ tmax = 0 for di in d.values(): if di.uTime.max() > tmax: tmax = di.uTime.max() return tmax
python
{ "resource": "" }
q275671
unitpicker
test
def unitpicker(a, llim=0.1, denominator=None, focus_stage=None): """ Determines the most appropriate plotting unit for data. Parameters ---------- a : float or array-like number to optimise. If array like, the 25% quantile is optimised. llim : float minimum allowable value in sc...
python
{ "resource": "" }
q275672
pretty_element
test
def pretty_element(s): """ Returns formatted element name. Parameters ---------- s : str of format [A-Z][a-z]?[0-9]+ Returns ------- str LaTeX formatted string with superscript numbers. """ el = re.match('.*?([A-z]{1,3}).*?', s).groups()[0] m = re.match('.*?...
python
{ "resource": "" }
q275673
analyte_2_namemass
test
def analyte_2_namemass(s): """ Converts analytes in format '27Al' to 'Al27'. Parameters ---------- s : str of format [A-z]{1,3}[0-9]{1,3} Returns ------- str Name in format [0-9]{1,3}[A-z]{1,3} """ el = re.match('.*?([A-z]{1,3}).*?', s).groups()[0] m = re.ma...
python
{ "resource": "" }
q275674
analyte_2_massname
test
def analyte_2_massname(s): """ Converts analytes in format 'Al27' to '27Al'. Parameters ---------- s : str of format [0-9]{1,3}[A-z]{1,3} Returns ------- str Name in format [A-z]{1,3}[0-9]{1,3} """ el = re.match('.*?([A-z]{1,3}).*?', s).groups()[0] m = re.ma...
python
{ "resource": "" }
q275675
collate_data
test
def collate_data(in_dir, extension='.csv', out_dir=None): """ Copy all csvs in nested directroy to single directory. Function to copy all csvs from a directory, and place them in a new directory. Parameters ---------- in_dir : str Input directory containing csv files in subfolders ...
python
{ "resource": "" }
q275676
enumerate_bool
test
def enumerate_bool(bool_array, nstart=0): """ Consecutively numbers contiguous booleans in array. i.e. a boolean sequence, and resulting numbering T F T T T F T F F F T T F 0-1 1 1 - 2 ---3 3 - where ' - ' Parameters ---------- bool_array : array_like Array of booleans. ...
python
{ "resource": "" }
q275677
tuples_2_bool
test
def tuples_2_bool(tuples, x): """ Generate boolean array from list of limit tuples. Parameters ---------- tuples : array_like [2, n] array of (start, end) values x : array_like x scale the tuples are mapped to Returns ------- array_like boolean array, True w...
python
{ "resource": "" }
q275678
fastsmooth
test
def fastsmooth(a, win=11): """ Returns rolling - window smooth of a. Function to efficiently calculate the rolling mean of a numpy array using 'stride_tricks' to split up a 1D array into an ndarray of sub - sections of the original array, of dimensions [len(a) - win, win]. Parameters -----...
python
{ "resource": "" }
q275679
fastgrad
test
def fastgrad(a, win=11): """ Returns rolling - window gradient of a. Function to efficiently calculate the rolling gradient of a numpy array using 'stride_tricks' to split up a 1D array into an ndarray of sub - sections of the original array, of dimensions [len(a) - win, win]. Parameters -...
python
{ "resource": "" }
q275680
findmins
test
def findmins(x, y): """ Function to find local minima. Parameters ---------- x, y : array_like 1D arrays of the independent (x) and dependent (y) variables. Returns ------- array_like Array of points in x where y has a local minimum. """ return x[np.r_[False, y[1:] ...
python
{ "resource": "" }
q275681
cluster_meanshift
test
def cluster_meanshift(data, bandwidth=None, bin_seeding=False, **kwargs): """ Identify clusters using Meanshift algorithm. Parameters ---------- data : array_like array of size [n_samples, n_features]. bandwidth : float or None If None, bandwidth is estimated automatically using...
python
{ "resource": "" }
q275682
cluster_kmeans
test
def cluster_kmeans(data, n_clusters, **kwargs): """ Identify clusters using K - Means algorithm. Parameters ---------- data : array_like array of size [n_samples, n_features]. n_clusters : int The number of clusters expected in the data. Returns ------- dict ...
python
{ "resource": "" }
q275683
cluster_DBSCAN
test
def cluster_DBSCAN(data, eps=None, min_samples=None, n_clusters=None, maxiter=200, **kwargs): """ Identify clusters using DBSCAN algorithm. Parameters ---------- data : array_like array of size [n_samples, n_features]. eps : float The minimum 'distance' points...
python
{ "resource": "" }
q275684
get_defined_srms
test
def get_defined_srms(srm_file): """ Returns list of SRMS defined in the SRM database """ srms = read_table(srm_file) return np.asanyarray(srms.index.unique())
python
{ "resource": "" }
q275685
read_configuration
test
def read_configuration(config='DEFAULT'): """ Read LAtools configuration file, and return parameters as dict. """ # read configuration file _, conf = read_latoolscfg() # if 'DEFAULT', check which is the default configuration if config == 'DEFAULT': config = conf['DEFAULT']['config'] ...
python
{ "resource": "" }
q275686
read_latoolscfg
test
def read_latoolscfg(): """ Reads configuration, returns a ConfigParser object. Distinct from read_configuration, which returns a dict. """ config_file = pkgrs.resource_filename('latools', 'latools.cfg') cf = configparser.ConfigParser() cf.read(config_file) return config_file, cf
python
{ "resource": "" }
q275687
print_all
test
def print_all(): """ Prints all currently defined configurations. """ # read configuration file _, conf = read_latoolscfg() default = conf['DEFAULT']['config'] pstr = '\nCurrently defined LAtools configurations:\n\n' for s in conf.sections(): if s == default: pstr +...
python
{ "resource": "" }
q275688
copy_SRM_file
test
def copy_SRM_file(destination=None, config='DEFAULT'): """ Creates a copy of the default SRM table at the specified location. Parameters ---------- destination : str The save location for the SRM file. If no location specified, saves it as 'LAtools_[config]_SRMTable.csv' in the cur...
python
{ "resource": "" }
q275689
create
test
def create(config_name, srmfile=None, dataformat=None, base_on='DEFAULT', make_default=False): """ Adds a new configuration to latools.cfg. Parameters ---------- config_name : str The name of the new configuration. This should be descriptive (e.g. UC Davis Foram Group) srmfile :...
python
{ "resource": "" }
q275690
change_default
test
def change_default(config): """ Change the default configuration. """ config_file, cf = read_latoolscfg() if config not in cf.sections(): raise ValueError("\n'{:s}' is not a defined configuration.".format(config)) if config == 'REPRODUCE': pstr = ('Are you SURE you want to set ...
python
{ "resource": "" }
q275691
exclude_downhole
test
def exclude_downhole(filt, threshold=2): """ Exclude all data after the first excluded portion. This makes sense for spot measurements where, because of the signal mixing inherent in LA-ICPMS, once a contaminant is ablated, it will always be present to some degree in signals from further down t...
python
{ "resource": "" }
q275692
defrag
test
def defrag(filt, threshold=3, mode='include'): """ 'Defragment' a filter. Parameters ---------- filt : boolean array A filter threshold : int Consecutive values equal to or below this threshold length are considered fragments, and will be removed. mode : str ...
python
{ "resource": "" }
q275693
D.despike
test
def despike(self, expdecay_despiker=True, exponent=None, noise_despiker=True, win=3, nlim=12., maxiter=3): """ Applies expdecay_despiker and noise_despiker to data. Parameters ---------- expdecay_despiker : bool Whether or not to apply the exponential...
python
{ "resource": "" }
q275694
D.autorange_plot
test
def autorange_plot(self, analyte='total_counts', gwin=7, swin=None, win=20, on_mult=[1.5, 1.], off_mult=[1., 1.5], transform='log'): """ Plot a detailed autorange report for this sample. """ if analyte is None: # sig = self.focus[...
python
{ "resource": "" }
q275695
D.mkrngs
test
def mkrngs(self): """ Transform boolean arrays into list of limit pairs. Gets Time limits of signal/background boolean arrays and stores them as sigrng and bkgrng arrays. These arrays can be saved by 'save_ranges' in the analyse object. """ bbool = bool_2_indices...
python
{ "resource": "" }
q275696
D.ratio
test
def ratio(self, internal_standard=None): """ Divide all analytes by a specified internal_standard analyte. Parameters ---------- internal_standard : str The analyte used as the internal_standard. Returns ------- None """ if in...
python
{ "resource": "" }
q275697
D.calibrate
test
def calibrate(self, calib_ps, analytes=None): """ Apply calibration to data. The `calib_dict` must be calculated at the `analyse` level, and passed to this calibrate function. Parameters ---------- calib_dict : dict A dict of calibration values to ap...
python
{ "resource": "" }
q275698
D.sample_stats
test
def sample_stats(self, analytes=None, filt=True, stat_fns={}, eachtrace=True): """ Calculate sample statistics Returns samples, analytes, and arrays of statistics of shape (samples, analytes). Statistics are calculated from the 'focus' d...
python
{ "resource": "" }
q275699
D.ablation_times
test
def ablation_times(self): """ Function for calculating the ablation time for each ablation. Returns ------- dict of times for each ablation. """ ats = {} for n in np.arange(self.n) + 1: t = self.Time[self.ns == n] ats[n...
python
{ "resource": "" }