function
stringlengths
11
56k
repo_name
stringlengths
5
60
features
list
def remove_absolute_paths(line): """ Removes libraries from the line that are found under /usr """ if sys.platform == 'win32': return line elif sys.platform == 'darwin': return re.sub('/Applications/[-_a-zA-Z0-9/.]+.framework[;]?', '', line) else: return re.sub('/usr/[-_...
DLR-SC/tigl
[ 186, 54, 186, 96, 1419243179 ]
def _IsDirectory(parent, item): """Helper that returns if parent/item is a directory.""" return tf.io.gfile.isdir(os.path.join(parent, item))
tensorflow/tensorboard
[ 6136, 1581, 6136, 616, 1494878887 ]
def ListPlugins(logdir): """List all the plugins that have registered assets in logdir. If the plugins_dir does not exist, it returns an empty list. This maintains compatibility with old directories that have no plugins written. Args: logdir: A directory that was created by a TensorFlow events w...
tensorflow/tensorboard
[ 6136, 1581, 6136, 616, 1494878887 ]
def read_batch_from_dataset_tables(input_table_patterns, batch_sizes, num_instances_per_record, shuffle, num_epochs, keypoint_names_3d=None, ...
google-research/google-research
[ 27788, 6881, 27788, 944, 1538678568 ]
def get_optimizer(optimizer_type, learning_rate, **kwargs): """Creates optimizer with learning rate. Currently supported optimizers include: 'ADAGRAD' Args: optimizer_type: A string for the type of optimizer to choose. learning_rate: A float or tensor for the learning rate. **kwargs: A dictionar...
google-research/google-research
[ 27788, 6881, 27788, 944, 1538678568 ]
def get_moving_average_variables_to_restore(global_step=None): """Gets variables to restore. Args: global_step: A tensor of global step to include. If None, do not restore global step variable, which is for exporting inference graph. For only evaluation, specifying a global step is needed. Retur...
google-research/google-research
[ 27788, 6881, 27788, 944, 1538678568 ]
def add_summary(scalars_to_summarize=None, histograms_to_summarize=None, images_to_summarize=None): """Adds summaries to the default summary collection. Args: scalars_to_summarize: A dictionary of (name, scalar tensor) tuples to summarize. histograms_to_summarize: A di...
google-research/google-research
[ 27788, 6881, 27788, 944, 1538678568 ]
def create_dir_and_save_flags(flags_module, log_dir, json_filename): """Creates log directory and saves flags to a JSON file. Args: flags_module: An absl.flags module. log_dir: A string for log directory. json_filename: A string for output JSON file name. """ # Create log directory if necessary. ...
google-research/google-research
[ 27788, 6881, 27788, 944, 1538678568 ]
def stack_embeddings(model_outputs, embedding_keys, common_module=common): """Selects and stacks embeddings by key. Args: model_outputs: A dictionary for model output tensors. embedding_keys: A list for enum strings for tensor keys to select. common_module: A Python module that defines common flags and...
google-research/google-research
[ 27788, 6881, 27788, 944, 1538678568 ]
def maybe_clamp(x, x_range, ignored_if_non_positive): """Clamps `x` to `x_range`.""" x_min, x_max = x_range if x_min is not None and x_max is not None and x_min > x_max: raise ValueError('Invalid range: %s.' % str(x_range)) if (x_min is not None) and (not ignored_if_non_positive or x_min > 0.0): ...
google-research/google-research
[ 27788, 6881, 27788, 944, 1538678568 ]
def __init__( self, tried, except_handler, break_handler, continue_handler, return_handler, source_ref,
kayhayen/Nuitka
[ 8411, 456, 8411, 240, 1366731633 ]
def computeStatement(self, trace_collection): # This node has many children to handle, pylint: disable=I0021,too-many-branches,too-many-locals,too-many-statements tried = self.subnode_tried except_handler = self.subnode_except_handler break_handler = self.subnode_break_handler c...
kayhayen/Nuitka
[ 8411, 456, 8411, 240, 1366731633 ]
def mayBreak(self): # TODO: If we optimized return handler away, this would be not needed # or even non-optimal. if self.subnode_tried.mayBreak(): return True except_handler = self.subnode_except_handler if except_handler is not None and except_handler.mayBreak(): ...
kayhayen/Nuitka
[ 8411, 456, 8411, 240, 1366731633 ]
def isStatementAborting(self): except_handler = self.subnode_except_handler if except_handler is None or not except_handler.isStatementAborting(): return False break_handler = self.subnode_break_handler if break_handler is not None and not break_handler.isStatementAborting...
kayhayen/Nuitka
[ 8411, 456, 8411, 240, 1366731633 ]
def needsFrame(self): except_handler = self.subnode_except_handler if except_handler is not None and except_handler.needsFrame(): return True break_handler = self.subnode_break_handler if break_handler is not None and break_handler.needsFrame(): return True ...
kayhayen/Nuitka
[ 8411, 456, 8411, 240, 1366731633 ]
def setUp(self): self.fd, self.path = tempfile.mkstemp()
rbuffat/pyidf
[ 20, 7, 20, 2, 1417292720 ]
def test_data_is_valid(self): """Limit Processor / Identifier Hint / Data Validation""" self.assertEqual(data_is_valid(DATA), (True, "OK")) self.assertEqual(data_is_valid({}), (False, "At /: 'hint' is a required property")) self.assertRaises(ValueError, data_is_valid, 123)
perfsonar/pscheduler
[ 45, 31, 45, 115, 1452259533 ]
def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.create_table('graph', sa.Column('id', sa.Integer(), nullable=False), sa.Column('created_at', sa.DateTime(), nullable=True), sa.Column('updated_at', sa.DateTime(), nullable=True), sa.Column('user_id', sa.Integer(), nu...
google/timesketch
[ 2113, 486, 2113, 278, 1403200185 ]
def setUp(self): self.set_filename('simple09.xlsx')
jmcnamara/XlsxWriter
[ 3172, 594, 3172, 18, 1357261626 ]
def upgrade(): op.drop_index('ix_team_domain', table_name='team') op.drop_column('team', 'domain')
hasgeek/lastuser
[ 165, 31, 165, 47, 1297954711 ]
def webhook(request): return HttpResponse('')
rackerlabs/django-DefectDojo
[ 2681, 1254, 2681, 272, 1424368427 ]
def express_new_github(request): return HttpResponse('')
rackerlabs/django-DefectDojo
[ 2681, 1254, 2681, 272, 1424368427 ]
def new_github(request): if request.method == 'POST': gform = GITHUBForm(request.POST, instance=GITHUB_Conf()) if gform.is_valid(): try: api_key = gform.cleaned_data.get('api_key') g = Github(api_key) user = g.get_user() log...
rackerlabs/django-DefectDojo
[ 2681, 1254, 2681, 272, 1424368427 ]
def github(request): confs = GITHUB_Conf.objects.all() add_breadcrumb(title="Github List", top_level=not len(request.GET), request=request) return render(request, 'dojo/github.html', {'confs': confs, })
rackerlabs/django-DefectDojo
[ 2681, 1254, 2681, 272, 1424368427 ]
def _insert_custom_filters(analyzer_name, filter_list, char=False): """ Takes a list containing in-built filters (as strings), and the settings for custom filters (as dicts). Turns the dicts into instances of `token_filter` or `char_filter` depending on the value of the `char` argument. """ def...
mozilla/kitsune
[ 1110, 779, 1110, 26, 1264532037 ]
def es_analyzer_for_locale(locale, search_analyzer=False): """Pick an appropriate analyzer for a given locale. If no analyzer is defined for `locale` or the locale analyzer uses a plugin but using plugin is turned off from settings, return an analyzer named "default_sumo". """ name = "" analyze...
mozilla/kitsune
[ 1110, 779, 1110, 26, 1264532037 ]
def get_doc_types(paths=["kitsune.search.documents"]): """Return all registered document types""" doc_types = [] modules = [importlib.import_module(path) for path in paths] for module in modules: for key in dir(module): cls = getattr(module, key) if ( in...
mozilla/kitsune
[ 1110, 779, 1110, 26, 1264532037 ]
def index_object(doc_type_name, obj_id): """Index an ORM object given an object id and a document type name.""" doc_type = next(cls for cls in get_doc_types() if cls.__name__ == doc_type_name) model = doc_type.get_model() try: obj = model.objects.get(pk=obj_id) except model.DoesNotExist: ...
mozilla/kitsune
[ 1110, 779, 1110, 26, 1264532037 ]
def index_objects_bulk( doc_type_name, obj_ids, timeout=settings.ES_BULK_DEFAULT_TIMEOUT, elastic_chunk_size=settings.ES_DEFAULT_ELASTIC_CHUNK_SIZE,
mozilla/kitsune
[ 1110, 779, 1110, 26, 1264532037 ]
def remove_from_field(doc_type_name, field_name, field_value): """Remove a value from all documents in the doc_type's index.""" doc_type = next(cls for cls in get_doc_types() if cls.__name__ == doc_type_name) script = ( f"if (ctx._source.{field_name}.contains(params.value)) {{" f"ctx._sourc...
mozilla/kitsune
[ 1110, 779, 1110, 26, 1264532037 ]
def extractWwwTccedwardsCom(item): ''' Parser for 'www.tccedwards.com' ''' vol, chp, frag, postfix = extractVolChapterFragmentPostfix(item['title']) if not (chp or vol) or "preview" in item['title'].lower(): return None tagmap = [ ('PRC', 'PRC', 'translated'), ('Loiterous', 'Loi...
fake-name/ReadableWebProxy
[ 191, 16, 191, 3, 1437712243 ]
def balance(user): return int(user.kv.stickers.currency.get() or 0)
canvasnetworks/canvas
[ 56, 15, 56, 3, 1447125133 ]
def publish_balance(user): user.redis.coin_channel.publish({'balance': balance(user)})
canvasnetworks/canvas
[ 56, 15, 56, 3, 1447125133 ]
def debit(user, amount): _adjust_balance(user, -amount)
canvasnetworks/canvas
[ 56, 15, 56, 3, 1447125133 ]
def credit_quest_of_the_day_completion(user): credit(user, knobs.REWARDS['quest_of_the_day'])
canvasnetworks/canvas
[ 56, 15, 56, 3, 1447125133 ]
def credit_personal_share(user): credit(user, knobs.REWARDS['personal_share'])
canvasnetworks/canvas
[ 56, 15, 56, 3, 1447125133 ]
def credit_star(user): user.kv.stickers_received.increment(1) credit(user, knobs.REWARDS['star'])
canvasnetworks/canvas
[ 56, 15, 56, 3, 1447125133 ]
def hide_comment(request, comment_id): comment = get_object_or_404(Comment, pk=comment_id) request.user.redis.hidden_comments.hide_comment(comment) Metrics.downvote_action.record(request, comment=comment.id) Metrics.hide_comment.record(request)
canvasnetworks/canvas
[ 56, 15, 56, 3, 1447125133 ]
def get_scan_types(self): return ["Meterian Scan"]
rackerlabs/django-DefectDojo
[ 2681, 1254, 2681, 272, 1424368427 ]
def get_description_for_scan_types(self, scan_type): return "Meterian JSON report output file can be imported."
rackerlabs/django-DefectDojo
[ 2681, 1254, 2681, 272, 1424368427 ]
def get_security_reports(self, report_json): if "reports" in report_json: if "security" in report_json["reports"]: if "reports" in report_json["reports"]["security"]: return report_json["reports"]["security"]["reports"] raise ValueError("Malformed report:...
rackerlabs/django-DefectDojo
[ 2681, 1254, 2681, 272, 1424368427 ]
def get_severity(self, advisory): # Following the CVSS Scoring per https://nvd.nist.gov/vuln-metrics/cvss if 'cvss' in advisory: if advisory['cvss'] <= 3.9: severity = "Low" elif advisory['cvss'] >= 4.0 and advisory['cvss'] <= 6.9: severity = "Medi...
rackerlabs/django-DefectDojo
[ 2681, 1254, 2681, 272, 1424368427 ]
def __init__(self): super(MessageNode, self).__init__() # Valid after EndParsing, this is the MessageClique that contains the # source message and any translations of it that have been loaded. self.clique = None # We don't send leading and trailing whitespace into the translation # console, but...
endlessm/chromium-browser
[ 21, 16, 21, 3, 1435959644 ]
def _IsValidAttribute(self, name, value): if name not in ['name', 'offset', 'translateable', 'desc', 'meaning', 'internal_comment', 'shortcut_groups', 'custom_type', 'validation_expr', 'use_name_for_id', 'sub_variable', 'formatter_data']: return Fals...
endlessm/chromium-browser
[ 21, 16, 21, 3, 1435959644 ]
def MandatoryAttributes(self): return ['name|offset']
endlessm/chromium-browser
[ 21, 16, 21, 3, 1435959644 ]
def HandleAttribute(self, attrib, value): base.ContentNode.HandleAttribute(self, attrib, value) if attrib != 'formatter_data': return # Parse value, a space-separated list of defines, into a dict. # Example: "foo=5 bar" -> {'foo':'5', 'bar':''} for item in value.split(): name, _, val = ...
endlessm/chromium-browser
[ 21, 16, 21, 3, 1435959644 ]
def IsTranslateable(self): return self.attrs['translateable'] == 'true'
endlessm/chromium-browser
[ 21, 16, 21, 3, 1435959644 ]
def InstallMessage(self, message): '''Sets this node's clique from a tclib.Message instance. Args: message: A tclib.Message. ''' self.clique = self.UberClique().MakeClique(message, self.IsTranslateable()) for group in self.shortcut_groups_: self.clique.AddToShortcutGroup(group) if s...
endlessm/chromium-browser
[ 21, 16, 21, 3, 1435959644 ]
def GetCliques(self): return [self.clique] if self.clique else []
endlessm/chromium-browser
[ 21, 16, 21, 3, 1435959644 ]
def NameOrOffset(self): key = 'name' if 'name' in self.attrs else 'offset' return self.attrs[key]
endlessm/chromium-browser
[ 21, 16, 21, 3, 1435959644 ]
def GetDataPackValue(self, lang, encoding): '''Returns a str represenation for a data_pack entry.''' message = self.ws_at_start + self.Translate(lang) + self.ws_at_end return util.Encode(message, encoding)
endlessm/chromium-browser
[ 21, 16, 21, 3, 1435959644 ]
def Construct(parent, message, name, desc='', meaning='', translateable=True): '''Constructs a new message node that is a child of 'parent', with the name, desc, meaning and translateable attributes set using the same-named parameters and the text of the message and any placeholders taken from 'message'...
endlessm/chromium-browser
[ 21, 16, 21, 3, 1435959644 ]
def _IsValidChild(self, child): return isinstance(child, ExNode)
endlessm/chromium-browser
[ 21, 16, 21, 3, 1435959644 ]
def EndParsing(self): super(PhNode, self).EndParsing() # We only allow a single example for each placeholder if len(self.children) > 1: raise exception.TooManyExamples()
endlessm/chromium-browser
[ 21, 16, 21, 3, 1435959644 ]
def create(kernel): result = Tangible() result.template = "object/tangible/ship/components/engine/shared_eng_moncal_ifs32.iff" result.attribute_template_id = 8 result.stfName("space/space_item","eng_moncal_ifs32_n")
anhstudios/swganh
[ 62, 37, 62, 37, 1297996365 ]
def create(kernel): result = Static() result.template = "object/static/structure/tatooine/shared_planter_hanging_style_01.iff" result.attribute_template_id = -1 result.stfName("obj_n","unknown_object")
anhstudios/swganh
[ 62, 37, 62, 37, 1297996365 ]
def create(kernel): result = Tangible() result.template = "object/tangible/powerup/weapon/fs_quest_sad/shared_melee_speed_quest.iff" result.attribute_template_id = -1 result.stfName("powerup_n","weapon_melee_speed_quest")
anhstudios/swganh
[ 62, 37, 62, 37, 1297996365 ]
def create(kernel): result = Creature() result.template = "object/mobile/shared_dressed_sean_trenwell.iff" result.attribute_template_id = 9 result.stfName("npc_name","sean_trenwell")
anhstudios/swganh
[ 62, 37, 62, 37, 1297996365 ]
def create(kernel): result = Static() result.template = "object/static/structure/general/shared_fountain_generic_style_1.iff" result.attribute_template_id = -1 result.stfName("obj_n","unknown_object")
anhstudios/swganh
[ 62, 37, 62, 37, 1297996365 ]
def collect(self): return []
cloudera/hue
[ 804, 271, 804, 38, 1277149611 ]
def setUp(self): self.asn1Spec = rfc5280.Certificate()
etingof/pyasn1-modules
[ 38, 39, 38, 8, 1456353005 ]
def testOpenTypes(self): substrate = pem.readBase64fromText(self.cert_pem_text) asn1Object, rest = der_decoder( substrate, asn1Spec=self.asn1Spec, decodeOpenTypes=True) self.assertFalse(rest) self.assertTrue(asn1Object.prettyPrint()) self.assertEqual(substrate, der_e...
etingof/pyasn1-modules
[ 38, 39, 38, 8, 1456353005 ]
def __init__(self, specification, other_id=None, other_valid=None, other_valid_pair=None, other_index=None): self._is_broadcast = specification == "rssi_broadcast" self._other_valid = other_valid self._other_id = other_id self._other_index = other_index self._oth...
timvandermeij/mobile-radio-tomography
[ 4, 1, 4, 4, 1442839964 ]
def is_broadcast(self): """ Whether the RSSI packet is a measurement broadcast packet, or that it is sent to the ground station. """ return self._is_broadcast
timvandermeij/mobile-radio-tomography
[ 4, 1, 4, 4, 1442839964 ]
def other_id(self): """ RF sensor ID of the other sensor. """ return self._other_id
timvandermeij/mobile-radio-tomography
[ 4, 1, 4, 4, 1442839964 ]
def other_valid(self): """ Whether the location of the other sensor is valid. """ return self._other_valid
timvandermeij/mobile-radio-tomography
[ 4, 1, 4, 4, 1442839964 ]
def other_valid_pair(self): """ Whether the other sensor has received a valid measurement from the current sensor. """ return self._other_valid_pair
timvandermeij/mobile-radio-tomography
[ 4, 1, 4, 4, 1442839964 ]
def other_index(self): """ The waypoint index of the other sensor. """ return self._other_index
timvandermeij/mobile-radio-tomography
[ 4, 1, 4, 4, 1442839964 ]
def __init__(self, arguments, thread_manager, location_callback, receive_callback, valid_callback): """ Initialize the RF sensor. The `arguments` parameter is used to load settings for a specific RF sensor type. The sensor has a `thread_manager`, which is a `Thread_Mana...
timvandermeij/mobile-radio-tomography
[ 4, 1, 4, 4, 1442839964 ]
def id(self): """ Get the ID of the RF sensor. """ return self._id
timvandermeij/mobile-radio-tomography
[ 4, 1, 4, 4, 1442839964 ]
def number_of_sensors(self): """ Get the number of sensors in the network. """ return self._number_of_sensors
timvandermeij/mobile-radio-tomography
[ 4, 1, 4, 4, 1442839964 ]
def buffer(self): """ Get the buffer of the RF sensor. """ return self._buffer
timvandermeij/mobile-radio-tomography
[ 4, 1, 4, 4, 1442839964 ]
def buffer(self, buffer): """ Set the buffer. The `buffer` argument must be a `Buffer` object. """ if not isinstance(buffer, Buffer): raise ValueError("The `buffer` argument must be a `Buffer` object") self._buffer = buffer
timvandermeij/mobile-radio-tomography
[ 4, 1, 4, 4, 1442839964 ]
def type(self): raise NotImplementedError("Subclasses must implement the `type` property")
timvandermeij/mobile-radio-tomography
[ 4, 1, 4, 4, 1442839964 ]
def identity(self): """ Get the identity of the RF sensor, consisting of its ID, address and network join status. Classes that inherit this base class may extend this property. """ return { "id": self._id, "address": self._address, "j...
timvandermeij/mobile-radio-tomography
[ 4, 1, 4, 4, 1442839964 ]
def deactivate(self): """ Deactivate the sensor to stop sending and receiving packets. Classes that inherit this base class may extend this method. """ super(RF_Sensor, self).deactivate() if self._activated: self._activated = False if self._connect...
timvandermeij/mobile-radio-tomography
[ 4, 1, 4, 4, 1442839964 ]
def stop(self): """ Stop the signal strength measurements (and start sending custom packets). """ self._started = False # Reset the scheduler timestamp so that it updates correctly in case we # restart the sensor measurements. self._scheduler.timestamp = 0
timvandermeij/mobile-radio-tomography
[ 4, 1, 4, 4, 1442839964 ]
def discover(self, callback, required_sensors=None): """ Discover RF sensors in the network. The `callback` callable function is called when an RF sensor reports its identity. The `required_sensors` set indicates which sensors should be discovered; if it is not provided, then all...
timvandermeij/mobile-radio-tomography
[ 4, 1, 4, 4, 1442839964 ]
def _loop(self): """ Execute the sensor loop. This runs in a separate thread. """ try: while self._activated: self._loop_body() except DisabledException: return except: super(RF_Sensor, self).interrupt()
timvandermeij/mobile-radio-tomography
[ 4, 1, 4, 4, 1442839964 ]
def _send(self): """ Send a broadcast packet to each other sensor in the network and send collected packets to the ground station. Classes that inherit this base class may extend this method. """ # Create and send the RSSI broadcast packets. for to_id in xrange(...
timvandermeij/mobile-radio-tomography
[ 4, 1, 4, 4, 1442839964 ]
def _send_tx_frame(self, packet, to=None): """ Send a TX frame with `packet` as payload `to` another sensor. Classes that inherit this base class must extend this method. """ if self._connection is None: raise DisabledException if not isinstance(packet, Pac...
timvandermeij/mobile-radio-tomography
[ 4, 1, 4, 4, 1442839964 ]
def _create_rssi_broadcast_packet(self, to_id): """ Create a `Packet` object according to the "rssi_broadcast" specification. The resulting packet is complete. """ location, waypoint_index = self._location_callback() request = RSSI_Validity_Request("rssi_broadcast", othe...
timvandermeij/mobile-radio-tomography
[ 4, 1, 4, 4, 1442839964 ]
def __init__(self, epw_file=None, output_wea_file=None): RadianceCommand.__init__(self) self.epw_file = epw_file """The path of the epw file that is to be converted to a wea file.""" self.output_wea_file = output_wea_file """The path of the output wea file. Note that this path...
ladybug-analysis-tools/honeybee
[ 90, 26, 90, 38, 1451000618 ]
def epw_file(self): return self._epw_file
ladybug-analysis-tools/honeybee
[ 90, 26, 90, 38, 1451000618 ]
def epw_file(self, value): """The path of the epw file that is to be converted to a wea file.""" if value: self._epw_file = value if not self.output_wea_file._value: self.output_wea_file = os.path.splitext(value)[0] + '.wea' else: self._epw_fil...
ladybug-analysis-tools/honeybee
[ 90, 26, 90, 38, 1451000618 ]
def main(): parser = argparse.ArgumentParser( description='Run swarming_xcode_install on the bots.') parser.add_argument('--luci_path', required=True, type=os.path.abspath) parser.add_argument('--swarming-server', required=True, type=str) parser.add_argument('--isolate-server', required=True, type=str) ...
endlessm/chromium-browser
[ 21, 16, 21, 3, 1435959644 ]
def test_basic_parse(self): events = list(self.backend.basic_parse(BytesIO(JSON))) self.assertEqual(events, JSON_EVENTS)
catapult-project/catapult
[ 1835, 570, 1835, 1039, 1429033745 ]
def test_scalar(self): events = list(self.backend.basic_parse(BytesIO(SCALAR_JSON))) self.assertEqual(events, [('number', 0)])
catapult-project/catapult
[ 1835, 570, 1835, 1039, 1429033745 ]
def test_surrogate_pairs(self): event = next(self.backend.basic_parse(BytesIO(SURROGATE_PAIRS_JSON))) parsed_string = event[1] self.assertEqual(parsed_string, '💩')
catapult-project/catapult
[ 1835, 570, 1835, 1039, 1429033745 ]
def test_invalid(self): for json in INVALID_JSONS: # Yajl1 doesn't complain about additional data after the end # of a parsed object. Skipping this test. if self.__class__.__name__ == 'YajlParse' and json == YAJL1_PASSING_INVALID: continue with sel...
catapult-project/catapult
[ 1835, 570, 1835, 1039, 1429033745 ]
def test_utf8_split(self): buf_size = JSON.index(b'\xd1') + 1 try: events = list(self.backend.basic_parse(BytesIO(JSON), buf_size=buf_size)) except UnicodeDecodeError: self.fail('UnicodeDecodeError raised')
catapult-project/catapult
[ 1835, 570, 1835, 1039, 1429033745 ]
def test_boundary_lexeme(self): buf_size = JSON.index(b'false') + 1 events = list(self.backend.basic_parse(BytesIO(JSON), buf_size=buf_size)) self.assertEqual(events, JSON_EVENTS)
catapult-project/catapult
[ 1835, 570, 1835, 1039, 1429033745 ]
def test_api(self): self.assertTrue(list(self.backend.items(BytesIO(JSON), ''))) self.assertTrue(list(self.backend.parse(BytesIO(JSON))))
catapult-project/catapult
[ 1835, 570, 1835, 1039, 1429033745 ]
def test_object_builder(self): builder = common.ObjectBuilder() for event, value in basic_parse(BytesIO(JSON)): builder.event(event, value) self.assertEqual(builder.value, { 'docs': [ { 'string': 'строка - тест', 'null...
catapult-project/catapult
[ 1835, 570, 1835, 1039, 1429033745 ]
def test_parse(self): events = common.parse(basic_parse(BytesIO(JSON))) events = [value for prefix, event, value in events if prefix == 'docs.item.meta.item.item' ] self.assertEqual(events, [1])
catapult-project/catapult
[ 1835, 570, 1835, 1039, 1429033745 ]
def test_bytes(self): l = Lexer(BytesIO(JSON)) self.assertEqual(next(l)[1], '{')
catapult-project/catapult
[ 1835, 570, 1835, 1039, 1429033745 ]
def _AsLong(array): """Casts arrays elements to long type. Used to convert from numpy tf.""" return [int(x) for x in array]
tensorflow/tensorflow
[ 171949, 87931, 171949, 2300, 1446859160 ]
def _TestCase(self, shape, indices, scatter_op=state_ops.scatter_add): """Run a random test case with the given shape and indices. Args: shape: Shape of the parameters array. indices: One-dimensional array of ints, the indices of the last dimension of the parameters to update. ...
tensorflow/tensorflow
[ 171949, 87931, 171949, 2300, 1446859160 ]
def testNoRepetitions(self): self._TestCase([2, 2], [1]) self._TestCase([4, 4, 4], [2, 0]) self._TestCase([43, 20, 10, 10], [42, 5, 6, 1, 3, 5, 7, 9])
tensorflow/tensorflow
[ 171949, 87931, 171949, 2300, 1446859160 ]
def testWithRepetitions(self): self._TestCase([2, 2], [1, 1]) self._TestCase([5, 3, 9, 5], [2, 0, 4, 1, 3, 1, 4, 0, 4, 3]) self._TestCase([32, 4, 4], [31] * 8)
tensorflow/tensorflow
[ 171949, 87931, 171949, 2300, 1446859160 ]