package face import ( "testing" "github.com/stretchr/testify/assert" ) func TestEmbeddings_Contains(t *testing.T) { t.Run("Ignore", func(t *testing.T) { e1 := Embedding{-0.00067741907, -0.0473858, -0.055704225, 0.066581585, 0.005290037, 0.03822874, -0.05082791, 0.049087, 0.018308854, -0.01478969, -0.0017964382, 0.057903986, -0.02245441, -0.033446193, -0.0071987803, -0.03150515, 0.017724376, 0.019948162, 0.056362633, -0.11701946, -0.09725581, 0.013104323, 0.07357148, -0.020104313, -0.014956488, -0.017257847, -0.020743687, -0.046340823, -0.021527996, 0.057039287, -0.051751148, -0.00595411, 0.011733857, -0.04644382, -0.028774152, 0.038308877, -0.015685631, 0.0038190065, -0.094677314, 0.07005245, -0.003068884, 0.050274804, -0.018143218, 0.012056174, 0.019058047, -0.00077958487, 0.030408988, 0.0885491, -0.11106459, -0.019910613, 0.01465938, 0.032499526, 0.04720623, 0.03163276, -0.079508044, 0.07914293, 0.03724754, 0.05636608, -0.016979787, -0.04298359, -0.03599786, 0.058342796, -0.024069536, -0.03200436, 0.015390179, 0.07293075, -0.0013783299, -0.01605161, -0.0045498423, -0.016551308, 0.060823392, 0.073548146, -0.021239666, -0.036749583, 0.00028047478, -0.025989566, -0.05310693, -0.009845653, -0.012862101, 0.058108855, 0.06915682, 0.021099294, 0.001225616, 0.033261415, 0.042154703, 0.05271609, -0.030613305, 0.041209485, 0.0019353209, -0.0019135632, 0.080911145, 0.011060149, 0.05281461, -0.10160427, 0.053647887, 0.01762615, -0.018661015, 0.02777136, -0.056023918, 0.057687696, 0.06513923, -0.069180146, -0.015231091, 0.03774808, 0.012945786, 0.090585396, 0.019942591, -0.015280875, -0.0011742035, -0.042135417, 0.05812486, 0.05519544, -0.06453465, -0.04014237, -0.03199121, 0.009241696, 0.043912023, 0.015467731, 0.0020673021, 0.08763925, -0.08974939, -0.05304043, 0.016309343, -0.04766073, -0.0046682972, -0.040477246, 0.012679025, 0.005960806, -0.03256039, -0.07089416, -0.02648642, -0.062463485, 0.08295411, -0.037147924, -0.074104264, 0.077417135, -0.042383663, 0.002088579, 0.07709948, 0.06521331, -0.07541816, 0.057679284, -0.0038482754, 0.055191133, 0.058614884, -0.018541405, -0.012277692, 0.057926673, -0.01724738, 0.020869015, 0.046103075, -0.0319926, -0.0671411, 0.02629761, 0.044356663, 0.036788594, 0.028035736, 0.06419986, 0.045972086, -0.044160895, 0.09784713, 0.00953585, -0.06252615, 0.025597766, 0.029688764, 0.027506752, -0.055384982, -0.028262418, -0.057812758, 0.042470966, -0.05840525, -0.03801629, 0.0043816785, -0.015086851, 0.022297874, 0.054110903, 0.07420415, -0.040949743, -0.08912868, -0.060081407, -0.046966024, -0.04826231, -0.031198893, 0.06643161, 0.01347482, 0.029003717, 0.047974125, 0.07580259, 0.0364837, 0.012980756, 0.020622224, -0.022555852, 0.10519882, -0.03425076, 0.03889103, -0.007944982, 0.060116176, 0.038143042, -0.043681793, 0.05316621, 0.0016697546, -0.0033659195, 0.020053076, -0.07204762, 0.009732797, 0.03862544, 0.03913928, -0.009832126, 0.06401315, 0.044209804, -0.051490918, 0.014780334, -0.025438532, -0.01395564, -0.038089562, -0.009803314, -0.04146325, 0.03357636, -0.009009651, 0.04373462, -0.05627207, -0.072068065, -0.007331119, -0.04238925, -0.021102922, -0.021610938, -0.063095644, -0.05075978, -0.07491732, 0.0113026835, 0.04940704, 0.084163934, -0.01636119, -0.06292533, -0.014526007, -0.007826649, 0.07212185, 0.004734863, -0.062791124, -0.016170232, -0.016590146, -0.024280416, -0.019522576, 0.01579864, 0.002749153, 0.053687476, -0.016495354, 0.03662209, -0.018870195, 0.039446633, 0.04715818, 0.013310755, 0.028033575, 0.067203104, -0.005826697, 0.042239364, -0.020745477, 0.0015561507, 0.065384425, 0.09041862, 0.01788624, -0.010026493, 0.0639752, -0.0041079777, -0.058741663, 0.034099422, 0.016963305, -0.0052649197, -0.07403116, -0.0029912698, -0.07583906, 0.001012409, -0.029492352, -0.04166984, -0.048218843, -0.06306306, -0.0033243645, -0.02919451, 0.0039520795, -0.037993237, 0.044352133, 0.03976749, -0.030565975, -0.076377496, -0.06569797, 0.01630497, 0.017201763, 0.028935125, 0.004058029, -0.09946857, 0.036038112, -0.06792709, 0.04493338, 0.035801385, -0.048764315, -0.06326099, 0.037968885, 0.038012274, 0.038041856, 0.04288072, 0.01531972, 0.032477308, 0.043926656, -0.0077148937, 0.056322563, -0.03451439, -0.0083661955, 0.0015379508, -0.007879496, 0.01986026, -0.019533899, 0.0405012, 0.015047856, 0.04601962, 0.080275685, 0.017424034, -0.032671392, 0.024088044, -0.021807125, 0.010775311, 0.094901696, 0.0048406925, 0.013086048, 0.04339756, -0.0069915624, 0.019183818, 0.0624931, 0.019509323, 0.07727781, 0.071851335, 0.046544127, 0.040363774, -0.027118236, 0.06800823, -0.01851149, 0.039025713, -0.037301723, 0.05617681, 0.027737545, -0.0011841523, 0.034742635, 0.006083848, 0.033872508, 0.012025738, -0.02354928, -0.07461171, 0.0027702893, 0.04646551, 0.06590462, -0.00794524, -0.011096932, 0.031695057, -0.06732352, -0.051879242, -0.0773121, -0.000517982, 0.08113213, -0.015312499, 0.018544769, -0.023654874, -0.01689197, 0.026425209, -0.08191027, 0.03139842, -0.011997609, 0.059896134, 0.07505033, -0.012907369, 0.008597082, 0.007715897, -0.07062183, -0.027084265, 0.0028182073, 0.03769887, 0.034299187, 0.046780333, -0.007847023, -0.051446356, 0.007982996, -0.034917314, -0.0038174198, -0.05954771, -0.044208106, 0.04685703, -0.0199229, -0.0032713648, 0.009684984, -0.050678924, 0.007356914, -0.06628045, 0.042982273, 0.0055478252, 0.011330174, -0.082057334, 0.026437566, -0.015942575, 0.048285805, -0.003856138, 0.04399534, 0.01741405, -0.059217025, 0.056499016, -0.03459506, 0.030366927, 0.016147505, -0.021027595, -0.013333387, -0.035330992, 0.0445699, -0.03483558, 0.02072434, -0.019552084, -0.0043943045, -0.03957101, 0.0041682394, 0.006047565, 0.03504845, 0.04675005, -0.021805461, -0.0033183587, -0.0017508261, 0.033419013, 0.008266579, 0.067113, -0.026226636, -0.020189233, 0.029219048, 0.031028047, 0.021648621, -0.055164326, -0.008505359, 0.05173594, 0.016450783, -0.017234024, -0.10492493, -0.04954522, 0.024168914, -0.008840458, -0.078473605, -0.042714797, -0.040692057, -0.05446264, 0.0148880705, 0.057658363, 0.005458192, 0.02171352, -0.04556389, 0.017333247, -0.10342444, -0.06159851, -0.03170678, 0.08064648, 0.024460033, -0.07185376, -0.0019515441, -0.026248276, 0.034460787, 0.08695437, 0.06363327, 0.012909266, 0.00093975884, 0.03682474, -0.041370448, -0.0070990156, 0.058603138, -0.038166087, -0.039693672, 0.025385896, 0.0035452761, -0.015794974, 0.019059189, -0.028707229, 0.038948998, -0.032039847, -0.07992934, -0.05482927, 0.048767164, -0.03186542, 0.059099294, 0.063702375, 0.01810526, -0.019284561, 0.036313917, 0.0006970895, 0.020730797, 0.08630282, -0.10650717, 0.0017196184, 0.023258938, -0.021214833, 0.015206377, -0.027243242, -0.021319263, -0.054438062, 0.066603355, -0.047786396, 0.018822387, -0.031346995, -0.0049103773, -0.020732613, -0.0841506, 0.00707288, -0.0033278253, 0.068160556, -0.011127404, 0.05533654, 0.0046188673, 0.039132893, 0.008633137, -0.057081457, -0.030337824, -0.0721918} e2 := Embedding{-0.037731018, -0.005501065, 0.04339579, 0.050818004, -0.059338734, 0.033849984, -0.006599584, -0.0017643301, 0.049746443, -0.103716515, 0.037138782, -0.0064612515, 0.071909964, 0.013218528, -0.065359734, 0.11057091, 0.031195551, 0.025612833, 0.0075477255, -0.034973715, -0.013490629, -0.08104751, -0.022038054, -0.05304818, 0.008366317, -0.056096837, -0.008484318, 0.049539477, 0.019540254, 0.067417614, -0.027856546, -0.008532138, -0.017063588, -0.00016265438, -0.106199585, 0.03904082, 0.030587498, 0.043008707, -0.015111545, -0.022849092, 0.0025588698, -0.012814152, 0.037556626, -0.0086288145, 0.05265788, 0.011832273, 0.00015048613, -0.0081366515, 0.0013409692, 0.028389124, 0.022627315, -0.015008434, -0.0007749727, 0.013927345, -0.012275729, -0.0090859635, 0.019502806, -0.011900984, 0.016286656, 0.08094661, 0.000306613, -0.06327904, 0.018552454, 0.08885108, -0.07583091, 0.09275318, -0.018484656, 0.074180886, -0.039385945, -0.08063905, -0.05360434, -0.037074074, 0.09909196, 0.025063906, -0.009406389, -0.029612983, -0.018644262, 0.08433939, -0.04466277, -0.07118042, -0.0053266245, -0.07471344, 0.06739151, -0.05399609, 0.03125197, -0.00007781149, -0.04214992, -0.044316035, 0.025013437, 0.031466946, 0.0023496088, 0.042693187, -0.046198968, 0.026152546, -0.017578958, 0.023763098, 0.027511515, -0.05229892, -0.005204117, 0.035853546, -0.031919815, -0.027175877, -0.033706605, 0.018576957, -0.0010251165, -0.006808904, 0.009910016, -0.046926413, -0.02833718, 0.0132687995, -0.033933964, 0.06434295, 0.046245363, 0.044698197, 0.041076522, 0.04224362, -0.050834127, 0.0037004466, 0.061506275, -0.018232772, 0.067569405, 0.048701495, 0.042266034, -0.11045008, 0.03627151, -0.07259142, -0.0027725939, 0.040572345, 0.010365194, -0.018683784, 0.004533848, 0.037213936, -0.050944775, 0.07134523, 0.004012727, 0.036228556, -0.013853831, -0.06910639, -0.011394227, -0.012075533, 0.036311198, -0.02587341, -0.04086224, -0.024498813, -0.019423751, -0.022674281, 0.052483488, 0.026303312, -0.051178075, 0.008410645, 0.039851066, -0.028721321, -0.027934253, -0.029567441, 0.054549955, 0.07423011, -0.07211806, 0.015979288, 0.002092099, 0.049062036, 0.025120452, 0.045975365, 0.025024865, -0.04019101, 0.0013054911, -0.0049644294, 0.0065203104, -0.03237452, -0.020704443, 0.028736785, -0.027353559, 0.07551169, 0.0842262, 0.019992182, 0.11138123, -0.028617613, 0.06700691, -0.048681036, -0.008201593, -0.058066163, 0.027867565, 0.07693089, -0.033642102, -0.05855467, -0.08575646, -0.019721355, 0.018443357, -0.0037373751, 0.032450553, -0.0074002664, -0.028135147, 0.046631414, 0.0192969, -0.0071076434, -0.004898368, 0.011896125, -0.026020564, 0.074016415, -0.033884488, -0.07919758, 0.021606326, -0.0142197255, 0.0807476, 0.03722956, -0.0015949347, 0.008076167, -0.009640628, 0.02341143, 0.015375526, -0.059428506, 0.051759534, 0.028049389, 0.07790443, 0.0478649, 0.09191913, -0.055882096, -0.026637457, 0.01236174, -0.0033003334, 0.008522798, 0.027216703, -0.033221588, -0.028086975, -0.11505473, -0.044336796, 0.013873659, 0.03982099, 0.060988583, -0.07439005, 0.01333661, -0.004818605, 0.02561305, -0.059055943, 0.0081638545, -0.032278564, 0.046092775, 0.025316834, -0.046857174, -0.0341012, 0.04379944, -0.029710777, 0.09238533, 0.009769442, 0.018552538, -0.02632421, 0.033739865, -0.022547472, 0.016400741, -0.05336998, -0.012623122, -0.08303054, -0.010368709, 0.01690871, 0.0014627968, -0.050720602, 0.038742293, -0.065664165, -0.10676187, -0.013403239, 0.075702645, -0.055623896, -0.03871971, -0.042371742, 0.03794916, -0.0590573, -0.002583715, -0.029995736, -0.08144537, -0.043295015, -0.034286328, -0.026538746, 0.01953962, 0.08203153, 0.036415525, 0.045531306, 0.004713152, 0.026550433, -0.0055336948, -0.031087596, -0.01923592, -0.1047651, 0.051826596, -0.009522955, 0.0023846119, -0.030824797, 0.0011774554, 0.03384506, 0.010090165, -0.033521466, -0.052155476, 0.0032979914, -0.004305921, -0.08622774, 0.03262125, 0.06332183, 0.00067599304, 0.01989574, 0.04406689, 0.019945903, -0.003796719, 0.00025200442, -0.010055775, 0.04070448, -0.004082432, -0.026942603, 0.110138796, -0.029453337, 0.015611174, 0.08778206, -0.027199872, -0.014513782, 0.021546016, 0.01706933, -0.01365763, 0.026393317, -0.029974515, 0.0050973813, 0.00732006, 0.034644503, 0.03125295, -0.01563078, -0.041023903, -0.04566191, -0.00013489528, 0.04253813, 0.045907266, -0.011943533, 0.031480506, -0.0034109016, -0.035025172, 0.028193155, -0.06832476, -0.0019371725, -0.049427234, -0.0061696135, 0.051213425, 0.07832765, -0.01894849, 0.0290217, 0.031639505, -0.045830216, -0.048976466, 0.052241277, -0.026111973, 0.037248738, -0.07693719, -0.00020981894, 0.030037824, -0.041687537, -0.015251262, 0.041234106, 0.031005232, 0.024838371, 0.0020733695, -0.038252156, -0.026375879, 0.03495583, 0.018539391, -0.07203285, 0.006305707, -0.004792029, -0.05153865, 0.0072443904, -0.017075827, 0.013596034, -0.0054885144, -0.052320853, -0.033805914, -0.038080305, -0.010182737, 0.012953395, 0.014565793, -0.023107765, 0.030313661, 0.011124675, 0.018100796, 0.1074551, -0.074430406, -0.04017658, -0.002058053, -0.07340946, 0.0033503077, 0.04565434, -0.033483636, -0.029218825, -0.05245377, -0.059680052, 0.017752757, -0.05493096, -0.10746678, 0.08623605, 0.014577705, 0.0044184765, -0.025559181, -0.015846781, -0.006661373, 0.09459266, 0.036481388, 0.030402042, -0.0152169075, 0.0037343376, 0.024195764, -0.01859682, -0.0022416788, 0.0056786016, -0.06771737, 0.02364697, 0.021247962, 0.05002757, 0.083975114, 0.011197936, 0.0035017033, -0.0014220127, -0.024415374, 0.023921741, -0.0108229555, -0.06622103, -0.00024976654, 0.06549428, -0.004968772, -0.011665843, 0.03409593, 0.028397659, -0.086434126, -0.074232705, 0.041721817, -0.034767248, -0.014432104, 0.006313255, 0.04040112, -0.0050085387, -0.0023618732, -0.02225774, 0.02383989, 0.061036374, 0.058602326, 0.04343989, -0.029145751, 0.0369256, -0.054843802, -0.017078603, 0.047091234, 0.050245833, -0.04615808, -0.02404996, 0.02584908, -0.006215116, -0.016719814, 0.052097827, 0.01908364, -0.07564805, -0.11024787, -0.036854018, -0.0056766514, -0.007618422, 0.034403287, 0.056957226, -0.03565076, -0.0365251, 0.040833052, 0.008173664, -0.04300709, 0.0028465139, -0.020792698, 0.020321466, -0.002447697, 0.019681728, -0.08843341, -0.042670425, 0.014576458, 0.009701015, -0.12435015, -0.025056241, 0.03084893, -0.031128377, 0.006784327, 0.052201632, 0.06773422, 0.015289244, 0.009421969, 0.0725144, -0.07110377, -0.05183192, -0.008816121, -0.11178569, 0.079700254, -0.0110752955, 0.0046521816, -0.07299747, 0.10732809, -0.06012486, 0.057736155, -0.02227576, -0.063017495, 0.085292354, 0.037407015, -0.07368719, 0.033426613, 0.062104296, -0.016089993, -0.023178348, -0.064638525, 0.028132388, -0.049967688, 0.053581465, 0.031400185, 0.0712773, -0.012665878, 0.0760322, 0.030081542, -0.022147592, 0.009422989} assert.True(t, IgnoredEmbeddings.Contains(e1, IgnoredDist)) assert.False(t, IgnoredEmbeddings.Contains(e2, IgnoredDist)) assert.False(t, IgnoredEmbeddings.Contains(e1, 0.1)) }) } func TestEmbeddings_First(t *testing.T) { t.Run("Ignore", func(t *testing.T) { e := IgnoredEmbeddings.First() assert.Equal(t, Embedding{0.0001326936762779951, 0.010595318133709952, -0.025556722866895143, 0.0469118170440197, -0.006627591326832771, 0.05271399952471256, -0.04542037146165967, 0.027480189339257777, -0.004917271726299077, -0.07468410208821297, 0.02064464334398508, 0.027222666889429092, 0.07686506863683462, -0.03543879697099328, -0.06587888672947884, 0.00656710215844214, 0.0468103364109993, 0.026114298962056637, 0.09671456180512905, -0.10109077207744122, -0.00781591737177223, -0.03552762418985367, 0.06885470915585756, -0.012004591058939695, 0.08148624002933502, -0.028154293075203896, 0.04417960252612829, -0.04447614587843418, -0.02476067957468331, 0.08517011441290379, 0.002213838277384639, -0.04421043721958995, -0.030782480724155903, -0.022004681872203946, 0.0009286352433264256, 0.010065821232274175, -0.02192891761660576, -0.012186611769720912, -0.08409351948648691, 0.03493268555030227, -0.044278232380747795, 0.028376419097185135, 0.0037802220904268324, 0.04365090653300285, 0.020489776856265962, 0.0062931065913289785, 0.012816649512387812, 0.08537860121577978, -0.08391124662011862, -0.0074469012033659965, 0.007379985763691366, 0.010717783472500741, 0.05138006154447794, 0.03530120011419058, -0.0252615287899971, 0.048870823346078396, 0.051952130161225796, 0.05130995064973831, -0.07164964452385902, 0.008358421036973596, 0.07212860928848386, 0.023144953418523073, 0.016010764054954052, -0.0020557132083922625, 0.0006047732058505062, 0.05894300062209368, 0.018385239876806736, 0.013549384311772883, 0.013471916783601046, -0.026798027334734797, 0.055714783258736134, 0.056760589592158794, -0.03564274637028575, 0.006639213301241398, -0.010688409092836082, -0.014488881919533014, -0.041894917376339436, 0.027378612896427512, 0.04120381874963641, 0.026110727107152343, 0.014362117013661191, -0.015710897743701935, 0.01369841955602169, -0.013755762134678662, -0.025898753898218274, 0.03539643401745707, -0.02275478537194431, 0.044916168320924044, 0.06104293651878834, 0.020197266509057954, 0.03360230568796396, 0.0005524924490600824, -0.03635450592264533, -0.04944554786197841, 0.07170013058930635, -0.0030192392878234386, 0.0010193748748861253, -0.010943924076855183, -0.06179766729474068, 0.056694529950618744, 0.004520991584286094, -0.09191464446485043, -0.02631867417949252, 0.03776269545778632, -0.00876810192130506, 0.10884877666831017, 0.005137963918969035, 0.014990123057032179, -0.012330824043601751, -0.007994036190211773, 0.04028965998440981, 0.030694966204464436, 0.013997081900015473, -0.027155806310474873, 0.008769600055529736, 0.0038997385127004236, -0.003813096962403506, 0.06714510265737772, 0.006777862668968737, 0.061618989799171686, -0.016695198486559093, -0.014862070740491617, 0.047256719786673784, -0.030920962191885337, -0.010902314214035869, 0.029649023665115237, -0.03882072772830725, 0.037115989718586206, -0.00044789700768887997, -0.050685918889939785, 0.023225090000778437, 0.005942594725638628, 0.03058242436964065, -0.05067136138677597, -0.013880123384296894, 0.0521021569147706, -0.03878975426778197, 0.0057146906128764385, 0.01622107159346342, 0.0286275401012972, -0.07171816006302834, -0.024164889007806778, -0.036472175968810916, -0.06874032877385616, -0.013022568658925593, -0.02637113118544221, 0.061983236111700535, 0.0328070695977658, 0.004039793537231162, -0.022473737597465515, 0.017253196332603693, -0.04853619821369648, -0.053010642528533936, 0.04317591618746519, 0.00835538915998768, 0.015444972610566765, 0.04270970821380615, 0.028640874341363087, 0.06504016369581223, 0.03173913527280092, 0.05225925333797932, 0.03651800798252225, -0.022531148977577686, -0.0032108076702570543, 0.030786060029640794, 0.01946059288457036, -0.020198959624394774, -0.010514225577935576, -0.04853967670351267, 0.02134396170731634, -0.05255058314651251, 0.016728751827031374, 0.0456616897135973, -0.021495807450264692, 0.03207355597987771, 0.010148180415853858, 0.03585670003667474, -0.02635771268978715, -0.04969983361661434, -0.034095218405127525, -0.02873873570933938, 0.020237101707607508, -0.026095976354554296, 0.06887094769626856, 0.010905503178946674, 0.05485152825713158, 0.03837144002318382, 0.07052317541092634, 0.006913394434377551, 0.010285209049470723, -0.03990606777369976, -0.05088027101010084, 0.0778753962367773, -0.0213193167001009, -0.03161718975752592, -0.02693262230604887, 0.0435414626263082, 0.01335046417079866, -0.036178333684802055, 0.037226798478513956, 0.052575312089174986, -0.0522100068628788, -0.009666121564805508, 0.009881116129690781, -0.0037592697190120816, 0.017672576592303813, -0.039784221327863634, -0.023527713026851416, -0.020135456696152687, -0.04171011736616492, -0.03752618143334985, 0.011444047326222062, 0.0015834929654374719, 0.008812893531285226, -0.023482086980948225, 0.006552054779604077, -0.0058590869884938, 0.04283139808103442, 0.052830352913588285, -0.0008150241555995308, -0.08346264809370041, -0.10364211909472942, -0.025862343376502395, -0.037633945466950536, -0.00131333211902529, 0.04283250030130148, -0.02747755730524659, -0.022013332003552932, -0.05700004659593105, -0.057958067394793034, 0.04643791541457176, 0.09375700354576111, 0.044992691837251186, -0.025699439109303057, 0.03685394627973437, 0.039113527920562774, -0.004286542231056956, -0.050266037695109844, 0.006167740881210193, 0.009338066913187504, -0.05799494404345751, 0.011283616302534938, -0.021689202752895653, -0.022013561276253313, 0.06421529594808817, 0.037321062409318984, -0.022122669965028763, 0.03338781511411071, 0.004881134445895441, -0.005090652208309621, -0.005954607389867306, -0.003857724070257973, 0.013872599869500846, 0.040445003658533096, 0.0030193766724551097, 0.020781447528861463, 0.04388184240087867, -0.00434388080611825, 0.014594015898182988, 0.07954355143010616, -0.003253952323575504, -0.05893095303326845, 0.012250101892277598, 0.029312842525541782, -0.08140432462096214, 0.024246320594102144, 0.006364793865941465, -0.012409177725203335, -0.022765739355236292, 0.07083966210484505, -0.0560477483086288, 0.02344445328344591, 0.025518586859107018, -0.038515486754477024, -0.040526574943214655, 0.0033363434486091137, 0.07186504639685154, -0.007116460474207997, -0.027830936181999277, -0.11900371685624123, 0.036241024266928434, -0.019209803780540824, 0.016880312585271895, -0.020635713124647737, -0.012299022404477, -0.012887225369922817, 0.013467759592458606, -0.056274086236953735, -0.07062955480068922, -0.047921731136739254, 0.050967195304110646, -0.09523350931704044, -0.01923635500133969, 0.0018940714071504772, -0.025784526020288467, 0.004750739550217986, 0.001268803607672453, 0.08276346698403358, 0.0475466912612319, 0.0204452850157395, 0.04777416866272688, 0.004511475046456326, 0.05325452284887433, -0.00824436274706386, 0.04315535444766283, 0.01829960517352447, -0.03411059989593923, 0.011709870072081685, -0.022576917544938624, 0.04093322320841253, -0.03366286098025739, 0.00007134396582841873, 0.0672286506742239, 0.057760706171393394, 0.05040881037712097, 0.019016009813640267, -0.07006099820137024, 0.011889255285495892, -0.035422834334895015, 0.03638885170221329, 0.0601487485691905, -0.03319359011948109, -0.045506994472816586, 0.019405824947170913, -0.00514926778851077, 0.07637834828346968, 0.07720410358160734, 0.022179096937179565, 0.09868652559816837, 0.06108273658901453, 0.0493094720877707, 0.03135237097740173, -0.04882502695545554, 0.0584859773516655, 0.030338898301124573, 0.003376852720975876, 0.01842997614585329, 0.046141053549945354, 0.03998812031932175, 0.06666938867419958, 0.021333562210202217, -0.024483966641128063, 0.04871886316686869, 0.02728640241548419, -0.05634338594973087, -0.007101567229256034, 0.027000208385288715, 0.03502309508621693, 0.011526696383953094, -0.03697758028283715, -0.010898058622842655, 0.056068443693220615, 0.029542725766077638, -0.06271603982895613, -0.05443012993782759, -0.0007829638198018074, 0.11164804548025131, -0.02070094458758831, 0.006636139118199935, -0.0727179991081357, 0.021099978126585484, -0.03498802054673433, -0.06967776361852884, -0.04527123365551233, -0.015574883203953505, 0.024440275970846415, 0.024940682807937264, -0.0767935961484909, -0.02395771024748683, 0.028084914898499846, -0.0915510281920433, 0.02133126324042678, 0.013071146167021652, 0.004649237322155386, 0.08952618017792702, 0.03991545923054218, 0.0416784998960793, -0.06148885563015938, -0.01432584528811276, 0.008203202858567238, 0.020670469384640455, -0.027112244328236557, 0.0039047824539011344, -0.024497278966009617, -0.043294325936585665, -0.025314603466540575, -0.0067777622025460005, -0.040093651972711086, 0.009956442285329103, -0.03299230616539717, -0.01792255137115717, 0.012778022966813296, -0.03521473368164152, -0.010197664145380259, 0.01715578866424039, -0.008158075157552958, 0.04854840412735939, 0.07429435942322016, 0.040353764314204454, 0.034050410613417625, -0.06899271160364151, 0.05916056968271732, 0.009034074377268553, -0.015106763457879424, -0.00039310590364038944, -0.01474015589337796, 0.0068119101342745125, 0.030776663683354855, 0.04403356648981571, -0.03385453065857291, 0.013438114430755377, 0.017026713234372437, -0.05315904412418604, 0.002748164813965559, -0.002453066874295473, -0.04506317153573036, 0.012577373650856316, 0.057200564071536064, 0.06909130979329348, -0.0031225606217049062, -0.003926296718418598, 0.048229482024908066, -0.008486846985761076, 0.0746435010805726, -0.000002196320565417409, 0.001961063011549413, 0.012371355667710304, -0.00031584547832608223, 0.03543752012774348, -0.009082387339731213, -0.019061634404351935, 0.018139481428079307, -0.0034449175582267344, 0.02569328702520579, -0.06800238601863384, -0.010652570286765695, 0.04442033916711807, 0.0008707062224857509, -0.03791629173792899, -0.01974694279488176, -0.012471344787627459, -0.05222656764090061, 0.027658848877763376, 0.0261795298429206, 0.03837209613993764, 0.03547914605587721, -0.065070073120296, 0.015463256451766938, 0.004419506039994303, -0.02969307790044695, -0.012613456230610609, 0.03048483419115655, 0.007312143221497536, -0.08750566467642784, -0.017710077576339245, -0.03023367328569293, 0.021140164230018854, 0.10436926037073135, 0.011926733888685703, 0.009961859206669033, -0.029476960422471166, -0.020159751875326037, -0.07790366746485233, 0.06886674929410219, 0.07955041993409395, -0.009233276476152241, -0.0632511768490076, 0.003533775918185711, 0.03217921918258071, -0.0017657459757174365, 0.0499554630368948, -0.022411202546209097, 0.00822790467645973, 0.007166558876633644, -0.13091474398970604, -0.06948660034686327, 0.031344231218099594, -0.010657696751877666, -0.025052876735571772, 0.009426685981452465, -0.000860230065882206, -0.04037135327234864, 0.06806340254843235, 0.02604401228018105, -0.07262456882745028, 0.10524584539234638, -0.017017694772221148, 0.03847663733176887, 0.015304135085898452, -0.022285677026957273, -0.0003880725707858801, 0.03794682491570711, -0.06800171174108982, -0.039943912997841835, 0.08338448591530323, 0.012431795010343194, -0.004205749952234328, 0.01789577683666721, 0.02100188471376896, 0.0023398662451654673, -0.03323878743685782, -0.06432780250906944, 0.03639972861856222, 0.011190281802555546, 0.002120053926773835, 0.06202080566436052, 0.05974051542580128, 0.024543930077925324, -0.0370339029468596, -0.020636610919609666, -0.0005317113827914, -0.07742119580507278}, e) }) } func TestEmbeddingsMidpoint(t *testing.T) { t.Run("2 embeddings, 1 dimension", func(t *testing.T) { e := Embeddings{Embedding{1}, Embedding{3}} result, r, c := EmbeddingsMidpoint(e) assert.Equal(t, Embedding{2}, result) assert.Equal(t, 1.01, r) assert.Equal(t, 2, c) }) t.Run("3 embeddings, 1 dimension", func(t *testing.T) { e := Embeddings{Embedding{1}, Embedding{3}, Embedding{4}} result, r, c := EmbeddingsMidpoint(e) assert.Equal(t, Embedding{2.6666666666666665}, result) assert.Equal(t, 1.6766666666666665, r) assert.Equal(t, 3, c) }) t.Run("4 embeddings, 1 dimension", func(t *testing.T) { e := Embeddings{Embedding{1}, Embedding{3}, Embedding{4}, Embedding{8}} result, r, c := EmbeddingsMidpoint(e) assert.Equal(t, Embedding{4}, result) assert.Equal(t, 4.01, r) assert.Equal(t, 4, c) }) t.Run("empty embedding", func(t *testing.T) { e := Embeddings{} result, r, c := EmbeddingsMidpoint(e) assert.Len(t, result, 0) assert.Equal(t, float64(0), r) assert.Equal(t, 0, c) }) t.Run("embedding with different length", func(t *testing.T) { e := Embeddings{Embedding{1}, Embedding{3, 5}} result, r, c := EmbeddingsMidpoint(e) assert.Equal(t, Embedding{2}, result) assert.Equal(t, 1.01, r) assert.Equal(t, 2, c) }) t.Run("vectors", func(t *testing.T) { e := Embeddings{Embedding{1, 0, 0, 0}, Embedding{0, 1, 0, 0}, Embedding{0, 0, 1, 0}, Embedding{0, 0, 0, 1}} result, radius, count := EmbeddingsMidpoint(e) assert.Equal(t, Embedding{0.25, 0.25, 0.25, 0.25}, result) assert.Greater(t, 0.87612, radius) assert.Less(t, 0.8760, radius) assert.Equal(t, 4, count) }) } func TestUnmarshalEmbeddings(t *testing.T) { t.Run("Success", func(t *testing.T) { emb, err := UnmarshalEmbeddings("[[-0.013,-0.031]]") assert.NoError(t, err) assert.Equal(t, Embeddings{{-0.013, -0.031}}, emb) }) t.Run("NoPrefix", func(t *testing.T) { emb, err := UnmarshalEmbeddings("-0.013,-0.031]") assert.Error(t, err) assert.Nil(t, emb) }) t.Run("InvalidValues", func(t *testing.T) { emb, err := UnmarshalEmbeddings("[[true, false]]") assert.Error(t, err) assert.Equal(t, Embeddings{{0, 0}}, emb) }) }