Search is not available for this dataset
id
int64
0
10.8M
vector
listlengths
1.54k
1.54k
ast_depth
int64
3
164
ast_data
stringlengths
297
510k
full_path
stringlengths
0
319
code
stringlengths
60
56.5k
16,001
[ -0.004625449422746897, -0.003369881771504879, 0.015972061082720757, 0.0061197299510240555, 0.024640128016471863, 0.01708812080323696, 0.027157464995980263, 0.012747887521982193, -0.006063926964998245, 0.014248368330299854, 0.04045098274946213, -0.06339222192764282, -0.012933897785842419, -...
8
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []...
def __init__(self): _opener.OpenerDirector.__init__(self) ua_handlers = self._ua_handlers = {} for scheme in (self.default_schemes+ self.default_others+ self.default_features): klass = self.handler_classes[scheme] ua_handlers...
16,002
[ 0.0319780670106411, 0.033239103853702545, -0.006935718934983015, 0.014882649295032024, -0.017892489209771156, 0.03105013072490692, 0.0244356207549572, 0.022972337901592255, 0.04501673951745033, 0.05957818031311035, 0.024744931608438492, -0.012669880874454975, 0.026529422029852867, -0.01462...
8
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []...
def __init__(self): self.supports_check_mode = True argument_spec = dict( reset=dict( type='bool', default=False ), merge_content=dict(), verify=dict( type='bool', default=False ),...
16,003
[ -0.018956603482365608, 0.03415645658969879, 0.017884893342852592, 0.010094823315739632, -0.026550767943263054, -0.010647964663803577, 0.010037204250693321, -0.002232730621472001, 0.06255102902650833, 0.053700774908065796, 0.043052807450294495, -0.02800276316702366, 0.005773409269750118, 0....
11
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "name", "annotation": null, "type_comment": null}}, {"_type": "arg...
def _replace_handler(self, name, newhandler=None): # first, if handler was previously added, remove it if name is not None: handler = self._ua_handlers.get(name) if handler: try: self.handlers.remove(handler) except ValueError: ...
16,004
[ 0.026981284841895103, 0.02126830816268921, -0.022992225363850594, -0.025778554379940033, -0.02832433581352234, 0.0025858734734356403, 0.0025595638435333967, 0.002405463717877865, 0.05255938321352005, 0.040171246975660324, 0.02970747835934162, -0.01523460354655981, 0.012638707645237446, 0.0...
9
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "name", "annotation": null, "type_comment": null}}, {"_type": "arg...
def _set_handler(self, name, handle=None, obj=None, constructor_args=(), constructor_kwds={}): if handle is None: handle = obj is not None if handle: handler_class = self.handler_classes[name] if obj is not None: newhandler = handl...
16,005
[ 0.018203753978013992, -0.03032059222459793, -0.02348136156797409, -0.016357161104679108, 0.009546427056193352, -0.03574638441205025, -0.042790792882442474, -0.028154835104942322, -0.009734505787491798, 0.07235907018184662, 0.008492046035826206, -0.013085729442536831, 0.05480504035949707, 0...
8
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "For", "_fields": {"body": [{"_type": "Assert", "_fields": {"ms...
def test_to_list(): for scalar in ('string', 1, True, False, None): assert isinstance(to_list(scalar), list) for container in ([1, 2, 3], {'one': 1}): assert isinstance(to_list(container), list) test_list = [1, 2, 3] assert id(test_list) != id(to_list(test_list))
16,006
[ -0.048090558499097824, 0.02690727636218071, 0.019729750230908394, 0.02058609575033188, 0.044913068413734436, -0.02120581828057766, -0.01700296439230442, -0.01018600445240736, 0.015876194462180138, -0.004842295777052641, 0.029273495078086853, -0.007295838091522455, 0.004245107527822256, 0.0...
9
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "fullurl", "annotation": null, "type_comment": null}}, {"_type": "...
def open(self, fullurl, data=None, timeout=_sockettimeout._GLOBAL_DEFAULT_TIMEOUT): if self._seekable: def bound_open(fullurl, data=None, timeout=_sockettimeout._GLOBAL_DEFAULT_TIMEOUT): return UserAgentBase.open(self, fullurl, data, timeout) ...
16,007
[ 0.02907523512840271, 0.004049843177199364, -0.03393944725394249, -0.049214400351047516, -0.0028668048325926065, 0.016815654933452606, 0.04333772510290146, 0.02226313389837742, -0.022626299411058426, 0.0010165877174586058, -0.011082043871283531, -0.032706886529922485, 0.006702050566673279, ...
10
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"a...
def test_dict_merge(): base = dict(obj2=dict(), b1=True, b2=False, b3=False, one=1, two=2, three=3, obj1=dict(key1=1, key2=2), l1=[1, 3], l2=[1, 2, 3], l4=[4], nested=dict(n1=dict(n2=2))) other = dict(b1=True, b2=False, b3=True, b4=True, one=1, t...
16,008
[ 0.033524539321660995, 0.012976505793631077, -0.0166140329092741, -0.05341120436787605, 0.0054933493956923485, 0.047572918236255646, 0.03507533669471741, 0.0009293367620557547, 0.015120252035558224, 0.009817901067435741, -0.0034921395126730204, -0.030103668570518494, -0.0010597574291750789, ...
10
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"a...
def test_dict_diff(): base = dict(obj2=dict(), b1=True, b2=False, b3=False, one=1, two=2, three=3, obj1=dict(key1=1, key2=2), l1=[1, 3], l2=[1, 2, 3], l4=[4], nested=dict(n1=dict(n2=2))) other = dict(b1=True, b2=False, b3=True, b4=True, one=1, th...
16,009
[ 0.012053044512867928, 0.012585707008838654, 0.029655691236257553, 0.004595765378326178, 0.01786278560757637, 0.04382700100541115, 0.03215796872973442, 0.01698327250778675, 0.05123472958803177, 0.04409952461719513, 0.03032461740076542, -0.04137427359819412, -0.006552991457283497, 0.01287062...
6
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assert", "_fields": {"msg": null, "test": {"_type": "Call", "_...
def test_conditional(): assert conditional(10, 10) assert conditional('10', '10') assert conditional('foo', 'foo') assert conditional(True, True) assert conditional(False, False) assert conditional(None, None) assert conditional("ge(1)", 1) assert conditional("gt(1)", 2) assert condi...
16,010
[ 0.029857492074370384, 0.003371007274836302, 0.028852472081780434, -0.015368442982435226, 0.019043050706386566, -0.04396965727210045, 0.026821492239832878, -0.018927890807390213, 0.0033500692807137966, 0.0042032902128994465, 0.015556883998215199, -0.02142997458577156, -0.02296891249716282, ...
9
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"a...
def test_render(): outfile = io.StringIO() e = Element("this is some text") e.append("and this is some more text") # with open("test1.html", 'w') as outfile: e.render(outfile, "") (outfile.seek(0)) file_contents = outfile.read() assert("this is some text") in file_contents assert("...
16,011
[ 0.03608063608407974, 0.01329286489635706, 0.03642590343952179, -0.042921282351017, 0.03800119459629059, -0.0444965735077858, 0.022679872810840607, 0.0036172347608953714, 0.04244653508067131, -0.030103160068392754, 0.0395549051463604, -0.010541501455008984, -0.04669766500592232, -0.04540290...
9
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"a...
def test_html_body(): outfile = io.StringIO() h = Html() b = Body("PythonClass - Session 6") h.append(b) h.render(outfile) file_output = outfile.getvalue() print(file_output) assert file_output.strip().startswith("<html>") assert file_output.strip().endswith("</html>")
16,012
[ 0.016041463240981102, 0.020550062879920006, 0.04157929867506027, -0.03761521726846695, 0.043060384690761566, -0.03513222187757492, 0.029621711000800133, 0.01972239650785923, 0.059940405189991, -0.02422010526061058, 0.03410853073000908, 0.010019108653068542, -0.05148950591683388, -0.0371142...
9
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"a...
def test_html_body_p(): outfile = io.StringIO() h = Html() b = Body("PythonClass - Session 6") p = P("Here is a paragraph of text -- there could be more of them, but this is enough to show that we can do some text") h.append(b) b.append(p) b.append("Adding plain text for verification.") ...
16,013
[ 0.009087027981877327, 0.04385975003242493, 0.02552587166428566, -0.06356353312730789, 0.010719496756792068, -0.029361601918935776, 0.027443736791610718, 0.007968273013830185, 0.012877094559371471, -0.0017195144901052117, 0.03602846711874008, 0.03497820720076561, 0.021381912752985954, 0.024...
8
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"a...
def test_indent(): outfile = io.StringIO() p = P("Test contents") p.render(outfile, " ") file_output = outfile.getvalue() lines = file_output.split("\n") print(file_output) assert file_output.startswith(" ") assert lines[1].startswith(" T") assert lines[2].startswith(" <")
16,014
[ 0.04235781729221344, 0.04720059037208557, 0.02192394994199276, -0.016412831842899323, -0.012687623500823975, -0.004738685209304094, 0.03396514058113098, -0.02159525640308857, 0.03683574125170708, -0.019612129777669907, 0.01432014163583517, 0.036397483199834824, -0.01402431633323431, 0.0184...
9
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"a...
def test_indent_subtag(): outfile = io.StringIO() b = Body() b.append(P("Test contents.")) b.render(outfile) file_output = outfile.getvalue() lines = file_output.split("\n") print(file_output) assert file_output.startswith("<body>") assert lines[1].startswith(Element.ind + "<p>") ...
16,015
[ 0.031028756871819496, 0.02294563502073288, 0.0007292735972441733, -0.06987988948822021, 0.01482992060482502, -0.027269670739769936, 0.03157197684049606, 0.018567277118563652, -0.0033190774265676737, -0.012135546654462814, 0.0368303507566452, -0.009854020550847054, -0.0269002802670002, 0.00...
7
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"a...
def test_meta(): outfile = io.StringIO() encode_attributes = dict(charset="UTF-8") e = Encoding(**encode_attributes) e.render(outfile) file_output = outfile.getvalue() print(file_output) assert 'meta charset="UTF-8"/' in file_output
16,016
[ 0.006909510120749474, 0.012263443320989609, 0.04912874102592468, -0.04712960496544838, 0.04877889156341553, -0.019091738387942314, 0.023302417248487473, -0.0021865537855774164, -0.007527992594987154, -0.030511796474456787, 0.044730644673109055, -0.024139555171132088, -0.04210678115487099, ...
9
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"a...
def test_full_rendering(): outfile = io.StringIO() dt = Doctype() h = Html() hd = Head() encode_attributes = dict(charset="UTF-8") e = Encoding(**encode_attributes) t = Title("PythonClass - Session6") b = Body() header = Header(2, "Text for header") p_attributes = dict(style="tex...
16,017
[ -0.007692677900195122, 0.03448524326086044, 0.06432133167982101, -0.006626247428357601, 0.008866949938237667, 0.02566622383892536, -0.03156154602766037, 0.021376537159085274, -0.002628631191328168, 0.015013902448117733, 0.002152332104742527, -0.03611484542489052, 0.00458025885745883, 0.024...
10
{"_type": "Module", "_fields": {"body": [{"_type": "ClassDef", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "part", "annotation": n...
class QueryParseTest(_common.TestCase): def pqp(self, part): return beets.library.parse_query_part( part, {'year': dbcore.query.NumericQuery}, {':': dbcore.query.RegexpQuery}, ) def test_one_basic_term(self): q = 'test' r = (None, 'test', dbco...
16,018
[ 0.03141704201698303, -0.04011010378599167, 0.006055914331227541, 0.022520629689097404, -0.0010580375092104077, 0.005789021961390972, 0.0016744316089898348, -0.02879895456135273, 0.031798314303159714, 0.02661297842860222, 0.04636301100254059, -0.020525291562080383, -0.016166049987077713, 0....
10
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "inverse_scale", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonly...
def check_exponential(inverse_scale): rng = check_random_state(1) p_carl = Exponential(inverse_scale=inverse_scale) p_scipy = st.expon(scale=1. / inverse_scale) X = rng.rand(50, 1) assert_array_almost_equal(p_carl.pdf(X), p_scipy.pdf(X.ravel())) assert_array_almos...
16,019
[ 0.039746735244989395, 0.023163501173257828, 0.04451923817396164, -0.019993886351585388, -0.0028713340871036053, 0.02213910035789013, -0.020692888647317886, 0.01146725844591856, -0.029816078022122383, -0.0006108740926720202, 0.017125563696026802, -0.021922169253230095, 0.012341012246906757, ...
13
{"_type": "Module", "_fields": {"body": [{"_type": "ClassDef", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs...
class AnyFieldQueryTest(_common.LibTestCase): def test_no_restriction(self): q = dbcore.query.AnyFieldQuery('title', beets.library.ITEM_KEYS, dbcore.query.SubstringQuery) self.assertEqual(self.lib.items(q).get().title, 'the title') def test_restriction_com...
16,020
[ 0.027363231405615807, -0.04778758063912392, 0.060365840792655945, -0.04683133587241173, -0.02682381309568882, -0.01667293719947338, -0.010966134257614613, -0.004689263645559549, -0.005599532276391983, -0.019382288679480553, -0.005198033060878515, -0.047738540917634964, -0.0069634029641747475...
10
{"_type": "Module", "_fields": {"body": [{"_type": "ClassDef", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs...
class DummyDataTestCase(_common.TestCase, AssertsMixin): def setUp(self): super(DummyDataTestCase, self).setUp() self.lib = beets.library.Library(':memory:') items = [_common.item() for _ in range(3)] items[0].title = 'foo bar' items[0].artist = 'one' items[0].album =...
16,021
[ 0.009231380186975002, -0.06558870524168015, 0.05008406564593315, -0.03743554279208183, -0.027388129383325577, -0.02056659758090973, -0.008561978116631508, 0.009556518867611885, -0.019992824643850327, -0.01670318841934204, 0.02213491126894951, -0.045697882771492004, -0.03164680302143097, -0...
9
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []...
def setUp(self): super(DummyDataTestCase, self).setUp() self.lib = beets.library.Library(':memory:') items = [_common.item() for _ in range(3)] items[0].title = 'foo bar' items[0].artist = 'one' items[0].album = 'baz' items[0].year = 2001 items[0].comp = T...
16,022
[ 0.0132645508274436, 0.017088327556848526, 0.05664464086294174, -0.028243208304047585, 0.016982844099402428, -0.002233283594250679, -0.025553379207849503, 0.02017372101545334, 0.011273549869656563, 0.027135631069540977, 0.012710762210190296, -0.056328192353248596, -0.020252833142876625, 0.0...
11
{"_type": "Module", "_fields": {"body": [{"_type": "ClassDef", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs...
class GetTest(DummyDataTestCase): def test_get_empty(self): q = '' results = self.lib.items(q) self.assert_matched_all(results) def test_get_none(self): q = None results = self.lib.items(q) self.assert_matched_all(results) def test_get_one_keyed_term(self): ...
16,023
[ -0.003668857039883733, -0.001289997948333621, 0.022261159494519234, -0.010434919036924839, -0.02402753382921219, -0.023567793890833855, -0.030076762661337852, 0.022515228018164635, -0.004258656874299049, -0.028286190703511238, 0.007785356603562832, -0.039755526930093765, -0.00979370065033435...
10
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []...
def test_unicode_query(self): item = self.lib.items().get() item.title = u'caf\xe9' item.store() q = u'title:caf\xe9' results = self.lib.items(q) self.assert_matched(results, [u'caf\xe9'])
16,024
[ -0.0002594298857729882, 0.0030818514060229063, 0.03723878413438797, -0.022455671802163124, -0.009932786226272583, 0.008326191455125809, 0.00011616121628321707, -0.022822193801403046, -0.01740986481308937, 0.012571754865348339, -0.0029581498820334673, -0.03740982711315155, 0.01562611758708954...
9
{"_type": "Module", "_fields": {"body": [{"_type": "ClassDef", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs...
class MatchTest(_common.TestCase): def setUp(self): super(MatchTest, self).setUp() self.item = _common.item() def test_regex_match_positive(self): q = dbcore.query.RegexpQuery('album', '^the album$') self.assertTrue(q.match(self.item)) def test_regex_match_negative(self): ...
16,025
[ -0.008501826785504818, 0.008605366572737694, 0.02144438959658146, -0.044016219675540924, 0.005758002866059542, 0.0032500214874744415, 0.014484167098999023, -0.020213408395648003, 0.014495671726763248, 0.020903678610920906, 0.018418706953525543, -0.02793292887508869, 0.011700077913701534, 0...
9
{"_type": "Module", "_fields": {"body": [{"_type": "ClassDef", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs...
class PathQueryTest(_common.LibTestCase, AssertsMixin): def setUp(self): super(PathQueryTest, self).setUp() self.i.path = '/a/b/c.mp3' self.i.title = 'path item' self.i.store() def test_path_exact_match(self): q = 'path:/a/b/c.mp3' results = self.lib.items(q) ...
16,026
[ 0.011775607243180275, -0.003127721603959799, 0.031661566346883774, -0.023372964933514595, 0.0018117389408871531, -0.03435758873820305, -0.010655976831912994, 0.008316452614963055, -0.0038824966177344322, 0.009931839071214199, 0.004562072921544313, -0.0798557698726654, -0.017178794369101524, ...
10
{"_type": "Module", "_fields": {"body": [{"_type": "ClassDef", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs...
class DefaultSearchFieldsTest(DummyDataTestCase): def test_albums_matches_album(self): albums = list(self.lib.albums('baz')) self.assertEqual(len(albums), 1) def test_albums_matches_albumartist(self): albums = list(self.lib.albums(['album artist'])) self.assertEqual(len(albums),...
16,027
[ -0.0016261968994513154, 0.022741040214896202, -0.0074409013614058495, -0.05771670490503311, 0.007893526926636696, 0.02608773112297058, 0.00654593575745821, 0.020807091146707535, 0.03818519413471222, -0.005551529582589865, 0.06408090144395828, -0.0211088415235281, -0.012200335040688515, 0.0...
12
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []...
def testSwitch( self ) : # Build a scene with a sphere, a plane, and # a filter switch controlling an attribute # assignment. Index 0 should assign to the # plane and index 1 should assign to the # sphere. script = Gaffer.ScriptNode() script["plane"] = GafferScene.Plane() script["sphere"] = GafferSce...
16,028
[ -0.014588815160095692, 0.024301068857312202, -0.0007917599286884069, -0.05693860352039337, -0.002193089807406068, 0.011680587194859982, -0.008840467780828476, 0.027270594611763954, 0.05710206553339958, -0.012695401906967163, 0.05960845202207565, -0.012334427796304226, -0.006521377246826887, ...
13
{"_type": "Module", "_fields": {"body": [{"_type": "ClassDef", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs...
class FilterSwitchTest( GafferSceneTest.SceneTestCase ) : def testConstruct( self ) : f = GafferScene.FilterSwitch() self.assertEqual( f.getName(), "FilterSwitch" ) def testSwitch( self ) : # Build a scene with a sphere, a plane, and # a filter switch controlling an attribute # assignment. Index 0 shoul...
16,029
[ -0.026557505130767822, 0.015149908140301704, -0.00015112404071260244, -0.04230102151632309, -0.004048793576657772, -0.029886871576309204, 0.013104541227221489, 0.04000401496887207, 0.05941241607069969, 0.0031212810426950455, 0.02487991750240326, -0.006500652525573969, -0.008755717426538467, ...
10
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []...
def testConnectWithoutInputs( self ) : s = Gaffer.ScriptNode() s["i"] = GafferScene.Isolate() s["p"] = GafferScene.PathFilter() s["s"] = Gaffer.Switch() s["s"].setup( s["p"]["out"] ) s["s"]["in"][0].setInput( s["p"]["out"] ) s["s"]["in"][0].setInput( None ) s["i"]["filter"].setInput( s["s"]["out"] )
16,030
[ -0.005797283258289099, 0.0016674981452524662, 0.003934118431061506, -0.013485437259078026, -0.014337367378175259, 0.015944261103868484, -0.010548700578510761, -0.023133723065257072, 0.05324912071228027, -0.024075696244835854, 0.03604428097605705, -0.029755232855677605, -0.0262921005487442, ...
9
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []...
def testSwitchConnectionSerializationProblem( self ): s = Gaffer.ScriptNode() b1 = Gaffer.Box() s.addChild( b1 ) b2 = Gaffer.Box() b1.addChild( b2 ) fs = Gaffer.Switch( "FilterSwitch" ) fs.setup( GafferScene.FilterPlug() ) b2.addChild( fs ) f1 = GafferScene.PathFilter() b2.addChild( f1 ) f2 = ...
16,031
[ -0.0009528746595606208, 0.021038945764303207, 0.006237296853214502, -0.07120063900947571, -0.023250799626111984, -0.02654225006699562, -0.0013815859565511346, 0.03070264309644699, 0.04389477148652077, -0.022171204909682274, 0.008663095533847809, -0.01130283810198307, -0.021881558001041412, ...
9
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []...
def testCompatibilityWithIntPlugs( self ) : s = Gaffer.ScriptNode() s["p"] = GafferScene.PathFilter() s["d"] = Gaffer.Dot() s["d"].setup( Gaffer.IntPlug() ) s["d"]["in"].setInput( s["p"]["out"] ) s["s"] = Gaffer.Switch() s["s"].setup( s["p"]["out"] ) # We use `execute()` here because the compatibilit...
16,032
[ -0.004680832382291555, -0.010195722803473473, -0.001656741718761623, -0.036253705620765686, -0.012576577253639698, 0.028934216126799583, 0.03732534125447273, -0.03382735326886177, -0.03952927514910698, 0.03350384160876274, -0.0022026703227311373, -0.0391855426132679, 0.014608644880354404, ...
12
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "filename", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs"...
def parse_dictionary(filename): dict_anagrams = defaultdict(set) with open(filename) as dictionary: for word in dictionary: word = word.rstrip() dict_anagrams[''.join(sorted(word))].add(word) return dict_anagrams
16,033
[ 0.03735193610191345, 0.01415904238820076, -0.010070154443383217, -0.019205383956432343, 0.0011031831381842494, 0.012401835061609745, 0.013742269016802311, 0.01366342045366764, -0.017718516290187836, 0.044470883905887604, -0.0015755736967548728, -0.008369266986846924, 0.023789895698428154, ...
11
{"_type": "Module", "_fields": {"body": [{"_type": "ClassDef", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs...
class index: def GET(self): form_word = input_word() return render.formtemplate(form_word) def POST(self): form_word = input_word() if not form_word.validates(): return render.formtemplate(form_word) else: anagram_list=set() sor...
16,034
[ 0.04565016180276871, 0.03578650578856468, -0.014929682947695255, 0.013073258101940155, -0.0066596451215445995, 0.0043810512870550156, 0.02677278034389019, 0.011099408380687237, 0.010366903617978096, 0.04929591342806816, -0.02619124948978424, 0.0015656596515327692, 0.0024141911417245865, -0...
10
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []...
def POST(self): form_word = input_word() if not form_word.validates(): return render.formtemplate(form_word) else: anagram_list=set() sorted_word = ''.join(sorted(form_word.d.Word)) if word_anagrams[sorted_word]: for word in w...
16,035
[ 0.028112225234508514, -0.014168862253427505, 0.023777632042765617, -0.0594816617667675, 0.018703900277614594, 0.002496150089427829, -0.004243768285959959, -0.028463002294301987, 0.03490225598216057, 0.042819779366254807, 0.0190922599285841, -0.07025551050901413, -0.0401388481259346, -0.014...
11
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "If", "_fields": {"body": [{"_type": "FunctionDef", "_fields": ...
def sa_version(): if hasattr(sa, '__version__'): def tryint(s): try: return int(s) except (ValueError, TypeError): return -1 return tuple(map(tryint, sa.__version__.split('.'))) return (0, 0, 0)
16,036
[ -0.01900513842701912, -0.04881319776177406, -0.02716290019452572, -0.0022533871233463287, 0.03363131731748581, -0.011869876645505428, -0.022350488230586052, -0.01624883897602558, 0.04083326458930969, 0.002813260769471526, 0.008341144770383835, -0.03676549717783928, 0.04254483804106712, -0....
10
{"_type": "Module", "_fields": {"body": [{"_type": "ClassDef", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs...
class UserTest(TestCase): @fixture def event(self): return mock.Mock(spec=Event()) @fixture def interface(self): return User.to_python(dict( id=1, email='lol@example.com', favorite_color='brown', )) def test_path(self): assert sel...
16,037
[ 0.06056048721075058, 0.023504244163632393, 0.052725739777088165, -0.04285819083452225, 0.005314923822879791, 0.021937295794487, 0.022932520136237144, -0.028819169849157333, -0.04309111461043358, -0.00623603630810976, 0.014970721676945686, -0.025621743872761726, 0.07106328755617142, 0.05319...
10
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "engine", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "connection", "annotation": null, "type_comment": null}}], "kwar...
def withoutSqliteForeignKeys(engine, connection=None): conn = connection if engine.dialect.name == 'sqlite': if conn is None: conn = engine.connect() # This context is not re-entrant. Ensure it. assert not getattr(engine, 'fk_disabled', False) engine.fk_disabled = Tru...
16,038
[ -0.0073004369623959064, 0.014646860770881176, 0.021648382768034935, 0.0034346545580774546, 0.020970074459910393, 0.015658576041460037, -0.008484601974487305, 0.006811825092881918, 0.003440402913838625, 0.05311499163508415, -0.006599135231226683, 0.011807163245975971, 0.027707170695066452, ...
13
{"_type": "Module", "_fields": {"body": [{"_type": "ClassDef", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs...
class MatrixDiagTest(test.TestCase): def testVector(self): with self.test_session(use_gpu=True): v = np.array([1.0, 2.0, 3.0]) mat = np.diag(v) v_diag = array_ops.matrix_diag(v) self.assertEqual((3, 3), v_diag.get_shape()) self.assertAllEqual(v_diag.eval(), mat) def _testBatchVec...
16,039
[ -0.020651161670684814, -0.01988345943391323, 0.03338403254747391, -0.025750890374183655, -0.002580024302005768, -0.0298526082187891, 0.0012625942472368479, 0.005680988542735577, 0.01272190548479557, 0.03676191717386246, 0.008066345937550068, 0.012425791472196579, 0.006306116934865713, 0.03...
11
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "dtype", "annotation": null, "type_comment": null}}], "kwarg": nul...
def _testBatchVector(self, dtype): with self.test_session(use_gpu=True): v_batch = np.array([[1.0, 0.0, 3.0], [4.0, 5.0, 6.0]]).astype(dtype) mat_batch = np.array([[[1.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 3.0]], [[4.0, 0.0, 0.0], [0.0, 5.0, 0.0], ...
16,040
[ -0.010850721038877964, -0.011441946029663086, 0.04537363722920418, 0.006961386650800705, 0.04326377436518669, -0.02060014009475708, 0.003614008892327547, 0.017504902556538582, 0.014931334182620049, 0.028332438319921494, -0.008758247829973698, 0.02793828956782818, 0.00732655543833971, 0.021...
12
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []...
def testGrad(self): shapes = ((3,), (7, 4)) with self.test_session(use_gpu=True): for shape in shapes: x = constant_op.constant(np.random.rand(*shape), np.float32) y = array_ops.matrix_diag(x) error = gradient_checker.compute_gradient_error(x, ...
16,041
[ -0.02283736877143383, -0.04880950599908829, 0.04959900304675102, -0.01735732890665531, 0.02103777974843979, -0.015580959618091583, -0.00157464062795043, -0.0007626485312357545, 0.04518710449337959, 0.032578371465206146, 0.0269590076059103, 0.015522908419370651, 0.003674645209684968, 0.0335...
9
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []...
def testSquare(self): with self.test_session(use_gpu=True): v = np.array([1.0, 2.0, 3.0]) mat = np.array([[0.0, 1.0, 0.0], [1.0, 0.0, 1.0], [1.0, 1.0, 1.0]]) mat_set_diag = np.array([[1.0, 1.0, 0.0], [1.0, 2.0, 1.0], [1.0, 1.0, 3.0]]) output = array_ops.matrix_...
16,042
[ -0.008776679635047913, -0.020730381831526756, 0.037977077066898346, 0.01119317952543497, 0.02713349461555481, 0.01873094215989113, 0.010457189753651619, -0.016314443200826645, 0.00178017548751086, 0.04254021495580673, 0.018951740115880966, 0.004391406197100878, 0.020411452278494835, 0.0521...
13
{"_type": "Module", "_fields": {"body": [{"_type": "ClassDef", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs...
class MatrixSetDiagTest(test.TestCase): def testSquare(self): with self.test_session(use_gpu=True): v = np.array([1.0, 2.0, 3.0]) mat = np.array([[0.0, 1.0, 0.0], [1.0, 0.0, 1.0], [1.0, 1.0, 1.0]]) mat_set_diag = np.array([[1.0, 1.0, 0.0], [1.0, 2.0, 1.0], [1.0, 1...
16,043
[ -0.036608509719371796, -0.028678201138973236, 0.06348855793476105, -0.003881585318595171, 0.02971559576690197, -0.0075038219802081585, -0.012806061655282974, -0.00777469715103507, 0.022730471566319466, 0.04419301450252533, 0.02489747479557991, 0.016045039519667625, 0.02711058221757412, 0.0...
9
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []...
def testRectangular(self): with self.test_session(use_gpu=True): v = np.array([3.0, 4.0]) mat = np.array([[0.0, 1.0, 0.0], [1.0, 0.0, 1.0]]) expected = np.array([[3.0, 1.0, 0.0], [1.0, 4.0, 1.0]]) output = array_ops.matrix_set_diag(mat, v) self.assertEqual((2, 3), output.get_shape()) ...
16,044
[ -0.022915655747056007, -0.05622725188732147, 0.052894920110702515, -0.02178923413157463, 0.0019301717402413487, -0.02550877444446087, 0.007063607219606638, -0.01254318282008171, 0.024663956835865974, 0.015852048993110657, 0.02041640505194664, 0.011733566410839558, -0.0019037711899727583, 0...
12
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "dtype", "annotation": null, "type_comment": null}}], "kwarg": nul...
def _testSquareBatch(self, dtype): with self.test_session(use_gpu=True): v_batch = np.array([[-1.0, 0.0, -3.0], [-4.0, -5.0, -6.0]]).astype(dtype) mat_batch = np.array([[[1.0, 0.0, 3.0], [0.0, 2.0, 0.0], [1.0, 0.0, 3.0]], [[4.0, 0.0, 4.0], [0.0, 5.0, 0.0], ...
16,045
[ 0.006400887854397297, -0.040070027112960815, 0.04023415222764015, 0.016975248232483864, 0.03477112576365471, 0.017971724271774292, -0.00998819898813963, 0.010339896194636822, -0.0028531430289149284, 0.021383186802268028, 0.0232120119035244, 0.007473564241081476, 0.043680787086486816, 0.029...
12
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []...
def testInvalidShapeAtEval(self): with self.test_session(use_gpu=True): v = array_ops.placeholder(dtype=dtypes_lib.float32) with self.assertRaisesOpError("input must be at least 2-dim"): array_ops.matrix_set_diag(v, [v]).eval(feed_dict={v: 0.0}) with self.assertRaisesOpError( r"b...
16,046
[ -0.035686906427145004, -0.04553474113345146, 0.06704812496900558, 0.008358006365597248, 0.01312661450356245, -0.026759427040815353, -0.0011828045826405287, -0.007121274713426828, -0.0042595346458256245, 0.02795589342713356, 0.00958898663520813, 0.010750939138233662, 0.020132845267653465, 0...
10
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []...
def testRectangularBatch(self): with self.test_session(use_gpu=True): v_batch = np.array([[-1.0, -2.0], [-4.0, -5.0]]) mat_batch = np.array([[[1.0, 0.0, 3.0], [0.0, 2.0, 0.0]], [[4.0, 0.0, 4.0], [0.0, 5.0, 0.0]]]) mat_set_diag_batch = np.array([[[-1.0, 0.0, 3.0], [0.0,...
16,047
[ 0.0008085062145255506, -0.02241867035627365, 0.0357528030872345, 0.006409515161067247, 0.033481668680906296, -0.0164949893951416, 0.01760714314877987, -0.00436666514724493, -0.01717398874461651, 0.02898622862994671, -0.0056895422749221325, 0.026855576783418655, 0.016307679936289787, 0.0460...
12
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []...
def testGradWithNoShapeInformation(self): with self.test_session(use_gpu=True) as sess: v = array_ops.placeholder(dtype=dtypes_lib.float32) mat = array_ops.placeholder(dtype=dtypes_lib.float32) grad_input = array_ops.placeholder(dtype=dtypes_lib.float32) output = array_ops.matrix_set_diag(ma...
16,048
[ -0.0003110604884568602, -0.02228725142776966, 0.049165867269039154, 0.0032850978896021843, 0.040030963718891144, 0.0007618647068738937, 0.000153194967424497, 0.015376290306448936, -0.00436418829485774, 0.027500363066792488, 0.0020012492313981056, 0.029772132635116577, 0.009451755322515965, ...
12
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []...
def testGrad(self): shapes = ((3, 4, 4), (3, 3, 4), (3, 4, 3), (7, 4, 8, 8)) with self.test_session(use_gpu=True): for shape in shapes: x = constant_op.constant( np.random.rand(*shape), dtype=dtypes_lib.float32) diag_shape = shape[:-2] + (min(shape[-2:]),) x_diag = cons...
16,049
[ -0.019052261486649513, -0.01363857090473175, 0.052197303622961044, 0.01878219097852707, 0.01997295580804348, 0.019285503774881363, -0.019481919705867767, -0.01617969013750553, 0.005935417488217354, 0.04416883736848831, 0.005336965434253216, -0.009145576506853104, 0.032604899257421494, 0.04...
13
{"_type": "Module", "_fields": {"body": [{"_type": "ClassDef", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs...
class MatrixDiagPartTest(test.TestCase): def testSquare(self): with self.test_session(use_gpu=True): v = np.array([1.0, 2.0, 3.0]) mat = np.diag(v) mat_diag = array_ops.matrix_diag_part(mat) self.assertEqual((3,), mat_diag.get_shape()) self.assertAllEqual(mat_diag.eval(), v) def ...
16,050
[ -0.02423921227455139, -0.02437759004533291, 0.07670753449201584, 0.016490044072270393, 0.029705142602324486, -0.010193845257163048, -0.022382639348506927, -0.006365387700498104, 0.01504860632121563, 0.05083084851503372, 0.021241022273898125, 0.0016605359269306064, 0.04008349031209946, 0.04...
9
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []...
def testRectangular(self): with self.test_session(use_gpu=True): mat = np.array([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]]) mat_diag = array_ops.matrix_diag_part(mat) self.assertAllEqual(mat_diag.eval(), np.array([1.0, 5.0])) mat = np.array([[1.0, 2.0], [3.0, 4.0], [5.0, 6.0]]) mat_diag = arra...
16,051
[ -0.02708503045141697, -0.0566723570227623, 0.05333596467971802, -0.022462734952569008, 0.0008196175913326442, -0.02727038599550724, 0.00301491841673851, -0.008792787790298462, 0.01634601317346096, 0.01759716123342514, 0.018153226003050804, 0.004465902224183083, -0.0025761479046195745, 0.04...
11
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "dtype", "annotation": null, "type_comment": null}}], "kwarg": nul...
def _testSquareBatch(self, dtype): with self.test_session(use_gpu=True): v_batch = np.array([[1.0, 0.0, 3.0], [4.0, 5.0, 6.0]]).astype(dtype) mat_batch = np.array([[[1.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 3.0]], [[4.0, 0.0, 0.0], [0.0, 5.0, 0.0], ...
16,052
[ -0.041276972740888596, -0.047483187168836594, 0.06156565248966217, 0.005650476552546024, 0.011780524626374245, -0.026314351707696915, -0.009794535115361214, -0.0033457139506936073, -0.008688700385391712, 0.03125675395131111, 0.008637922815978527, 0.00475339638069272, 0.02066105417907238, 0...
9
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []...
def testRectangularBatch(self): with self.test_session(use_gpu=True): v_batch = np.array([[1.0, 2.0], [4.0, 5.0]]) mat_batch = np.array([[[1.0, 0.0, 0.0], [0.0, 2.0, 0.0]], [[4.0, 0.0, 0.0], [0.0, 5.0, 0.0]]]) self.assertEqual(mat_batch.shape, (2, 2, 3)) mat_batch...
16,053
[ -0.017568698152899742, -0.03278809413313866, 0.04389621317386627, -0.00524124363437295, 0.00999092124402523, 0.011695441789925098, -0.031741123646497726, 0.022343913093209267, 0.0005346579127945006, 0.03666955232620239, 0.011867809109389782, -0.011625218205153942, 0.03485650196671486, 0.00...
11
{"_type": "Module", "_fields": {"body": [{"_type": "ClassDef", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs...
class DiagPartOpTest(test.TestCase): def setUp(self): np.random.seed(0) def _diagPartOp(self, tensor, dtype, expected_ans, use_gpu): with self.test_session(use_gpu=use_gpu): tensor = ops.convert_to_tensor(tensor.astype(dtype)) tf_ans_inv = array_ops.diag_part(tensor) inv_out = tf_ans_inv...
16,054
[ -0.006237959489226341, -0.010164069011807442, 0.05350117012858391, 0.006261020433157682, 0.04522232338786125, -0.015589133836328983, 0.0020106176380068064, 0.009039852768182755, 0.010861659422516823, 0.03454514965415001, -0.008371087722480297, 0.03242355212569237, 0.0010881838388741016, 0....
12
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []...
def testGrad(self): shapes = ((3, 3), (2, 3), (3, 2), (5, 3, 3)) with self.test_session(use_gpu=True): for shape in shapes: x = constant_op.constant(np.random.rand(*shape), dtype=np.float32) y = array_ops.matrix_diag_part(x) error = gradient_checker.compute_gradient_error(x, ...
16,055
[ -0.017984384670853615, -0.027896035462617874, 0.033655665814876556, 0.008448612876236439, 0.03825874254107475, -0.038119956851005554, -0.00923506822437048, 0.039022065699100494, 0.025837372988462448, 0.04189031571149826, 0.007719985209405422, 0.03490474075078964, 0.011235903017222881, 0.00...
10
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []...
def testRankFourFloatTensorUnknownShape(self): x = np.random.rand(3, 3) i = np.arange(3) expected_ans = x[i, i] for shape in None, (None, 3), (3, None): with self.test_session(use_gpu=False): t = ops.convert_to_tensor(x.astype(np.float32)) t.set_shape(shape) tf_ans = array_...
16,056
[ 0.006583188660442829, -0.01670021004974842, 0.028886234387755394, -0.018011149019002914, 0.0053206984885036945, -0.03618188947439194, -0.017121991142630577, 0.028133869171142578, 0.00425769854336977, 0.01919669285416603, -0.01220882311463356, 0.0014413193566724658, -0.019971854984760284, -...
8
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []...
def testRankSixFloatTensor(self): x = np.random.rand(2, 2, 2, 2, 2, 2) i = np.arange(2)[:, None, None] j = np.arange(2)[:, None] k = np.arange(2) expected_ans = x[i, j, k, i, j, k] self.diagPartOp(x, np.float32, expected_ans) self.diagPartOp(x, np.float64, expected_ans)
16,057
[ -0.00663908151909709, -0.006260043941438198, 0.024708516895771027, -0.006935204844921827, 0.0040124692022800446, -0.017068538814783096, -0.016772417351603508, 0.02295546792447567, 0.015410250052809715, 0.027361780405044556, -0.005981687922030687, 0.0049363733269274235, 0.007870953530073166, ...
8
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []...
def testRankEightComplexTensor(self): x = np.random.rand(2, 2, 2, 3, 2, 2, 2, 3) i = np.arange(2)[:, None, None, None] j = np.arange(2)[:, None, None] k = np.arange(2)[:, None] l = np.arange(3) expected_ans = x[i, j, k, l, i, j, k, l] self.diagPartOp(x, np.complex64, expected_ans) self.d...
16,058
[ -0.002741847187280655, -0.025483399629592896, 0.03374764323234558, -0.0031705398578196764, 0.02857951447367668, -0.00006447136547649279, 0.0017445412231609225, 0.015361488796770573, -0.015802089124917984, -0.007650974206626415, -0.0055610970593988895, 0.004400054458528757, 0.0196484159678220...
14
{"_type": "Module", "_fields": {"body": [{"_type": "ClassDef", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs...
class DiagGradOpTest(test.TestCase): def testDiagGrad(self): np.random.seed(0) shapes = ((3,), (3, 3), (3, 3, 3)) dtypes = (dtypes_lib.float32, dtypes_lib.float64) with self.test_session(use_gpu=False): errors = [] for shape in shapes: for dtype in dtypes: x1 = constant_...
16,059
[ -0.01231295894831419, -0.030926739796996117, 0.06240574270486832, 0.00397252943366766, 0.03125307708978653, -0.019981887191534042, -0.004405554383993149, 0.03022385947406292, -0.01788579672574997, 0.021638676524162292, 0.003319854848086834, 0.02565513551235199, 0.006966046988964081, 0.0249...
13
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []...
def testDiagGrad(self): np.random.seed(0) shapes = ((3,), (3, 3), (3, 3, 3)) dtypes = (dtypes_lib.float32, dtypes_lib.float64) with self.test_session(use_gpu=False): errors = [] for shape in shapes: for dtype in dtypes: x1 = constant_op.constant(np.random.rand(*shape), dtyp...
16,060
[ -0.008631809614598751, -0.021350806578993797, 0.041584767401218414, 0.012380379252135754, 0.02394094318151474, 0.004131743684411049, -0.012819989584386349, 0.017928974702954292, -0.014257634058594704, -0.006600096356123686, -0.01669331267476082, -0.00006595083686988801, 0.027921199798583984,...
14
{"_type": "Module", "_fields": {"body": [{"_type": "ClassDef", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs...
class DiagGradPartOpTest(test.TestCase): def testDiagPartGrad(self): np.random.seed(0) shapes = ((3, 3), (3, 3, 3, 3)) dtypes = (dtypes_lib.float32, dtypes_lib.float64) with self.test_session(use_gpu=False): errors = [] for shape in shapes: for dtype in dtypes: x1 = cons...
16,061
[ -0.01852310821413994, -0.03277648240327835, 0.0660552829504013, 0.012432458810508251, 0.02206447534263134, -0.010096663609147072, -0.012501528486609459, 0.029837900772690773, -0.013889191672205925, 0.017254745587706566, -0.004451824817806482, 0.02020588517189026, 0.015119879506528378, 0.02...
13
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []...
def testDiagPartGrad(self): np.random.seed(0) shapes = ((3, 3), (3, 3, 3, 3)) dtypes = (dtypes_lib.float32, dtypes_lib.float64) with self.test_session(use_gpu=False): errors = [] for shape in shapes: for dtype in dtypes: x1 = constant_op.constant(np.random.rand(*shape), dty...
16,062
[ -0.013124694116413593, -0.04873891547322273, 0.008918060921132565, -0.0029707530047744513, 0.021654004231095314, 0.009010897018015385, 0.009614331647753716, -0.029382603242993355, 0.008007107302546501, 0.028709542006254196, -0.04632518067955971, -0.012985439971089363, 0.008889050222933292, ...
11
{"_type": "Module", "_fields": {"body": [{"_type": "ClassDef", "_fields": {"body": [{"_type": "Assign", "_fields": {"value": {"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "List", "_fields": {"ctx": {"_type": "Load", "_fields": {}}, "elts": [{"_type": "Constant", "_fields": {"...
class Laplacian(Benchmark): params = [ [30, 300, 900], ['dense', 'coo', 'csc', 'csr', 'dia'], [True, False] ] param_names = ['n', 'format', 'normed'] def setup(self, n, format, normed): data = scipy.sparse.rand(9, n, density=0.5, random_state=42).toarray() data =...
16,063
[ -0.010676240548491478, -0.05050443857908249, 0.02184983901679516, 0.010382347740232944, 0.040873780846595764, -0.0015189199475571513, 0.00807641539722681, -0.013959934003651142, -0.01817617192864418, 0.01618674024939537, -0.05018794164061546, 0.0004705119354184717, 0.01832311972975731, 0.0...
10
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "n", "annotation": null, "type_comment": null}}, {"_type": "arg", ...
def setup(self, n, format, normed): data = scipy.sparse.rand(9, n, density=0.5, random_state=42).toarray() data = np.vstack((data, data)) diags = list(range(-9, 0)) + list(range(1, 10)) A = scipy.sparse.spdiags(data, diags, n, n) if format == 'dense': self.A = A.toarr...
16,064
[ 0.018783533945679665, 0.035732582211494446, 0.011080024763941765, -0.03844442963600159, -0.005819173529744148, 0.009890268556773663, 0.000978724448941648, -0.005367198958992958, 0.0059554302133619785, 0.0012686861446127295, 0.049956489354372025, -0.05551312118768692, -0.01855754666030407, ...
9
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []...
def test_fix_not_found(self): course = CourseFactory.create(default_store=ModuleStoreEnum.Type.split) ItemFactory.create(category='chapter', parent_location=course.location) # get course again in order to update its children list course = self.store.get_course(course.id) # crea...
16,065
[ 0.02865595556795597, 0.028515255078673363, -0.02298104576766491, 0.020424989983439445, -0.04406263679265976, -0.024458397179841995, 0.028843555599451065, 0.01231127418577671, 0.004349983297288418, 0.015805330127477646, 0.03533921763300896, -0.0052176350727677345, -0.0051824599504470825, -0...
8
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "_step", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": [...
def clear_fields(_step): # Clear the input fields and trigger an 'input' event script = """ $('{selector}') .prop('disabled', false) .removeClass('is-disabled') .val('') .trigger('input'); """.format(selector=SELECTORS['url_inputs']) world.browser...
16,066
[ 0.01412787102162838, -0.028021838515996933, 0.006923592649400234, 0.0075434413738548756, 0.01645522750914097, 0.014431947842240334, 0.03796280547976494, 0.010835655964910984, 0.04790377616882324, 0.015355873852968216, -0.010514036752283573, -0.03157719597220421, 0.005704361945390701, 0.008...
7
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"a...
def test_multiplication(): a=Matrix(( (1, 2), (3, 1), (0, 6), )) b = Matrix (( (1, 2), (3, 0), )) c= a*b assert c[0,0]==7 assert c[0,1]==2 assert c[1,0]==6 assert c[1,1]==6 assert c[2,0]==18 assert c[2,1]==0 x = Symbol("x...
16,067
[ 0.046457767486572266, 0.001316610723733902, -0.01740322820842266, -0.02024231292307377, 0.019947342574596405, 0.01319990586489439, 0.014207719825208187, -0.03586342930793762, 0.049038756638765335, 0.01319990586489439, -0.0014241518219932914, -0.027972985059022903, 0.04114830866456032, 0.02...
7
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"a...
def test_creation(): x = Symbol("x") a = Matrix([x, 0], [0, 0]) m = a assert m.cols == m.lines assert m.cols == 2 assert m[:] == [x,0,0,0] b = Matrix(2,2, [x, 0, 0, 0]) m = b assert m.cols == m.lines assert m.cols == 2 assert m[:] == [x,0,0,0] assert a == b
16,068
[ 0.02286829613149166, -0.01833084039390087, -0.02121502161026001, 0.03784431517124176, 0.025535259395837784, 0.03154497593641281, -0.0029173672664910555, 0.008857693523168564, 0.04421606287360191, 0.02325446344912052, 0.016231060028076172, -0.031182944774627686, 0.008157767355442047, 0.0211...
10
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"a...
def test_power(): A = Matrix([[2,3],[4,5]]) assert (A**5)[:] == [6140, 8097, 10796, 14237] A = Matrix([[2, 1, 3],[4,2, 4], [6,12, 1]]) assert (A**3)[:] == [290, 262, 251, 448, 440, 368, 702, 954, 433] assert A**0 == eye(3) assert A**1 == A assert (Matrix([[2]]) ** 100)[0,0] == 2**100 ass...
16,069
[ 0.031051721423864365, 0.009249698370695114, -0.027361243963241577, 0.054487425833940506, -0.0001163374399766326, 0.04247574508190155, 0.013751140795648098, -0.02675008215010166, 0.005471073556691408, 0.026044895872473717, 0.010918640531599522, -0.02325940690934658, 0.016618900001049042, 0....
12
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Tuple", "_fields": {"...
def test_determinant(): x, y, z = Symbol('x'), Symbol('y'), Symbol('z') assert Matrix([ [1] ]).det() == 1 assert Matrix(( (-3, 2), ( 8, -5) )).det() == -1 assert Matrix(( (x, 1), (y, 2*y) )).det() == 2*x*y-y assert Matrix(( (1, 1, 1), ...
16,070
[ 0.007854371331632137, -0.012176532298326492, -0.009422988630831242, 0.008537114597856998, 0.006708941888064146, -0.010686909779906273, 0.05755358189344406, -0.01188312191516161, 0.030627533793449402, 0.05299443379044533, 0.008853094652295113, -0.024375634267926216, 0.04861585050821304, 0.0...
9
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"a...
def test_submatrix(): m0 = eye(4) assert m0[0:3, 0:3] == eye(3) assert m0[2:4, 0:2] == zero(2) m1 = Matrix(3,3, lambda i,j: i+j) assert m1[0,:] == Matrix(1,3,(0,1,2)) assert m1[1:3, 1] == Matrix(2,1,(2,3)) m2 = Matrix([0,1,2,3],[4,5,6,7],[8,9,10,11],[12,13,14,15]) assert m2[:,-1] == Ma...
16,071
[ -0.03909263014793396, -0.03827435150742531, -0.03560834378004074, 0.011792459525167942, 0.021539220586419106, 0.022146331146359444, -0.009509196504950523, 0.010545243509113789, 0.037403278052806854, 0.03785201162099838, 0.02336055226624012, -0.01763259805738926, 0.0002181802992708981, 0.01...
10
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"a...
def test_LUdecomp(): testmat = Matrix([[0,2,5,3], [3,3,7,4], [8,4,0,2], [-2,6,3,4]]) L,U,p = testmat.LUdecomposition() assert L.is_lower() assert U.is_upper() assert (L*U).permuteBkwd(p)-testmat == zero(4) testmat = Matrix([[6,-2...
16,072
[ 0.005926491692662239, -0.005681689362972975, -0.018456950783729553, 0.00855099968612194, 0.012114864774048328, -0.014027738012373447, 0.0507366880774498, -0.026711909100413322, 0.023091113194823265, 0.05019015446305275, 0.024890126660466194, -0.005260401871055365, 0.04773074388504028, 0.03...
8
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"a...
def test_submatrix_assignment(): m = zero(4) m[2:4, 2:4] = eye(2) assert m == Matrix((0,0,0,0), (0,0,0,0), (0,0,1,0), (0,0,0,1)) m[0:2, 0:2] = eye(2) assert m == eye(4) m[:,0] = Matrix(4,1,(1,2,3,4)) assert m == Matrix((...
16,073
[ 0.001378268818370998, -0.04948892444372177, -0.03389780595898628, 0.01865783892571926, 0.026617268100380898, -0.013624670915305614, 0.008380810730159283, 0.0018596388399600983, 0.028068695217370987, 0.01981663890182972, 0.010996888391673565, -0.01899728551506996, 0.03523218259215355, 0.027...
8
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"a...
def test_inverse(): A = eye(4) assert A.inv() == eye(4) A = Matrix([[2,3,5], [3,6,2], [8,3,6]]) Ainv = A.inv() assert A*Ainv == eye(3) Ainv2 = A.inv("LU") assert Ainv == Ainv2
16,074
[ -0.02524997666478157, -0.0416923351585865, -0.013985964469611645, -0.0004287627525627613, 0.001284905127249658, -0.020403575152158737, -0.028303874656558037, -0.006417610216885805, 0.0457199402153492, 0.024630345404148102, -0.01782546564936638, -0.043551232665777206, -0.03308388590812683, ...
8
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"a...
def test_LUsolve(): A = Matrix([[2,3,5], [3,6,2], [8,3,6]]) x = Matrix(3,1,[3,7,5]) b = A*x soln = A.LUsolve(b) assert soln == x A = Matrix([[0,-1,2], [5,10,7], [8,3,4]]) x = Matrix(3,1,[-1,2,5]) b = A*x soln = A.LUsolve...
16,075
[ -0.03187275305390358, -0.025183409452438354, -0.012904182076454163, 0.01579749770462513, 0.005448111332952976, 0.017695510759949684, 0.020473092794418335, -0.023100223392248154, 0.04356174170970917, 0.05522758513689041, 0.008818822912871838, -0.024836210533976555, 0.026780517771840096, 0.0...
9
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"a...
def test_util(): v1 = Matrix(1,3,[1,2,3]) v2 = Matrix(1,3,[3,4,5]) assert v1.cross(v2) == Matrix(1,3,[-2,4,-2]) assert v1.norm() == sqrt(14) # cofactor assert eye(3) == eye(3).cofactorMatrix() test = Matrix([[1,3,2],[2,6,3],[2,3,6]]) assert test.cofactorMatrix() == Matrix([[27,-6,-6],[-1...
16,076
[ 0.009644871577620506, -0.04700963571667671, -0.0004004777583759278, 0.017078952863812447, 0.01615576632320881, 0.00948695745319128, -0.0004779161245096475, -0.01860949955880642, 0.0401100292801857, 0.009274382144212723, -0.0163622684776783, -0.07302892208099365, -0.029882093891501427, 0.00...
12
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"a...
def test_jacobian_hessian(): x = Symbol('x') y = Symbol('y') L = Matrix(1,2,[x**2*y, 2*y**2 + x*y]) syms = [x,y] assert L.jacobian(syms) == Matrix([[2*x*y, x**2],[y, 4*y+x]]) L = Matrix(1,2,[x, x**2*y**3]) assert L.jacobian(syms) == Matrix([[1, 0], [2*x*y**3, x**2*3*y**2]]) f = x**2*y ...
16,077
[ -0.013205192051827908, 0.03545675799250603, 0.03910043463110924, -0.0026432371232658625, 0.013745461590588093, -0.014260602183640003, 0.015466785058379173, 0.005666547920554876, 0.01540396362543106, 0.06468156725168228, -0.013845976442098618, -0.0299284178763628, 0.004947235342115164, 0.06...
12
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Name", "_fields": {"i...
def test_nullspace(): # first test reduced row-ech form R = Rational M = Matrix([[5,7,2,1], [1,6,2,-1]]) out, tmp = M.rref() assert out == Matrix([[1,0,-R(2)/23,R(13)/23], [0,1,R(8)/23, R(-6)/23]]) M = Matrix([[1,3,0,2,6,3,1], [-2,-6...
16,078
[ 0.008508093655109406, -0.0038536658976227045, -0.025874612852931023, 0.039562635123729706, 0.02016918547451496, 0.021357817575335503, -0.027951588854193687, 0.014739020727574825, -0.015877604484558105, 0.04321610927581787, 0.007907521910965443, -0.03933741897344589, -0.0011370191350579262, ...
13
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"a...
def test_QR(): A = Matrix([[1,2],[2,3]]) Q, S = A.QRdecomposition() R = Rational assert Q == Matrix([[5**R(-1,2), (R(2)/5)*(R(1)/5)**R(-1,2)], [2*5**R(-1,2), (-R(1)/5)*(R(1)/5)**R(-1,2)]]) assert S == Matrix([[5**R(1,2), 8*5**R(-1,2)], [0, (R(1)/5)**R(1,2)]]) assert Q*S == A assert Q.T * Q =...
16,079
[ 0.03773465007543564, -0.0219059307128191, -0.019986141473054886, 0.015752436593174934, 0.022465338930487633, 0.008639047853648663, -0.0028447196818888187, 0.01699839159846306, 0.03694639354944229, 0.05878875404596329, 0.034149348735809326, -0.0489228218793869, 0.0320897102355957, 0.0010075...
13
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"a...
def test_eigen(): # test charpoly x = Symbol('x') y = Symbol('y') eye3 = eye(3) assert eye3.charpoly(x) == ((1-x)**3).expand() assert eye3.charpoly(y) == ((1-y)**3).expand() # test values M = Matrix([(0,1,-1), (1,1,0), (-1,0,1) ]) vals = M.eigenvals() ...
16,080
[ 0.020829614251852036, -0.014237514697015285, 0.0050269197672605515, -0.002806376200169325, -0.012923828326165676, 0.0025371296796947718, -0.019882813096046448, -0.024806177243590355, 0.046014510095119476, 0.039339564740657806, 0.0024202591739594936, -0.02067575789988041, -0.01146220508962869...
14
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"a...
def test_wronskian(): x = Symbol('x') assert wronskian([cos(x), sin(x)], x) == cos(x)**2 + sin(x)**2 assert wronskian([exp(x), exp(2*x)], x) == exp(3*x) assert wronskian([exp(x), x], x) == exp(x) - x*exp(x) assert wronskian([1, x, x**2], x) == 2 assert wronskian([exp(x), cos(x), x**3], x).expand...
16,081
[ -0.010389522649347782, -0.0063217030838131905, 0.01453856285661459, 0.020630139857530594, 0.017205320298671722, 0.0045889876782894135, -0.01918169856071472, -0.013171342201530933, 0.010585806332528591, 0.04578158259391785, 0.011262648738920689, -0.05019459128379822, 0.016135910525918007, 0...
13
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Return", "_fields": {"value": null}}, {"_type": "FunctionDef",...
def test_sparse_matrix(): return def eye(n): tmp = SMatrix(n,n,lambda i,j:0) for i in range(tmp.lines): tmp[i,i] = 1 return tmp def zero(n): return SMatrix(n,n,lambda i,j:0) # test_multiplication a=SMatrix(( (1, 2), (3, 1), (0, 6),...
16,082
[ 0.012659992091357708, -0.018978044390678406, -0.014857576228678226, 0.0014406712725758553, 0.010766965337097645, 0.02871190756559372, 0.020339591428637505, -0.01503672730177641, 0.03098115138709545, 0.023946495726704597, -0.010319088585674763, -0.00468479422852397, 0.051643215119838715, 0....
10
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"a...
def test_conjugate(): M = Matrix([ [0,I,5], [1,2,0]]) assert M.T == Matrix([ [0,1], [I,2], [5,0]]) assert M.C == Matrix([ [0,-I,5], [1,2,0]]) assert M.H == M.T.C assert M.H == Matrix([ [0,1], ...
16,083
[ 0.0008063300629146397, -0.024583347141742706, 0.04110495001077652, 0.028216108679771423, 0.040681954473257065, 0.03130146861076355, 0.017255619168281555, 0.004500519018620253, -0.025951853021979332, 0.027345240116119385, -0.03458588197827339, -0.007601429708302021, 0.06125931069254875, 0.0...
10
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"arg...
def test_conj_dirac(): py.test.raises(ShapeError, "eye(3).D") M = Matrix([ [1,I,I,I], [0,1,I,I], [0,0,1,I], [0,0,0,1] ]) assert M.D == Matrix([ [1,0,0,0], [-I,1,0,0], [-I,-I,-1,0], [-I,-I...
16,084
[ 0.053865354508161545, 0.016762467101216316, 0.00016848239465616643, -0.02030366100370884, 0.016382616013288498, 0.03533841669559479, 0.014324067160487175, -0.0419306755065918, -0.011407789774239063, 0.015794459730386734, -0.023060645908117294, -0.04803280159831047, 0.00009687738202046603, ...
10
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"a...
def test_col_row(): x, y = symbols("xy") M = Matrix([[x,0,0], [0,y,0]]) M.row(1,lambda x,i: x+i+1) assert M == Matrix([[x,0,0], [1,y+2,3]]) M.col(0,lambda x,i: x+y**i) assert M == Matrix([[x+1,0,0], [1+y,y+2,3]])
16,085
[ -0.006067828740924597, 0.021904194727540016, 0.04394174739718437, -0.01165778748691082, -0.08179344236850739, -0.016569839790463448, 0.003561793128028512, -0.006973557639867067, 0.024871429428458214, 0.010985436849296093, -0.003428434254601598, 0.0030811454635113478, -0.012102317065000534, ...
11
{"_type": "Module", "_fields": {"body": [{"_type": "ClassDef", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "ui", "annotation": nul...
class debugformatter(baseformatter): def __init__(self, ui, topic, opts): baseformatter.__init__(self, ui, topic, opts) self._ui.write("%s = {\n" % self._topic) def _showitem(self): self._ui.write(" " + repr(self._item) + ",\n") def end(self): baseformatter.end(self) ...
16,086
[ -0.010186957195401192, 0.026926778256893158, 0.06964173913002014, -0.02253265492618084, -0.06100677698850632, -0.03408000245690346, 0.005738545674830675, -0.029966898262500763, -0.031142069026827812, 0.008960690349340439, -0.0033945878967642784, 0.02188120037317276, -0.013744408264756203, ...
10
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []...
def __ConfigureWidgets(self): # configures widgets in base class: Viewer._ConfigureWidgets(self) self.connect(self._btnLoad, SIGNAL('clicked()'), self.LoadImage) B = self._border Wi, Wb, Wt = self._imageWidth , self._btnWidth , self._textWidth Hi, Hb, Ht = ...
16,087
[ 0.05879731476306915, 0.0384443961083889, 0.008042684756219387, -0.012644583359360695, -0.030322683975100517, -0.0061125620268285275, 0.016462275758385658, 0.0006778226234018803, 0.0053587500005960464, 0.048389848321676254, 0.00462317606434226, 0.03331361338496208, -0.00251675839535892, 0.0...
8
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "autoreset", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "convert", "annotation": null, "type_comment": null}}, {"_typ...
def init(autoreset=False, convert=None, strip=None, wrap=True): if wrap==False and (autoreset==True or convert==True or strip==True): raise ValueError('wrap=False conflicts with any other arg=True') sys.stdout = wrap_stream(orig_stdout, convert, strip, autoreset, wrap) sys.stderr = wrap_stream(ori...
16,088
[ 0.002987769665196538, 0.016137681901454926, 0.06097286194562912, 0.010168354958295822, -0.009870199486613274, -0.007193008903414011, 0.03779124841094017, 0.0007877058815211058, 0.013330048881471157, 0.008068840950727463, 0.029144730418920517, -0.040300726890563965, 0.021169062703847885, 0....
11
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "app", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "db", "annotation": null, "type_comment": null}}, {"_type": "arg", ...
def test_delete_some_group(app, db, check_ui): if len (db.get_group_list()) == 0: app.group.create(Group(name="test")) old_groups = db.get_group_list() group = random.choice(old_groups) app.group.delete_group_by_id(group.id) new_groups = db.get_group_list() assert len(old_groups) - 1 == ...
16,089
[ 0.011136071756482124, -0.011073541827499866, 0.04734109714627266, -0.0443623811006546, 0.010630144737660885, 0.02101016975939274, 0.015825841575860977, 0.0012903972528874874, -0.00411562854424119, -0.025034844875335693, 0.060029055923223495, -0.05116112530231476, 0.031083226203918457, -0.0...
10
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "session", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "sector", "annotation": null, "type_comment": null}}], "kwarg":...
def create_from_object(session, sector): data = Sector.get_schema_query(session, sector.uid).first() if not data: data = Sector() data.copy_from_object(sector) for location in sector.locations: location_data = Location.create_from_object(session, location) if loc...
16,090
[ 0.010036803781986237, 0.015846407040953636, 0.008599779568612576, -0.021739885210990906, -0.017535051330924034, -0.014135397970676422, -0.009807550348341465, 0.04674522578716278, -0.023350246250629425, 0.008348160423338413, -0.018877018243074417, -0.027398517355322838, 0.002556728897616267, ...
10
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}], "kwarg": {"_type": "arg", "_fields": {"arg": "kwargs", "annotation": null, "type_comment": null}}, "v...
def run(self, **kwargs): self.prompt.render_title(_('Repositories')) # Limit to only repositories of a specific type if kwargs.get('str-eq', None) is None: kwargs['str-eq'] = [] kwargs['str-eq'].append(['notes.%s' % constants.REPO_NOTE_TYPE_KEY, self.repo_type]) # S...
16,091
[ -0.006454683840274811, 0.006282038986682892, 0.009551149792969227, -0.02414797991514206, -0.011427965015172958, -0.04392972216010094, 0.016740966588258743, 0.0015844327863305807, -0.03034091182053089, 0.023813828825950623, -0.010291851125657558, -0.00324683403596282, -0.0031159583013504744, ...
10
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "image_file_path", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "number", "annotation": null, "type_comment": null}}], ...
def write_number(image_file_path, number=1): img = Image.open(image_file_path) font_size = img.size[0] if img.size[0] < img.size[1] else img.size[1] font_size = font_size / 4 number_txt = str(number) + ' ' if number < 100 else '99+' font = ImageFont.truetype("arial.ttf", size=font_size) if font....
16,092
[ 0.034941092133522034, 0.007060249801725149, 0.07738262414932251, -0.03752508759498596, 0.027097640559077263, -0.034072138369083405, 0.003695912193506956, -0.050445057451725006, -0.04916449263691902, 0.008506600745022297, -0.012096752412617207, -0.04186985641717911, 0.0696992427110672, 0.04...
11
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [{"_type": "arg", "_fields": {"arg": "self", "annotation": null, "type_comment": null}}, {"_type": "arg", "_fields": {"arg": "tblName", "annotation": null, "type_comment": null}}], "kwarg": n...
def _confirm(self,tblName): conn = DbConnect(self.dbName,tblName) res = conn.GetColumnNamesAndTypes() assert len(res)==len(self.colHeads),'bad number of columns' names = [x[0] for x in res] for i in range(len(names)): assert names[i].upper()==self.colHeads[i].upper(),'bad column head' if R...
16,093
[ 0.0011392309097573161, 0.035224370658397675, -0.001363972551189363, -0.028939705342054367, 0.05554695427417755, 0.02210431918501854, 0.0048997728154063225, 0.0014672322431579232, 0.07856913655996323, 0.041811395436525345, 0.02148880995810032, -0.03662816435098648, -0.016564741730690002, 0....
10
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "For", "_fields": {"body": [{"_type": "Assign", "_fields": {"va...
def test_kernel_gradient(): # Compare analytic and numeric gradient of kernels. for kernel in kernels: K, K_gradient = kernel(X, eval_gradient=True) assert_equal(K_gradient.shape[0], X.shape[0]) assert_equal(K_gradient.shape[1], X.shape[0]) assert_equal(K_gradient.shape[2], kern...
16,094
[ 0.008343435823917389, -0.029519440606236458, 0.019520919770002365, 0.006688352674245834, 0.0028496349696069956, -0.00292757130227983, 0.03446201980113983, -0.021584106609225273, 0.010616342537105083, 0.040175460278987885, -0.028793923556804657, 0.009448714554309845, 0.004500467795878649, 0...
7
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "For", "_fields": {"body": [{"_type": "If", "_fields": {"body":...
def test_auto_vs_cross(): # Auto-correlation and cross-correlation should be consistent. for kernel in kernels: if kernel == kernel_white: continue # Identity is not satisfied on diagonal K_auto = kernel(X) K_cross = kernel(X, X) assert_almost_equal(K_auto, K_cross, ...
16,095
[ -0.011898458003997803, -0.007863528095185757, 0.010614616796374321, 0.0044533247128129005, 0.029046909883618355, -0.014546380378305912, 0.02943664789199829, 0.022146262228488922, 0.04096829518675804, 0.02840498834848404, -0.010694856755435467, 0.020220501348376274, -0.007250264752656221, 0...
9
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Expr", "_fields": {"value": {"_type": "Call", "_fields": {"arg...
def test_kernel_operator_commutative(): # Adding kernels and multiplying kernels should be commutative. # Check addition assert_almost_equal((RBF(2.0) + 1.0)(X), (1.0 + RBF(2.0))(X)) # Check multiplication assert_almost_equal((3.0 * RBF(2.0))(X), (RBF...
16,096
[ -0.0035770798567682505, -0.0063514974899590015, 0.012691362760961056, -0.00899213831871748, 0.012784425169229507, -0.006101393140852451, 0.009678472764790058, -0.036294274032115936, 0.04553069919347763, 0.04713602364063263, -0.014715466648340225, 0.01047531794756651, 0.020136341452598572, ...
8
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "BinOp", "_fields": {"...
def test_kernel_anisotropic(): # Anisotropic kernel should be consistent with isotropic kernels. kernel = 3.0 * RBF([0.5, 2.0]) K = kernel(X) X1 = np.array(X) X1[:, 0] *= 4 K1 = 3.0 * RBF(2.0)(X1) assert_almost_equal(K, K1) X2 = np.array(X) X2[:, 1] /= 4 K2 = 3.0 * RBF(0.5)(X2)...
16,097
[ -0.002487081103026867, 0.003515111980959773, 0.008101495914161205, 0.0023950187023729086, -0.005177815444767475, -0.0045389579609036446, 0.03385666385293007, -0.00889379158616066, 0.034682437777519226, 0.05566151812672615, 0.018613355234265327, 0.009234143421053886, 0.0016459651524201035, ...
10
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Call", "_fields": {"a...
def test_matern_kernel(): # Test consistency of Matern kernel for special values of nu. K = Matern(nu=1.5, length_scale=1.0)(X) # the diagonal elements of a matern kernel are 1 assert_array_almost_equal(np.diag(K), np.ones(X.shape[0])) # matern kernel for coef0==0.5 is equal to absolute exponential ...
16,098
[ 0.016772059723734856, 0.026461360976099968, 0.008737968280911446, -0.010668129660189152, -0.0029364849906414747, 0.007533678784966469, -0.016178162768483162, -0.002607917645946145, -0.0014352482976391912, 0.060709353536367416, 0.03215835988521576, -0.04364034906029701, -0.030222700908780098,...
10
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "Assign", "_fields": {"value": {"_type": "Tuple", "_fields": {"...
def test_kernel_clone(): # Test that sklearn's clone works correctly on kernels. bounds = (1e-5, 1e5) for kernel in kernels: kernel_cloned = clone(kernel) # XXX: Should this be fixed? # This differs from the sklearn's estimators equality check. assert_equal(kernel, kernel_cl...
16,099
[ -0.03191469982266426, -0.021625326946377754, 0.021366622298955917, -0.034172482788562775, -0.004489107057452202, -0.018967727199196815, 0.0047213532961905, -0.0027693116571754217, 0.04249805957078934, 0.03283192589879036, 0.013464381918311119, -0.010642153210937977, -0.011041969060897827, ...
9
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "For", "_fields": {"body": [{"_type": "If", "_fields": {"body":...
def test_kernel_versus_pairwise(): # Check that GP kernels can also be used as pairwise kernels. for kernel in kernels: # Test auto-kernel if kernel != kernel_white: # For WhiteKernel: k(X) != k(X,X). This is assumed by # pairwise_kernels K1 = kernel(X) ...
16,100
[ -0.020132284611463547, 0.003534158691763878, -0.02316962741315365, -0.062282487750053406, -0.007271559443324804, 0.026466671377420425, 0.001236391020938754, 0.0037910344544798136, 0.04936530813574791, 0.020403273403644562, 0.003133319551125169, -0.004047910217195749, -0.0034805252216756344, ...
13
{"_type": "Module", "_fields": {"body": [{"_type": "FunctionDef", "_fields": {"args": {"_type": "arguments", "_fields": {"args": [], "kwarg": null, "vararg": null, "defaults": [], "kwonlyargs": [], "kw_defaults": [], "posonlyargs": []}}, "body": [{"_type": "For", "_fields": {"body": [{"_type": "Assign", "_fields": {"va...
def test_set_get_params(): # Check that set_params()/get_params() is consistent with kernel.theta. for kernel in kernels: # Test get_params() index = 0 params = kernel.get_params() for hyperparameter in kernel.hyperparameters: if hyperparameter.bounds == "fixed": ...