partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
valid | EncryptedPickle.unseal | Unseal data | encryptedpickle/encryptedpickle.py | def unseal(self, data, return_options=False):
'''Unseal data'''
data = self._remove_magic(data)
data = urlsafe_nopadding_b64decode(data)
options = self._read_header(data)
data = self._add_magic(data)
data = self._unsign_data(data, options)
data = self._remove_mag... | def unseal(self, data, return_options=False):
'''Unseal data'''
data = self._remove_magic(data)
data = urlsafe_nopadding_b64decode(data)
options = self._read_header(data)
data = self._add_magic(data)
data = self._unsign_data(data, options)
data = self._remove_mag... | [
"Unseal",
"data"
] | vingd/encrypted-pickle-python | python | https://github.com/vingd/encrypted-pickle-python/blob/7656233598e02e65971f69e11849a0f288b2b2a5/encryptedpickle/encryptedpickle.py#L305-L322 | [
"def",
"unseal",
"(",
"self",
",",
"data",
",",
"return_options",
"=",
"False",
")",
":",
"data",
"=",
"self",
".",
"_remove_magic",
"(",
"data",
")",
"data",
"=",
"urlsafe_nopadding_b64decode",
"(",
"data",
")",
"options",
"=",
"self",
".",
"_read_header"... | 7656233598e02e65971f69e11849a0f288b2b2a5 |
valid | EncryptedPickle.verify_signature | Verify sealed data signature | encryptedpickle/encryptedpickle.py | def verify_signature(self, data):
'''Verify sealed data signature'''
data = self._remove_magic(data)
data = urlsafe_nopadding_b64decode(data)
options = self._read_header(data)
data = self._add_magic(data)
self._unsign_data(data, options) | def verify_signature(self, data):
'''Verify sealed data signature'''
data = self._remove_magic(data)
data = urlsafe_nopadding_b64decode(data)
options = self._read_header(data)
data = self._add_magic(data)
self._unsign_data(data, options) | [
"Verify",
"sealed",
"data",
"signature"
] | vingd/encrypted-pickle-python | python | https://github.com/vingd/encrypted-pickle-python/blob/7656233598e02e65971f69e11849a0f288b2b2a5/encryptedpickle/encryptedpickle.py#L324-L331 | [
"def",
"verify_signature",
"(",
"self",
",",
"data",
")",
":",
"data",
"=",
"self",
".",
"_remove_magic",
"(",
"data",
")",
"data",
"=",
"urlsafe_nopadding_b64decode",
"(",
"data",
")",
"options",
"=",
"self",
".",
"_read_header",
"(",
"data",
")",
"data",... | 7656233598e02e65971f69e11849a0f288b2b2a5 |
valid | EncryptedPickle._encode | Encode data with specific algorithm | encryptedpickle/encryptedpickle.py | def _encode(self, data, algorithm, key=None):
'''Encode data with specific algorithm'''
if algorithm['type'] == 'hmac':
return data + self._hmac_generate(data, algorithm, key)
elif algorithm['type'] == 'aes':
return self._aes_encrypt(data, algorithm, key)
elif al... | def _encode(self, data, algorithm, key=None):
'''Encode data with specific algorithm'''
if algorithm['type'] == 'hmac':
return data + self._hmac_generate(data, algorithm, key)
elif algorithm['type'] == 'aes':
return self._aes_encrypt(data, algorithm, key)
elif al... | [
"Encode",
"data",
"with",
"specific",
"algorithm"
] | vingd/encrypted-pickle-python | python | https://github.com/vingd/encrypted-pickle-python/blob/7656233598e02e65971f69e11849a0f288b2b2a5/encryptedpickle/encryptedpickle.py#L344-L360 | [
"def",
"_encode",
"(",
"self",
",",
"data",
",",
"algorithm",
",",
"key",
"=",
"None",
")",
":",
"if",
"algorithm",
"[",
"'type'",
"]",
"==",
"'hmac'",
":",
"return",
"data",
"+",
"self",
".",
"_hmac_generate",
"(",
"data",
",",
"algorithm",
",",
"ke... | 7656233598e02e65971f69e11849a0f288b2b2a5 |
valid | EncryptedPickle._decode | Decode data with specific algorithm | encryptedpickle/encryptedpickle.py | def _decode(self, data, algorithm, key=None):
'''Decode data with specific algorithm'''
if algorithm['type'] == 'hmac':
verify_signature = data[-algorithm['hash_size']:]
data = data[:-algorithm['hash_size']]
signature = self._hmac_generate(data, algorithm, key)
... | def _decode(self, data, algorithm, key=None):
'''Decode data with specific algorithm'''
if algorithm['type'] == 'hmac':
verify_signature = data[-algorithm['hash_size']:]
data = data[:-algorithm['hash_size']]
signature = self._hmac_generate(data, algorithm, key)
... | [
"Decode",
"data",
"with",
"specific",
"algorithm"
] | vingd/encrypted-pickle-python | python | https://github.com/vingd/encrypted-pickle-python/blob/7656233598e02e65971f69e11849a0f288b2b2a5/encryptedpickle/encryptedpickle.py#L362-L383 | [
"def",
"_decode",
"(",
"self",
",",
"data",
",",
"algorithm",
",",
"key",
"=",
"None",
")",
":",
"if",
"algorithm",
"[",
"'type'",
"]",
"==",
"'hmac'",
":",
"verify_signature",
"=",
"data",
"[",
"-",
"algorithm",
"[",
"'hash_size'",
"]",
":",
"]",
"d... | 7656233598e02e65971f69e11849a0f288b2b2a5 |
valid | EncryptedPickle._sign_data | Add signature to data | encryptedpickle/encryptedpickle.py | def _sign_data(self, data, options):
'''Add signature to data'''
if options['signature_algorithm_id'] not in self.signature_algorithms:
raise Exception('Unknown signature algorithm id: %d'
% options['signature_algorithm_id'])
signature_algorithm = \
... | def _sign_data(self, data, options):
'''Add signature to data'''
if options['signature_algorithm_id'] not in self.signature_algorithms:
raise Exception('Unknown signature algorithm id: %d'
% options['signature_algorithm_id'])
signature_algorithm = \
... | [
"Add",
"signature",
"to",
"data"
] | vingd/encrypted-pickle-python | python | https://github.com/vingd/encrypted-pickle-python/blob/7656233598e02e65971f69e11849a0f288b2b2a5/encryptedpickle/encryptedpickle.py#L385-L403 | [
"def",
"_sign_data",
"(",
"self",
",",
"data",
",",
"options",
")",
":",
"if",
"options",
"[",
"'signature_algorithm_id'",
"]",
"not",
"in",
"self",
".",
"signature_algorithms",
":",
"raise",
"Exception",
"(",
"'Unknown signature algorithm id: %d'",
"%",
"options"... | 7656233598e02e65971f69e11849a0f288b2b2a5 |
valid | EncryptedPickle._unsign_data | Verify and remove signature | encryptedpickle/encryptedpickle.py | def _unsign_data(self, data, options):
'''Verify and remove signature'''
if options['signature_algorithm_id'] not in self.signature_algorithms:
raise Exception('Unknown signature algorithm id: %d'
% options['signature_algorithm_id'])
signature_algorithm ... | def _unsign_data(self, data, options):
'''Verify and remove signature'''
if options['signature_algorithm_id'] not in self.signature_algorithms:
raise Exception('Unknown signature algorithm id: %d'
% options['signature_algorithm_id'])
signature_algorithm ... | [
"Verify",
"and",
"remove",
"signature"
] | vingd/encrypted-pickle-python | python | https://github.com/vingd/encrypted-pickle-python/blob/7656233598e02e65971f69e11849a0f288b2b2a5/encryptedpickle/encryptedpickle.py#L405-L427 | [
"def",
"_unsign_data",
"(",
"self",
",",
"data",
",",
"options",
")",
":",
"if",
"options",
"[",
"'signature_algorithm_id'",
"]",
"not",
"in",
"self",
".",
"signature_algorithms",
":",
"raise",
"Exception",
"(",
"'Unknown signature algorithm id: %d'",
"%",
"option... | 7656233598e02e65971f69e11849a0f288b2b2a5 |
valid | EncryptedPickle._encrypt_data | Encrypt data | encryptedpickle/encryptedpickle.py | def _encrypt_data(self, data, options):
'''Encrypt data'''
if options['encryption_algorithm_id'] not in self.encryption_algorithms:
raise Exception('Unknown encryption algorithm id: %d'
% options['encryption_algorithm_id'])
encryption_algorithm = \
... | def _encrypt_data(self, data, options):
'''Encrypt data'''
if options['encryption_algorithm_id'] not in self.encryption_algorithms:
raise Exception('Unknown encryption algorithm id: %d'
% options['encryption_algorithm_id'])
encryption_algorithm = \
... | [
"Encrypt",
"data"
] | vingd/encrypted-pickle-python | python | https://github.com/vingd/encrypted-pickle-python/blob/7656233598e02e65971f69e11849a0f288b2b2a5/encryptedpickle/encryptedpickle.py#L429-L447 | [
"def",
"_encrypt_data",
"(",
"self",
",",
"data",
",",
"options",
")",
":",
"if",
"options",
"[",
"'encryption_algorithm_id'",
"]",
"not",
"in",
"self",
".",
"encryption_algorithms",
":",
"raise",
"Exception",
"(",
"'Unknown encryption algorithm id: %d'",
"%",
"op... | 7656233598e02e65971f69e11849a0f288b2b2a5 |
valid | EncryptedPickle._decrypt_data | Decrypt data | encryptedpickle/encryptedpickle.py | def _decrypt_data(self, data, options):
'''Decrypt data'''
if options['encryption_algorithm_id'] not in self.encryption_algorithms:
raise Exception('Unknown encryption algorithm id: %d'
% options['encryption_algorithm_id'])
encryption_algorithm = \
... | def _decrypt_data(self, data, options):
'''Decrypt data'''
if options['encryption_algorithm_id'] not in self.encryption_algorithms:
raise Exception('Unknown encryption algorithm id: %d'
% options['encryption_algorithm_id'])
encryption_algorithm = \
... | [
"Decrypt",
"data"
] | vingd/encrypted-pickle-python | python | https://github.com/vingd/encrypted-pickle-python/blob/7656233598e02e65971f69e11849a0f288b2b2a5/encryptedpickle/encryptedpickle.py#L449-L471 | [
"def",
"_decrypt_data",
"(",
"self",
",",
"data",
",",
"options",
")",
":",
"if",
"options",
"[",
"'encryption_algorithm_id'",
"]",
"not",
"in",
"self",
".",
"encryption_algorithms",
":",
"raise",
"Exception",
"(",
"'Unknown encryption algorithm id: %d'",
"%",
"op... | 7656233598e02e65971f69e11849a0f288b2b2a5 |
valid | EncryptedPickle._serialize_data | Serialize data | encryptedpickle/encryptedpickle.py | def _serialize_data(self, data, options):
'''Serialize data'''
serialization_algorithm_id = options['serialization_algorithm_id']
if serialization_algorithm_id not in self.serialization_algorithms:
raise Exception('Unknown serialization algorithm id: %d'
... | def _serialize_data(self, data, options):
'''Serialize data'''
serialization_algorithm_id = options['serialization_algorithm_id']
if serialization_algorithm_id not in self.serialization_algorithms:
raise Exception('Unknown serialization algorithm id: %d'
... | [
"Serialize",
"data"
] | vingd/encrypted-pickle-python | python | https://github.com/vingd/encrypted-pickle-python/blob/7656233598e02e65971f69e11849a0f288b2b2a5/encryptedpickle/encryptedpickle.py#L473-L488 | [
"def",
"_serialize_data",
"(",
"self",
",",
"data",
",",
"options",
")",
":",
"serialization_algorithm_id",
"=",
"options",
"[",
"'serialization_algorithm_id'",
"]",
"if",
"serialization_algorithm_id",
"not",
"in",
"self",
".",
"serialization_algorithms",
":",
"raise"... | 7656233598e02e65971f69e11849a0f288b2b2a5 |
valid | EncryptedPickle._unserialize_data | Unserialize data | encryptedpickle/encryptedpickle.py | def _unserialize_data(self, data, options):
'''Unserialize data'''
serialization_algorithm_id = options['serialization_algorithm_id']
if serialization_algorithm_id not in self.serialization_algorithms:
raise Exception('Unknown serialization algorithm id: %d'
... | def _unserialize_data(self, data, options):
'''Unserialize data'''
serialization_algorithm_id = options['serialization_algorithm_id']
if serialization_algorithm_id not in self.serialization_algorithms:
raise Exception('Unknown serialization algorithm id: %d'
... | [
"Unserialize",
"data"
] | vingd/encrypted-pickle-python | python | https://github.com/vingd/encrypted-pickle-python/blob/7656233598e02e65971f69e11849a0f288b2b2a5/encryptedpickle/encryptedpickle.py#L490-L505 | [
"def",
"_unserialize_data",
"(",
"self",
",",
"data",
",",
"options",
")",
":",
"serialization_algorithm_id",
"=",
"options",
"[",
"'serialization_algorithm_id'",
"]",
"if",
"serialization_algorithm_id",
"not",
"in",
"self",
".",
"serialization_algorithms",
":",
"rais... | 7656233598e02e65971f69e11849a0f288b2b2a5 |
valid | EncryptedPickle._compress_data | Compress data | encryptedpickle/encryptedpickle.py | def _compress_data(self, data, options):
'''Compress data'''
compression_algorithm_id = options['compression_algorithm_id']
if compression_algorithm_id not in self.compression_algorithms:
raise Exception('Unknown compression algorithm id: %d'
% compressio... | def _compress_data(self, data, options):
'''Compress data'''
compression_algorithm_id = options['compression_algorithm_id']
if compression_algorithm_id not in self.compression_algorithms:
raise Exception('Unknown compression algorithm id: %d'
% compressio... | [
"Compress",
"data"
] | vingd/encrypted-pickle-python | python | https://github.com/vingd/encrypted-pickle-python/blob/7656233598e02e65971f69e11849a0f288b2b2a5/encryptedpickle/encryptedpickle.py#L507-L527 | [
"def",
"_compress_data",
"(",
"self",
",",
"data",
",",
"options",
")",
":",
"compression_algorithm_id",
"=",
"options",
"[",
"'compression_algorithm_id'",
"]",
"if",
"compression_algorithm_id",
"not",
"in",
"self",
".",
"compression_algorithms",
":",
"raise",
"Exce... | 7656233598e02e65971f69e11849a0f288b2b2a5 |
valid | EncryptedPickle._decompress_data | Decompress data | encryptedpickle/encryptedpickle.py | def _decompress_data(self, data, options):
'''Decompress data'''
compression_algorithm_id = options['compression_algorithm_id']
if compression_algorithm_id not in self.compression_algorithms:
raise Exception('Unknown compression algorithm id: %d'
% compre... | def _decompress_data(self, data, options):
'''Decompress data'''
compression_algorithm_id = options['compression_algorithm_id']
if compression_algorithm_id not in self.compression_algorithms:
raise Exception('Unknown compression algorithm id: %d'
% compre... | [
"Decompress",
"data"
] | vingd/encrypted-pickle-python | python | https://github.com/vingd/encrypted-pickle-python/blob/7656233598e02e65971f69e11849a0f288b2b2a5/encryptedpickle/encryptedpickle.py#L529-L544 | [
"def",
"_decompress_data",
"(",
"self",
",",
"data",
",",
"options",
")",
":",
"compression_algorithm_id",
"=",
"options",
"[",
"'compression_algorithm_id'",
"]",
"if",
"compression_algorithm_id",
"not",
"in",
"self",
".",
"compression_algorithms",
":",
"raise",
"Ex... | 7656233598e02e65971f69e11849a0f288b2b2a5 |
valid | EncryptedPickle._remove_magic | Verify and remove magic | encryptedpickle/encryptedpickle.py | def _remove_magic(self, data):
'''Verify and remove magic'''
if not self.magic:
return data
magic_size = len(self.magic)
magic = data[:magic_size]
if magic != self.magic:
raise Exception('Invalid magic')
data = data[magic_size:]
return d... | def _remove_magic(self, data):
'''Verify and remove magic'''
if not self.magic:
return data
magic_size = len(self.magic)
magic = data[:magic_size]
if magic != self.magic:
raise Exception('Invalid magic')
data = data[magic_size:]
return d... | [
"Verify",
"and",
"remove",
"magic"
] | vingd/encrypted-pickle-python | python | https://github.com/vingd/encrypted-pickle-python/blob/7656233598e02e65971f69e11849a0f288b2b2a5/encryptedpickle/encryptedpickle.py#L546-L558 | [
"def",
"_remove_magic",
"(",
"self",
",",
"data",
")",
":",
"if",
"not",
"self",
".",
"magic",
":",
"return",
"data",
"magic_size",
"=",
"len",
"(",
"self",
".",
"magic",
")",
"magic",
"=",
"data",
"[",
":",
"magic_size",
"]",
"if",
"magic",
"!=",
... | 7656233598e02e65971f69e11849a0f288b2b2a5 |
valid | EncryptedPickle._add_header | Add header to data | encryptedpickle/encryptedpickle.py | def _add_header(self, data, options):
'''Add header to data'''
# pylint: disable=W0142
version_info = self._get_version_info(options['version'])
flags = options['flags']
header_flags = dict(
(i, str(int(j))) for i, j in options['flags'].iteritems())
header... | def _add_header(self, data, options):
'''Add header to data'''
# pylint: disable=W0142
version_info = self._get_version_info(options['version'])
flags = options['flags']
header_flags = dict(
(i, str(int(j))) for i, j in options['flags'].iteritems())
header... | [
"Add",
"header",
"to",
"data"
] | vingd/encrypted-pickle-python | python | https://github.com/vingd/encrypted-pickle-python/blob/7656233598e02e65971f69e11849a0f288b2b2a5/encryptedpickle/encryptedpickle.py#L568-L592 | [
"def",
"_add_header",
"(",
"self",
",",
"data",
",",
"options",
")",
":",
"# pylint: disable=W0142",
"version_info",
"=",
"self",
".",
"_get_version_info",
"(",
"options",
"[",
"'version'",
"]",
")",
"flags",
"=",
"options",
"[",
"'flags'",
"]",
"header_flags"... | 7656233598e02e65971f69e11849a0f288b2b2a5 |
valid | EncryptedPickle._read_header | Read header from data | encryptedpickle/encryptedpickle.py | def _read_header(self, data):
'''Read header from data'''
# pylint: disable=W0212
version = self._read_version(data)
version_info = self._get_version_info(version)
header_data = data[:version_info['header_size']]
header = version_info['header']
header = header._... | def _read_header(self, data):
'''Read header from data'''
# pylint: disable=W0212
version = self._read_version(data)
version_info = self._get_version_info(version)
header_data = data[:version_info['header_size']]
header = version_info['header']
header = header._... | [
"Read",
"header",
"from",
"data"
] | vingd/encrypted-pickle-python | python | https://github.com/vingd/encrypted-pickle-python/blob/7656233598e02e65971f69e11849a0f288b2b2a5/encryptedpickle/encryptedpickle.py#L594-L621 | [
"def",
"_read_header",
"(",
"self",
",",
"data",
")",
":",
"# pylint: disable=W0212",
"version",
"=",
"self",
".",
"_read_version",
"(",
"data",
")",
"version_info",
"=",
"self",
".",
"_get_version_info",
"(",
"version",
")",
"header_data",
"=",
"data",
"[",
... | 7656233598e02e65971f69e11849a0f288b2b2a5 |
valid | EncryptedPickle._remove_header | Remove header from data | encryptedpickle/encryptedpickle.py | def _remove_header(self, data, options):
'''Remove header from data'''
version_info = self._get_version_info(options['version'])
header_size = version_info['header_size']
if options['flags']['timestamp']:
header_size += version_info['timestamp_size']
data = data[he... | def _remove_header(self, data, options):
'''Remove header from data'''
version_info = self._get_version_info(options['version'])
header_size = version_info['header_size']
if options['flags']['timestamp']:
header_size += version_info['timestamp_size']
data = data[he... | [
"Remove",
"header",
"from",
"data"
] | vingd/encrypted-pickle-python | python | https://github.com/vingd/encrypted-pickle-python/blob/7656233598e02e65971f69e11849a0f288b2b2a5/encryptedpickle/encryptedpickle.py#L623-L634 | [
"def",
"_remove_header",
"(",
"self",
",",
"data",
",",
"options",
")",
":",
"version_info",
"=",
"self",
".",
"_get_version_info",
"(",
"options",
"[",
"'version'",
"]",
")",
"header_size",
"=",
"version_info",
"[",
"'header_size'",
"]",
"if",
"options",
"[... | 7656233598e02e65971f69e11849a0f288b2b2a5 |
valid | EncryptedPickle._read_version | Read header version from data | encryptedpickle/encryptedpickle.py | def _read_version(self, data):
'''Read header version from data'''
version = ord(data[0])
if version not in self.VERSIONS:
raise Exception('Version not defined: %d' % version)
return version | def _read_version(self, data):
'''Read header version from data'''
version = ord(data[0])
if version not in self.VERSIONS:
raise Exception('Version not defined: %d' % version)
return version | [
"Read",
"header",
"version",
"from",
"data"
] | vingd/encrypted-pickle-python | python | https://github.com/vingd/encrypted-pickle-python/blob/7656233598e02e65971f69e11849a0f288b2b2a5/encryptedpickle/encryptedpickle.py#L636-L642 | [
"def",
"_read_version",
"(",
"self",
",",
"data",
")",
":",
"version",
"=",
"ord",
"(",
"data",
"[",
"0",
"]",
")",
"if",
"version",
"not",
"in",
"self",
".",
"VERSIONS",
":",
"raise",
"Exception",
"(",
"'Version not defined: %d'",
"%",
"version",
")",
... | 7656233598e02e65971f69e11849a0f288b2b2a5 |
valid | EncryptedPickle._get_algorithm_info | Get algorithm info | encryptedpickle/encryptedpickle.py | def _get_algorithm_info(self, algorithm_info):
'''Get algorithm info'''
if algorithm_info['algorithm'] not in self.ALGORITHMS:
raise Exception('Algorithm not supported: %s'
% algorithm_info['algorithm'])
algorithm = self.ALGORITHMS[algorithm_info['algori... | def _get_algorithm_info(self, algorithm_info):
'''Get algorithm info'''
if algorithm_info['algorithm'] not in self.ALGORITHMS:
raise Exception('Algorithm not supported: %s'
% algorithm_info['algorithm'])
algorithm = self.ALGORITHMS[algorithm_info['algori... | [
"Get",
"algorithm",
"info"
] | vingd/encrypted-pickle-python | python | https://github.com/vingd/encrypted-pickle-python/blob/7656233598e02e65971f69e11849a0f288b2b2a5/encryptedpickle/encryptedpickle.py#L649-L659 | [
"def",
"_get_algorithm_info",
"(",
"self",
",",
"algorithm_info",
")",
":",
"if",
"algorithm_info",
"[",
"'algorithm'",
"]",
"not",
"in",
"self",
".",
"ALGORITHMS",
":",
"raise",
"Exception",
"(",
"'Algorithm not supported: %s'",
"%",
"algorithm_info",
"[",
"'algo... | 7656233598e02e65971f69e11849a0f288b2b2a5 |
valid | EncryptedPickle._generate_key | Generate and return PBKDF2 key | encryptedpickle/encryptedpickle.py | def _generate_key(pass_id, passphrases, salt, algorithm):
'''Generate and return PBKDF2 key'''
if pass_id not in passphrases:
raise Exception('Passphrase not defined for id: %d' % pass_id)
passphrase = passphrases[pass_id]
if len(passphrase) < 32:
raise Excepti... | def _generate_key(pass_id, passphrases, salt, algorithm):
'''Generate and return PBKDF2 key'''
if pass_id not in passphrases:
raise Exception('Passphrase not defined for id: %d' % pass_id)
passphrase = passphrases[pass_id]
if len(passphrase) < 32:
raise Excepti... | [
"Generate",
"and",
"return",
"PBKDF2",
"key"
] | vingd/encrypted-pickle-python | python | https://github.com/vingd/encrypted-pickle-python/blob/7656233598e02e65971f69e11849a0f288b2b2a5/encryptedpickle/encryptedpickle.py#L662-L679 | [
"def",
"_generate_key",
"(",
"pass_id",
",",
"passphrases",
",",
"salt",
",",
"algorithm",
")",
":",
"if",
"pass_id",
"not",
"in",
"passphrases",
":",
"raise",
"Exception",
"(",
"'Passphrase not defined for id: %d'",
"%",
"pass_id",
")",
"passphrase",
"=",
"pass... | 7656233598e02e65971f69e11849a0f288b2b2a5 |
valid | EncryptedPickle._update_dict | Update algorithm definition type dictionaries | encryptedpickle/encryptedpickle.py | def _update_dict(data, default_data, replace_data=False):
'''Update algorithm definition type dictionaries'''
if not data:
data = default_data.copy()
return data
if not isinstance(data, dict):
raise TypeError('Value not dict type')
if len(data) > 255... | def _update_dict(data, default_data, replace_data=False):
'''Update algorithm definition type dictionaries'''
if not data:
data = default_data.copy()
return data
if not isinstance(data, dict):
raise TypeError('Value not dict type')
if len(data) > 255... | [
"Update",
"algorithm",
"definition",
"type",
"dictionaries"
] | vingd/encrypted-pickle-python | python | https://github.com/vingd/encrypted-pickle-python/blob/7656233598e02e65971f69e11849a0f288b2b2a5/encryptedpickle/encryptedpickle.py#L682-L702 | [
"def",
"_update_dict",
"(",
"data",
",",
"default_data",
",",
"replace_data",
"=",
"False",
")",
":",
"if",
"not",
"data",
":",
"data",
"=",
"default_data",
".",
"copy",
"(",
")",
"return",
"data",
"if",
"not",
"isinstance",
"(",
"data",
",",
"dict",
"... | 7656233598e02e65971f69e11849a0f288b2b2a5 |
valid | EncryptedPickle._get_hashlib | Generate HMAC hash | encryptedpickle/encryptedpickle.py | def _get_hashlib(digestmode):
'''Generate HMAC hash'''
if digestmode == 'sha1':
return SHA
if digestmode == 'sha256':
return SHA256
elif digestmode == 'sha384':
return SHA384
elif digestmode == 'sha512':
return SHA512
else:... | def _get_hashlib(digestmode):
'''Generate HMAC hash'''
if digestmode == 'sha1':
return SHA
if digestmode == 'sha256':
return SHA256
elif digestmode == 'sha384':
return SHA384
elif digestmode == 'sha512':
return SHA512
else:... | [
"Generate",
"HMAC",
"hash"
] | vingd/encrypted-pickle-python | python | https://github.com/vingd/encrypted-pickle-python/blob/7656233598e02e65971f69e11849a0f288b2b2a5/encryptedpickle/encryptedpickle.py#L705-L717 | [
"def",
"_get_hashlib",
"(",
"digestmode",
")",
":",
"if",
"digestmode",
"==",
"'sha1'",
":",
"return",
"SHA",
"if",
"digestmode",
"==",
"'sha256'",
":",
"return",
"SHA256",
"elif",
"digestmode",
"==",
"'sha384'",
":",
"return",
"SHA384",
"elif",
"digestmode",
... | 7656233598e02e65971f69e11849a0f288b2b2a5 |
valid | EncryptedPickle._hmac_generate | Generate HMAC hash | encryptedpickle/encryptedpickle.py | def _hmac_generate(data, algorithm, key):
'''Generate HMAC hash'''
digestmod = EncryptedPickle._get_hashlib(algorithm['subtype'])
return HMAC.new(key, data, digestmod).digest() | def _hmac_generate(data, algorithm, key):
'''Generate HMAC hash'''
digestmod = EncryptedPickle._get_hashlib(algorithm['subtype'])
return HMAC.new(key, data, digestmod).digest() | [
"Generate",
"HMAC",
"hash"
] | vingd/encrypted-pickle-python | python | https://github.com/vingd/encrypted-pickle-python/blob/7656233598e02e65971f69e11849a0f288b2b2a5/encryptedpickle/encryptedpickle.py#L720-L725 | [
"def",
"_hmac_generate",
"(",
"data",
",",
"algorithm",
",",
"key",
")",
":",
"digestmod",
"=",
"EncryptedPickle",
".",
"_get_hashlib",
"(",
"algorithm",
"[",
"'subtype'",
"]",
")",
"return",
"HMAC",
".",
"new",
"(",
"key",
",",
"data",
",",
"digestmod",
... | 7656233598e02e65971f69e11849a0f288b2b2a5 |
valid | EncryptedPickle._aes_encrypt | AES encrypt | encryptedpickle/encryptedpickle.py | def _aes_encrypt(data, algorithm, key):
'''AES encrypt'''
if algorithm['subtype'] == 'cbc':
mode = AES.MODE_CBC
else:
raise Exception('AES subtype not supported: %s'
% algorithm['subtype'])
iv_size = algorithm['iv_size']
block... | def _aes_encrypt(data, algorithm, key):
'''AES encrypt'''
if algorithm['subtype'] == 'cbc':
mode = AES.MODE_CBC
else:
raise Exception('AES subtype not supported: %s'
% algorithm['subtype'])
iv_size = algorithm['iv_size']
block... | [
"AES",
"encrypt"
] | vingd/encrypted-pickle-python | python | https://github.com/vingd/encrypted-pickle-python/blob/7656233598e02e65971f69e11849a0f288b2b2a5/encryptedpickle/encryptedpickle.py#L728-L757 | [
"def",
"_aes_encrypt",
"(",
"data",
",",
"algorithm",
",",
"key",
")",
":",
"if",
"algorithm",
"[",
"'subtype'",
"]",
"==",
"'cbc'",
":",
"mode",
"=",
"AES",
".",
"MODE_CBC",
"else",
":",
"raise",
"Exception",
"(",
"'AES subtype not supported: %s'",
"%",
"... | 7656233598e02e65971f69e11849a0f288b2b2a5 |
valid | EncryptedPickle._aes_decrypt | AES decrypt | encryptedpickle/encryptedpickle.py | def _aes_decrypt(data, algorithm, key):
'''AES decrypt'''
if algorithm['subtype'] == 'cbc':
mode = AES.MODE_CBC
else:
raise Exception('AES subtype not supported: %s'
% algorithm['subtype'])
iv_size = algorithm['iv_size']
if '... | def _aes_decrypt(data, algorithm, key):
'''AES decrypt'''
if algorithm['subtype'] == 'cbc':
mode = AES.MODE_CBC
else:
raise Exception('AES subtype not supported: %s'
% algorithm['subtype'])
iv_size = algorithm['iv_size']
if '... | [
"AES",
"decrypt"
] | vingd/encrypted-pickle-python | python | https://github.com/vingd/encrypted-pickle-python/blob/7656233598e02e65971f69e11849a0f288b2b2a5/encryptedpickle/encryptedpickle.py#L760-L785 | [
"def",
"_aes_decrypt",
"(",
"data",
",",
"algorithm",
",",
"key",
")",
":",
"if",
"algorithm",
"[",
"'subtype'",
"]",
"==",
"'cbc'",
":",
"mode",
"=",
"AES",
".",
"MODE_CBC",
"else",
":",
"raise",
"Exception",
"(",
"'AES subtype not supported: %s'",
"%",
"... | 7656233598e02e65971f69e11849a0f288b2b2a5 |
valid | EncryptedPickle._zlib_compress | GZIP compress | encryptedpickle/encryptedpickle.py | def _zlib_compress(data, algorithm):
'''GZIP compress'''
if algorithm['subtype'] == 'deflate':
encoder = zlib.compressobj(algorithm['level'], zlib.DEFLATED, -15)
compressed = encoder.compress(data)
compressed += encoder.flush()
return compressed
... | def _zlib_compress(data, algorithm):
'''GZIP compress'''
if algorithm['subtype'] == 'deflate':
encoder = zlib.compressobj(algorithm['level'], zlib.DEFLATED, -15)
compressed = encoder.compress(data)
compressed += encoder.flush()
return compressed
... | [
"GZIP",
"compress"
] | vingd/encrypted-pickle-python | python | https://github.com/vingd/encrypted-pickle-python/blob/7656233598e02e65971f69e11849a0f288b2b2a5/encryptedpickle/encryptedpickle.py#L788-L799 | [
"def",
"_zlib_compress",
"(",
"data",
",",
"algorithm",
")",
":",
"if",
"algorithm",
"[",
"'subtype'",
"]",
"==",
"'deflate'",
":",
"encoder",
"=",
"zlib",
".",
"compressobj",
"(",
"algorithm",
"[",
"'level'",
"]",
",",
"zlib",
".",
"DEFLATED",
",",
"-",... | 7656233598e02e65971f69e11849a0f288b2b2a5 |
valid | RemoteZip.getTableOfContents | This function populates the internal tableOfContents list with the contents
of the zip file TOC. If the server does not support ranged requests, this will raise
and exception. It will also throw an exception if the TOC cannot be found. | pyremotezip/remotezip.py | def getTableOfContents(self):
"""
This function populates the internal tableOfContents list with the contents
of the zip file TOC. If the server does not support ranged requests, this will raise
and exception. It will also throw an exception if the TOC cannot be found.
"""
... | def getTableOfContents(self):
"""
This function populates the internal tableOfContents list with the contents
of the zip file TOC. If the server does not support ranged requests, this will raise
and exception. It will also throw an exception if the TOC cannot be found.
"""
... | [
"This",
"function",
"populates",
"the",
"internal",
"tableOfContents",
"list",
"with",
"the",
"contents",
"of",
"the",
"zip",
"file",
"TOC",
".",
"If",
"the",
"server",
"does",
"not",
"support",
"ranged",
"requests",
"this",
"will",
"raise",
"and",
"exception"... | fcvarela/pyremotezip | python | https://github.com/fcvarela/pyremotezip/blob/52cc885b2ed1e690d92d3b41fef7a1a3fcc2b509/pyremotezip/remotezip.py#L86-L136 | [
"def",
"getTableOfContents",
"(",
"self",
")",
":",
"self",
".",
"directory_size",
"=",
"self",
".",
"getDirectorySize",
"(",
")",
"if",
"self",
".",
"directory_size",
">",
"65536",
":",
"self",
".",
"directory_size",
"+=",
"2",
"self",
".",
"requestContentD... | 52cc885b2ed1e690d92d3b41fef7a1a3fcc2b509 |
valid | RemoteZip.extractFile | This function will extract a single file from the remote zip without downloading
the entire zip file. The filename argument should match whatever is in the 'filename'
key of the tableOfContents. | pyremotezip/remotezip.py | def extractFile(self, filename):
"""
This function will extract a single file from the remote zip without downloading
the entire zip file. The filename argument should match whatever is in the 'filename'
key of the tableOfContents.
"""
files = [x for x in self.tableOfCont... | def extractFile(self, filename):
"""
This function will extract a single file from the remote zip without downloading
the entire zip file. The filename argument should match whatever is in the 'filename'
key of the tableOfContents.
"""
files = [x for x in self.tableOfCont... | [
"This",
"function",
"will",
"extract",
"a",
"single",
"file",
"from",
"the",
"remote",
"zip",
"without",
"downloading",
"the",
"entire",
"zip",
"file",
".",
"The",
"filename",
"argument",
"should",
"match",
"whatever",
"is",
"in",
"the",
"filename",
"key",
"... | fcvarela/pyremotezip | python | https://github.com/fcvarela/pyremotezip/blob/52cc885b2ed1e690d92d3b41fef7a1a3fcc2b509/pyremotezip/remotezip.py#L138-L192 | [
"def",
"extractFile",
"(",
"self",
",",
"filename",
")",
":",
"files",
"=",
"[",
"x",
"for",
"x",
"in",
"self",
".",
"tableOfContents",
"if",
"x",
"[",
"'filename'",
"]",
"==",
"filename",
"]",
"if",
"len",
"(",
"files",
")",
"==",
"0",
":",
"raise... | 52cc885b2ed1e690d92d3b41fef7a1a3fcc2b509 |
valid | star.make_postcard | Develop a "postcard" region around the target star.
Other stars in this postcard will be used as possible reference stars.
Args:
npix: The size of the postcard region. The region will be a square with sides npix pixels
(default: ``300``)
shape: The size ... | f3/photometry.py | def make_postcard(self, npix=300, shape=(1070, 1132), buffer_size=15):
"""
Develop a "postcard" region around the target star.
Other stars in this postcard will be used as possible reference stars.
Args:
npix: The size of the postcard region. The region will be a sq... | def make_postcard(self, npix=300, shape=(1070, 1132), buffer_size=15):
"""
Develop a "postcard" region around the target star.
Other stars in this postcard will be used as possible reference stars.
Args:
npix: The size of the postcard region. The region will be a sq... | [
"Develop",
"a",
"postcard",
"region",
"around",
"the",
"target",
"star",
".",
"Other",
"stars",
"in",
"this",
"postcard",
"will",
"be",
"used",
"as",
"possible",
"reference",
"stars",
".",
"Args",
":",
"npix",
":",
"The",
"size",
"of",
"the",
"postcard",
... | benmontet/f3 | python | https://github.com/benmontet/f3/blob/b2e1dc250e4e3e884a54c501cd35cf02d5b8719e/f3/photometry.py#L48-L134 | [
"def",
"make_postcard",
"(",
"self",
",",
"npix",
"=",
"300",
",",
"shape",
"=",
"(",
"1070",
",",
"1132",
")",
",",
"buffer_size",
"=",
"15",
")",
":",
"source",
"=",
"self",
".",
"kic",
"client",
"=",
"kplr",
".",
"API",
"(",
")",
"targ",
"=",
... | b2e1dc250e4e3e884a54c501cd35cf02d5b8719e |
valid | star.find_other_sources | Identify apertures for all sources on the postcard, both for the
target and potential reference stars
Args:
edge_lim: The initial limit for the creation of apertures. The aperture will be a region of
contiguous pixels with flux values larger than the product of ``e... | f3/photometry.py | def find_other_sources(self, edge_lim = 0.015, min_val = 5000,
ntargets = 250, extend_region_size=3, remove_excess=4,
plot_flag = False, plot_window=15):
"""
Identify apertures for all sources on the postcard, both for the
target and potenti... | def find_other_sources(self, edge_lim = 0.015, min_val = 5000,
ntargets = 250, extend_region_size=3, remove_excess=4,
plot_flag = False, plot_window=15):
"""
Identify apertures for all sources on the postcard, both for the
target and potenti... | [
"Identify",
"apertures",
"for",
"all",
"sources",
"on",
"the",
"postcard",
"both",
"for",
"the",
"target",
"and",
"potential",
"reference",
"stars",
"Args",
":",
"edge_lim",
":",
"The",
"initial",
"limit",
"for",
"the",
"creation",
"of",
"apertures",
".",
"T... | benmontet/f3 | python | https://github.com/benmontet/f3/blob/b2e1dc250e4e3e884a54c501cd35cf02d5b8719e/f3/photometry.py#L194-L299 | [
"def",
"find_other_sources",
"(",
"self",
",",
"edge_lim",
"=",
"0.015",
",",
"min_val",
"=",
"5000",
",",
"ntargets",
"=",
"250",
",",
"extend_region_size",
"=",
"3",
",",
"remove_excess",
"=",
"4",
",",
"plot_flag",
"=",
"False",
",",
"plot_window",
"=",... | b2e1dc250e4e3e884a54c501cd35cf02d5b8719e |
valid | star.do_photometry | Does photometry and estimates uncertainties by calculating the scatter around a linear fit to the data
in each orientation. This function is called by other functions and generally the user will not need
to interact with it directly. | f3/photometry.py | def do_photometry(self):
"""
Does photometry and estimates uncertainties by calculating the scatter around a linear fit to the data
in each orientation. This function is called by other functions and generally the user will not need
to interact with it directly.
"""
... | def do_photometry(self):
"""
Does photometry and estimates uncertainties by calculating the scatter around a linear fit to the data
in each orientation. This function is called by other functions and generally the user will not need
to interact with it directly.
"""
... | [
"Does",
"photometry",
"and",
"estimates",
"uncertainties",
"by",
"calculating",
"the",
"scatter",
"around",
"a",
"linear",
"fit",
"to",
"the",
"data",
"in",
"each",
"orientation",
".",
"This",
"function",
"is",
"called",
"by",
"other",
"functions",
"and",
"gen... | benmontet/f3 | python | https://github.com/benmontet/f3/blob/b2e1dc250e4e3e884a54c501cd35cf02d5b8719e/f3/photometry.py#L301-L329 | [
"def",
"do_photometry",
"(",
"self",
")",
":",
"std_f",
"=",
"np",
".",
"zeros",
"(",
"4",
")",
"data_save",
"=",
"np",
".",
"zeros_like",
"(",
"self",
".",
"postcard",
")",
"self",
".",
"obs_flux",
"=",
"np",
".",
"zeros_like",
"(",
"self",
".",
"... | b2e1dc250e4e3e884a54c501cd35cf02d5b8719e |
valid | star.generate_panel | Creates the figure shown in ``adjust_aperture`` for visualization purposes. Called by other functions
and generally not called by the user directly.
Args:
img: The data frame to be passed through to be plotted. A cutout of the ``integrated_postcard`` | f3/photometry.py | def generate_panel(self, img):
"""
Creates the figure shown in ``adjust_aperture`` for visualization purposes. Called by other functions
and generally not called by the user directly.
Args:
img: The data frame to be passed through to be plotted. A cutout of the ``integrated... | def generate_panel(self, img):
"""
Creates the figure shown in ``adjust_aperture`` for visualization purposes. Called by other functions
and generally not called by the user directly.
Args:
img: The data frame to be passed through to be plotted. A cutout of the ``integrated... | [
"Creates",
"the",
"figure",
"shown",
"in",
"adjust_aperture",
"for",
"visualization",
"purposes",
".",
"Called",
"by",
"other",
"functions",
"and",
"generally",
"not",
"called",
"by",
"the",
"user",
"directly",
"."
] | benmontet/f3 | python | https://github.com/benmontet/f3/blob/b2e1dc250e4e3e884a54c501cd35cf02d5b8719e/f3/photometry.py#L331-L368 | [
"def",
"generate_panel",
"(",
"self",
",",
"img",
")",
":",
"plt",
".",
"figure",
"(",
"figsize",
"=",
"(",
"14",
",",
"6",
")",
")",
"ax",
"=",
"plt",
".",
"gca",
"(",
")",
"fig",
"=",
"plt",
".",
"gcf",
"(",
")",
"plt",
".",
"subplot",
"(",... | b2e1dc250e4e3e884a54c501cd35cf02d5b8719e |
valid | star.adjust_aperture | Develop a panel showing the current aperture and the light curve as judged from that aperture.
Clicking on individual pixels on the aperture will toggle those pixels on or off into the
aperture (which will be updated after closing the plot).
Clicking on the 0th row or column will turn off all pi... | f3/photometry.py | def adjust_aperture(self, image_region=15, ignore_bright=0):
"""
Develop a panel showing the current aperture and the light curve as judged from that aperture.
Clicking on individual pixels on the aperture will toggle those pixels on or off into the
aperture (which will be updated after ... | def adjust_aperture(self, image_region=15, ignore_bright=0):
"""
Develop a panel showing the current aperture and the light curve as judged from that aperture.
Clicking on individual pixels on the aperture will toggle those pixels on or off into the
aperture (which will be updated after ... | [
"Develop",
"a",
"panel",
"showing",
"the",
"current",
"aperture",
"and",
"the",
"light",
"curve",
"as",
"judged",
"from",
"that",
"aperture",
".",
"Clicking",
"on",
"individual",
"pixels",
"on",
"the",
"aperture",
"will",
"toggle",
"those",
"pixels",
"on",
"... | benmontet/f3 | python | https://github.com/benmontet/f3/blob/b2e1dc250e4e3e884a54c501cd35cf02d5b8719e/f3/photometry.py#L372-L421 | [
"def",
"adjust_aperture",
"(",
"self",
",",
"image_region",
"=",
"15",
",",
"ignore_bright",
"=",
"0",
")",
":",
"self",
".",
"ignore_bright",
"=",
"ignore_bright",
"self",
".",
"calc_fluxes",
"(",
")",
"self",
".",
"coordsx",
"=",
"[",
"]",
"self",
".",... | b2e1dc250e4e3e884a54c501cd35cf02d5b8719e |
valid | star.data_for_target | Determine the normalized photometry, accounting for effects shared by reference stars. Does not provide
the opportunity to adjust the aperture
Args:
image_region: If ``True`` allow the aperture to be shifted up to one pixel in both the x and y
directions to account ... | f3/photometry.py | def data_for_target(self, do_roll=True, ignore_bright=0):
"""
Determine the normalized photometry, accounting for effects shared by reference stars. Does not provide
the opportunity to adjust the aperture
Args:
image_region: If ``True`` allow the aperture to be shif... | def data_for_target(self, do_roll=True, ignore_bright=0):
"""
Determine the normalized photometry, accounting for effects shared by reference stars. Does not provide
the opportunity to adjust the aperture
Args:
image_region: If ``True`` allow the aperture to be shif... | [
"Determine",
"the",
"normalized",
"photometry",
"accounting",
"for",
"effects",
"shared",
"by",
"reference",
"stars",
".",
"Does",
"not",
"provide",
"the",
"opportunity",
"to",
"adjust",
"the",
"aperture",
"Args",
":",
"image_region",
":",
"If",
"True",
"allow",... | benmontet/f3 | python | https://github.com/benmontet/f3/blob/b2e1dc250e4e3e884a54c501cd35cf02d5b8719e/f3/photometry.py#L424-L449 | [
"def",
"data_for_target",
"(",
"self",
",",
"do_roll",
"=",
"True",
",",
"ignore_bright",
"=",
"0",
")",
":",
"self",
".",
"ignore_bright",
"=",
"ignore_bright",
"self",
".",
"calc_fluxes",
"(",
")",
"self",
".",
"roll_best",
"=",
"np",
".",
"zeros",
"("... | b2e1dc250e4e3e884a54c501cd35cf02d5b8719e |
valid | star.calc_fluxes | Determine the suitable reference stars, and then the total flux in those stars and
in the target star in each epoch
Args:
min_flux: The size of the region around the target star to be plotted. Images will be a square
with side length ``image_region`` (default: ``5... | f3/photometry.py | def calc_fluxes(self, min_flux = 5000, outlier_iterations=5,
max_outlier_obs=4, outlier_limit=1.7):
"""
Determine the suitable reference stars, and then the total flux in those stars and
in the target star in each epoch
Args:
min_flux: The si... | def calc_fluxes(self, min_flux = 5000, outlier_iterations=5,
max_outlier_obs=4, outlier_limit=1.7):
"""
Determine the suitable reference stars, and then the total flux in those stars and
in the target star in each epoch
Args:
min_flux: The si... | [
"Determine",
"the",
"suitable",
"reference",
"stars",
"and",
"then",
"the",
"total",
"flux",
"in",
"those",
"stars",
"and",
"in",
"the",
"target",
"star",
"in",
"each",
"epoch",
"Args",
":",
"min_flux",
":",
"The",
"size",
"of",
"the",
"region",
"around",
... | benmontet/f3 | python | https://github.com/benmontet/f3/blob/b2e1dc250e4e3e884a54c501cd35cf02d5b8719e/f3/photometry.py#L452-L527 | [
"def",
"calc_fluxes",
"(",
"self",
",",
"min_flux",
"=",
"5000",
",",
"outlier_iterations",
"=",
"5",
",",
"max_outlier_obs",
"=",
"4",
",",
"outlier_limit",
"=",
"1.7",
")",
":",
"jj",
",",
"ii",
"=",
"self",
".",
"center",
"numer",
"=",
"np",
".",
... | b2e1dc250e4e3e884a54c501cd35cf02d5b8719e |
valid | star.calc_centroids | Identify the centroid positions for the target star at all epochs. Useful for verifying that there is
no correlation between flux and position, as might be expected for high proper motion stars. | f3/photometry.py | def calc_centroids(self):
"""
Identify the centroid positions for the target star at all epochs. Useful for verifying that there is
no correlation between flux and position, as might be expected for high proper motion stars.
"""
self.cm = np.zeros((len(self.postcard), 2))
... | def calc_centroids(self):
"""
Identify the centroid positions for the target star at all epochs. Useful for verifying that there is
no correlation between flux and position, as might be expected for high proper motion stars.
"""
self.cm = np.zeros((len(self.postcard), 2))
... | [
"Identify",
"the",
"centroid",
"positions",
"for",
"the",
"target",
"star",
"at",
"all",
"epochs",
".",
"Useful",
"for",
"verifying",
"that",
"there",
"is",
"no",
"correlation",
"between",
"flux",
"and",
"position",
"as",
"might",
"be",
"expected",
"for",
"h... | benmontet/f3 | python | https://github.com/benmontet/f3/blob/b2e1dc250e4e3e884a54c501cd35cf02d5b8719e/f3/photometry.py#L529-L538 | [
"def",
"calc_centroids",
"(",
"self",
")",
":",
"self",
".",
"cm",
"=",
"np",
".",
"zeros",
"(",
"(",
"len",
"(",
"self",
".",
"postcard",
")",
",",
"2",
")",
")",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"self",
".",
"postcard",
")",
")",
... | b2e1dc250e4e3e884a54c501cd35cf02d5b8719e |
valid | star.define_spotsignal | Identify the "expected" flux value at the time of each observation based on the
Kepler long-cadence data, to ensure variations observed are not the effects of a single
large starspot. Only works if the target star was targeted for long or short cadence
observations during the primary mission. | f3/photometry.py | def define_spotsignal(self):
"""
Identify the "expected" flux value at the time of each observation based on the
Kepler long-cadence data, to ensure variations observed are not the effects of a single
large starspot. Only works if the target star was targeted for long or short cadence
... | def define_spotsignal(self):
"""
Identify the "expected" flux value at the time of each observation based on the
Kepler long-cadence data, to ensure variations observed are not the effects of a single
large starspot. Only works if the target star was targeted for long or short cadence
... | [
"Identify",
"the",
"expected",
"flux",
"value",
"at",
"the",
"time",
"of",
"each",
"observation",
"based",
"on",
"the",
"Kepler",
"long",
"-",
"cadence",
"data",
"to",
"ensure",
"variations",
"observed",
"are",
"not",
"the",
"effects",
"of",
"a",
"single",
... | benmontet/f3 | python | https://github.com/benmontet/f3/blob/b2e1dc250e4e3e884a54c501cd35cf02d5b8719e/f3/photometry.py#L540-L583 | [
"def",
"define_spotsignal",
"(",
"self",
")",
":",
"client",
"=",
"kplr",
".",
"API",
"(",
")",
"star",
"=",
"client",
".",
"star",
"(",
"self",
".",
"kic",
")",
"lcs",
"=",
"star",
".",
"get_light_curves",
"(",
"short_cadence",
"=",
"False",
")",
"t... | b2e1dc250e4e3e884a54c501cd35cf02d5b8719e |
valid | star.model_uncert | Estimate the photometric uncertainties on each data point following Equation A.2 of The Paper.
Based on the kepcal package of Dan Foreman-Mackey. | f3/photometry.py | def model_uncert(self):
"""
Estimate the photometric uncertainties on each data point following Equation A.2 of The Paper.
Based on the kepcal package of Dan Foreman-Mackey.
"""
Y = self.photometry_array.T
Y /= np.median(Y, axis=1)[:, None]
C = np.median(Y, axis=0... | def model_uncert(self):
"""
Estimate the photometric uncertainties on each data point following Equation A.2 of The Paper.
Based on the kepcal package of Dan Foreman-Mackey.
"""
Y = self.photometry_array.T
Y /= np.median(Y, axis=1)[:, None]
C = np.median(Y, axis=0... | [
"Estimate",
"the",
"photometric",
"uncertainties",
"on",
"each",
"data",
"point",
"following",
"Equation",
"A",
".",
"2",
"of",
"The",
"Paper",
".",
"Based",
"on",
"the",
"kepcal",
"package",
"of",
"Dan",
"Foreman",
"-",
"Mackey",
"."
] | benmontet/f3 | python | https://github.com/benmontet/f3/blob/b2e1dc250e4e3e884a54c501cd35cf02d5b8719e/f3/photometry.py#L585-L613 | [
"def",
"model_uncert",
"(",
"self",
")",
":",
"Y",
"=",
"self",
".",
"photometry_array",
".",
"T",
"Y",
"/=",
"np",
".",
"median",
"(",
"Y",
",",
"axis",
"=",
"1",
")",
"[",
":",
",",
"None",
"]",
"C",
"=",
"np",
".",
"median",
"(",
"Y",
",",... | b2e1dc250e4e3e884a54c501cd35cf02d5b8719e |
valid | Pbd._print | Append line to internal list.
Uses self.tabs to format indents.
Keyword arguments:
line -- line to append | pbd/__init__.py | def _print(self, line=''):
"""Append line to internal list.
Uses self.tabs to format indents.
Keyword arguments:
line -- line to append
"""
self.lines.append('{}{}'.format('\t'*self.tabs , line)) | def _print(self, line=''):
"""Append line to internal list.
Uses self.tabs to format indents.
Keyword arguments:
line -- line to append
"""
self.lines.append('{}{}'.format('\t'*self.tabs , line)) | [
"Append",
"line",
"to",
"internal",
"list",
".",
"Uses",
"self",
".",
"tabs",
"to",
"format",
"indents",
".",
"Keyword",
"arguments",
":",
"line",
"--",
"line",
"to",
"append"
] | rsc-dev/pbd | python | https://github.com/rsc-dev/pbd/blob/16c2eed1e35df238a76a7a469c056ff9ea8ec2a2/pbd/__init__.py#L46-L53 | [
"def",
"_print",
"(",
"self",
",",
"line",
"=",
"''",
")",
":",
"self",
".",
"lines",
".",
"append",
"(",
"'{}{}'",
".",
"format",
"(",
"'\\t'",
"*",
"self",
".",
"tabs",
",",
"line",
")",
")"
] | 16c2eed1e35df238a76a7a469c056ff9ea8ec2a2 |
valid | Pbd._dump_enum | Dump single enum type.
Keyword arguments:
top -- top namespace | pbd/__init__.py | def _dump_enum(self, e, top=''):
"""Dump single enum type.
Keyword arguments:
top -- top namespace
"""
self._print()
self._print('enum {} {{'.format(e.name))
self.defines.append('{}.{}'.format(top,e.name))
self.tabs+=1
for v in e.... | def _dump_enum(self, e, top=''):
"""Dump single enum type.
Keyword arguments:
top -- top namespace
"""
self._print()
self._print('enum {} {{'.format(e.name))
self.defines.append('{}.{}'.format(top,e.name))
self.tabs+=1
for v in e.... | [
"Dump",
"single",
"enum",
"type",
".",
"Keyword",
"arguments",
":",
"top",
"--",
"top",
"namespace"
] | rsc-dev/pbd | python | https://github.com/rsc-dev/pbd/blob/16c2eed1e35df238a76a7a469c056ff9ea8ec2a2/pbd/__init__.py#L56-L70 | [
"def",
"_dump_enum",
"(",
"self",
",",
"e",
",",
"top",
"=",
"''",
")",
":",
"self",
".",
"_print",
"(",
")",
"self",
".",
"_print",
"(",
"'enum {} {{'",
".",
"format",
"(",
"e",
".",
"name",
")",
")",
"self",
".",
"defines",
".",
"append",
"(",
... | 16c2eed1e35df238a76a7a469c056ff9ea8ec2a2 |
valid | Pbd._dump_field | Dump single field. | pbd/__init__.py | def _dump_field(self, fd):
"""Dump single field.
"""
v = {}
v['label'] = Pbd.LABELS[fd.label]
v['type'] = fd.type_name if len(fd.type_name) > 0 else Pbd.TYPES[fd.type]
v['name'] = fd.name
v['number'] = fd.number
v['default'] = '[default = {}]'.format(fd.de... | def _dump_field(self, fd):
"""Dump single field.
"""
v = {}
v['label'] = Pbd.LABELS[fd.label]
v['type'] = fd.type_name if len(fd.type_name) > 0 else Pbd.TYPES[fd.type]
v['name'] = fd.name
v['number'] = fd.number
v['default'] = '[default = {}]'.format(fd.de... | [
"Dump",
"single",
"field",
"."
] | rsc-dev/pbd | python | https://github.com/rsc-dev/pbd/blob/16c2eed1e35df238a76a7a469c056ff9ea8ec2a2/pbd/__init__.py#L73-L88 | [
"def",
"_dump_field",
"(",
"self",
",",
"fd",
")",
":",
"v",
"=",
"{",
"}",
"v",
"[",
"'label'",
"]",
"=",
"Pbd",
".",
"LABELS",
"[",
"fd",
".",
"label",
"]",
"v",
"[",
"'type'",
"]",
"=",
"fd",
".",
"type_name",
"if",
"len",
"(",
"fd",
".",
... | 16c2eed1e35df238a76a7a469c056ff9ea8ec2a2 |
valid | Pbd._dump_message | Dump single message type.
Keyword arguments:
top -- top namespace | pbd/__init__.py | def _dump_message(self, m, top=''):
"""Dump single message type.
Keyword arguments:
top -- top namespace
"""
self._print()
self._print('message {} {{'.format(m.name))
self.defines.append('{}.{}'.format(top, m.name))
self.tabs+=1
f... | def _dump_message(self, m, top=''):
"""Dump single message type.
Keyword arguments:
top -- top namespace
"""
self._print()
self._print('message {} {{'.format(m.name))
self.defines.append('{}.{}'.format(top, m.name))
self.tabs+=1
f... | [
"Dump",
"single",
"message",
"type",
".",
"Keyword",
"arguments",
":",
"top",
"--",
"top",
"namespace"
] | rsc-dev/pbd | python | https://github.com/rsc-dev/pbd/blob/16c2eed1e35df238a76a7a469c056ff9ea8ec2a2/pbd/__init__.py#L91-L112 | [
"def",
"_dump_message",
"(",
"self",
",",
"m",
",",
"top",
"=",
"''",
")",
":",
"self",
".",
"_print",
"(",
")",
"self",
".",
"_print",
"(",
"'message {} {{'",
".",
"format",
"(",
"m",
".",
"name",
")",
")",
"self",
".",
"defines",
".",
"append",
... | 16c2eed1e35df238a76a7a469c056ff9ea8ec2a2 |
valid | Pbd._walk | Walk and dump (disasm) descriptor. | pbd/__init__.py | def _walk(self, fd):
"""Walk and dump (disasm) descriptor.
"""
top = '.{}'.format(fd.package) if len(fd.package) > 0 else ''
for e in fd.enum_type: self._dump_enum(e, top)
for m in fd.message_type: self. _dump_message(m, top) | def _walk(self, fd):
"""Walk and dump (disasm) descriptor.
"""
top = '.{}'.format(fd.package) if len(fd.package) > 0 else ''
for e in fd.enum_type: self._dump_enum(e, top)
for m in fd.message_type: self. _dump_message(m, top) | [
"Walk",
"and",
"dump",
"(",
"disasm",
")",
"descriptor",
"."
] | rsc-dev/pbd | python | https://github.com/rsc-dev/pbd/blob/16c2eed1e35df238a76a7a469c056ff9ea8ec2a2/pbd/__init__.py#L115-L121 | [
"def",
"_walk",
"(",
"self",
",",
"fd",
")",
":",
"top",
"=",
"'.{}'",
".",
"format",
"(",
"fd",
".",
"package",
")",
"if",
"len",
"(",
"fd",
".",
"package",
")",
">",
"0",
"else",
"''",
"for",
"e",
"in",
"fd",
".",
"enum_type",
":",
"self",
... | 16c2eed1e35df238a76a7a469c056ff9ea8ec2a2 |
valid | Pbd.disassemble | Disassemble serialized protocol buffers file. | pbd/__init__.py | def disassemble(self):
"""Disassemble serialized protocol buffers file.
"""
ser_pb = open(self.input_file, 'rb').read() # Read serialized pb file
fd = FileDescriptorProto()
fd.ParseFromString(ser_pb)
self.name = fd.name
self._print('// Reversed ... | def disassemble(self):
"""Disassemble serialized protocol buffers file.
"""
ser_pb = open(self.input_file, 'rb').read() # Read serialized pb file
fd = FileDescriptorProto()
fd.ParseFromString(ser_pb)
self.name = fd.name
self._print('// Reversed ... | [
"Disassemble",
"serialized",
"protocol",
"buffers",
"file",
"."
] | rsc-dev/pbd | python | https://github.com/rsc-dev/pbd/blob/16c2eed1e35df238a76a7a469c056ff9ea8ec2a2/pbd/__init__.py#L124-L143 | [
"def",
"disassemble",
"(",
"self",
")",
":",
"ser_pb",
"=",
"open",
"(",
"self",
".",
"input_file",
",",
"'rb'",
")",
".",
"read",
"(",
")",
"# Read serialized pb file",
"fd",
"=",
"FileDescriptorProto",
"(",
")",
"fd",
".",
"ParseFromString",
"(",
"ser_pb... | 16c2eed1e35df238a76a7a469c056ff9ea8ec2a2 |
valid | Pbd.dump | Dump proto file to given directory.
Keyword arguments:
out_dir -- dump directory. Default='.' | pbd/__init__.py | def dump(self, out_dir='.'):
"""Dump proto file to given directory.
Keyword arguments:
out_dir -- dump directory. Default='.'
"""
uri = out_dir + os.sep + self.name
with open(uri, 'w') as fh:
fh.write('\n'.join(self.lines)) | def dump(self, out_dir='.'):
"""Dump proto file to given directory.
Keyword arguments:
out_dir -- dump directory. Default='.'
"""
uri = out_dir + os.sep + self.name
with open(uri, 'w') as fh:
fh.write('\n'.join(self.lines)) | [
"Dump",
"proto",
"file",
"to",
"given",
"directory",
".",
"Keyword",
"arguments",
":",
"out_dir",
"--",
"dump",
"directory",
".",
"Default",
"=",
"."
] | rsc-dev/pbd | python | https://github.com/rsc-dev/pbd/blob/16c2eed1e35df238a76a7a469c056ff9ea8ec2a2/pbd/__init__.py#L146-L154 | [
"def",
"dump",
"(",
"self",
",",
"out_dir",
"=",
"'.'",
")",
":",
"uri",
"=",
"out_dir",
"+",
"os",
".",
"sep",
"+",
"self",
".",
"name",
"with",
"open",
"(",
"uri",
",",
"'w'",
")",
"as",
"fh",
":",
"fh",
".",
"write",
"(",
"'\\n'",
".",
"jo... | 16c2eed1e35df238a76a7a469c056ff9ea8ec2a2 |
valid | Pbd.find_imports | Find all missing imports in list of Pbd instances. | pbd/__init__.py | def find_imports(self, pbds):
"""Find all missing imports in list of Pbd instances.
"""
# List of types used, but not defined
imports = list(set(self.uses).difference(set(self.defines)))
# Clumpsy, but enought for now
for imp in imports:
for p in pbd... | def find_imports(self, pbds):
"""Find all missing imports in list of Pbd instances.
"""
# List of types used, but not defined
imports = list(set(self.uses).difference(set(self.defines)))
# Clumpsy, but enought for now
for imp in imports:
for p in pbd... | [
"Find",
"all",
"missing",
"imports",
"in",
"list",
"of",
"Pbd",
"instances",
"."
] | rsc-dev/pbd | python | https://github.com/rsc-dev/pbd/blob/16c2eed1e35df238a76a7a469c056ff9ea8ec2a2/pbd/__init__.py#L158-L174 | [
"def",
"find_imports",
"(",
"self",
",",
"pbds",
")",
":",
"# List of types used, but not defined",
"imports",
"=",
"list",
"(",
"set",
"(",
"self",
".",
"uses",
")",
".",
"difference",
"(",
"set",
"(",
"self",
".",
"defines",
")",
")",
")",
"# Clumpsy, bu... | 16c2eed1e35df238a76a7a469c056ff9ea8ec2a2 |
valid | fasta_file_to_dict | Returns a dict from a fasta file and the number of sequences as the second return value.
fasta_file can be a string path or a file object.
The key of fasta_dict can be set using the keyword arguments and
results in a combination of id, header, sequence, in that order. joined with '||'. (default: id)
Dup... | gff3/gff3.py | def fasta_file_to_dict(fasta_file, id=True, header=False, seq=False):
"""Returns a dict from a fasta file and the number of sequences as the second return value.
fasta_file can be a string path or a file object.
The key of fasta_dict can be set using the keyword arguments and
results in a combination of... | def fasta_file_to_dict(fasta_file, id=True, header=False, seq=False):
"""Returns a dict from a fasta file and the number of sequences as the second return value.
fasta_file can be a string path or a file object.
The key of fasta_dict can be set using the keyword arguments and
results in a combination of... | [
"Returns",
"a",
"dict",
"from",
"a",
"fasta",
"file",
"and",
"the",
"number",
"of",
"sequences",
"as",
"the",
"second",
"return",
"value",
".",
"fasta_file",
"can",
"be",
"a",
"string",
"path",
"or",
"a",
"file",
"object",
".",
"The",
"key",
"of",
"fas... | hotdogee/gff3-py | python | https://github.com/hotdogee/gff3-py/blob/d239bc9ed1eb7014c174f5fbed754f0f02d6e1b9/gff3/gff3.py#L57-L122 | [
"def",
"fasta_file_to_dict",
"(",
"fasta_file",
",",
"id",
"=",
"True",
",",
"header",
"=",
"False",
",",
"seq",
"=",
"False",
")",
":",
"fasta_file_f",
"=",
"fasta_file",
"if",
"isinstance",
"(",
"fasta_file",
",",
"str",
")",
":",
"fasta_file_f",
"=",
... | d239bc9ed1eb7014c174f5fbed754f0f02d6e1b9 |
valid | fasta_dict_to_file | Write fasta_dict to fasta_file
:param fasta_dict: returned by fasta_file_to_dict
:param fasta_file: output file can be a string path or a file object
:param line_char_limit: None = no limit (default)
:return: None | gff3/gff3.py | def fasta_dict_to_file(fasta_dict, fasta_file, line_char_limit=None):
"""Write fasta_dict to fasta_file
:param fasta_dict: returned by fasta_file_to_dict
:param fasta_file: output file can be a string path or a file object
:param line_char_limit: None = no limit (default)
:return: None
"""
... | def fasta_dict_to_file(fasta_dict, fasta_file, line_char_limit=None):
"""Write fasta_dict to fasta_file
:param fasta_dict: returned by fasta_file_to_dict
:param fasta_file: output file can be a string path or a file object
:param line_char_limit: None = no limit (default)
:return: None
"""
... | [
"Write",
"fasta_dict",
"to",
"fasta_file"
] | hotdogee/gff3-py | python | https://github.com/hotdogee/gff3-py/blob/d239bc9ed1eb7014c174f5fbed754f0f02d6e1b9/gff3/gff3.py#L124-L140 | [
"def",
"fasta_dict_to_file",
"(",
"fasta_dict",
",",
"fasta_file",
",",
"line_char_limit",
"=",
"None",
")",
":",
"fasta_fp",
"=",
"fasta_file",
"if",
"isinstance",
"(",
"fasta_file",
",",
"str",
")",
":",
"fasta_fp",
"=",
"open",
"(",
"fasta_file",
",",
"'w... | d239bc9ed1eb7014c174f5fbed754f0f02d6e1b9 |
valid | Gff3.add_line_error | Helper function to record and log an error message
:param line_data: dict
:param error_info: dict
:param logger:
:param log_level: int
:return: | gff3/gff3.py | def add_line_error(self, line_data, error_info, log_level=logging.ERROR):
"""Helper function to record and log an error message
:param line_data: dict
:param error_info: dict
:param logger:
:param log_level: int
:return:
"""
if not error_info: return
... | def add_line_error(self, line_data, error_info, log_level=logging.ERROR):
"""Helper function to record and log an error message
:param line_data: dict
:param error_info: dict
:param logger:
:param log_level: int
:return:
"""
if not error_info: return
... | [
"Helper",
"function",
"to",
"record",
"and",
"log",
"an",
"error",
"message"
] | hotdogee/gff3-py | python | https://github.com/hotdogee/gff3-py/blob/d239bc9ed1eb7014c174f5fbed754f0f02d6e1b9/gff3/gff3.py#L158-L177 | [
"def",
"add_line_error",
"(",
"self",
",",
"line_data",
",",
"error_info",
",",
"log_level",
"=",
"logging",
".",
"ERROR",
")",
":",
"if",
"not",
"error_info",
":",
"return",
"try",
":",
"line_data",
"[",
"'line_errors'",
"]",
".",
"append",
"(",
"error_in... | d239bc9ed1eb7014c174f5fbed754f0f02d6e1b9 |
valid | Gff3.check_parent_boundary | checks whether child features are within the coordinate boundaries of parent features
:return: | gff3/gff3.py | def check_parent_boundary(self):
"""
checks whether child features are within the coordinate boundaries of parent features
:return:
"""
for line in self.lines:
for parent_feature in line['parents']:
ok = False
for parent_line in parent... | def check_parent_boundary(self):
"""
checks whether child features are within the coordinate boundaries of parent features
:return:
"""
for line in self.lines:
for parent_feature in line['parents']:
ok = False
for parent_line in parent... | [
"checks",
"whether",
"child",
"features",
"are",
"within",
"the",
"coordinate",
"boundaries",
"of",
"parent",
"features"
] | hotdogee/gff3-py | python | https://github.com/hotdogee/gff3-py/blob/d239bc9ed1eb7014c174f5fbed754f0f02d6e1b9/gff3/gff3.py#L203-L220 | [
"def",
"check_parent_boundary",
"(",
"self",
")",
":",
"for",
"line",
"in",
"self",
".",
"lines",
":",
"for",
"parent_feature",
"in",
"line",
"[",
"'parents'",
"]",
":",
"ok",
"=",
"False",
"for",
"parent_line",
"in",
"parent_feature",
":",
"if",
"parent_l... | d239bc9ed1eb7014c174f5fbed754f0f02d6e1b9 |
valid | Gff3.check_phase | 1. get a list of CDS with the same parent
2. sort according to strand
3. calculate and validate phase | gff3/gff3.py | def check_phase(self):
"""
1. get a list of CDS with the same parent
2. sort according to strand
3. calculate and validate phase
"""
plus_minus = set(['+', '-'])
for k, g in groupby(sorted([line for line in self.lines if line['line_type'] == 'feature' and line['t... | def check_phase(self):
"""
1. get a list of CDS with the same parent
2. sort according to strand
3. calculate and validate phase
"""
plus_minus = set(['+', '-'])
for k, g in groupby(sorted([line for line in self.lines if line['line_type'] == 'feature' and line['t... | [
"1",
".",
"get",
"a",
"list",
"of",
"CDS",
"with",
"the",
"same",
"parent",
"2",
".",
"sort",
"according",
"to",
"strand",
"3",
".",
"calculate",
"and",
"validate",
"phase"
] | hotdogee/gff3-py | python | https://github.com/hotdogee/gff3-py/blob/d239bc9ed1eb7014c174f5fbed754f0f02d6e1b9/gff3/gff3.py#L222-L253 | [
"def",
"check_phase",
"(",
"self",
")",
":",
"plus_minus",
"=",
"set",
"(",
"[",
"'+'",
",",
"'-'",
"]",
")",
"for",
"k",
",",
"g",
"in",
"groupby",
"(",
"sorted",
"(",
"[",
"line",
"for",
"line",
"in",
"self",
".",
"lines",
"if",
"line",
"[",
... | d239bc9ed1eb7014c174f5fbed754f0f02d6e1b9 |
valid | Gff3.check_reference | Check seqid, bounds and the number of Ns in each feature using one or more reference sources.
Seqid check: check if the seqid can be found in the reference sources.
Bounds check: check the start and end fields of each features and log error if the values aren't within the seqid sequence length, requir... | gff3/gff3.py | def check_reference(self, sequence_region=False, fasta_embedded=False, fasta_external=False, check_bounds=True, check_n=True, allowed_num_of_n=0, feature_types=('CDS',)):
"""
Check seqid, bounds and the number of Ns in each feature using one or more reference sources.
Seqid check: check if the ... | def check_reference(self, sequence_region=False, fasta_embedded=False, fasta_external=False, check_bounds=True, check_n=True, allowed_num_of_n=0, feature_types=('CDS',)):
"""
Check seqid, bounds and the number of Ns in each feature using one or more reference sources.
Seqid check: check if the ... | [
"Check",
"seqid",
"bounds",
"and",
"the",
"number",
"of",
"Ns",
"in",
"each",
"feature",
"using",
"one",
"or",
"more",
"reference",
"sources",
"."
] | hotdogee/gff3-py | python | https://github.com/hotdogee/gff3-py/blob/d239bc9ed1eb7014c174f5fbed754f0f02d6e1b9/gff3/gff3.py#L258-L382 | [
"def",
"check_reference",
"(",
"self",
",",
"sequence_region",
"=",
"False",
",",
"fasta_embedded",
"=",
"False",
",",
"fasta_external",
"=",
"False",
",",
"check_bounds",
"=",
"True",
",",
"check_n",
"=",
"True",
",",
"allowed_num_of_n",
"=",
"0",
",",
"fea... | d239bc9ed1eb7014c174f5fbed754f0f02d6e1b9 |
valid | Gff3.parse | Parse the gff file into the following data structures:
* lines(list of line_data(dict))
- line_index(int): the index in lines
- line_raw(str)
- line_type(str in ['feature', 'directive', 'comment', 'blank', 'unknown'])
- line_errors(list of str): a list of error m... | gff3/gff3.py | def parse(self, gff_file, strict=False):
"""Parse the gff file into the following data structures:
* lines(list of line_data(dict))
- line_index(int): the index in lines
- line_raw(str)
- line_type(str in ['feature', 'directive', 'comment', 'blank', 'unknown'])
... | def parse(self, gff_file, strict=False):
"""Parse the gff file into the following data structures:
* lines(list of line_data(dict))
- line_index(int): the index in lines
- line_raw(str)
- line_type(str in ['feature', 'directive', 'comment', 'blank', 'unknown'])
... | [
"Parse",
"the",
"gff",
"file",
"into",
"the",
"following",
"data",
"structures",
":"
] | hotdogee/gff3-py | python | https://github.com/hotdogee/gff3-py/blob/d239bc9ed1eb7014c174f5fbed754f0f02d6e1b9/gff3/gff3.py#L384-L783 | [
"def",
"parse",
"(",
"self",
",",
"gff_file",
",",
"strict",
"=",
"False",
")",
":",
"valid_strand",
"=",
"set",
"(",
"(",
"'+'",
",",
"'-'",
",",
"'.'",
",",
"'?'",
")",
")",
"valid_phase",
"=",
"set",
"(",
"(",
"0",
",",
"1",
",",
"2",
")",
... | d239bc9ed1eb7014c174f5fbed754f0f02d6e1b9 |
valid | Gff3.descendants | BFS graph algorithm
:param line_data: line_data(dict) with line_data['line_index'] or line_index(int)
:return: list of line_data(dict) | gff3/gff3.py | def descendants(self, line_data):
"""
BFS graph algorithm
:param line_data: line_data(dict) with line_data['line_index'] or line_index(int)
:return: list of line_data(dict)
"""
# get start node
try:
start = line_data['line_index']
except TypeEr... | def descendants(self, line_data):
"""
BFS graph algorithm
:param line_data: line_data(dict) with line_data['line_index'] or line_index(int)
:return: list of line_data(dict)
"""
# get start node
try:
start = line_data['line_index']
except TypeEr... | [
"BFS",
"graph",
"algorithm",
":",
"param",
"line_data",
":",
"line_data",
"(",
"dict",
")",
"with",
"line_data",
"[",
"line_index",
"]",
"or",
"line_index",
"(",
"int",
")",
":",
"return",
":",
"list",
"of",
"line_data",
"(",
"dict",
")"
] | hotdogee/gff3-py | python | https://github.com/hotdogee/gff3-py/blob/d239bc9ed1eb7014c174f5fbed754f0f02d6e1b9/gff3/gff3.py#L785-L803 | [
"def",
"descendants",
"(",
"self",
",",
"line_data",
")",
":",
"# get start node",
"try",
":",
"start",
"=",
"line_data",
"[",
"'line_index'",
"]",
"except",
"TypeError",
":",
"start",
"=",
"self",
".",
"lines",
"[",
"line_data",
"]",
"[",
"'line_index'",
... | d239bc9ed1eb7014c174f5fbed754f0f02d6e1b9 |
valid | Gff3.adopt | Transfer children from old_parent to new_parent
:param old_parent: feature_id(str) or line_index(int) or line_data(dict) or feature
:param new_parent: feature_id(str) or line_index(int) or line_data(dict)
:return: List of children transferred | gff3/gff3.py | def adopt(self, old_parent, new_parent):
"""
Transfer children from old_parent to new_parent
:param old_parent: feature_id(str) or line_index(int) or line_data(dict) or feature
:param new_parent: feature_id(str) or line_index(int) or line_data(dict)
:return: List of children tra... | def adopt(self, old_parent, new_parent):
"""
Transfer children from old_parent to new_parent
:param old_parent: feature_id(str) or line_index(int) or line_data(dict) or feature
:param new_parent: feature_id(str) or line_index(int) or line_data(dict)
:return: List of children tra... | [
"Transfer",
"children",
"from",
"old_parent",
"to",
"new_parent"
] | hotdogee/gff3-py | python | https://github.com/hotdogee/gff3-py/blob/d239bc9ed1eb7014c174f5fbed754f0f02d6e1b9/gff3/gff3.py#L826-L870 | [
"def",
"adopt",
"(",
"self",
",",
"old_parent",
",",
"new_parent",
")",
":",
"try",
":",
"# assume line_data(dict)",
"old_id",
"=",
"old_parent",
"[",
"'attributes'",
"]",
"[",
"'ID'",
"]",
"except",
"TypeError",
":",
"try",
":",
"# assume line_index(int)",
"o... | d239bc9ed1eb7014c174f5fbed754f0f02d6e1b9 |
valid | Gff3.remove | Marks line_data and all of its associated feature's 'line_status' as 'removed', does not actually remove the line_data from the data structure.
The write function checks the 'line_status' when writing the gff file.
Find the root parent of line_data of type root_type, remove all of its descendants.
... | gff3/gff3.py | def remove(self, line_data, root_type=None):
"""
Marks line_data and all of its associated feature's 'line_status' as 'removed', does not actually remove the line_data from the data structure.
The write function checks the 'line_status' when writing the gff file.
Find the root parent of ... | def remove(self, line_data, root_type=None):
"""
Marks line_data and all of its associated feature's 'line_status' as 'removed', does not actually remove the line_data from the data structure.
The write function checks the 'line_status' when writing the gff file.
Find the root parent of ... | [
"Marks",
"line_data",
"and",
"all",
"of",
"its",
"associated",
"feature",
"s",
"line_status",
"as",
"removed",
"does",
"not",
"actually",
"remove",
"the",
"line_data",
"from",
"the",
"data",
"structure",
".",
"The",
"write",
"function",
"checks",
"the",
"line_... | hotdogee/gff3-py | python | https://github.com/hotdogee/gff3-py/blob/d239bc9ed1eb7014c174f5fbed754f0f02d6e1b9/gff3/gff3.py#L887-L908 | [
"def",
"remove",
"(",
"self",
",",
"line_data",
",",
"root_type",
"=",
"None",
")",
":",
"roots",
"=",
"[",
"ld",
"for",
"ld",
"in",
"self",
".",
"ancestors",
"(",
"line_data",
")",
"if",
"(",
"root_type",
"and",
"ld",
"[",
"'line_type'",
"]",
"==",
... | d239bc9ed1eb7014c174f5fbed754f0f02d6e1b9 |
valid | Gff3.sequence | Get the sequence of line_data, according to the columns 'seqid', 'start', 'end', 'strand'.
Requires fasta reference.
When used on 'mRNA' type line_data, child_type can be used to specify which kind of sequence to return:
* child_type=None: pre-mRNA, returns the sequence of line_data from start ... | gff3/gff3.py | def sequence(self, line_data, child_type=None, reference=None):
"""
Get the sequence of line_data, according to the columns 'seqid', 'start', 'end', 'strand'.
Requires fasta reference.
When used on 'mRNA' type line_data, child_type can be used to specify which kind of sequence to return:... | def sequence(self, line_data, child_type=None, reference=None):
"""
Get the sequence of line_data, according to the columns 'seqid', 'start', 'end', 'strand'.
Requires fasta reference.
When used on 'mRNA' type line_data, child_type can be used to specify which kind of sequence to return:... | [
"Get",
"the",
"sequence",
"of",
"line_data",
"according",
"to",
"the",
"columns",
"seqid",
"start",
"end",
"strand",
".",
"Requires",
"fasta",
"reference",
".",
"When",
"used",
"on",
"mRNA",
"type",
"line_data",
"child_type",
"can",
"be",
"used",
"to",
"spec... | hotdogee/gff3-py | python | https://github.com/hotdogee/gff3-py/blob/d239bc9ed1eb7014c174f5fbed754f0f02d6e1b9/gff3/gff3.py#L989-L1018 | [
"def",
"sequence",
"(",
"self",
",",
"line_data",
",",
"child_type",
"=",
"None",
",",
"reference",
"=",
"None",
")",
":",
"# get start node",
"reference",
"=",
"reference",
"or",
"self",
".",
"fasta_external",
"or",
"self",
".",
"fasta_embedded",
"if",
"not... | d239bc9ed1eb7014c174f5fbed754f0f02d6e1b9 |
valid | abfIDfromFname | given a filename, return the ABFs ID string. | swhlab/core.py | def abfIDfromFname(fname):
"""given a filename, return the ABFs ID string."""
fname=os.path.abspath(fname)
basename=os.path.basename(fname)
return os.path.splitext(basename)[0] | def abfIDfromFname(fname):
"""given a filename, return the ABFs ID string."""
fname=os.path.abspath(fname)
basename=os.path.basename(fname)
return os.path.splitext(basename)[0] | [
"given",
"a",
"filename",
"return",
"the",
"ABFs",
"ID",
"string",
"."
] | swharden/SWHLab | python | https://github.com/swharden/SWHLab/blob/a86c3c65323cec809a4bd4f81919644927094bf5/swhlab/core.py#L25-L29 | [
"def",
"abfIDfromFname",
"(",
"fname",
")",
":",
"fname",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"fname",
")",
"basename",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"fname",
")",
"return",
"os",
".",
"path",
".",
"splitext",
"(",
"basename"... | a86c3c65323cec809a4bd4f81919644927094bf5 |
valid | abfProtocol | Determine the protocol used to record an ABF file | swhlab/core.py | def abfProtocol(fname):
"""Determine the protocol used to record an ABF file"""
f=open(fname,'rb')
raw=f.read(30*1000) #it should be in the first 30k of the file
f.close()
raw=raw.decode("utf-8","ignore")
raw=raw.split("Clampex")[1].split(".pro")[0]
protocol = os.path.basename(raw) # the who... | def abfProtocol(fname):
"""Determine the protocol used to record an ABF file"""
f=open(fname,'rb')
raw=f.read(30*1000) #it should be in the first 30k of the file
f.close()
raw=raw.decode("utf-8","ignore")
raw=raw.split("Clampex")[1].split(".pro")[0]
protocol = os.path.basename(raw) # the who... | [
"Determine",
"the",
"protocol",
"used",
"to",
"record",
"an",
"ABF",
"file"
] | swharden/SWHLab | python | https://github.com/swharden/SWHLab/blob/a86c3c65323cec809a4bd4f81919644927094bf5/swhlab/core.py#L31-L40 | [
"def",
"abfProtocol",
"(",
"fname",
")",
":",
"f",
"=",
"open",
"(",
"fname",
",",
"'rb'",
")",
"raw",
"=",
"f",
".",
"read",
"(",
"30",
"*",
"1000",
")",
"#it should be in the first 30k of the file",
"f",
".",
"close",
"(",
")",
"raw",
"=",
"raw",
"... | a86c3c65323cec809a4bd4f81919644927094bf5 |
valid | headerHTML | given the bytestring ABF header, make and launch HTML. | swhlab/core.py | def headerHTML(header,fname):
"""given the bytestring ABF header, make and launch HTML."""
html="<html><body><code>"
html+="<h2>%s</h2>"%(fname)
html+=pprint.pformat(header, indent=1)
html=html.replace("\n",'<br>').replace(" "," ")
html=html.replace(r"\x00","")
... | def headerHTML(header,fname):
"""given the bytestring ABF header, make and launch HTML."""
html="<html><body><code>"
html+="<h2>%s</h2>"%(fname)
html+=pprint.pformat(header, indent=1)
html=html.replace("\n",'<br>').replace(" "," ")
html=html.replace(r"\x00","")
... | [
"given",
"the",
"bytestring",
"ABF",
"header",
"make",
"and",
"launch",
"HTML",
"."
] | swharden/SWHLab | python | https://github.com/swharden/SWHLab/blob/a86c3c65323cec809a4bd4f81919644927094bf5/swhlab/core.py#L42-L54 | [
"def",
"headerHTML",
"(",
"header",
",",
"fname",
")",
":",
"html",
"=",
"\"<html><body><code>\"",
"html",
"+=",
"\"<h2>%s</h2>\"",
"%",
"(",
"fname",
")",
"html",
"+=",
"pprint",
".",
"pformat",
"(",
"header",
",",
"indent",
"=",
"1",
")",
"html",
"=",
... | a86c3c65323cec809a4bd4f81919644927094bf5 |
valid | ABF.setsweep | set the sweep and channel of an ABF. Both start at 0. | swhlab/core.py | def setsweep(self, sweep=0, channel=0):
"""set the sweep and channel of an ABF. Both start at 0."""
try:
sweep=int(sweep)
except:
self.log.error("trying to set sweep to [%s]",sweep)
return
if sweep<0:
sweep=self.sweeps-1-sweep # if negative... | def setsweep(self, sweep=0, channel=0):
"""set the sweep and channel of an ABF. Both start at 0."""
try:
sweep=int(sweep)
except:
self.log.error("trying to set sweep to [%s]",sweep)
return
if sweep<0:
sweep=self.sweeps-1-sweep # if negative... | [
"set",
"the",
"sweep",
"and",
"channel",
"of",
"an",
"ABF",
".",
"Both",
"start",
"at",
"0",
"."
] | swharden/SWHLab | python | https://github.com/swharden/SWHLab/blob/a86c3c65323cec809a4bd4f81919644927094bf5/swhlab/core.py#L109-L169 | [
"def",
"setsweep",
"(",
"self",
",",
"sweep",
"=",
"0",
",",
"channel",
"=",
"0",
")",
":",
"try",
":",
"sweep",
"=",
"int",
"(",
"sweep",
")",
"except",
":",
"self",
".",
"log",
".",
"error",
"(",
"\"trying to set sweep to [%s]\"",
",",
"sweep",
")"... | a86c3c65323cec809a4bd4f81919644927094bf5 |
valid | ABF.setsweeps | iterate over every sweep | swhlab/core.py | def setsweeps(self):
"""iterate over every sweep"""
for sweep in range(self.sweeps):
self.setsweep(sweep)
yield self.sweep | def setsweeps(self):
"""iterate over every sweep"""
for sweep in range(self.sweeps):
self.setsweep(sweep)
yield self.sweep | [
"iterate",
"over",
"every",
"sweep"
] | swharden/SWHLab | python | https://github.com/swharden/SWHLab/blob/a86c3c65323cec809a4bd4f81919644927094bf5/swhlab/core.py#L175-L179 | [
"def",
"setsweeps",
"(",
"self",
")",
":",
"for",
"sweep",
"in",
"range",
"(",
"self",
".",
"sweeps",
")",
":",
"self",
".",
"setsweep",
"(",
"sweep",
")",
"yield",
"self",
".",
"sweep"
] | a86c3c65323cec809a4bd4f81919644927094bf5 |
valid | ABF.comments_load | read the header and populate self with information about comments | swhlab/core.py | def comments_load(self):
"""read the header and populate self with information about comments"""
self.comment_times,self.comment_sweeps,self.comment_tags=[],[],[]
self.comments=0 # will be >0 if comments exist
self.comment_text=""
try:
# this used to work
... | def comments_load(self):
"""read the header and populate self with information about comments"""
self.comment_times,self.comment_sweeps,self.comment_tags=[],[],[]
self.comments=0 # will be >0 if comments exist
self.comment_text=""
try:
# this used to work
... | [
"read",
"the",
"header",
"and",
"populate",
"self",
"with",
"information",
"about",
"comments"
] | swharden/SWHLab | python | https://github.com/swharden/SWHLab/blob/a86c3c65323cec809a4bd4f81919644927094bf5/swhlab/core.py#L181-L200 | [
"def",
"comments_load",
"(",
"self",
")",
":",
"self",
".",
"comment_times",
",",
"self",
".",
"comment_sweeps",
",",
"self",
".",
"comment_tags",
"=",
"[",
"]",
",",
"[",
"]",
",",
"[",
"]",
"self",
".",
"comments",
"=",
"0",
"# will be >0 if comments e... | a86c3c65323cec809a4bd4f81919644927094bf5 |
valid | ABF.generate_protocol | Recreate the command stimulus (protocol) for the current sweep.
It's not stored point by point (that's a waste of time and memory!)
Instead it's stored as a few (x,y) points which can be easily graphed.
TODO: THIS
for segment in abf.ABFreader.read_protocol():
for analogsigna... | swhlab/core.py | def generate_protocol(self):
"""
Recreate the command stimulus (protocol) for the current sweep.
It's not stored point by point (that's a waste of time and memory!)
Instead it's stored as a few (x,y) points which can be easily graphed.
TODO: THIS
for segment in abf.ABFre... | def generate_protocol(self):
"""
Recreate the command stimulus (protocol) for the current sweep.
It's not stored point by point (that's a waste of time and memory!)
Instead it's stored as a few (x,y) points which can be easily graphed.
TODO: THIS
for segment in abf.ABFre... | [
"Recreate",
"the",
"command",
"stimulus",
"(",
"protocol",
")",
"for",
"the",
"current",
"sweep",
".",
"It",
"s",
"not",
"stored",
"point",
"by",
"point",
"(",
"that",
"s",
"a",
"waste",
"of",
"time",
"and",
"memory!",
")",
"Instead",
"it",
"s",
"store... | swharden/SWHLab | python | https://github.com/swharden/SWHLab/blob/a86c3c65323cec809a4bd4f81919644927094bf5/swhlab/core.py#L202-L289 | [
"def",
"generate_protocol",
"(",
"self",
")",
":",
"# TODO: elegantly read the protocol like this:",
"#abf.ABFreader.read_protocol()[0].analogsignals()[sigNum]",
"# TODO: right now this works only for the first channel",
"# correct for weird recording/protocol misalignment",
"#what is magic here... | a86c3c65323cec809a4bd4f81919644927094bf5 |
valid | ABF.get_protocol | given a sweep, return the protocol as [Xs,Ys].
This is good for plotting/recreating the protocol trace.
There may be duplicate numbers. | swhlab/core.py | def get_protocol(self,sweep):
"""
given a sweep, return the protocol as [Xs,Ys].
This is good for plotting/recreating the protocol trace.
There may be duplicate numbers.
"""
self.setsweep(sweep)
return list(self.protoX),list(self.protoY) | def get_protocol(self,sweep):
"""
given a sweep, return the protocol as [Xs,Ys].
This is good for plotting/recreating the protocol trace.
There may be duplicate numbers.
"""
self.setsweep(sweep)
return list(self.protoX),list(self.protoY) | [
"given",
"a",
"sweep",
"return",
"the",
"protocol",
"as",
"[",
"Xs",
"Ys",
"]",
".",
"This",
"is",
"good",
"for",
"plotting",
"/",
"recreating",
"the",
"protocol",
"trace",
".",
"There",
"may",
"be",
"duplicate",
"numbers",
"."
] | swharden/SWHLab | python | https://github.com/swharden/SWHLab/blob/a86c3c65323cec809a4bd4f81919644927094bf5/swhlab/core.py#L291-L298 | [
"def",
"get_protocol",
"(",
"self",
",",
"sweep",
")",
":",
"self",
".",
"setsweep",
"(",
"sweep",
")",
"return",
"list",
"(",
"self",
".",
"protoX",
")",
",",
"list",
"(",
"self",
".",
"protoY",
")"
] | a86c3c65323cec809a4bd4f81919644927094bf5 |
valid | ABF.get_protocol_sequence | given a sweep, return the protocol as condensed sequence.
This is better for comparing similarities and determining steps.
There should be no duplicate numbers. | swhlab/core.py | def get_protocol_sequence(self,sweep):
"""
given a sweep, return the protocol as condensed sequence.
This is better for comparing similarities and determining steps.
There should be no duplicate numbers.
"""
self.setsweep(sweep)
return list(self.protoSeqX),list(se... | def get_protocol_sequence(self,sweep):
"""
given a sweep, return the protocol as condensed sequence.
This is better for comparing similarities and determining steps.
There should be no duplicate numbers.
"""
self.setsweep(sweep)
return list(self.protoSeqX),list(se... | [
"given",
"a",
"sweep",
"return",
"the",
"protocol",
"as",
"condensed",
"sequence",
".",
"This",
"is",
"better",
"for",
"comparing",
"similarities",
"and",
"determining",
"steps",
".",
"There",
"should",
"be",
"no",
"duplicate",
"numbers",
"."
] | swharden/SWHLab | python | https://github.com/swharden/SWHLab/blob/a86c3c65323cec809a4bd4f81919644927094bf5/swhlab/core.py#L300-L307 | [
"def",
"get_protocol_sequence",
"(",
"self",
",",
"sweep",
")",
":",
"self",
".",
"setsweep",
"(",
"sweep",
")",
"return",
"list",
"(",
"self",
".",
"protoSeqX",
")",
",",
"list",
"(",
"self",
".",
"protoSeqY",
")"
] | a86c3c65323cec809a4bd4f81919644927094bf5 |
valid | ABF.epochTimes | alternative to the existing abf protocol stuff
return the start/stop time of an epoch.
Epoch start at zero.
A=0, B=1, C=2, D=3, ... | swhlab/core.py | def epochTimes(self,nEpoch=2):
"""
alternative to the existing abf protocol stuff
return the start/stop time of an epoch.
Epoch start at zero.
A=0, B=1, C=2, D=3, ...
"""
times=[]
durations=[]
for epoch in self.header['dictEpochInfoPerDAC'][self.ch... | def epochTimes(self,nEpoch=2):
"""
alternative to the existing abf protocol stuff
return the start/stop time of an epoch.
Epoch start at zero.
A=0, B=1, C=2, D=3, ...
"""
times=[]
durations=[]
for epoch in self.header['dictEpochInfoPerDAC'][self.ch... | [
"alternative",
"to",
"the",
"existing",
"abf",
"protocol",
"stuff",
"return",
"the",
"start",
"/",
"stop",
"time",
"of",
"an",
"epoch",
".",
"Epoch",
"start",
"at",
"zero",
".",
"A",
"=",
"0",
"B",
"=",
"1",
"C",
"=",
"2",
"D",
"=",
"3",
"..."
] | swharden/SWHLab | python | https://github.com/swharden/SWHLab/blob/a86c3c65323cec809a4bd4f81919644927094bf5/swhlab/core.py#L317-L335 | [
"def",
"epochTimes",
"(",
"self",
",",
"nEpoch",
"=",
"2",
")",
":",
"times",
"=",
"[",
"]",
"durations",
"=",
"[",
"]",
"for",
"epoch",
"in",
"self",
".",
"header",
"[",
"'dictEpochInfoPerDAC'",
"]",
"[",
"self",
".",
"channel",
"]",
".",
"values",
... | a86c3c65323cec809a4bd4f81919644927094bf5 |
valid | ABF.average | return the average of part of the current sweep. | swhlab/core.py | def average(self,t1=0,t2=None,setsweep=False):
"""return the average of part of the current sweep."""
if setsweep:
self.setsweep(setsweep)
if t2 is None or t2>self.sweepLength:
t2=self.sweepLength
self.log.debug("resetting t2 to [%f]",t2)
t1=max(t1,0)
... | def average(self,t1=0,t2=None,setsweep=False):
"""return the average of part of the current sweep."""
if setsweep:
self.setsweep(setsweep)
if t2 is None or t2>self.sweepLength:
t2=self.sweepLength
self.log.debug("resetting t2 to [%f]",t2)
t1=max(t1,0)
... | [
"return",
"the",
"average",
"of",
"part",
"of",
"the",
"current",
"sweep",
"."
] | swharden/SWHLab | python | https://github.com/swharden/SWHLab/blob/a86c3c65323cec809a4bd4f81919644927094bf5/swhlab/core.py#L339-L353 | [
"def",
"average",
"(",
"self",
",",
"t1",
"=",
"0",
",",
"t2",
"=",
"None",
",",
"setsweep",
"=",
"False",
")",
":",
"if",
"setsweep",
":",
"self",
".",
"setsweep",
"(",
"setsweep",
")",
"if",
"t2",
"is",
"None",
"or",
"t2",
">",
"self",
".",
"... | a86c3c65323cec809a4bd4f81919644927094bf5 |
valid | ABF.averageSweep | Return a sweep which is the average of multiple sweeps.
For now, standard deviation is lost. | swhlab/core.py | def averageSweep(self,sweepFirst=0,sweepLast=None):
"""
Return a sweep which is the average of multiple sweeps.
For now, standard deviation is lost.
"""
if sweepLast is None:
sweepLast=self.sweeps-1
nSweeps=sweepLast-sweepFirst+1
runningSum=np.zeros(le... | def averageSweep(self,sweepFirst=0,sweepLast=None):
"""
Return a sweep which is the average of multiple sweeps.
For now, standard deviation is lost.
"""
if sweepLast is None:
sweepLast=self.sweeps-1
nSweeps=sweepLast-sweepFirst+1
runningSum=np.zeros(le... | [
"Return",
"a",
"sweep",
"which",
"is",
"the",
"average",
"of",
"multiple",
"sweeps",
".",
"For",
"now",
"standard",
"deviation",
"is",
"lost",
"."
] | swharden/SWHLab | python | https://github.com/swharden/SWHLab/blob/a86c3c65323cec809a4bd4f81919644927094bf5/swhlab/core.py#L355-L370 | [
"def",
"averageSweep",
"(",
"self",
",",
"sweepFirst",
"=",
"0",
",",
"sweepLast",
"=",
"None",
")",
":",
"if",
"sweepLast",
"is",
"None",
":",
"sweepLast",
"=",
"self",
".",
"sweeps",
"-",
"1",
"nSweeps",
"=",
"sweepLast",
"-",
"sweepFirst",
"+",
"1",... | a86c3c65323cec809a4bd4f81919644927094bf5 |
valid | ABF.kernel_gaussian | create kernel based on this ABF info. | swhlab/core.py | def kernel_gaussian(self, sizeMS, sigmaMS=None, forwardOnly=False):
"""create kernel based on this ABF info."""
sigmaMS=sizeMS/10 if sigmaMS is None else sigmaMS
size,sigma=sizeMS*self.pointsPerMs,sigmaMS*self.pointsPerMs
self.kernel=swhlab.common.kernel_gaussian(size,sigma,forwardOnly)
... | def kernel_gaussian(self, sizeMS, sigmaMS=None, forwardOnly=False):
"""create kernel based on this ABF info."""
sigmaMS=sizeMS/10 if sigmaMS is None else sigmaMS
size,sigma=sizeMS*self.pointsPerMs,sigmaMS*self.pointsPerMs
self.kernel=swhlab.common.kernel_gaussian(size,sigma,forwardOnly)
... | [
"create",
"kernel",
"based",
"on",
"this",
"ABF",
"info",
"."
] | swharden/SWHLab | python | https://github.com/swharden/SWHLab/blob/a86c3c65323cec809a4bd4f81919644927094bf5/swhlab/core.py#L372-L377 | [
"def",
"kernel_gaussian",
"(",
"self",
",",
"sizeMS",
",",
"sigmaMS",
"=",
"None",
",",
"forwardOnly",
"=",
"False",
")",
":",
"sigmaMS",
"=",
"sizeMS",
"/",
"10",
"if",
"sigmaMS",
"is",
"None",
"else",
"sigmaMS",
"size",
",",
"sigma",
"=",
"sizeMS",
"... | a86c3c65323cec809a4bd4f81919644927094bf5 |
valid | ABF.sweepYfiltered | Get the filtered sweepY of the current sweep.
Only works if self.kernel has been generated. | swhlab/core.py | def sweepYfiltered(self):
"""
Get the filtered sweepY of the current sweep.
Only works if self.kernel has been generated.
"""
assert self.kernel is not None
return swhlab.common.convolve(self.sweepY,self.kernel) | def sweepYfiltered(self):
"""
Get the filtered sweepY of the current sweep.
Only works if self.kernel has been generated.
"""
assert self.kernel is not None
return swhlab.common.convolve(self.sweepY,self.kernel) | [
"Get",
"the",
"filtered",
"sweepY",
"of",
"the",
"current",
"sweep",
".",
"Only",
"works",
"if",
"self",
".",
"kernel",
"has",
"been",
"generated",
"."
] | swharden/SWHLab | python | https://github.com/swharden/SWHLab/blob/a86c3c65323cec809a4bd4f81919644927094bf5/swhlab/core.py#L379-L385 | [
"def",
"sweepYfiltered",
"(",
"self",
")",
":",
"assert",
"self",
".",
"kernel",
"is",
"not",
"None",
"return",
"swhlab",
".",
"common",
".",
"convolve",
"(",
"self",
".",
"sweepY",
",",
"self",
".",
"kernel",
")"
] | a86c3c65323cec809a4bd4f81919644927094bf5 |
valid | ABF.phasicNet | Calculates the net difference between positive/negative phasic events
Returns return the phasic difference value of the current sweep.
Arguments:
biggestEvent (int): the size of the largest event anticipated
m1 (int, optional): the time (sec) to start analyzing
m2 (i... | swhlab/core.py | def phasicNet(self,biggestEvent=50,m1=.5,m2=None):
"""
Calculates the net difference between positive/negative phasic events
Returns return the phasic difference value of the current sweep.
Arguments:
biggestEvent (int): the size of the largest event anticipated
... | def phasicNet(self,biggestEvent=50,m1=.5,m2=None):
"""
Calculates the net difference between positive/negative phasic events
Returns return the phasic difference value of the current sweep.
Arguments:
biggestEvent (int): the size of the largest event anticipated
... | [
"Calculates",
"the",
"net",
"difference",
"between",
"positive",
"/",
"negative",
"phasic",
"events",
"Returns",
"return",
"the",
"phasic",
"difference",
"value",
"of",
"the",
"current",
"sweep",
"."
] | swharden/SWHLab | python | https://github.com/swharden/SWHLab/blob/a86c3c65323cec809a4bd4f81919644927094bf5/swhlab/core.py#L391-L441 | [
"def",
"phasicNet",
"(",
"self",
",",
"biggestEvent",
"=",
"50",
",",
"m1",
"=",
".5",
",",
"m2",
"=",
"None",
")",
":",
"# determine marks (between which we will analyze)",
"m1",
"=",
"0",
"if",
"m1",
"is",
"None",
"else",
"self",
".",
"pointsPerSec",
"*"... | a86c3c65323cec809a4bd4f81919644927094bf5 |
valid | ABF.output_touch | ensure the ./swhlab/ folder exists. | swhlab/core.py | def output_touch(self):
"""ensure the ./swhlab/ folder exists."""
if not os.path.exists(self.outFolder):
self.log.debug("creating %s",self.outFolder)
os.mkdir(self.outFolder) | def output_touch(self):
"""ensure the ./swhlab/ folder exists."""
if not os.path.exists(self.outFolder):
self.log.debug("creating %s",self.outFolder)
os.mkdir(self.outFolder) | [
"ensure",
"the",
".",
"/",
"swhlab",
"/",
"folder",
"exists",
"."
] | swharden/SWHLab | python | https://github.com/swharden/SWHLab/blob/a86c3c65323cec809a4bd4f81919644927094bf5/swhlab/core.py#L445-L449 | [
"def",
"output_touch",
"(",
"self",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"outFolder",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"\"creating %s\"",
",",
"self",
".",
"outFolder",
")",
"os",
".",
"mkdir",
... | a86c3c65323cec809a4bd4f81919644927094bf5 |
valid | dictFlat | Given a list of list of dicts, return just the dicts. | doc/oldcode/swhlab/core/common.py | def dictFlat(l):
"""Given a list of list of dicts, return just the dicts."""
if type(l) is dict:
return [l]
if "numpy" in str(type(l)):
return l
dicts=[]
for item in l:
if type(item)==dict:
dicts.append(item)
elif type(item)==list:
for item2 in... | def dictFlat(l):
"""Given a list of list of dicts, return just the dicts."""
if type(l) is dict:
return [l]
if "numpy" in str(type(l)):
return l
dicts=[]
for item in l:
if type(item)==dict:
dicts.append(item)
elif type(item)==list:
for item2 in... | [
"Given",
"a",
"list",
"of",
"list",
"of",
"dicts",
"return",
"just",
"the",
"dicts",
"."
] | swharden/SWHLab | python | https://github.com/swharden/SWHLab/blob/a86c3c65323cec809a4bd4f81919644927094bf5/doc/oldcode/swhlab/core/common.py#L83-L96 | [
"def",
"dictFlat",
"(",
"l",
")",
":",
"if",
"type",
"(",
"l",
")",
"is",
"dict",
":",
"return",
"[",
"l",
"]",
"if",
"\"numpy\"",
"in",
"str",
"(",
"type",
"(",
"l",
")",
")",
":",
"return",
"l",
"dicts",
"=",
"[",
"]",
"for",
"item",
"in",
... | a86c3c65323cec809a4bd4f81919644927094bf5 |
valid | listCount | returns len() of each item in a list, as a list. | doc/oldcode/swhlab/core/common.py | def listCount(l):
"""returns len() of each item in a list, as a list."""
for i in range(len(l)):
l[i]=len(l[i])
return l | def listCount(l):
"""returns len() of each item in a list, as a list."""
for i in range(len(l)):
l[i]=len(l[i])
return l | [
"returns",
"len",
"()",
"of",
"each",
"item",
"in",
"a",
"list",
"as",
"a",
"list",
"."
] | swharden/SWHLab | python | https://github.com/swharden/SWHLab/blob/a86c3c65323cec809a4bd4f81919644927094bf5/doc/oldcode/swhlab/core/common.py#L98-L102 | [
"def",
"listCount",
"(",
"l",
")",
":",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"l",
")",
")",
":",
"l",
"[",
"i",
"]",
"=",
"len",
"(",
"l",
"[",
"i",
"]",
")",
"return",
"l"
] | a86c3c65323cec809a4bd4f81919644927094bf5 |
valid | dictVals | Return all 'key' from a list of dicts. (or list of list of dicts) | doc/oldcode/swhlab/core/common.py | def dictVals(l,key):
"""Return all 'key' from a list of dicts. (or list of list of dicts)"""
dicts=dictFlat(l)
vals=np.empty(len(dicts))*np.nan
for i in range(len(dicts)):
if key in dicts[i]:
vals[i]=dicts[i][key]
return vals | def dictVals(l,key):
"""Return all 'key' from a list of dicts. (or list of list of dicts)"""
dicts=dictFlat(l)
vals=np.empty(len(dicts))*np.nan
for i in range(len(dicts)):
if key in dicts[i]:
vals[i]=dicts[i][key]
return vals | [
"Return",
"all",
"key",
"from",
"a",
"list",
"of",
"dicts",
".",
"(",
"or",
"list",
"of",
"list",
"of",
"dicts",
")"
] | swharden/SWHLab | python | https://github.com/swharden/SWHLab/blob/a86c3c65323cec809a4bd4f81919644927094bf5/doc/oldcode/swhlab/core/common.py#L104-L111 | [
"def",
"dictVals",
"(",
"l",
",",
"key",
")",
":",
"dicts",
"=",
"dictFlat",
"(",
"l",
")",
"vals",
"=",
"np",
".",
"empty",
"(",
"len",
"(",
"dicts",
")",
")",
"*",
"np",
".",
"nan",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"dicts",
")",
... | a86c3c65323cec809a4bd4f81919644927094bf5 |
valid | dictAvg | Given a list (l) of dicts (d), return AV and SD. | doc/oldcode/swhlab/core/common.py | def dictAvg(listOfDicts,key,stdErr=False):
"""Given a list (l) of dicts (d), return AV and SD."""
vals=dictVals(listOfDicts,key)
if len(vals) and np.any(vals):
av=np.nanmean(vals)
er=np.nanstd(vals)
if stdErr:
er=er/np.sqrt(np.count_nonzero(~np.isnan(er)))
else:
... | def dictAvg(listOfDicts,key,stdErr=False):
"""Given a list (l) of dicts (d), return AV and SD."""
vals=dictVals(listOfDicts,key)
if len(vals) and np.any(vals):
av=np.nanmean(vals)
er=np.nanstd(vals)
if stdErr:
er=er/np.sqrt(np.count_nonzero(~np.isnan(er)))
else:
... | [
"Given",
"a",
"list",
"(",
"l",
")",
"of",
"dicts",
"(",
"d",
")",
"return",
"AV",
"and",
"SD",
"."
] | swharden/SWHLab | python | https://github.com/swharden/SWHLab/blob/a86c3c65323cec809a4bd4f81919644927094bf5/doc/oldcode/swhlab/core/common.py#L113-L123 | [
"def",
"dictAvg",
"(",
"listOfDicts",
",",
"key",
",",
"stdErr",
"=",
"False",
")",
":",
"vals",
"=",
"dictVals",
"(",
"listOfDicts",
",",
"key",
")",
"if",
"len",
"(",
"vals",
")",
"and",
"np",
".",
"any",
"(",
"vals",
")",
":",
"av",
"=",
"np",... | a86c3c65323cec809a4bd4f81919644927094bf5 |
valid | dummyListOfDicts | returns a list (of the given size) of dicts with fake data.
some dictionary keys are missing for some of the items. | doc/oldcode/swhlab/core/common.py | def dummyListOfDicts(size=100):
"""
returns a list (of the given size) of dicts with fake data.
some dictionary keys are missing for some of the items.
"""
titles="ahp,halfwidth,peak,expT,expI,sweep".split(",")
ld=[] #list of dicts
for i in range(size):
d={}
for t in titles:
... | def dummyListOfDicts(size=100):
"""
returns a list (of the given size) of dicts with fake data.
some dictionary keys are missing for some of the items.
"""
titles="ahp,halfwidth,peak,expT,expI,sweep".split(",")
ld=[] #list of dicts
for i in range(size):
d={}
for t in titles:
... | [
"returns",
"a",
"list",
"(",
"of",
"the",
"given",
"size",
")",
"of",
"dicts",
"with",
"fake",
"data",
".",
"some",
"dictionary",
"keys",
"are",
"missing",
"for",
"some",
"of",
"the",
"items",
"."
] | swharden/SWHLab | python | https://github.com/swharden/SWHLab/blob/a86c3c65323cec809a4bd4f81919644927094bf5/doc/oldcode/swhlab/core/common.py#L125-L140 | [
"def",
"dummyListOfDicts",
"(",
"size",
"=",
"100",
")",
":",
"titles",
"=",
"\"ahp,halfwidth,peak,expT,expI,sweep\"",
".",
"split",
"(",
"\",\"",
")",
"ld",
"=",
"[",
"]",
"#list of dicts",
"for",
"i",
"in",
"range",
"(",
"size",
")",
":",
"d",
"=",
"{"... | a86c3c65323cec809a4bd4f81919644927094bf5 |
valid | matrixValues | given a key, return a list of values from the matrix with that key. | doc/oldcode/swhlab/core/common.py | def matrixValues(matrix,key):
"""given a key, return a list of values from the matrix with that key."""
assert key in matrix.dtype.names
col=matrix.dtype.names.index(key)
values=np.empty(len(matrix))*np.nan
for i in range(len(matrix)):
values[i]=matrix[i][col]
return values | def matrixValues(matrix,key):
"""given a key, return a list of values from the matrix with that key."""
assert key in matrix.dtype.names
col=matrix.dtype.names.index(key)
values=np.empty(len(matrix))*np.nan
for i in range(len(matrix)):
values[i]=matrix[i][col]
return values | [
"given",
"a",
"key",
"return",
"a",
"list",
"of",
"values",
"from",
"the",
"matrix",
"with",
"that",
"key",
"."
] | swharden/SWHLab | python | https://github.com/swharden/SWHLab/blob/a86c3c65323cec809a4bd4f81919644927094bf5/doc/oldcode/swhlab/core/common.py#L142-L149 | [
"def",
"matrixValues",
"(",
"matrix",
",",
"key",
")",
":",
"assert",
"key",
"in",
"matrix",
".",
"dtype",
".",
"names",
"col",
"=",
"matrix",
".",
"dtype",
".",
"names",
".",
"index",
"(",
"key",
")",
"values",
"=",
"np",
".",
"empty",
"(",
"len",... | a86c3c65323cec809a4bd4f81919644927094bf5 |
valid | matrixToDicts | given a recarray, return it as a list of dicts. | doc/oldcode/swhlab/core/common.py | def matrixToDicts(data):
"""given a recarray, return it as a list of dicts."""
# 1D array
if "float" in str(type(data[0])):
d={}
for x in range(len(data)):
d[data.dtype.names[x]]=data[x]
return d
# 2D array
l=[]
for y in range(len(data)):
d={}
... | def matrixToDicts(data):
"""given a recarray, return it as a list of dicts."""
# 1D array
if "float" in str(type(data[0])):
d={}
for x in range(len(data)):
d[data.dtype.names[x]]=data[x]
return d
# 2D array
l=[]
for y in range(len(data)):
d={}
... | [
"given",
"a",
"recarray",
"return",
"it",
"as",
"a",
"list",
"of",
"dicts",
"."
] | swharden/SWHLab | python | https://github.com/swharden/SWHLab/blob/a86c3c65323cec809a4bd4f81919644927094bf5/doc/oldcode/swhlab/core/common.py#L151-L168 | [
"def",
"matrixToDicts",
"(",
"data",
")",
":",
"# 1D array",
"if",
"\"float\"",
"in",
"str",
"(",
"type",
"(",
"data",
"[",
"0",
"]",
")",
")",
":",
"d",
"=",
"{",
"}",
"for",
"x",
"in",
"range",
"(",
"len",
"(",
"data",
")",
")",
":",
"d",
"... | a86c3c65323cec809a4bd4f81919644927094bf5 |
valid | matrixfromDicts | Give a list of dicts (or list of list of dicts) return a structured array.
Headings will be sorted in alphabetical order. | doc/oldcode/swhlab/core/common.py | def matrixfromDicts(dicts):
"""
Give a list of dicts (or list of list of dicts) return a structured array.
Headings will be sorted in alphabetical order.
"""
if 'numpy' in str(type(dicts)):
return dicts #already an array?
names=set([])
dicts=dictFlat(dicts)
for item in dicts:
... | def matrixfromDicts(dicts):
"""
Give a list of dicts (or list of list of dicts) return a structured array.
Headings will be sorted in alphabetical order.
"""
if 'numpy' in str(type(dicts)):
return dicts #already an array?
names=set([])
dicts=dictFlat(dicts)
for item in dicts:
... | [
"Give",
"a",
"list",
"of",
"dicts",
"(",
"or",
"list",
"of",
"list",
"of",
"dicts",
")",
"return",
"a",
"structured",
"array",
".",
"Headings",
"will",
"be",
"sorted",
"in",
"alphabetical",
"order",
"."
] | swharden/SWHLab | python | https://github.com/swharden/SWHLab/blob/a86c3c65323cec809a4bd4f81919644927094bf5/doc/oldcode/swhlab/core/common.py#L170-L190 | [
"def",
"matrixfromDicts",
"(",
"dicts",
")",
":",
"if",
"'numpy'",
"in",
"str",
"(",
"type",
"(",
"dicts",
")",
")",
":",
"return",
"dicts",
"#already an array?",
"names",
"=",
"set",
"(",
"[",
"]",
")",
"dicts",
"=",
"dictFlat",
"(",
"dicts",
")",
"... | a86c3c65323cec809a4bd4f81919644927094bf5 |
valid | htmlListToTR | turns a list into a <tr><td>something</td></tr>
call this when generating HTML tables dynamically. | doc/oldcode/swhlab/core/common.py | def htmlListToTR(l,trClass=None,tdClass=None,td1Class=None):
"""
turns a list into a <tr><td>something</td></tr>
call this when generating HTML tables dynamically.
"""
html="<tr>"
for item in l:
if 'array' in str(type(item)):
item=item[0] #TODO: why is this needed
htm... | def htmlListToTR(l,trClass=None,tdClass=None,td1Class=None):
"""
turns a list into a <tr><td>something</td></tr>
call this when generating HTML tables dynamically.
"""
html="<tr>"
for item in l:
if 'array' in str(type(item)):
item=item[0] #TODO: why is this needed
htm... | [
"turns",
"a",
"list",
"into",
"a",
"<tr",
">",
"<td",
">",
"something<",
"/",
"td",
">",
"<",
"/",
"tr",
">",
"call",
"this",
"when",
"generating",
"HTML",
"tables",
"dynamically",
"."
] | swharden/SWHLab | python | https://github.com/swharden/SWHLab/blob/a86c3c65323cec809a4bd4f81919644927094bf5/doc/oldcode/swhlab/core/common.py#L192-L211 | [
"def",
"htmlListToTR",
"(",
"l",
",",
"trClass",
"=",
"None",
",",
"tdClass",
"=",
"None",
",",
"td1Class",
"=",
"None",
")",
":",
"html",
"=",
"\"<tr>\"",
"for",
"item",
"in",
"l",
":",
"if",
"'array'",
"in",
"str",
"(",
"type",
"(",
"item",
")",
... | a86c3c65323cec809a4bd4f81919644927094bf5 |
valid | html_temp_launch | given text, make it a temporary HTML file and launch it. | doc/oldcode/swhlab/core/common.py | def html_temp_launch(html):
"""given text, make it a temporary HTML file and launch it."""
fname = tempfile.gettempdir()+"/swhlab/temp.html"
with open(fname,'w') as f:
f.write(html)
webbrowser.open(fname) | def html_temp_launch(html):
"""given text, make it a temporary HTML file and launch it."""
fname = tempfile.gettempdir()+"/swhlab/temp.html"
with open(fname,'w') as f:
f.write(html)
webbrowser.open(fname) | [
"given",
"text",
"make",
"it",
"a",
"temporary",
"HTML",
"file",
"and",
"launch",
"it",
"."
] | swharden/SWHLab | python | https://github.com/swharden/SWHLab/blob/a86c3c65323cec809a4bd4f81919644927094bf5/doc/oldcode/swhlab/core/common.py#L213-L218 | [
"def",
"html_temp_launch",
"(",
"html",
")",
":",
"fname",
"=",
"tempfile",
".",
"gettempdir",
"(",
")",
"+",
"\"/swhlab/temp.html\"",
"with",
"open",
"(",
"fname",
",",
"'w'",
")",
"as",
"f",
":",
"f",
".",
"write",
"(",
"html",
")",
"webbrowser",
"."... | a86c3c65323cec809a4bd4f81919644927094bf5 |
valid | checkOut | show everything we can about an object's projects and methods. | doc/oldcode/swhlab/core/common.py | def checkOut(thing,html=True):
"""show everything we can about an object's projects and methods."""
msg=""
for name in sorted(dir(thing)):
if not "__" in name:
msg+="<b>%s</b>\n"%name
try:
msg+=" ^-VALUE: %s\n"%getattr(thing,name)()
except:
... | def checkOut(thing,html=True):
"""show everything we can about an object's projects and methods."""
msg=""
for name in sorted(dir(thing)):
if not "__" in name:
msg+="<b>%s</b>\n"%name
try:
msg+=" ^-VALUE: %s\n"%getattr(thing,name)()
except:
... | [
"show",
"everything",
"we",
"can",
"about",
"an",
"object",
"s",
"projects",
"and",
"methods",
"."
] | swharden/SWHLab | python | https://github.com/swharden/SWHLab/blob/a86c3c65323cec809a4bd4f81919644927094bf5/doc/oldcode/swhlab/core/common.py#L222-L239 | [
"def",
"checkOut",
"(",
"thing",
",",
"html",
"=",
"True",
")",
":",
"msg",
"=",
"\"\"",
"for",
"name",
"in",
"sorted",
"(",
"dir",
"(",
"thing",
")",
")",
":",
"if",
"not",
"\"__\"",
"in",
"name",
":",
"msg",
"+=",
"\"<b>%s</b>\\n\"",
"%",
"name",... | a86c3c65323cec809a4bd4f81919644927094bf5 |
valid | matrixToWks | Put 2d numpy data into an Origin worksheet.
If bookname and sheetname are given try to load data into that book/sheet.
If the book/sheet doesn't exist, create it. | doc/oldcode/swhlab/core/common.py | def matrixToWks(data,names=None,units=None,bookName=None,sheetName=" ",xCol=None):
"""
Put 2d numpy data into an Origin worksheet.
If bookname and sheetname are given try to load data into that book/sheet.
If the book/sheet doesn't exist, create it.
"""
if type(data) is list:
data=matrix... | def matrixToWks(data,names=None,units=None,bookName=None,sheetName=" ",xCol=None):
"""
Put 2d numpy data into an Origin worksheet.
If bookname and sheetname are given try to load data into that book/sheet.
If the book/sheet doesn't exist, create it.
"""
if type(data) is list:
data=matrix... | [
"Put",
"2d",
"numpy",
"data",
"into",
"an",
"Origin",
"worksheet",
".",
"If",
"bookname",
"and",
"sheetname",
"are",
"given",
"try",
"to",
"load",
"data",
"into",
"that",
"book",
"/",
"sheet",
".",
"If",
"the",
"book",
"/",
"sheet",
"doesn",
"t",
"exis... | swharden/SWHLab | python | https://github.com/swharden/SWHLab/blob/a86c3c65323cec809a4bd4f81919644927094bf5/doc/oldcode/swhlab/core/common.py#L241-L294 | [
"def",
"matrixToWks",
"(",
"data",
",",
"names",
"=",
"None",
",",
"units",
"=",
"None",
",",
"bookName",
"=",
"None",
",",
"sheetName",
"=",
"\" \"",
",",
"xCol",
"=",
"None",
")",
":",
"if",
"type",
"(",
"data",
")",
"is",
"list",
":",
"data",
... | a86c3c65323cec809a4bd4f81919644927094bf5 |
valid | matrixToHTML | Put 2d numpy data into a temporary HTML file. | doc/oldcode/swhlab/core/common.py | def matrixToHTML(data,names=None,units=None,bookName=None,sheetName=None,xCol=None):
"""Put 2d numpy data into a temporary HTML file."""
if not names:
names=[""]*len(data[0])
if data.dtype.names:
names=list(data.dtype.names)
if not units:
units=[""]*len(data[0])
f... | def matrixToHTML(data,names=None,units=None,bookName=None,sheetName=None,xCol=None):
"""Put 2d numpy data into a temporary HTML file."""
if not names:
names=[""]*len(data[0])
if data.dtype.names:
names=list(data.dtype.names)
if not units:
units=[""]*len(data[0])
f... | [
"Put",
"2d",
"numpy",
"data",
"into",
"a",
"temporary",
"HTML",
"file",
"."
] | swharden/SWHLab | python | https://github.com/swharden/SWHLab/blob/a86c3c65323cec809a4bd4f81919644927094bf5/doc/oldcode/swhlab/core/common.py#L296-L368 | [
"def",
"matrixToHTML",
"(",
"data",
",",
"names",
"=",
"None",
",",
"units",
"=",
"None",
",",
"bookName",
"=",
"None",
",",
"sheetName",
"=",
"None",
",",
"xCol",
"=",
"None",
")",
":",
"if",
"not",
"names",
":",
"names",
"=",
"[",
"\"\"",
"]",
... | a86c3c65323cec809a4bd4f81919644927094bf5 |
valid | XMLtoPython | given a string or a path to an XML file, return an XML object. | doc/oldcode/swhlab/core/common.py | def XMLtoPython(xmlStr=r"C:\Apps\pythonModules\GSTemp.xml"):
"""
given a string or a path to an XML file, return an XML object.
"""
#TODO: this absolute file path crazy stuff needs to stop!
if os.path.exists(xmlStr):
with open(xmlStr) as f:
xmlStr=f.read()
print(xmlStr)
p... | def XMLtoPython(xmlStr=r"C:\Apps\pythonModules\GSTemp.xml"):
"""
given a string or a path to an XML file, return an XML object.
"""
#TODO: this absolute file path crazy stuff needs to stop!
if os.path.exists(xmlStr):
with open(xmlStr) as f:
xmlStr=f.read()
print(xmlStr)
p... | [
"given",
"a",
"string",
"or",
"a",
"path",
"to",
"an",
"XML",
"file",
"return",
"an",
"XML",
"object",
"."
] | swharden/SWHLab | python | https://github.com/swharden/SWHLab/blob/a86c3c65323cec809a4bd4f81919644927094bf5/doc/oldcode/swhlab/core/common.py#L373-L383 | [
"def",
"XMLtoPython",
"(",
"xmlStr",
"=",
"r\"C:\\Apps\\pythonModules\\GSTemp.xml\"",
")",
":",
"#TODO: this absolute file path crazy stuff needs to stop!",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"xmlStr",
")",
":",
"with",
"open",
"(",
"xmlStr",
")",
"as",
"f... | a86c3c65323cec809a4bd4f81919644927094bf5 |
valid | algo_exp | mono-exponential curve. | doc/oldcode/swhlab/core/common.py | def algo_exp(x, m, t, b):
"""mono-exponential curve."""
return m*np.exp(-t*x)+b | def algo_exp(x, m, t, b):
"""mono-exponential curve."""
return m*np.exp(-t*x)+b | [
"mono",
"-",
"exponential",
"curve",
"."
] | swharden/SWHLab | python | https://github.com/swharden/SWHLab/blob/a86c3c65323cec809a4bd4f81919644927094bf5/doc/oldcode/swhlab/core/common.py#L394-L396 | [
"def",
"algo_exp",
"(",
"x",
",",
"m",
",",
"t",
",",
"b",
")",
":",
"return",
"m",
"*",
"np",
".",
"exp",
"(",
"-",
"t",
"*",
"x",
")",
"+",
"b"
] | a86c3c65323cec809a4bd4f81919644927094bf5 |
valid | fit_exp | Exponential fit. Returns [multiplier, t, offset, time constant] | doc/oldcode/swhlab/core/common.py | def fit_exp(y,graphToo=False):
"""Exponential fit. Returns [multiplier, t, offset, time constant]"""
x=np.arange(len(y))
try:
params, cv = scipy.optimize.curve_fit(algo_exp, x, y, p0=(1,1e-6,1))
except:
print(" !! curve fit failed (%.02f points)"%len(x))
return np.nan,np.nan,np.n... | def fit_exp(y,graphToo=False):
"""Exponential fit. Returns [multiplier, t, offset, time constant]"""
x=np.arange(len(y))
try:
params, cv = scipy.optimize.curve_fit(algo_exp, x, y, p0=(1,1e-6,1))
except:
print(" !! curve fit failed (%.02f points)"%len(x))
return np.nan,np.nan,np.n... | [
"Exponential",
"fit",
".",
"Returns",
"[",
"multiplier",
"t",
"offset",
"time",
"constant",
"]"
] | swharden/SWHLab | python | https://github.com/swharden/SWHLab/blob/a86c3c65323cec809a4bd4f81919644927094bf5/doc/oldcode/swhlab/core/common.py#L398-L415 | [
"def",
"fit_exp",
"(",
"y",
",",
"graphToo",
"=",
"False",
")",
":",
"x",
"=",
"np",
".",
"arange",
"(",
"len",
"(",
"y",
")",
")",
"try",
":",
"params",
",",
"cv",
"=",
"scipy",
".",
"optimize",
".",
"curve_fit",
"(",
"algo_exp",
",",
"x",
","... | a86c3c65323cec809a4bd4f81919644927094bf5 |
valid | numpyAlignXY | given a numpy array (XYXYXY columns), return it aligned.
data returned will be XYYY. NANs may be returned. | doc/oldcode/swhlab/core/common.py | def numpyAlignXY(data):
"""
given a numpy array (XYXYXY columns), return it aligned.
data returned will be XYYY. NANs may be returned.
"""
print(data)
Xs=data.flatten()[::2] # get all X values
Xs=Xs[~np.isnan(Xs)] # remove nans
Xs=sorted(list(set(Xs))) # eliminate duplicates then sort it... | def numpyAlignXY(data):
"""
given a numpy array (XYXYXY columns), return it aligned.
data returned will be XYYY. NANs may be returned.
"""
print(data)
Xs=data.flatten()[::2] # get all X values
Xs=Xs[~np.isnan(Xs)] # remove nans
Xs=sorted(list(set(Xs))) # eliminate duplicates then sort it... | [
"given",
"a",
"numpy",
"array",
"(",
"XYXYXY",
"columns",
")",
"return",
"it",
"aligned",
".",
"data",
"returned",
"will",
"be",
"XYYY",
".",
"NANs",
"may",
"be",
"returned",
"."
] | swharden/SWHLab | python | https://github.com/swharden/SWHLab/blob/a86c3c65323cec809a4bd4f81919644927094bf5/doc/oldcode/swhlab/core/common.py#L419-L437 | [
"def",
"numpyAlignXY",
"(",
"data",
")",
":",
"print",
"(",
"data",
")",
"Xs",
"=",
"data",
".",
"flatten",
"(",
")",
"[",
":",
":",
"2",
"]",
"# get all X values",
"Xs",
"=",
"Xs",
"[",
"~",
"np",
".",
"isnan",
"(",
"Xs",
")",
"]",
"# remove nan... | a86c3c65323cec809a4bd4f81919644927094bf5 |
valid | filter_gaussian | simple gaussian convolution. Returns same # of points as gotten. | doc/oldcode/swhlab/core/common.py | def filter_gaussian(Ys,sigma,plotToo=False):
"""simple gaussian convolution. Returns same # of points as gotten."""
timeA=time.time()
window=scipy.signal.gaussian(len(Ys),sigma)
window/=sum(window)
Ys2=np.convolve(Ys,window,'same')
print("LEN:",len(Ys2),len(Ys))
timeB=time.time()
print("... | def filter_gaussian(Ys,sigma,plotToo=False):
"""simple gaussian convolution. Returns same # of points as gotten."""
timeA=time.time()
window=scipy.signal.gaussian(len(Ys),sigma)
window/=sum(window)
Ys2=np.convolve(Ys,window,'same')
print("LEN:",len(Ys2),len(Ys))
timeB=time.time()
print("... | [
"simple",
"gaussian",
"convolution",
".",
"Returns",
"same",
"#",
"of",
"points",
"as",
"gotten",
"."
] | swharden/SWHLab | python | https://github.com/swharden/SWHLab/blob/a86c3c65323cec809a4bd4f81919644927094bf5/doc/oldcode/swhlab/core/common.py#L439-L455 | [
"def",
"filter_gaussian",
"(",
"Ys",
",",
"sigma",
",",
"plotToo",
"=",
"False",
")",
":",
"timeA",
"=",
"time",
".",
"time",
"(",
")",
"window",
"=",
"scipy",
".",
"signal",
".",
"gaussian",
"(",
"len",
"(",
"Ys",
")",
",",
"sigma",
")",
"window",... | a86c3c65323cec809a4bd4f81919644927094bf5 |
valid | where_cross | return a list of Is where the data first crosses above threshold. | doc/oldcode/swhlab/core/common.py | def where_cross(data,threshold):
"""return a list of Is where the data first crosses above threshold."""
Is=np.where(data>threshold)[0]
Is=np.concatenate(([0],Is))
Ds=Is[:-1]-Is[1:]+1
return Is[np.where(Ds)[0]+1] | def where_cross(data,threshold):
"""return a list of Is where the data first crosses above threshold."""
Is=np.where(data>threshold)[0]
Is=np.concatenate(([0],Is))
Ds=Is[:-1]-Is[1:]+1
return Is[np.where(Ds)[0]+1] | [
"return",
"a",
"list",
"of",
"Is",
"where",
"the",
"data",
"first",
"crosses",
"above",
"threshold",
"."
] | swharden/SWHLab | python | https://github.com/swharden/SWHLab/blob/a86c3c65323cec809a4bd4f81919644927094bf5/doc/oldcode/swhlab/core/common.py#L458-L463 | [
"def",
"where_cross",
"(",
"data",
",",
"threshold",
")",
":",
"Is",
"=",
"np",
".",
"where",
"(",
"data",
">",
"threshold",
")",
"[",
"0",
"]",
"Is",
"=",
"np",
".",
"concatenate",
"(",
"(",
"[",
"0",
"]",
",",
"Is",
")",
")",
"Ds",
"=",
"Is... | a86c3c65323cec809a4bd4f81919644927094bf5 |
valid | show | alternative to pylab.show() that updates IPython window. | doc/oldcode/swhlab/core/common.py | def show(closeToo=False):
"""alternative to pylab.show() that updates IPython window."""
IPython.display.display(pylab.gcf())
if closeToo:
pylab.close('all') | def show(closeToo=False):
"""alternative to pylab.show() that updates IPython window."""
IPython.display.display(pylab.gcf())
if closeToo:
pylab.close('all') | [
"alternative",
"to",
"pylab",
".",
"show",
"()",
"that",
"updates",
"IPython",
"window",
"."
] | swharden/SWHLab | python | https://github.com/swharden/SWHLab/blob/a86c3c65323cec809a4bd4f81919644927094bf5/doc/oldcode/swhlab/core/common.py#L467-L471 | [
"def",
"show",
"(",
"closeToo",
"=",
"False",
")",
":",
"IPython",
".",
"display",
".",
"display",
"(",
"pylab",
".",
"gcf",
"(",
")",
")",
"if",
"closeToo",
":",
"pylab",
".",
"close",
"(",
"'all'",
")"
] | a86c3c65323cec809a4bd4f81919644927094bf5 |
valid | originFormat_listOfDicts | Return [{},{},{}] as a 2d matrix. | doc/oldcode/swhlab/core/common.py | def originFormat_listOfDicts(l):
"""Return [{},{},{}] as a 2d matrix."""
titles=[]
for d in l:
for k in d.keys():
if not k in titles:
titles.append(k)
titles.sort()
data=np.empty((len(l),len(titles)))*np.nan
for y in range(len(l)):
for x in range(len(t... | def originFormat_listOfDicts(l):
"""Return [{},{},{}] as a 2d matrix."""
titles=[]
for d in l:
for k in d.keys():
if not k in titles:
titles.append(k)
titles.sort()
data=np.empty((len(l),len(titles)))*np.nan
for y in range(len(l)):
for x in range(len(t... | [
"Return",
"[",
"{}",
"{}",
"{}",
"]",
"as",
"a",
"2d",
"matrix",
"."
] | swharden/SWHLab | python | https://github.com/swharden/SWHLab/blob/a86c3c65323cec809a4bd4f81919644927094bf5/doc/oldcode/swhlab/core/common.py#L476-L489 | [
"def",
"originFormat_listOfDicts",
"(",
"l",
")",
":",
"titles",
"=",
"[",
"]",
"for",
"d",
"in",
"l",
":",
"for",
"k",
"in",
"d",
".",
"keys",
"(",
")",
":",
"if",
"not",
"k",
"in",
"titles",
":",
"titles",
".",
"append",
"(",
"k",
")",
"title... | a86c3c65323cec809a4bd4f81919644927094bf5 |
valid | originFormat | Try to format anything as a 2D matrix with column names. | doc/oldcode/swhlab/core/common.py | def originFormat(thing):
"""Try to format anything as a 2D matrix with column names."""
if type(thing) is list and type(thing[0]) is dict:
return originFormat_listOfDicts(thing)
if type(thing) is list and type(thing[0]) is list:
return originFormat_listOfDicts(dictFlat(thing))
else:
... | def originFormat(thing):
"""Try to format anything as a 2D matrix with column names."""
if type(thing) is list and type(thing[0]) is dict:
return originFormat_listOfDicts(thing)
if type(thing) is list and type(thing[0]) is list:
return originFormat_listOfDicts(dictFlat(thing))
else:
... | [
"Try",
"to",
"format",
"anything",
"as",
"a",
"2D",
"matrix",
"with",
"column",
"names",
"."
] | swharden/SWHLab | python | https://github.com/swharden/SWHLab/blob/a86c3c65323cec809a4bd4f81919644927094bf5/doc/oldcode/swhlab/core/common.py#L491-L499 | [
"def",
"originFormat",
"(",
"thing",
")",
":",
"if",
"type",
"(",
"thing",
")",
"is",
"list",
"and",
"type",
"(",
"thing",
"[",
"0",
"]",
")",
"is",
"dict",
":",
"return",
"originFormat_listOfDicts",
"(",
"thing",
")",
"if",
"type",
"(",
"thing",
")"... | a86c3c65323cec809a4bd4f81919644927094bf5 |
valid | pickle_save | save something to a pickle file | doc/oldcode/swhlab/core/common.py | def pickle_save(thing,fname):
"""save something to a pickle file"""
pickle.dump(thing, open(fname,"wb"),pickle.HIGHEST_PROTOCOL)
return thing | def pickle_save(thing,fname):
"""save something to a pickle file"""
pickle.dump(thing, open(fname,"wb"),pickle.HIGHEST_PROTOCOL)
return thing | [
"save",
"something",
"to",
"a",
"pickle",
"file"
] | swharden/SWHLab | python | https://github.com/swharden/SWHLab/blob/a86c3c65323cec809a4bd4f81919644927094bf5/doc/oldcode/swhlab/core/common.py#L506-L509 | [
"def",
"pickle_save",
"(",
"thing",
",",
"fname",
")",
":",
"pickle",
".",
"dump",
"(",
"thing",
",",
"open",
"(",
"fname",
",",
"\"wb\"",
")",
",",
"pickle",
".",
"HIGHEST_PROTOCOL",
")",
"return",
"thing"
] | a86c3c65323cec809a4bd4f81919644927094bf5 |
valid | msgDict | convert a dictionary to a pretty formatted string. | doc/oldcode/swhlab/core/common.py | def msgDict(d,matching=None,sep1="=",sep2="\n",sort=True,cantEndWith=None):
"""convert a dictionary to a pretty formatted string."""
msg=""
if "record" in str(type(d)):
keys=d.dtype.names
else:
keys=d.keys()
if sort:
keys=sorted(keys)
for key in keys:
if key[0]=="... | def msgDict(d,matching=None,sep1="=",sep2="\n",sort=True,cantEndWith=None):
"""convert a dictionary to a pretty formatted string."""
msg=""
if "record" in str(type(d)):
keys=d.dtype.names
else:
keys=d.keys()
if sort:
keys=sorted(keys)
for key in keys:
if key[0]=="... | [
"convert",
"a",
"dictionary",
"to",
"a",
"pretty",
"formatted",
"string",
"."
] | swharden/SWHLab | python | https://github.com/swharden/SWHLab/blob/a86c3c65323cec809a4bd4f81919644927094bf5/doc/oldcode/swhlab/core/common.py#L516-L540 | [
"def",
"msgDict",
"(",
"d",
",",
"matching",
"=",
"None",
",",
"sep1",
"=",
"\"=\"",
",",
"sep2",
"=",
"\"\\n\"",
",",
"sort",
"=",
"True",
",",
"cantEndWith",
"=",
"None",
")",
":",
"msg",
"=",
"\"\"",
"if",
"\"record\"",
"in",
"str",
"(",
"type",... | a86c3c65323cec809a4bd4f81919644927094bf5 |
valid | groupsFromKey | given a groups file, return a dict of groups.
Example:
### GROUP: TR
16602083
16608059
### GROUP: TU
16504000
16507011 | doc/oldcode/swhlab/core/common.py | def groupsFromKey(keyFile='./key.txt'):
"""
given a groups file, return a dict of groups.
Example:
### GROUP: TR
16602083
16608059
### GROUP: TU
16504000
16507011
"""
groups={}
thisGroup="?"
with open(keyFile) as f:
raw=f.read().split("... | def groupsFromKey(keyFile='./key.txt'):
"""
given a groups file, return a dict of groups.
Example:
### GROUP: TR
16602083
16608059
### GROUP: TU
16504000
16507011
"""
groups={}
thisGroup="?"
with open(keyFile) as f:
raw=f.read().split("... | [
"given",
"a",
"groups",
"file",
"return",
"a",
"dict",
"of",
"groups",
".",
"Example",
":",
"###",
"GROUP",
":",
"TR",
"16602083",
"16608059",
"###",
"GROUP",
":",
"TU",
"16504000",
"16507011"
] | swharden/SWHLab | python | https://github.com/swharden/SWHLab/blob/a86c3c65323cec809a4bd4f81919644927094bf5/doc/oldcode/swhlab/core/common.py#L562-L586 | [
"def",
"groupsFromKey",
"(",
"keyFile",
"=",
"'./key.txt'",
")",
":",
"groups",
"=",
"{",
"}",
"thisGroup",
"=",
"\"?\"",
"with",
"open",
"(",
"keyFile",
")",
"as",
"f",
":",
"raw",
"=",
"f",
".",
"read",
"(",
")",
".",
"split",
"(",
"\"\\n\"",
")"... | a86c3c65323cec809a4bd4f81919644927094bf5 |
valid | findRelevantData | return an abf of the *FIRST* of every type of thing. | doc/oldcode/swhlab/core/common.py | def findRelevantData(fileList,abfs):
"""return an abf of the *FIRST* of every type of thing."""
relevant=[]
things={}
for abf in abfs:
for fname in fileList:
if abf in fname and not fname in relevant:
relevant.append(fname)
for item in sorted(relevant):
th... | def findRelevantData(fileList,abfs):
"""return an abf of the *FIRST* of every type of thing."""
relevant=[]
things={}
for abf in abfs:
for fname in fileList:
if abf in fname and not fname in relevant:
relevant.append(fname)
for item in sorted(relevant):
th... | [
"return",
"an",
"abf",
"of",
"the",
"*",
"FIRST",
"*",
"of",
"every",
"type",
"of",
"thing",
"."
] | swharden/SWHLab | python | https://github.com/swharden/SWHLab/blob/a86c3c65323cec809a4bd4f81919644927094bf5/doc/oldcode/swhlab/core/common.py#L589-L606 | [
"def",
"findRelevantData",
"(",
"fileList",
",",
"abfs",
")",
":",
"relevant",
"=",
"[",
"]",
"things",
"=",
"{",
"}",
"for",
"abf",
"in",
"abfs",
":",
"for",
"fname",
"in",
"fileList",
":",
"if",
"abf",
"in",
"fname",
"and",
"not",
"fname",
"in",
... | a86c3c65323cec809a4bd4f81919644927094bf5 |
valid | determineProtocol | determine the comment cooked in the protocol. | doc/oldcode/swhlab/core/common.py | def determineProtocol(fname):
"""determine the comment cooked in the protocol."""
f=open(fname,'rb')
raw=f.read(5000) #it should be in the first 5k of the file
f.close()
protoComment="unknown"
if b"SWHLab4[" in raw:
protoComment=raw.split(b"SWHLab4[")[1].split(b"]",1)[0]
elif b"SWH["... | def determineProtocol(fname):
"""determine the comment cooked in the protocol."""
f=open(fname,'rb')
raw=f.read(5000) #it should be in the first 5k of the file
f.close()
protoComment="unknown"
if b"SWHLab4[" in raw:
protoComment=raw.split(b"SWHLab4[")[1].split(b"]",1)[0]
elif b"SWH["... | [
"determine",
"the",
"comment",
"cooked",
"in",
"the",
"protocol",
"."
] | swharden/SWHLab | python | https://github.com/swharden/SWHLab/blob/a86c3c65323cec809a4bd4f81919644927094bf5/doc/oldcode/swhlab/core/common.py#L608-L622 | [
"def",
"determineProtocol",
"(",
"fname",
")",
":",
"f",
"=",
"open",
"(",
"fname",
",",
"'rb'",
")",
"raw",
"=",
"f",
".",
"read",
"(",
"5000",
")",
"#it should be in the first 5k of the file",
"f",
".",
"close",
"(",
")",
"protoComment",
"=",
"\"unknown\... | a86c3c65323cec809a4bd4f81919644927094bf5 |
valid | forwardSlash | convert silly C:\\names\\like\\this.txt to c:/names/like/this.txt | doc/oldcode/swhlab/core/common.py | def forwardSlash(listOfFiles):
"""convert silly C:\\names\\like\\this.txt to c:/names/like/this.txt"""
for i,fname in enumerate(listOfFiles):
listOfFiles[i]=fname.replace("\\","/")
return listOfFiles | def forwardSlash(listOfFiles):
"""convert silly C:\\names\\like\\this.txt to c:/names/like/this.txt"""
for i,fname in enumerate(listOfFiles):
listOfFiles[i]=fname.replace("\\","/")
return listOfFiles | [
"convert",
"silly",
"C",
":",
"\\\\",
"names",
"\\\\",
"like",
"\\\\",
"this",
".",
"txt",
"to",
"c",
":",
"/",
"names",
"/",
"like",
"/",
"this",
".",
"txt"
] | swharden/SWHLab | python | https://github.com/swharden/SWHLab/blob/a86c3c65323cec809a4bd4f81919644927094bf5/doc/oldcode/swhlab/core/common.py#L625-L629 | [
"def",
"forwardSlash",
"(",
"listOfFiles",
")",
":",
"for",
"i",
",",
"fname",
"in",
"enumerate",
"(",
"listOfFiles",
")",
":",
"listOfFiles",
"[",
"i",
"]",
"=",
"fname",
".",
"replace",
"(",
"\"\\\\\"",
",",
"\"/\"",
")",
"return",
"listOfFiles"
] | a86c3c65323cec809a4bd4f81919644927094bf5 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.