Instruction
stringlengths
362
7.83k
output_code
stringlengths
1
945
Predict the next line for this snippet: <|code_start|>#! /usr/bin/env python -i """ Load some useful stuff into the console when running python interactively. """ def _set_prompt(): """ Color code the Python prompt based on environment. """ env = os.environ.get('ENV', 'dev') color = {'dev': '32', # Green...
log.init_logging(log.logging.DEBUG)
Given the code snippet: <|code_start|>""" Tests for the Groups Model """ from __future__ import (absolute_import, division, print_function, unicode_literals) try: except ImportError: print("WARNING: Cannot Load builtins for py3 compatibility.", file=sys.stderr) warnings.simplefilter("error") # Make All warnin...
group = groups.Groups()
Given the following code snippet before the placeholder: <|code_start|> warnings.simplefilter("error") # Make All warnings errors while testing. def test_required_fields_blank(dbsession): """ Groups must have a name. :param sqlalchemy.orm.session.Session dbsession: pytest fixture for database session ...
membership1 = memberships.Memberships(profile=profile1)
Given the following code snippet before the placeholder: <|code_start|> warnings.simplefilter("error") # Make All warnings errors while testing. def test_required_fields_blank(dbsession): """ Groups must have a name. :param sqlalchemy.orm.session.Session dbsession: pytest fixture for database session ...
profile1 = profiles.Profiles(full_name='92e17a59 740480af51b5', email='6b7d@4c4b.b33d')
Predict the next line after this snippet: <|code_start|>""" Tests for the API JsonApiResource class details endpoints with identifiers. Read, Update, and Delete all by identifier. """ from __future__ import (absolute_import, division, print_function, unicode_literals) try: except ImportError: print("WARNING: Cannot...
class Horses(bases.BaseModel):
Here is a snippet: <|code_start|> with pytest.raises(NotFound) as excinfo: resource.patch(999, patch_data) assert excinfo.value.description == {'detail': '999 not found.', 'source': {'parameter': '/id'}} def test_detail_update_id_required(dbsession): # pylint: ...
with pytest.raises(Conflict) as excinfo:
Given the following code snippet before the placeholder: <|code_start|>class HorsesResource(ourapi.JsonApiResource): """ JSONAPI CRUD endpoints for HorsesSchema/Horses Model. """ schema = HorsesSchema def test_new_detail_resource(): """ Resource endpoint for Model details. """ resource = HorsesResourc...
with pytest.raises(NotFound) as excinfo:
Next line prediction: <|code_start|>""" Tests for the Memberships Model """ from __future__ import (absolute_import, division, print_function, unicode_literals) try: except ImportError: print("WARNING: Cannot Load builtins for py3 compatibility.", file=sys.stderr) warnings.simplefilter("error") # Make All war...
group = groups.Groups(name='61f7d724-d90c-4e2f-85f4-7cab51d68b61')
Predict the next line for this snippet: <|code_start|>""" Tests for the Memberships Model """ from __future__ import (absolute_import, division, print_function, unicode_literals) try: except ImportError: print("WARNING: Cannot Load builtins for py3 compatibility.", file=sys.stderr) warnings.simplefilter("error...
inst = memberships.Memberships()
Given the following code snippet before the placeholder: <|code_start|>warnings.simplefilter("error") # Make All warnings errors while testing. def test_required_relations(dbsession): """ Memberships must have a Profile and a Group. :param sqlalchemy.orm.session.Session dbsession: pytest fixture for datab...
profile = profiles.Profiles(full_name='103ae318 69f4f2471acc', email='73c5@4568.8dd9')
Given the following code snippet before the placeholder: <|code_start|> """ def __init__(self, objs, fields): """ Constructor Objs must be a list of (class, id) with optionally extra fields """ self.objs = objs self.fields = fields def brains(self): ""...
except config.orm.not_found:
Predict the next line for this snippet: <|code_start|> except config.orm.not_found: log.warning("Object %r does not exist ! Broken index ?" % (obj,)) __iter__ = iterator def all(self): """ Get all the results as a list """ return list(self) def ge...
objclass = typemap.get_class_by_name(objclass)
Using the snippet: <|code_start|># MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with SeSQL. If not, see <http://www.gnu.org/licenses/>. """ This monkey patch will enable to use s...
if getattr(config, 'ENABLE_SESQL_ADMIN', False):
Continue the code snippet: <|code_start|> # You should have received a copy of the GNU General Public License # along with SeSQL. If not, see <http://www.gnu.org/licenses/>. def sql_function(func): """ Decorator to execute or print SQL statements """ def sql_function_inner(cursor = None, execute = Fal...
"DROP TEXT SEARCH CONFIGURATION IF EXISTS public.%s" % config.TS_CONFIG_NAME,
Predict the next line for this snippet: <|code_start|> STOPWORDS = %s )""" % (config.TS_CONFIG_NAME, config.STOPWORDS_FILE), """ALTER TEXT SEARCH CONFIGURATION %s ALTER MAPPING FOR asciiword, asciihword, hword_asciipart WITH %s_dict""" % (config.TS_CONFIG_NAME, config.TS_CONFIG_NAME) ] + ...
condition = typemap.get_class_names_for(table)
Given snippet: <|code_start|>""" # Allow "with" with python2.5 from __future__ import with_statement STEP = 1000 class Command(BaseCommand): help = "Update some columns of all already indexed objects in SeSQL" option_list = BaseCommand.option_list + ( make_option('--class', des...
full_tmr = Timer()
Next line prediction: <|code_start|># but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with SeSQL. If not, see <http:...
def update(self, classnames, fields):
Next line prediction: <|code_start|> obj = None broken += 1 log.warning("Object %r does not exist ! Broken index ?" % (obj,)) except: transaction.rollback() raise with index_tmr: ...
classes = typemap.all_class_names()
Using the snippet: <|code_start|># along with SeSQL. If not, see <http://www.gnu.org/licenses/>. """ This is a variation over the reindex command, which will only reindex selected columns. It'll be faster when you've a lot of data and only a few columns changed. """ # Allow "with" with python2.5 from __future__ import...
result = longquery(Q(classname__in = classnames))
Next line prediction: <|code_start|># along with SeSQL. If not, see <http://www.gnu.org/licenses/>. # Maximal number of words to lemmatize at once MAX_WORDS = 1000 # Use GenericCache for now, but will probably be moved to memcached later _word_cache = GenericCache(maxsize = 50000, expiry = 86400) def lemmatize_for...
cursor = config.orm.cursor()
Predict the next line after this snippet: <|code_start|> for word in words: value = _word_cache[(word, dictionnary)] if value is not None: values[word] = value else: remaining.append(word) if remaining: pattern = "plainto_tsquery('%s', %%s)" % dictionnary...
index = fieldmap.primary
Predict the next line after this snippet: <|code_start|> def get_dictionnary(self): if self._dictionnary is None: self._dictionnary = "public.%s" % config.TS_CONFIG_NAME return self._dictionnary dictionnary = property(get_dictionnary, set_dictionnary) def marshall(self, value, ...
value = strip_ligatures(value)
Given the following code snippet before the placeholder: <|code_start|>Contain the field types for SeSQL We cannot reuse Django types because what we need is too specific """ log = logging.getLogger('sesql') class Field(object): """ This represent an abstract field """ primary = False slqtype =...
self.source = guess_source(source)
Given the following code snippet before the placeholder: <|code_start|>class LongIntField(IntField): """ This is a bigint field """ sqltype = "bigint" class StrField(Field): """ This is a simple string field, with specified length """ def __init__(self, name, source = None, size = 255):...
self.source = ClassSource(dereference_proxy = dereference_proxy)
Next line prediction: <|code_start|># (at your option) any later version. # SeSQL is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You sho...
print shortquery(query, order).objs
Here is a snippet: <|code_start|># (at your option) any later version. # SeSQL is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should...
print longquery(query, order).objs
Next line prediction: <|code_start|># it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 of the License, or # (at your option) any later version. # SeSQL is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the im...
default=config.HISTORY_DEFAULT_FILTER,
Using the snippet: <|code_start|> for hit in last_hits: query = hit.query # blacklist if query in config.HISTORY_BLACKLIST: continue if hit.nb_results < filter_nb: SearchHitHistoric(query=hit.query, ...
lems = lemmatize(query.split())
Using the snippet: <|code_start|> help = """Build SearchQuery index""" option_list = BaseCommand.option_list + ( make_option('-e','--erode', action='store_true', dest='erode', help = 'tell if we must erode result or not'), make_option(...
last_hits = SearchHit.objects.all()
Predict the next line after this snippet: <|code_start|># along with SeSQL. If not, see <http://www.gnu.org/licenses/>. """ This should be runned in a cron to process search histories and compute stats """ class Command(BaseCommand): help = """Build SearchQuery index""" option_list = BaseCommand.option_li...
for search_query in SearchQuery.objects.all():
Given the code snippet: <|code_start|> help = 'how many time a search must occur to be treated')) def handle(self, *apps, **options): self.process_hits(options['filter']) if options['erode']: self.erode() def erode(self): for search_query in SearchQuery....
SearchHitHistoric(query=hit.query,
Predict the next line after this snippet: <|code_start|> def process_hits(self, filter_nb): last_hits = SearchHit.objects.all() processed_hits = [] for hit in last_hits: query = hit.query # blacklist if query in config.HISTORY_BLACKLIST: ...
search_query.phonex = phonex(query)
Based on the snippet: <|code_start|># This file is part of SeSQL. # SeSQL is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 of the License, or # (at your option) any later version. # SeSQL is ...
datamodel.create_dictionnary(include_drop = True)
Given the following code snippet before the placeholder: <|code_start|># it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 of the License, or # (at your option) any later version. # SeSQL is distributed in the hope that it will be useful, # but WITHOU...
for table in typemap.all_tables():
Using the snippet: <|code_start|># Copyright (c) Pilot Systems and Libération, 2010-2011 # This file is part of SeSQL. # SeSQL is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 of the License,...
self.fields = config.FIELDS
Using the snippet: <|code_start|># it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 of the License, or # (at your option) any later version. # SeSQL is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the impli...
obj = SeSQLResultSet.load(apps)
Based on the snippet: <|code_start|># (at your option) any later version. # SeSQL is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You sho...
index(obj)
Predict the next line after this snippet: <|code_start|> log = logging.getLogger('sesql') def cached(method): """ Decorator to make a method without argument to store result in the object itself """ cache_name = "_cache_" + method.__name__ def cached_inner(self, *args, **kwargs): if arg...
order = order or config.DEFAULT_ORDER
Given the following code snippet before the placeholder: <|code_start|> def shortquery(self, limit = 50): """ Perform a long query and return a lazy Django result set """ table = self.get_table_name() if table == config.MASTER_TABLE_NAME: # Multitable or unprecise...
tables.add(typemap.get_table_for(k))
Next line prediction: <|code_start|> return SeSQLResultSet(list(query), self.fields) def _do_longquery(self, limit = None): """ Perform a long query and return a cursor """ table = self.get_table_name() pattern, values = self.get_pattern() o_pattern, o_values ...
l_pattern, l_values = fieldmap.get_field("classname").get_in(classes)
Next line prediction: <|code_start|> """ SeSQL Query handler """ def __init__(self, query, order, fields = ()): """ Constructor """ self.query = query order = order or config.DEFAULT_ORDER if isinstance(order, (str, unicode)): order = order.spli...
return SeSQLResultSet(list(query), self.fields)
Given the code snippet: <|code_start|> class Command(BaseCommand): help = "Fixate a date field by copying empty values from another" option_list = BaseCommand.option_list + ( make_option('-s', '--step', dest='step', default=1000, type='int', ...
cursor = config.orm.cursor()
Given the following code snippet before the placeholder: <|code_start|> start_time = time.time() idmin, idmax = cursor.fetchone() if idmin and idmax: print "Processing table %s from id %d to %d" % (table, idmin, idmax) start = idmin while start <= idmax: ...
for table in typemap.typemap.tables.keys():
Given the code snippet: <|code_start|> cursor = config.orm.cursor() query = ''' UPDATE %s SET %s = %s WHERE %s IS NULL AND (id >= %d) AND (id <= %d) ''' % (table, self.target, self.source, self.target, idmin, idmax) cursor.execute(query) def process_ta...
print_eta(percent, timedelta)
Given snippet: <|code_start|># Copyright (c) Pilot Systems and Libération, 2010-2011 # This file is part of SeSQL. # SeSQL is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 of the License, or ...
return utils.log_time(function, message)(obj, message, *args, **kwargs)
Continue the code snippet: <|code_start|> inner.__name__ = function.__name__ return inner def get_values(obj, fields): """ Get SQL keys, placeholders and results for this object and those fields """ keys = [ ] placeholders = [ ] results = [ ] for field in fields: keys.extend...
@config.orm.transactional
Based on the snippet: <|code_start|> results = [ ] for field in fields: keys.extend(field.index_columns) placeholders.extend(field.index_placeholders) results.extend(field.get_values(obj)) return keys, placeholders, results def get_sesql_id(obj): """ Get classname and id, t...
table_name = typemap.typemap.get_table_for(classname)
Given the following code snippet before the placeholder: <|code_start|> message = "%s (%s:%s)" % (function.__name__, classname, objid) except (TypeError, AttributeError, ValueError): message = "%s (invalid object %r)" % (function.__name__, obj) return utils.log_time(function, mess...
vals = fieldmap.fieldmap[field].get_values(obj)
Using the snippet: <|code_start|># (at your option) any later version. # SeSQL is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should...
lems = lemmatize(words, index)
Here is a snippet: <|code_start|># -*- coding: utf-8 -*- # Copyright (c) Pilot Systems and Libération, 2010-2011 # This file is part of SeSQL. # SeSQL is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either ...
index = fieldmap.primary
Predict the next line for this snippet: <|code_start|># it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 of the License, or # (at your option) any later version. # SeSQL is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; w...
type_map = [ len(t) == 3 and t or t + (True,) for t in config.TYPE_MAP ]
Predict the next line for this snippet: <|code_start|> class current_question(service_func): def __init__(self): service_func.__init__(self, "/question/current") self.name = "Get the current question" self.description = "Return the current question or nothing if there is ongoing question" <...
self.args.append(meta_arg("key", "Protection key", "none"))
Predict the next line for this snippet: <|code_start|>#this will answer the current answer in game_data.current_question class answer_question(service_func): def __init__(self): service_func.__init__(self, "/question/answer") self.name = "Answer question" self.description = "Answer the cu...
self.args.append(meta_arg("key", "Protection key", "none"))
Based on the snippet: <|code_start|> class answer_question(service_func): def __init__(self): service_func.__init__(self, "/question/answer") self.name = "Answer question" self.description = "Answer the current question" self.args.append(meta_arg("key", "Protection key", "none")) ...
raise func_error("No question waiting for an answer")
Given the following code snippet before the placeholder: <|code_start|> class add_point_to_team(service_func): def __init__(self): service_func.__init__(self, "/team/addpoint") self.name = "Add point to team" self.description = "Add point to a team corresponding by it team id" self....
raise func_error("Invalid key")
Predict the next line after this snippet: <|code_start|> class add_point_to_team(service_func): def __init__(self): service_func.__init__(self, "/team/addpoint") self.name = "Add point to team" self.description = "Add point to a team corresponding by it team id" <|code_end|> using the curr...
self.args.append(meta_arg("key", "Protection key", "none"))
Using the snippet: <|code_start|> def init(self): self.question = None self.points = 0 def execute(self, args, server): key = args["key"] category = int(args["category"]) rank = int(args["rank"]) team = int(args["team"]) if server.key == key: ...
raise func_error("No more question in this category with this rank")
Here is a snippet: <|code_start|> class ask_question(service_func): def __init__(self): service_func.__init__(self, '/question/ask') self.name = "Ask Question" self.description = "Ask a question to a team, with a category id and a rank" self.question = None self.points = 0 <|...
self.args.append(meta_arg("key", "Protection Key", "none"))
Next line prediction: <|code_start|> class remove_team(service_func): def __init__(self): service_func.__init__(self, "/team/remove") self.name = "Remove team" self.description = "Remove a team from the Jeopardy Game" self.args.append(meta_arg("key", "Protection key", "none")) ...
raise func_error("Key is invalid")
Based on the snippet: <|code_start|> class remove_team(service_func): def __init__(self): service_func.__init__(self, "/team/remove") self.name = "Remove team" self.description = "Remove a team from the Jeopardy Game" <|code_end|> , predict the immediate next line with the help of imports: ...
self.args.append(meta_arg("key", "Protection key", "none"))
Continue the code snippet: <|code_start|> class start_game(service_func): def __init__(self): service_func.__init__(self, "/game/start") self.name = "Start Game" self.description = "Start a new game, need correct number of teams (4)" self.args.append(meta_arg("key", "Protection Key"...
raise func_error("Only %d teams are registered, need 4" % len(server.game_data.teams))
Using the snippet: <|code_start|> class start_game(service_func): def __init__(self): service_func.__init__(self, "/game/start") self.name = "Start Game" self.description = "Start a new game, need correct number of teams (4)" <|code_end|> , determine the next line of code. You have imports:...
self.args.append(meta_arg("key", "Protection Key", "none"))
Given the following code snippet before the placeholder: <|code_start|> class add_team(service_func): def __init__(self): service_func.__init__(self, "/team/add") self.name = "Add team" self.description = "Add a new team to the jeopardy" self.args.append(meta_arg("key", "Protection K...
raise func_error("Invalid key")
Using the snippet: <|code_start|> class add_team(service_func): def __init__(self): service_func.__init__(self, "/team/add") self.name = "Add team" self.description = "Add a new team to the jeopardy" <|code_end|> , determine the next line of code. You have imports: from ..service_func impor...
self.args.append(meta_arg("key", "Protection Key", "none"))
Given the code snippet: <|code_start|> class test_key(service_func): def __init__(self): service_func.__init__(self, "/key") self.name = "Test Key" self.description = "Test the protection key if it's valid or not" <|code_end|> , generate the next line using the imports in this file: from ....
self.args.append(meta_arg("key", "Protection key", "none"))
Predict the next line after this snippet: <|code_start|>from __future__ import division from __future__ import print_function def test_join_overlapping(): <|code_end|> using the current file's imports: import numpy as np import numpy.testing as npt import pandas as pd from deepcpg.data import annotations as annos...
f = annos.join_overlapping
Given snippet: <|code_start|> filename: Path of HDF5 file. group: HDF5 group to be explored. recursive: bool If `True`, list records recursively. groups: bool If `True`, only list group names but not name of datasets. regex: str Regex to filter listed records. ...
keys = filter_regex(keys, regex)
Given the following code snippet before the placeholder: <|code_start|> if is_root: group.close() def hnames_to_names(hnames): """Flattens `dict` `hnames` of hierarchical names. Converts hierarchical `dict`, e.g. hnames={'a': ['a1', 'a2'], 'b'}, to flat list of keys for accessing HDF5 file, e....
names = to_list(names)
Predict the next line after this snippet: <|code_start|> def main(self, name, opts): logging.basicConfig(filename=opts.log_file, format='%(levelname)s (%(asctime)s): %(message)s') log = logging.getLogger(name) if opts.verbose: log.setLevel(logging.DEBU...
output_names = hdf.ls(filename, 'outputs', recursive=True)
Here is a snippet: <|code_start|>from __future__ import division from __future__ import print_function def test_hnames_to_names(): hnames = OrderedDict.fromkeys(['a', 'b']) <|code_end|> . Write the next line using the current file imports: from collections import OrderedDict from numpy import testing as npt f...
names = hdf.hnames_to_names(hnames)
Given snippet: <|code_start|> Returns ------- List of :class:`FastaSeq` objects. """ list if gzip is None: gzip = filename.endswith('.gz') if gzip: lines = gz.open(filename, 'r').read().decode() else: lines = open(filename, 'r').read() lines = lines.splitli...
filenames = to_list(filenames)
Predict the next line after this snippet: <|code_start|> # Add new validation epoch logs to logs table for metric, metric_logs in six.iteritems(self.val_epoch_logs): metric_val = 'val_' + metric if metric_val in logs: metric_logs.append(logs[metric_val]) ...
self._log(format_table(table, precision=self.precision))
Here is a snippet: <|code_start|> class TestMake(object): def setup_class(self): self.data_path = os.path.join( os.path.dirname(os.path.realpath(__file__)), 'data') self.data_files = glob(os.path.join(self.data_path, 'c*.h5')) names = ['chromo', 'pos', ...
self.data = hdf.read(self.data_files, names)
Given the code snippet: <|code_start|> assert actual[idx] == e[2] def test_outputs(self): expected = [('18', 3000023, 1.0), ('18', 3000086, 1.0), ('18', 3012584, 0.0), ('19', 4398070, 0.0), ('19', 4428709, 1.0), ...
dna_seq = read_chromo(os.path.join(self.data_path, '../dna_db'),
Predict the next line for this snippet: <|code_start|> ('19', 4447847, 1.0) ] self._test_outputs('cpg/BS27_4_SER', expected) expected = [('18', 3000092, 1.0), ('18', 3010064, 0.0), ('18', 3140338, 1.0), (...
assert dna[idx, center + 10] == CHAR_TO_INT[dna_seq[p + 10]]
Based on the snippet: <|code_start|>def _cat_sample_weights(y, mask=None): return 1 - K.cast(K.equal(K.sum(y, axis=-1), 0), K.floatx()) def cat_acc(y, z): """Compute categorical accuracy given one-hot matrices.""" weights = _cat_sample_weights(y) _acc = K.cast(K.equal(K.argmax(y, axis=-1), ...
return get_from_module(name, globals())
Given the following code snippet before the placeholder: <|code_start|>"""DNA models. Provides models trained with DNA sequence windows. """ from __future__ import division from __future__ import print_function <|code_end|> , predict the next line using imports from the current file: import inspect from keras i...
class DnaModel(Model):
Predict the next line after this snippet: <|code_start|> x = self._res_unit(x, [64, 64, 256], stage=2, block=1, stride=2) x = self._res_unit(x, [64, 64, 256], atrous=2, stage=2, block=2) x = self._res_unit(x, [64, 64, 256], atrous=4, stage=2, block=3) # 32 x = self._res_unit(x, [...
return get_from_module(name, globals())
Continue the code snippet: <|code_start|> p.add_argument( '--log_file', help='Write log messages to file') return p def main(self, name, opts): logging.basicConfig(filename=opts.log_file, format='%(levelname)s (%(asctime)s): %(message)s') ...
make_dir(opts.out_dir)
Next line prediction: <|code_start|> def mean(x): """Mean methylation rate.""" if x.ndim > 2: x = x.mean(axis=2) return np.mean(x, 1) def mode(x): """Mode of methylation rate.""" if x.ndim > 2: x = x.mean(axis=2) return x.mean(axis=1).round().astype(np.int8) def var(x, *arg...
bins = np.linspace(-EPS, 0.25, nb_bin + 1)
Next line prediction: <|code_start|> cv = np.digitize(v, bins, right=True) - 1 return np.ma.masked_array(cv, v.mask) def cat2_var(*args, **kwargs): """Binary variance between cells.""" cv = cat_var(*args, **kwargs) cv[cv > 0] = 1 return cv def entropy(x): """Entropy of single CpG sites be...
return get_from_module(name, globals())
Predict the next line for this snippet: <|code_start|>"""Joint models. Provides models for joining features from DNA and CpG model. """ from __future__ import division from __future__ import print_function <|code_end|> with the help of current file imports: import inspect from keras import layers as kl from ke...
class JointModel(Model):
Using the snippet: <|code_start|> def __init__(self, *args, **kwargs): super(JointL2h512, self).__init__(*args, **kwargs) self.nb_layer = 2 class JointL3h512(JointL1h512): """Three fully-connected layers with 512 units. .. code:: Parameters: 1,000,000 Specification: fc[512...
return get_from_module(name, globals())
Given snippet: <|code_start|> # Create output directories make_dir(opts.out_dir) sub_dirs = dict() names = ['logos', 'fa'] if opts.plot_dens: names.append('dens') if opts.plot_heat: names.append('heat') if opts.motif_dbs: names....
weights = linear_weights(pca_act.shape[1])
Predict the next line after this snippet: <|code_start|>.. code:: bash dcpg_filter_motifs.py ./activations.h5 --out_dir ./motifs --motif_db ./motif_databases/CIS-BP/Mus_musculus.meme --plot_heat --plot_dens --plot_pca """ from __future__ import print_function from _...
ALPHABET = dna.get_alphabet(False)
Next line prediction: <|code_start|>"""CpG models. Provides models trained with observed neighboring methylation states of multiple cells. """ from __future__ import division from __future__ import print_function <|code_end|> . Use current file imports: (import inspect from keras import layers as kl from keras ...
class CpgModel(Model):
Based on the snippet: <|code_start|> shape = getattr(x, '_keras_shape') replicate_model = self._replicate_model(kl.Input(shape=shape[2:])) x = kl.TimeDistributed(replicate_model)(x) kernel_regularizer = kr.L1L2(l1=self.l1_decay, l2=self.l2_decay) x = kl.Bidirectional(kl.GRU(128,...
return get_from_module(name, globals())
Based on the snippet: <|code_start|>from __future__ import division from __future__ import print_function class TestKnnCpgFeatureExtractor(object): def test_larger_equal(self): # y: 1 5 8 15 <|code_end|> , predict the immediate next line with the help of imports: import numpy as np import numpy.testin...
e = fe.KnnCpgFeatureExtractor()
Here is a snippet: <|code_start|> expect = [] result = f(x, ys, ye) npt.assert_array_equal(result, expect) x = [-1, 3, 9, 19] expect = [-1, -1, -1, -1] result = f(x, ys, ye) npt.assert_array_equal(result, expect) x = [-1, 2, 2, 3, 4, 8, 15, 16] ex...
_seqs = np.array([dna.char_to_int(seq) for seq in seqs], dtype=np.int32)
Given the code snippet: <|code_start|> report = pd.pivot_table(report, index=index, columns='metric', values='value') report.reset_index(index, inplace=True) report.columns.name = None # Sort columns columns = list(report.columns) sorted_columns = [] for fun in CA...
return get_from_module(name, globals())
Next line prediction: <|code_start|># -*- coding: utf-8 -*- """ oauthlib.oauth2.rfc6749 ~~~~~~~~~~~~~~~~~~~~~~~ This module is an implementation of various logic needed for consuming and providing OAuth 2.0 RFC6749. """ from __future__ import absolute_import, unicode_literals <|code_end|> . Use current file import...
class AuthorizationEndpoint(BaseEndpoint):
Continue the code snippet: <|code_start|> MUST NOT be included more than once:: # Enforced through the design of oauthlib.common.Request .. _`Appendix B`: http://tools.ietf.org/html/rfc6749#appendix-B """ def __init__(self, default_response_type, default_token_type, response_types)...
@catch_errors_and_unavailability
Given snippet: <|code_start|># -*- coding: utf-8 -*- """ oauthlib.oauth2.rfc6749.endpoint.revocation ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ An implementation of the OAuth 2 `Token Revocation`_ spec (draft 11). .. _`Token Revocation`: http://tools.ietf.org/html/draft-ietf-oauth-revocation-11 """ from __future__ i...
class RevocationEndpoint(BaseEndpoint):
Using the snippet: <|code_start|>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ An implementation of the OAuth 2 `Token Revocation`_ spec (draft 11). .. _`Token Revocation`: http://tools.ietf.org/html/draft-ietf-oauth-revocation-11 """ from __future__ import absolute_import, unicode_literals class RevocationEndpoint...
@catch_errors_and_unavailability
Based on the snippet: <|code_start|> server is unable to locate the token using the given hint, it MUST extend its search accross all of its supported token types. An authorization server MAY ignore this parameter, particularly if it is able to detect the token type automatically. This ...
raise InvalidClientError(request=request)
Given snippet: <|code_start|> defines two such values: * access_token: An Access Token as defined in [RFC6749], `section 1.4`_ * refresh_token: A Refresh Token as defined in [RFC6749], `section 1.5`_ Specific implementat...
raise UnsupportedTokenTypeError(request=request)
Based on the snippet: <|code_start|> BaseEndpoint.__init__(self) self.request_validator = request_validator self._supported_token_types = ( supported_token_types or self.valid_token_types) @catch_errors_and_unavailability def create_revocation_response(self, uri, http_met...
except OAuth2Error as e:
Given the code snippet: <|code_start|> Pragma: no-cache { "access_token":"2YotnFZFEjr1zCsicMWpAA", "token_type":"example", "expires_in":3600, "refresh_token":"tGzv3JOkF0XG5Qx2TlKWIA", "example_parameter":"example_value" } .. _`Sect...
raise_from_error(params.get('error'), params)
Based on the snippet: <|code_start|> "access_token":"2YotnFZFEjr1zCsicMWpAA", "token_type":"example", "expires_in":3600, "refresh_token":"tGzv3JOkF0XG5Qx2TlKWIA", "example_parameter":"example_value" } .. _`Section 7.1`: http://tools.ietf.org/html/r...
raise MissingTokenError(description="Missing access token parameter.")
Continue the code snippet: <|code_start|> "refresh_token":"tGzv3JOkF0XG5Qx2TlKWIA", "example_parameter":"example_value" } .. _`Section 7.1`: http://tools.ietf.org/html/rfc6749#section-7.1 .. _`Section 6`: http://tools.ietf.org/html/rfc6749#section-6 .. _`Section 3.3`: http://...
raise MissingTokenTypeError()