function
stringlengths
11
56k
repo_name
stringlengths
5
60
features
list
def test_one(self, f, foo): self._test(f, foo)
FFMG/myoddweb.piger
[ 16, 2, 16, 2, 1456065110 ]
def test_patch_multiple_create(self): patcher = patch.multiple(Foo, blam='blam') self.assertRaises(AttributeError, patcher.start) patcher = patch.multiple(Foo, blam='blam', create=True) patcher.start() try: self.assertEqual(Foo.blam, 'blam') finally: ...
FFMG/myoddweb.piger
[ 16, 2, 16, 2, 1456065110 ]
def test_patch_multiple_new_callable(self): class Thing(object): pass patcher = patch.multiple( Foo, f=DEFAULT, g=DEFAULT, new_callable=Thing ) result = patcher.start() try: self.assertIs(Foo.f, result['f']) self.assertIs(Foo.g, re...
FFMG/myoddweb.piger
[ 16, 2, 16, 2, 1456065110 ]
def thing1(): pass
FFMG/myoddweb.piger
[ 16, 2, 16, 2, 1456065110 ]
def thing2(): pass
FFMG/myoddweb.piger
[ 16, 2, 16, 2, 1456065110 ]
def thing3(): pass
FFMG/myoddweb.piger
[ 16, 2, 16, 2, 1456065110 ]
def test_new_callable_failure(self): original_f = Foo.f original_g = Foo.g original_foo = Foo.foo def crasher(): raise NameError('crasher') @patch.object(Foo, 'g', 1) @patch.object(Foo, 'foo', new_callable=crasher) @patch.object(Foo, 'f', 1) ...
FFMG/myoddweb.piger
[ 16, 2, 16, 2, 1456065110 ]
def func(): pass
FFMG/myoddweb.piger
[ 16, 2, 16, 2, 1456065110 ]
def test_patch_multiple_new_callable_failure(self): original_f = Foo.f original_g = Foo.g original_foo = Foo.foo def crasher(): raise NameError('crasher') patcher = patch.object(Foo, 'f', 1) patcher.attribute_name = 'f' good = patch.object(Foo, 'g',...
FFMG/myoddweb.piger
[ 16, 2, 16, 2, 1456065110 ]
def test(): self.assertEqual(foo.fish, 'nearly gone')
FFMG/myoddweb.piger
[ 16, 2, 16, 2, 1456065110 ]
def test_patch_test_prefix(self): class Foo(object): thing = 'original' def foo_one(self): return self.thing def foo_two(self): return self.thing def test_one(self): return self.thing def test_two(self):...
FFMG/myoddweb.piger
[ 16, 2, 16, 2, 1456065110 ]
def test_patch_dict_test_prefix(self): class Foo(object): def bar_one(self): return dict(the_dict) def bar_two(self): return dict(the_dict) def test_one(self): return dict(the_dict) def test_two(self): ...
FFMG/myoddweb.piger
[ 16, 2, 16, 2, 1456065110 ]
def test_patch_nested_autospec_repr(self): with patch('unittest.test.testmock.support', autospec=True) as m: self.assertIn(" name='support.SomeClass.wibble()'", repr(m.SomeClass.wibble())) self.assertIn(" name='support.SomeClass().wibble()'", ...
FFMG/myoddweb.piger
[ 16, 2, 16, 2, 1456065110 ]
def test_patch_imports_lazily(self): p1 = patch('squizz.squozz') self.assertRaises(ImportError, p1.start) with uncache('squizz'): squizz = Mock() sys.modules['squizz'] = squizz squizz.squozz = 6 p1 = patch('squizz.squozz') squizz.squo...
FFMG/myoddweb.piger
[ 16, 2, 16, 2, 1456065110 ]
def __exit__(self, etype=None, val=None, tb=None): _patch.__exit__(self, etype, val, tb) holder.exc_info = etype, val, tb
FFMG/myoddweb.piger
[ 16, 2, 16, 2, 1456065110 ]
def with_custom_patch(target): getter, attribute = _get_target(target) return custom_patch( getter, attribute, DEFAULT, None, False, None, None, None, {} )
FFMG/myoddweb.piger
[ 16, 2, 16, 2, 1456065110 ]
def test(mock): raise RuntimeError
FFMG/myoddweb.piger
[ 16, 2, 16, 2, 1456065110 ]
def test_create_and_specs(self): for kwarg in ('spec', 'spec_set', 'autospec'): p = patch('%s.doesnotexist' % __name__, create=True, **{kwarg: True}) self.assertRaises(TypeError, p.start) self.assertRaises(NameError, lambda: doesnotexist) # ...
FFMG/myoddweb.piger
[ 16, 2, 16, 2, 1456065110 ]
def test_specs_false_instead_of_none(self): p = patch(MODNAME, spec=False, spec_set=False, autospec=False) mock = p.start() try: # no spec should have been set, so attribute access should not fail mock.does_not_exist mock.does_not_exist = 3 finally: ...
FFMG/myoddweb.piger
[ 16, 2, 16, 2, 1456065110 ]
def test_spec_set_true(self): for kwarg in ('spec', 'autospec'): p = patch(MODNAME, spec_set=True, **{kwarg: True}) m = p.start() try: self.assertRaises(AttributeError, setattr, m, 'doesnotexist', 'something') ...
FFMG/myoddweb.piger
[ 16, 2, 16, 2, 1456065110 ]
def test_not_callable_spec_as_list(self): spec = ('foo', 'bar') p = patch(MODNAME, spec=spec) m = p.start() try: self.assertFalse(callable(m)) finally: p.stop()
FFMG/myoddweb.piger
[ 16, 2, 16, 2, 1456065110 ]
def patched(mock_path): patch.stopall() self.assertIs(os.path, mock_path) self.assertIs(os.unlink, unlink) self.assertIs(os.chdir, chdir)
FFMG/myoddweb.piger
[ 16, 2, 16, 2, 1456065110 ]
def test_stopall_lifo(self): stopped = [] class thing(object): one = two = three = None def get_patch(attribute): class mypatch(_patch): def stop(self): stopped.append(attribute) return super(mypatch, self).stop() ...
FFMG/myoddweb.piger
[ 16, 2, 16, 2, 1456065110 ]
def foo(x=0): """TEST""" return x
FFMG/myoddweb.piger
[ 16, 2, 16, 2, 1456065110 ]
def foo(*a, x=0): return x
FFMG/myoddweb.piger
[ 16, 2, 16, 2, 1456065110 ]
def __init__(self, name, dependency): self.name = name self.id = 1 self.dependency = dependency self.plan_version = "v0.10" self.success = False self.start_date = datetime.datetime.now().strftime("%I:%M%p %d-%B-%Y") self.resources = [] self.constraint = []...
acutesoftware/AIKIF
[ 54, 13, 54, 10, 1378213987 ]
def __str__(self): res = "---== Plan ==---- \n" res += "name : " + self.name + "\n" res += "version : " + self.plan_version + "\n" for i in self.beliefs.list(): res += "belief : " + i + "\n" for i in self.desires.list(): res += "desire ...
acutesoftware/AIKIF
[ 54, 13, 54, 10, 1378213987 ]
def get_name(self): return self.name
acutesoftware/AIKIF
[ 54, 13, 54, 10, 1378213987 ]
def generate_plan(self): """ Main logic in class which generates a plan """ print("generating plan... TODO")
acutesoftware/AIKIF
[ 54, 13, 54, 10, 1378213987 ]
def load_plan(self, fname): """ read the list of thoughts from a text file """ with open(fname, "r") as f: for line in f: if line != '': tpe, txt = self.parse_plan_from_string(line) #print('tpe= "' + tpe + '"', txt) ...
acutesoftware/AIKIF
[ 54, 13, 54, 10, 1378213987 ]
def save_plan(self, fname):
acutesoftware/AIKIF
[ 54, 13, 54, 10, 1378213987 ]
def parse_plan_from_string(self, line): tpe = '' txt = '' if line != '': if line[0:1] != '#': parts = line.split(":") tpe = parts[0].strip() txt = parts[1].strip() return tpe, txt
acutesoftware/AIKIF
[ 54, 13, 54, 10, 1378213987 ]
def add_resource(self, name, tpe): """ add a resource available for the plan. These are text strings of real world objects mapped to an ontology key or programs from the toolbox section (can also be external programs) """ self.resources.append([name, tpe])
acutesoftware/AIKIF
[ 54, 13, 54, 10, 1378213987 ]
def add_constraint(self, name, tpe, val): """ adds a constraint for the plan """ self.constraint.append([name, tpe, val])
acutesoftware/AIKIF
[ 54, 13, 54, 10, 1378213987 ]
def __init__(self, thought_type): #print("Thoughts - init: thought_type = " + thought_type + "\n") self._thoughts = [] self._type = thought_type
acutesoftware/AIKIF
[ 54, 13, 54, 10, 1378213987 ]
def __str__(self): res = ' -- Thoughts --\n' for i in self._thoughts: res += i + '\n' return res
acutesoftware/AIKIF
[ 54, 13, 54, 10, 1378213987 ]
def add(self, name): self._thoughts.append(name)
acutesoftware/AIKIF
[ 54, 13, 54, 10, 1378213987 ]
def list(self, print_console=False): lst = [] for i, thought in enumerate(self._thoughts): if print_console is True: print(self._type + str(i) + ' = ' + thought) lst.append(thought) return lst
acutesoftware/AIKIF
[ 54, 13, 54, 10, 1378213987 ]
def __init__(self, parent_plan): self.parent_plan = parent_plan super(Beliefs, self).__init__('belief')
acutesoftware/AIKIF
[ 54, 13, 54, 10, 1378213987 ]
def __init__(self, parent_plan): self.parent_plan = parent_plan super(Desires, self).__init__('desire')
acutesoftware/AIKIF
[ 54, 13, 54, 10, 1378213987 ]
def __init__(self, parent_plan): self.parent_plan = parent_plan super(Intentions, self).__init__('intention')
acutesoftware/AIKIF
[ 54, 13, 54, 10, 1378213987 ]
def TEST(): myplan = Plan_BDI('new plan', '') myplan.beliefs.add('belief0') myplan.beliefs.add('belief1') myplan.beliefs.add('belief2') myplan.desires.add('desire0') myplan.desires.add('desire1') myplan.intentions.add('intention0') myplan.beliefs.list() myplan.desires.list() ...
acutesoftware/AIKIF
[ 54, 13, 54, 10, 1378213987 ]
def __init__(self, parent=None, id=wx.ID_ANY, project=None, localRoot="", *args, **kwargs): wx.Dialog.__init__(self, parent, id, *args, **kwargs) panel = wx.Panel(self, wx.ID_ANY, style=wx.TAB_TRAVERSAL) # when a project is successfully created these ...
psychopy/psychopy
[ 1370, 772, 1370, 229, 1283360404 ]
def submitChanges(self, evt=None): session = pavlovia.getCurrentSession() if not session.user: user = logInPavlovia(parent=self.parent) if not session.user: return # get current values name = self.nameBox.GetValue() namespace = self.groupBox.GetStr...
psychopy/psychopy
[ 1370, 772, 1370, 229, 1283360404 ]
def __init__(self, parent, iconCache, value=False): wx.Button.__init__(self, parent, label=_translate("Star")) # Setup icons self.icons = { True: iconCache.getBitmap(name="starred", size=16), False: iconCache.getBitmap(name="unstarred", size=16), ...
psychopy/psychopy
[ 1370, 772, 1370, 229, 1283360404 ]
def value(self): return self._value
psychopy/psychopy
[ 1370, 772, 1370, 229, 1283360404 ]
def value(self, value): # Store value self._value = bool(value) # Change icon self.SetBitmap(self.icons[self._value]) self.SetBitmapCurrent(self.icons[self._value]) self.SetBitmapFocus(self.icons[self._value])
psychopy/psychopy
[ 1370, 772, 1370, 229, 1283360404 ]
def __init__(self, parent, project=None, size=(650, 550), style=wx.NO_BORDER): wx.Panel.__init__(self, parent, -1, size=size, style=style) self.SetBackgroundColour("white") iconCache = parent.app.iconCache ...
psychopy/psychopy
[ 1370, 772, 1370, 229, 1283360404 ]
def project(self): return self._project
psychopy/psychopy
[ 1370, 772, 1370, 229, 1283360404 ]
def project(self, project): self._project = project # Populate fields if project is None: # Icon self.icon.SetBitmap(wx.Bitmap()) self.icon.SetBackgroundColour("#f2f2f2") self.icon.Disable() # Title self.title.SetValue("") ...
psychopy/psychopy
[ 1370, 772, 1370, 229, 1283360404 ]
def session(self): # Cache session if not cached if not hasattr(self, "_session"): self._session = pavlovia.getCurrentSession() # Return cached session return self._session
psychopy/psychopy
[ 1370, 772, 1370, 229, 1283360404 ]
def sync(self, evt=None): # If not synced locally, choose a folder if not self.localRoot.GetValue(): self.localRoot.browse() # If cancelled, return if not self.localRoot.GetValue(): return self.project.localRoot = self.localRoot.GetValue() # Enable...
psychopy/psychopy
[ 1370, 772, 1370, 229, 1283360404 ]
def star(self, evt=None): # Toggle button self.starBtn.toggle() # Star/unstar project self.updateProject(evt) # todo: Refresh stars count
psychopy/psychopy
[ 1370, 772, 1370, 229, 1283360404 ]
def __init__(self, app, parent=None, style=None, pos=wx.DefaultPosition, project=None): if style is None: style = (wx.DEFAULT_DIALOG_STYLE | wx.CENTER | wx.TAB_TRAVERSAL | wx.RESIZE_BORDER) if project: title = project['name'] else: ...
psychopy/psychopy
[ 1370, 772, 1370, 229, 1283360404 ]
def __init__(self, project, *args, **kwargs): wx.Dialog.__init__(self, *args, **kwargs) existingName = project.name session = pavlovia.getCurrentSession() groups = [session.user['username']] groups.extend(session.listUserGroups()) msg = wx.StaticText(self, label="Where s...
psychopy/psychopy
[ 1370, 772, 1370, 229, 1283360404 ]
def __init__(self, project, parent, *args, **kwargs): wx.Dialog.__init__(self, parent, *args, **kwargs) self.parent = parent self.project = project existingName = project.name msgText = _translate("points to a remote that doesn't exist (deleted?).") msgText += (" "+_trans...
psychopy/psychopy
[ 1370, 772, 1370, 229, 1283360404 ]
def get_ordering(self, request, queryset): if self.model_admin.sortable_is_enabled(): return [self.model_admin.sortable, '-' + self.model._meta.pk.name] return super(SortableChangeList, self).get_ordering(request, queryset)
82Flex/DCRM
[ 226, 97, 226, 5, 1485696947 ]
def __init__(self, *args, **kwargs): super(SortableTabularInlineBase, self).__init__(*args, **kwargs) self.ordering = (self.sortable,) self.fields = self.fields or [] if self.fields and self.sortable not in self.fields: self.fields = list(self.fields) + [self.sortable]
82Flex/DCRM
[ 226, 97, 226, 5, 1485696947 ]
def __init__(self, *args, **kwargs): super(SortableStackedInlineBase, self).__init__(*args, **kwargs) self.ordering = (self.sortable,)
82Flex/DCRM
[ 226, 97, 226, 5, 1485696947 ]
def formfield_for_dbfield(self, db_field, **kwargs): if db_field.name == self.sortable: kwargs['widget'] = deepcopy(SortableListForm.Meta.widgets['order']) kwargs['widget'].attrs['class'] += ' suit-sortable-stacked' kwargs['widget'].attrs['rowclass'] = ' suit-sortable-stacked...
82Flex/DCRM
[ 226, 97, 226, 5, 1485696947 ]
def __init__(self, *args, **kwargs): super(SortableModelAdmin, self).__init__(*args, **kwargs) # Keep originals for restore self._original_ordering = copy(self.ordering) self._original_list_display = copy(self.list_display) self._original_list_editable = copy(self.list_editable)...
82Flex/DCRM
[ 226, 97, 226, 5, 1485696947 ]
def get_changelist_form(self, request, **kwargs): form = super(SortableModelAdmin, self).get_changelist_form(request, **kwargs) self.merge_form_meta(form) return form
82Flex/DCRM
[ 226, 97, 226, 5, 1485696947 ]
def enable_sortable(self): self.list_per_page = 500 self.ordering = (self.sortable,) if self.list_display and self.sortable not in self.list_display: self.list_display = list(self.list_display) + [self.sortable] self.list_editable = self.list_editable or [] if self.s...
82Flex/DCRM
[ 226, 97, 226, 5, 1485696947 ]
def sortable_is_enabled(self): return self.list_display and self.sortable in self.list_display
82Flex/DCRM
[ 226, 97, 226, 5, 1485696947 ]
def __init__(self): super(ConsultarLoteRpsEnvio, self).__init__() self.versao = TagDecimal(nome=u'ConsultarLoteRpsEnvio', propriedade=u'versao', namespace=NAMESPACE_NFSE, valor=u'1.00', raiz=u'/') self.Prestador = IdentificacaoPrestador() self.Protocolo = TagCaracter(nome=u'Protocolo', ...
thiagopena/PySIGNFe
[ 43, 35, 43, 4, 1480611950 ]
def get_xml(self): xml = XMLNFe.get_xml(self) xml += ABERTURA xml += u'<ConsultarLoteRpsEnvio xmlns="'+ NAMESPACE_NFSE + '">' xml += self.Prestador.xml.replace(ABERTURA, u'') xml += self.Protocolo.xml
thiagopena/PySIGNFe
[ 43, 35, 43, 4, 1480611950 ]
def set_xml(self, arquivo): if self._le_xml(arquivo): self.Prestador.xml = arquivo self.Protocolo.xml = arquivo
thiagopena/PySIGNFe
[ 43, 35, 43, 4, 1480611950 ]
def __init__(self): super(ConsultarLoteRpsResposta, self).__init__() self.CompNfse = [] self.ListaMensagemRetorno = ListaMensagemRetorno()
thiagopena/PySIGNFe
[ 43, 35, 43, 4, 1480611950 ]
def get_xml(self): xml = XMLNFe.get_xml(self) xml += ABERTURA xml += u'<ConsultarLoteRpsResposta xmlns="'+ NAMESPACE_NFSE + '">' if len(self.ListaMensagemRetorno.MensagemRetorno) != 0: xml += self.ListaMensagemRetorno.xml.replace(ABERTURA, u'') else: xml +...
thiagopena/PySIGNFe
[ 43, 35, 43, 4, 1480611950 ]
def set_xml(self, arquivo): if self._le_xml(arquivo): self.CompNfse = self.le_grupo('[nfse]//ConsultarLoteRpsResposta/CompNfse', CompNfse) self.ListaMensagemRetorno.xml = arquivo
thiagopena/PySIGNFe
[ 43, 35, 43, 4, 1480611950 ]
def __init__(self, id, page): self.id = id self.page = page
Splawik/pytigon
[ 6, 1, 6, 2, 1419597762 ]
def get_href(self): return self.page.attr("_href")
Splawik/pytigon
[ 6, 1, 6, 2, 1419597762 ]
def __init__(self, id, title, url, data=None): self.id = id self.title = jQuery.trim(title) self.url = url self.data = data
Splawik/pytigon
[ 6, 1, 6, 2, 1419597762 ]
def __init__(self): self.id = 0 self.titles = {} self.active_item = None
Splawik/pytigon
[ 6, 1, 6, 2, 1419597762 ]
def is_open(self, title): if self.titles and title in self.titles and self.titles[title]: return True else: return False
Splawik/pytigon
[ 6, 1, 6, 2, 1419597762 ]
def register(self, title): self.titles[title] = "$$$"
Splawik/pytigon
[ 6, 1, 6, 2, 1419597762 ]
def _on_show_tab(self, e): nonlocal menu_item window.ACTIVE_PAGE = Page(_id, jQuery("#" + _id), menu_item) menu = get_menu() menu_item = menu.titles[jQuery.trim(e.target.text)] self.active_item = menu_item if window.PUSH_STATE: his...
Splawik/pytigon
[ 6, 1, 6, 2, 1419597762 ]
def _on_button_click(self, event): get_menu().remove_page(jQuery(this).attr("id").replace("button_", ""))
Splawik/pytigon
[ 6, 1, 6, 2, 1419597762 ]
def _local_fun(index, element): eval(this.innerHTML)
Splawik/pytigon
[ 6, 1, 6, 2, 1419597762 ]
def remove_page(self, id): def _local_fun(index, value): if value and value.id == id: self.titles[index] = None jQuery.each(self.titles, _local_fun) remove_element(sprintf("#li_%s", id)) remove_element(sprintf("#%s", id)) last_a = jQuery("#tabs2 a:l...
Splawik/pytigon
[ 6, 1, 6, 2, 1419597762 ]
def on_menu_href(self, elem, data_or_html, title, title_alt=None, url=None): if window.APPLICATION_TEMPLATE == "modern": if self.is_open(title): self.activate(title) else: self.register(title) if url: href = url ...
Splawik/pytigon
[ 6, 1, 6, 2, 1419597762 ]
def __init__(self, fname=None): if not fname: fname = '/usr/share/dict/words' with open(fname) as f: self.repository = [x.rstrip('\n') for x in f.readlines()]
amitsaha/learning
[ 4, 4, 4, 20, 1413605035 ]
def find_close_matches(r, w, count=3): return difflib.get_close_matches(w, r.repository, count)
amitsaha/learning
[ 4, 4, 4, 20, 1413605035 ]
def create_update_Conv2d(c_in, c_out, k_size): kernel_scale = 1.0 / 3.0 if isinstance(k_size, list) or isinstance(k_size, tuple): bias_scale = c_out / (3.0 * c_in * k_size[0] * k_size[1]) else: bias_scale = c_out / (3.0 * c_in * k_size * k_size) return tf.keras.layers.Conv2D( filters=c_out, ...
google-research/google-research
[ 27788, 6881, 27788, 944, 1538678568 ]
def __init__(self, hidden_dim=128, input_dim=192 + 128, **kwargs): super(ConvGRU, self).__init__(**kwargs) self.convz = create_update_Conv2d( c_in=hidden_dim + input_dim, c_out=hidden_dim, k_size=3) self.convr = create_update_Conv2d( c_in=hidden_dim + input_dim, c_out=hidden_dim, k_size=3) ...
google-research/google-research
[ 27788, 6881, 27788, 944, 1538678568 ]
def __init__(self, hidden_dim=128, input_dim=192 + 128): super(SepConvGRU, self).__init__() self.convz1 = create_update_Conv2d( c_in=hidden_dim + input_dim, c_out=hidden_dim, k_size=(1, 5)) self.convr1 = create_update_Conv2d( c_in=hidden_dim + input_dim, c_out=hidden_dim, k_size=(1, 5)) ...
google-research/google-research
[ 27788, 6881, 27788, 944, 1538678568 ]
def __init__(self, hidden_dim=256, input_dim=128, **kwargs): super(FlowHead, self).__init__(**kwargs) self.conv1 = create_update_Conv2d( c_in=input_dim, c_out=hidden_dim, k_size=3) self.conv2 = create_update_Conv2d(c_in=hidden_dim, c_out=2, k_size=3)
google-research/google-research
[ 27788, 6881, 27788, 944, 1538678568 ]
def __init__(self, args, **kwargs): super(BasicMotionEncoder, self).__init__(**kwargs) cor_planes = args.corr_levels * (2 * args.corr_radius + 1)**2 self.convc1 = create_update_Conv2d(c_in=cor_planes, c_out=256, k_size=1) self.convc2 = create_update_Conv2d(c_in=256, c_out=192, k_size=3) self.convf1 ...
google-research/google-research
[ 27788, 6881, 27788, 944, 1538678568 ]
def __init__(self, args, **kwargs): super(SmallMotionEncoder, self).__init__(**kwargs) cor_planes = args.corr_levels * (2 * args.corr_radius + 1)**2 self.convc1 = create_update_Conv2d(c_in=cor_planes, c_out=96, k_size=1) self.convf1 = create_update_Conv2d(c_in=96, c_out=64, k_size=7) self.convf2 = c...
google-research/google-research
[ 27788, 6881, 27788, 944, 1538678568 ]
def __init__(self, args, hidden_dim=128, **kwargs): super(BasicUpdateBlock, self).__init__(**kwargs) self.args = args self.encoder = BasicMotionEncoder(args) self.gru = SepConvGRU(hidden_dim=hidden_dim, input_dim=128 + hidden_dim) self.flow_head = FlowHead(hidden_dim=256, input_dim=hidden_dim) ...
google-research/google-research
[ 27788, 6881, 27788, 944, 1538678568 ]
def __init__(self, args, hidden_dim=96, **kwargs): super(SmallUpdateBlock, self).__init__(**kwargs) self.encoder = SmallMotionEncoder(args) self.gru = ConvGRU(hidden_dim=hidden_dim, input_dim=82 + 64) self.flow_head = FlowHead(hidden_dim=128, input_dim=hidden_dim)
google-research/google-research
[ 27788, 6881, 27788, 944, 1538678568 ]
def sample_update_folder(): # Create a client client = resourcemanager_v3.FoldersClient() # Initialize request argument(s) folder = resourcemanager_v3.Folder() folder.parent = "parent_value" request = resourcemanager_v3.UpdateFolderRequest( folder=folder, ) # Make the request ...
googleapis/python-resource-manager
[ 22, 19, 22, 9, 1575936598 ]
def setUp(self): self.fd, self.path = tempfile.mkstemp()
rbuffat/pyidf
[ 20, 7, 20, 2, 1417292720 ]
def domaindownload():# this function downloads domain and website links from multible blacklisted website databases. if os.path.isfile("list/list1.txt")==True: print "Malicious website database from https://spyeyetracker.abuse.ch exists!\n" print "Continuing with the next list." else: print "Fetching list from:...
Masood-M/yalih
[ 66, 10, 66, 1, 1392605442 ]
def duplicateremover(): mylist=list() fopen2=open("list/malwebsites.txt","r") for line in fopen2: line=line.strip() if line.startswith("127.0.0.1"): line=line[10:] pass if line.startswith("#"): continue if line.find('#') == 1: continue
Masood-M/yalih
[ 66, 10, 66, 1, 1392605442 ]
def whitespace_split_with_indices( text: str) -> Tuple[List[str], List[int], List[int]]: """Whitespace splits a text into unigrams and returns indices mapping.""" if not isinstance(text, str): raise ValueError("The input text is not of unicode format.") unigrams = [] unigram_to_char_map = [] char_to_u...
google-research/google-research
[ 27788, 6881, 27788, 944, 1538678568 ]
def get_wordpiece_tokenized_text( text: str, tokenizer: tokenization.FullTokenizer) -> TokenizedText: """Gets WordPiece TokenizedText for a text with indices mapping.""" unigrams, _, chars_to_unigrams = whitespace_split_with_indices(text) tokens, unigrams_to_tokens, tokens_to_unigrams = ( wordpiece_toke...
google-research/google-research
[ 27788, 6881, 27788, 944, 1538678568 ]
def get_sentencepiece_tokenized_text( text: str, tokenizer: tokenization.FullTokenizer) -> TokenizedText: """Gets SentencePiece TokenizedText for a text with indices mapping.""" tokens = [six.ensure_text(tk, "utf-8") for tk in tokenizer.tokenize(text)] token_ids = tokenizer.convert_tokens_to_ids(tokens) cha...
google-research/google-research
[ 27788, 6881, 27788, 944, 1538678568 ]
def _improve_answer_span( doc_tokens: Sequence[str], unimproved_span: Tuple[int, int], orig_answer_text: str, tokenizer: tokenization.FullTokenizer,
google-research/google-research
[ 27788, 6881, 27788, 944, 1538678568 ]
def _convert_answer_spans(answer_unigram_spans: Sequence[Tuple[int, int]], unigram_to_token_map: Sequence[int], num_tokens: int) -> List[Tuple[int, int]]: """Converts answer unigram spans to token spans.""" answer_token_spans = [] for unigram_begin, unigram_end ...
google-research/google-research
[ 27788, 6881, 27788, 944, 1538678568 ]