How to use get_keys method in wpt

Best JavaScript code snippet using wpt

hashmap_test.py

Source:hashmap_test.py Github

copy

Full Screen

...18 cls = None19 cast_dtype = None20 view_dtype = None21 @classmethod22 def get_keys(cls, n=None):23 """ must return keys such that calling twice return an entirely different set """24 raise NotImplementedError()25 @classmethod26 def new(cls, keys):27 return cls.cls.new(keys, None, cls.cast_dtype, cls.view_dtype)28 def test_search(self):29 """ should succeed at indexing a set of unique keys """30 n = 1<<1031 keys = self.get_keys(n)32 ht = self.new(keys)33 # assert all keys are found34 indexes, found = ht.lookup(keys)35 assert found.all()36 # assert all indexes are different37 assert numpy.unique(indexes).shape == indexes.shape38 # assert none of other keys are found (very high probability)39 keys2 = self.get_keys(n)40 found = ht.contains(keys2)41 assert not found.any()42 # combine both43 found = ht.contains(_cat(keys, keys2))44 assert found[:n].all()45 assert not found[n:].any()46 def test_search_w_dups(self):47 """ should succeed at indexing a set of keys with duplicates """48 keys = self.get_keys()49 ht = self.new(_cat(keys, keys)) # duplicate keys50 # assert all keys are found51 indexes, found = ht.lookup(keys)52 assert found.all()53 # assert uniques are correct54 uniques = ht.unique_keys()55 assert (numpy.sort(uniques) == numpy.sort(keys)).all()56 def test_set_many(self):57 """ should succeed at re-indexing a set of growing size """58 keys = self.get_keys()59 ht = self.new(keys)60 for i in range(10):61 new_keys = self.get_keys()62 ht.set_many(new_keys)63 found = ht.contains(new_keys)64 assert found.all()65 # test first keys are still here66 found = ht.contains(keys)67 assert found.all()68 def test_keys_hash(self):69 """ should succeed at returning consistent keys hash """70 keys = self.get_keys()71 n = keys.size72 # init with half and then add remaining73 ht = self.new(keys[:n//2])74 hsh_before = ht.keys_hash()75 ht.set_many(keys[n//2:])76 hsh = ht.keys_hash()77 assert hsh != hsh_before78 # compare with both at the same time79 ht2 = self.new(keys)80 assert ht2.keys_hash() == hsh81 # shuffle82 numpy.random.shuffle(keys)83 ht2 = self.new(keys)84 assert ht2.keys_hash() == hsh85class UInt64HashtableTestCase(BaseHashtableTestCase, unittest.TestCase):86 cls = UInt64Hashmap87 @classmethod88 def get_keys(cls, n=None):89 n = n or 1<<1090 return numpy.random.randint(1, 1 << 63, size=n).astype('uint64')91 # ...all test inherited from BaseHashtableTestCase...92 def test_sequential(self):93 """ test that we can map sequential data """94 n = 1 << 1095 keys = numpy.arange(n).astype('uint64') # start at 0 to also test edge case96 ht = self.cls.new(keys)97 indexes, found = ht.lookup(keys)98 assert found.all()99 def test_prime_numbers(self):100 """ test that it works with lots of prime numbers """101 n = 1<<10102 # Generate prime-looking numbers103 keys = 1 + 2 * numpy.random.randint(low=1, high=1<<20, size=4 * n).astype('uint64')104 first_primes = [5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73]105 looks_prime = (keys % 3) != 0106 for prime in first_primes:107 looks_prime &= (keys % prime) != 0108 keys = keys[looks_prime][:n]109 # Test hashtable110 ht = self.new(keys)111 indexes, found = ht.lookup(keys)112 assert found.all()113 def test_piecewise_sequential(self):114 """ test that it works with piecewise sequential numbers """115 # Generate staircase numbers [x x+1 x+2 ... x+n y y+1 ... y+n ...]116 n_steps = 1 << 7117 n_stairs = 1 << 6118 base = numpy.random.randint(low=1, high=1 << 63, size=n_stairs).astype('uint64')119 steps = numpy.arange(n_steps * n_stairs, dtype='uint64')120 keys = numpy.repeat(base, n_steps) + steps121 # Test hashtable122 ht = self.new(keys)123 indexes, found = ht.lookup(keys)124 assert found.all()125 def test_benchmark_against_pandas(self):126 """ assert the common sequence of operations are not 10% slower than pandas """127 try:128 from pandas._libs import hashtable as pd_hashtable129 except ImportError:130 print('pandas is not installed. skip benchmark')131 return132 n = 1<<20133 keys = self.get_keys(n)134 keys2 = self.get_keys(n)135 # run xmlib136 time_start = time.perf_counter()137 ht = self.new(keys) # init138 ht.lookup(keys) # search found139 ht.lookup(keys2) # search not found140 ht.set_many(keys2) # add new141 time_end = time.perf_counter()142 time_xmlib = time_end - time_start143 # run pandas144 time_start = time.perf_counter()145 ht = pd_hashtable.UInt64HashTable()146 ht.map_locations(keys) # init147 ht.lookup(keys) # search found148 ht.lookup(keys2) # search not found149 ht.map_locations(keys2) # add new150 time_end = time.perf_counter()151 time_pandas = time_end - time_start152 # test xmlib is competitive153 print('xmlib: {:.0f}ms, pandas: {:.0f}ms'.format(1000 * time_xmlib, 1000 * time_pandas))154 assert time_xmlib < 1.25 * time_pandas155class UInt64StructHashtableTestCase(BaseHashtableTestCase, unittest.TestCase):156 cls = UInt64StructHashmap157 dtype = [('a', 'uint64'), ('b', 'uint64')]158 @classmethod159 def get_keys(cls, n=None, dtype=None):160 n = n or 1<<10161 dtype = list(dtype or cls.dtype)162 # shuffle order of fields in dtype to assert implementation re-orders163 random.shuffle(dtype)164 keys = numpy.empty(n, dtype=dtype)165 keys[:] = [tuple(t) for t in numpy.random.randint(1, 1 << 63, size=(n, len(dtype)))]166 return keys167 # ...all test inherited from BaseHashtableTestCase...168 def test_sanity_check_2d(self):169 """ check the tests are correctly building struct-array """170 ht = self.new(self.get_keys(10))171 uniques = ht.unique_keys()172 assert all(uniques.dtype.fields[f][0] == dt for f, dt in self.dtype)173 def test_zeros(self):174 """ check hashtable is supporting rows of zeros """175 n = 1<<10176 # test by starting without zero and adding it after177 keys = self.get_keys(n)178 ht = self.new(keys)179 keys2 = self.get_keys(n)180 keys2[0] = 0181 ht.set_many(keys2)182 indexes, found = ht.lookup(keys2)183 assert found.all()184 # test by starting from zero185 ht = self.new(keys2)186 indexes, found = ht.lookup(keys2)187 assert found.all()188class StructWithOffsetsHashtableTestCase(BaseHashtableTestCase, unittest.TestCase):189 @classmethod190 def new(cls, keys):191 return Hashmap(keys)192 @classmethod193 def get_keys(cls, n=None):194 n = n or 1<<10195 dtype = [('a', 'uint64'), ('b', 'uint64'), ('c', 'uint64')]196 # shuffle order of fields in dtype to assert implementation re-orders197 random.shuffle(dtype)198 keys = numpy.empty(n, dtype=dtype)199 keys[:] = [tuple(t) for t in numpy.random.randint(1, 1 << 63, size=(n, len(dtype)))]200 return keys[['a', 'c']]201class StringTupleHashtableTestCase(BaseHashtableTestCase, unittest.TestCase):202 cls = UInt64StructHashmap203 @classmethod204 def get_keys(cls, n=None):205 n = n or 1 << 10206 dtype = [('s1', 'S20'), ('s2', 'S20'), ('offset_to_remove', 'S20')]207 # shuffle order of fields in dtype to assert implementation re-orders208 random.shuffle(dtype)209 keys = numpy.empty(n, dtype=dtype)210 keys[:] = [(str(i), str(i+1), str(i+2))211 for i in numpy.random.randint(1, 1 << 63, size=n)]212 keys = keys[[k for k in keys.dtype.names if k != 'offset_to_remove']]213 return keys214class BytesHashtableTestCase(BaseHashtableTestCase, unittest.TestCase):215 cls = UInt64StructHashmap216 KIND = 'S'217 STR_LEN = 19 # 19bytes218 cast_dtype = f'S24' # smallest multiple of 8 bigger than 19219 view_dtype = [(f'f{i}', 'u8') for i in range(3)]220 @classmethod221 def get_keys(cls, n=None, str_len=None):222 n = n or 1 << 10223 str_len = str_len or cls.STR_LEN224 dtype = numpy.dtype(f'{cls.KIND}{str_len}')225 keys = numpy.random.randint(0, 256, n * dtype.itemsize, 'u1').view(dtype)226 return keys227 def test_sanity_check_keys_dtype(self):228 """ check the tests are correctly building bytes-array """229 keys = self.get_keys(10)230 ht = self.new(keys)231 uniques = ht.unique_keys()232 assert uniques.dtype == f'{self.KIND}{self.STR_LEN}'233class StrHashtableTestCase(BytesHashtableTestCase):234 cls = UInt64StructHashmap235 KIND = 'U'236 STR_LEN = 5 # 20bytes237 CHARS = '๓๔๕๖๗๘北亰☀☂;? `}£μστυφχψωϊϋόύώϏϐϑϒϓϔϕϖϗϘϙϚϛϜϝϞϟϠϡϢϣϤϥϦϧϨϩϪϫϬϭ'238 cast_dtype = 'U6' # 1/4 of the smallest multiple of 8 bigger than 4*5239 view_dtype = [(f'f{i}', 'u8') for i in range(3)]240 @classmethod241 def get_keys(cls, n=None, str_len=None):242 chars = numpy.array(list(cls.CHARS), dtype='U1')243 n = n or 1 << 10244 str_len = str_len or cls.STR_LEN245 dtype = numpy.dtype(f'{cls.KIND}{str_len}')246 keys = numpy.random.choice(chars, n * str_len).view(dtype)247 return keys248class BytesObjectHashtableTestCase(BytesHashtableTestCase):249 cls = BytesObjectHashmap250 cast_dtype = 'O'251 view_dtype = 'O'252 @classmethod253 def get_keys(cls, n=None, str_len=None):254 return super().get_keys(n, str_len).astype('O')255 def test_sanity_check_keys_dtype(self):256 """ check the tests are correctly building object-array """257 keys = self.get_keys(10)258 ht = self.new(keys)259 uniques = ht.unique_keys()260 assert uniques.dtype == 'O'261class StrObjectHashtableTestCase(StrHashtableTestCase):262 cls = StrObjectHashmap263 cast_dtype = 'O'264 view_dtype = 'O'265 @classmethod266 def get_keys(cls, n=None, str_len=None):267 return super().get_keys(n, str_len).astype('O')268 def test_sanity_check_keys_dtype(self):269 """ check the tests are correctly building object-array """270 keys = self.get_keys(10)271 ht = self.new(keys)272 uniques = ht.unique_keys()273 assert uniques.dtype == 'O'274class StrObjectTupleHashtableTestCase(BaseHashtableTestCase, unittest.TestCase):275 cls = BytesObjectTupleHashmap276 dtypes = [('a', 'uint64'), ('o1', 'O'), ('b', 'uint64'), ('o2', 'O')]277 cast_dtype = [('a', 'uint64'), ('b', 'uint64'), ('o1', 'O'), ('o2', 'O')]278 view_dtype = [('allbytes', 'V16'), ('o1', 'O'), ('o2', 'O')]279 @classmethod280 def get_keys(cls, n=None):281 n = n or (1 << 10)282 keys = numpy.empty(n, dtype=cls.dtypes)283 keys[:] = [tuple(v if dt != 'O' else str(v) for v, (_, dt) in zip(t, cls.dtypes))284 for t in numpy.random.randint(1, 1 << 63, size=(n, len(cls.dtypes)))]285 return keys286class OnlyStrObjectTupleHashtableTestCase(StrObjectTupleHashtableTestCase):287 dtypes = [('o1', 'O'), ('o2', 'O')]288 cast_dtype = None289 view_dtype = None290class UniqueTestCase(unittest.TestCase):291 """ test that `unique` automatically adapts to its arguments """292 def test_unique_on_uint64(self):293 vals = UInt64HashtableTestCase.get_keys()294 self._test_unique(vals)295 def test_unique_on_uint32(self):296 vals = UInt64HashtableTestCase.get_keys().astype('uint32')297 self._test_unique(vals)298 def test_unique_on_int64(self):299 vals = UInt64HashtableTestCase.get_keys().astype('int64')300 self._test_unique(vals)301 def test_unique_on_int32(self):302 vals = UInt64HashtableTestCase.get_keys().astype('int32')303 self._test_unique(vals)304 def test_unique_on_uint64_struct(self):305 vals = UInt64StructHashtableTestCase.get_keys()306 self._test_unique(vals)307 def test_unique_on_mix_int_struct(self):308 dtype = [('a', 'uint8'), ('b', 'int64'),309 ('c', 'uint64'), ('d', 'int8')]310 vals = UInt64StructHashtableTestCase.get_keys(dtype=dtype)311 self._test_unique(vals)312 def test_unique_on_short_bytes(self):313 vals = BytesHashtableTestCase.get_keys(str_len=1)314 self._test_unique(vals, vals_are_unique=False)315 vals = BytesHashtableTestCase.get_keys(str_len=2)316 self._test_unique(vals, vals_are_unique=False)317 vals = BytesHashtableTestCase.get_keys(str_len=7)318 self._test_unique(vals, vals_are_unique=False)319 def test_unique_on_long_bytes(self):320 vals = BytesHashtableTestCase.get_keys(str_len=21)321 self._test_unique(vals)322 def test_unique_on_short_string(self):323 vals = StrHashtableTestCase.get_keys(str_len=1)324 self._test_unique(vals, vals_are_unique=False)325 vals = StrHashtableTestCase.get_keys(str_len=2)326 self._test_unique(vals, vals_are_unique=False)327 vals = StrHashtableTestCase.get_keys(str_len=7)328 self._test_unique(vals, vals_are_unique=False)329 def test_unique_on_long_string(self):330 vals = StrHashtableTestCase.get_keys(str_len=21)331 self._test_unique(vals)332 def test_unique_on_string_object(self):333 vals = StrObjectHashtableTestCase.get_keys(str_len=21)334 self._test_unique(vals)335 def test_unique_on_string_object_in_tuple(self):336 vals = StrObjectTupleHashtableTestCase.get_keys()337 self._test_unique(vals)338 def test_unique_on_only_string_object_in_tuple(self):339 vals = OnlyStrObjectTupleHashtableTestCase.get_keys()340 self._test_unique(vals)341 def _test_unique(self, vals, vals_are_unique=True):342 if vals_are_unique:343 uniq_vals = vals344 else:345 uniq_vals = numpy.unique(vals)346 n_uniq = uniq_vals.size347 # unique on itself348 uniq = unique(vals)349 assert uniq.size == n_uniq350 assert uniq.dtype == vals.dtype351 assert (numpy.sort(uniq) == numpy.sort(uniq_vals)).all()352 uniq, idx_in_uniq, uniq_idx = unique(353 vals, return_inverse=True, return_index=True)354 assert (uniq[idx_in_uniq] == vals).all()355 assert (uniq == vals[uniq_idx]).all()356 # unique count on itself357 assert unique_count(vals) == n_uniq358 # duplicate values359 dups = _cat(vals, vals)360 numpy.random.shuffle(dups)361 uniq = unique(dups)362 assert uniq.size == n_uniq363 assert (numpy.sort(uniq) == numpy.sort(uniq_vals)).all()364 uniq, idx_in_uniq, uniq_idx = unique(365 dups, return_inverse=True, return_index=True)366 assert (uniq[idx_in_uniq] == dups).all()367 assert (uniq == dups[uniq_idx]).all()368 # unique count on dups369 assert unique_count(dups) == n_uniq370class BaseHashmapTestCaseMixin(object):371 """ TestCase template to test hashmap with values """372 cls = None373 val_dtype = [('tinyint', 'uint8'), ('bigint', 'uint64'),374 ('vector', 'float32', 10)]375 cast_dtype = None376 view_dtype = None377 @classmethod378 def get_keys(cls, n=None):379 raise NotImplementedError()380 @classmethod381 def new(cls, keys, values):382 return cls.cls.new(keys, values, cls.cast_dtype, cls.view_dtype)383 @classmethod384 def get_values(cls, n=None):385 n = n or 1<<10386 keys = numpy.empty(n, dtype=cls.val_dtype)387 keys[:] = [tuple(t) for t in numpy.random.randint(388 1, 1 << 63, size=(n, len(cls.val_dtype)))]389 return keys390 def test_get_many(self):391 n = 1<<10392 keys = self.get_keys(n)393 values = self.get_values(n)394 hm = self.new(keys, values)395 # test found396 found_vals, found = hm.get_many(keys)397 assert found.all()398 assert (found_vals == values).all()399 # test not found400 keys2 = self.get_keys(n)401 _, found = hm.get_many(keys2)402 assert not found.any()403 # test mixed404 found_vals, found = hm.get_many(_cat(keys, keys2))405 assert found[:n].all()406 assert not found[n:].any()407 assert (found_vals[:n] == values).all()408 def test_set_many_no_update(self):409 keys = self.get_keys()410 values = self.get_values()411 hm = self.new(keys, values)412 for _ in range(10):413 new_keys = self.get_keys()414 new_values = self.get_values()415 hm.set_many(new_keys, new_values)416 # test we still have the first keys417 found_vals, found = hm.get_many(keys)418 assert found.all()419 assert (found_vals == values).all()420 def test_set_many_updates(self):421 keys = self.get_keys()422 values = self.get_values()423 hm = self.new(keys, values)424 new_values = self.get_values()425 hm.set_many(keys, new_values)426 found_vals, found = hm.get_many(keys)427 assert found.all()428 assert (found_vals == new_values).all()429class UInt64HashmapTestCase(BaseHashmapTestCaseMixin, unittest.TestCase):430 """ test uint64 -> struct-dtype mapping """431 cls = UInt64Hashmap432 @classmethod433 def get_keys(cls, n=None):434 return UInt64HashtableTestCase.get_keys(n)435class UInt64StructHashmapTestCase(BaseHashmapTestCaseMixin, unittest.TestCase):436 """ test uint64-struct -> struct-dtype mapping """437 cls = UInt64StructHashmap438 keys_dtype = [('a', 'uint64'), ('b', 'uint64')]439 @classmethod440 def get_keys(cls, n=None, dtype=None):441 return UInt64StructHashtableTestCase.get_keys(n, dtype=dtype)442class StrObjectHashmapTestCase(BaseHashmapTestCaseMixin, unittest.TestCase):443 """ test str -> struct-dtype mapping """444 cls = StrObjectHashmap445 @classmethod446 def get_keys(cls, n=None):447 return StrObjectHashtableTestCase.get_keys(n)448class ArrayHashTestCase(unittest.TestCase):449 def test_array_hash_on_uint64(self):450 vals = UInt64HashtableTestCase.get_keys()451 self._test_array_hash(vals)452 def test_array_hash_on_uint32(self):453 vals = UInt64HashtableTestCase.get_keys().astype('uint32')454 self._test_array_hash(vals)455 def test_array_hash_on_int64(self):456 vals = UInt64HashtableTestCase.get_keys().astype('int64')457 self._test_array_hash(vals)458 def test_array_hash_on_int32(self):459 vals = UInt64HashtableTestCase.get_keys().astype('int32')460 self._test_array_hash(vals)461 def test_array_hash_on_bool(self):462 vals = UInt64HashtableTestCase.get_keys()463 vals = vals > numpy.median(vals)464 self._test_array_hash(vals)465 def test_array_hash_on_uint64_struct(self):466 vals = UInt64StructHashtableTestCase.get_keys()467 self._test_array_hash(vals)468 def test_array_hash_on_mix_int_struct(self):469 dtype = [('a', 'uint8'), ('b', 'int64'),470 ('c', 'uint64'), ('d', 'int8'), ('e', '?')]471 vals = UInt64StructHashtableTestCase.get_keys(dtype=dtype)472 self._test_array_hash(vals)473 def test_array_hash_on_bytes(self):474 vals = BytesHashtableTestCase.get_keys()475 self._test_array_hash(vals)476 def test_array_hash_on_str(self):477 vals = StrHashtableTestCase.get_keys()478 self._test_array_hash(vals)479 def test_array_hash_on_bytes_object(self):480 vals = BytesObjectHashtableTestCase.get_keys()481 self._test_array_hash(vals)482 def test_array_hash_on_str_object(self):483 vals = StrObjectHashtableTestCase.get_keys()484 self._test_array_hash(vals)485 def _test_array_hash(self, vals):486 hsh_w_order = array_hash(vals, order_matters=True)487 hsh_wo_order = array_hash(vals, order_matters=False)488 # permute values and check that order_matters=0 is the same489 for _ in range(10):490 numpy.random.shuffle(vals)491 hsh_w_order_ = array_hash(vals, order_matters=True)492 hsh_wo_order_ = array_hash(vals, order_matters=False)493 assert hsh_w_order != hsh_w_order_494 assert hsh_wo_order == hsh_wo_order_495 # edit some value496 vals[0] = next(v for v in vals if v != vals[0])497 hsh_w_order_ = array_hash(vals, order_matters=True)498 hsh_wo_order_ = array_hash(vals, order_matters=False)499 assert hsh_w_order != hsh_w_order_500 # 1st part of assert may fail if we are testing with only few values (e.g. bool)501 assert (hsh_wo_order != hsh_wo_order_) or (len(set(vals)) < 100)502class ValuesHashTestCase(unittest.TestCase):503 def test_values_hash_on_uint64(self):504 vals = UInt64HashtableTestCase.get_keys()505 self._test_values_hash(vals)506 def test_values_hash_on_uint32(self):507 vals = UInt64HashtableTestCase.get_keys().astype('uint32')508 self._test_values_hash(vals)509 def test_values_hash_on_int64(self):510 vals = UInt64HashtableTestCase.get_keys().astype('int64')511 self._test_values_hash(vals)512 def test_values_hash_on_int32(self):513 vals = UInt64HashtableTestCase.get_keys().astype('int32')514 self._test_values_hash(vals)515 def test_values_hash_on_bool(self):516 vals = UInt64HashtableTestCase.get_keys()517 vals = vals > numpy.median(vals)518 self._test_values_hash(vals, assume_unique=False)519 def test_values_hash_on_uint64_struct(self):520 vals = UInt64StructHashtableTestCase.get_keys()521 self._test_values_hash(vals)522 def test_values_hash_on_mix_int_struct(self):523 dtype = [('a', 'uint8'), ('b', 'int64'),524 ('c', 'uint64'), ('d', 'int8'), ('e', '?')]525 vals = UInt64StructHashtableTestCase.get_keys(dtype=dtype)526 self._test_values_hash(vals)527 def test_values_hash_on_bytes(self):528 vals = BytesHashtableTestCase.get_keys()529 self._test_values_hash(vals)530 def test_values_hash_on_str(self):531 vals = StrHashtableTestCase.get_keys()532 self._test_values_hash(vals)533 def test_values_hash_on_bytes_object(self):534 vals = BytesObjectHashtableTestCase.get_keys()535 self._test_values_hash(vals)536 def test_values_hash_on_str_object(self):537 vals = StrObjectHashtableTestCase.get_keys()538 self._test_values_hash(vals)539 def _test_values_hash(self, vals, assume_unique=True):540 n = len(vals)541 hsh = values_hash(vals)542 if assume_unique:543 assert len(numpy.unique(hsh)) == n544 # duplicate545 hsh = values_hash(numpy.r_[vals, vals])...

Full Screen

Full Screen

function2_declension.js

Source:function2_declension.js Github

copy

Full Screen

1var dict_records = 0;2function GetKeys(ary, dname, key, ret_key) {3 key_x = '0';4 if (key.slice(-1) == '*') {5 key = key.substring(0, key.length-1);6 key_x = '1';7 }8 if (key.substring(0, 1) == '*') {9 key = key.substring(1);10 key_x = '1' + key_x;11 } else {12 key_x = '0' + key_x;13 }14 this.ary = ary;15 var tag = '@'; // english dictionary;16 if (dname != 'ee1') { //pali dictionary;17 tag = '!';18 }19 20 str = key.replace(/[atnidlm]/g, (m) => variations[m]);21 filterRegex = new RegExp(str);22 var result = '#';23 var key_len = key.length;24 for (var i in ary) {25 var s1 = '#' + tag + i + '#';26 if (ret_key.indexOf(s1) == -1) {27 v1 = i.substring(0, key_len);28 v2 = i.slice(-key_len);29 v3 = i.indexOf(key);30 if (i.search(filterRegex)==0 ){ // && (key_x.substring(0, 1) == '0')) || ((v2 == key) && (key_x == '10')) || ((v3 != -1) && (key_x == '11'))) {31 result = result + tag + i + '#';32 dict_records = dict_records +1;33 if (100 < dict_records) {34 break;35 }36 } 37 }38 }39 return (result.trim());40}41function GetValues(aryVal, dname, key) {42 this.aryVal = aryVal;43 var meaning_from_dict = "" + aryVal[key];44 if (meaning_from_dict != "undefined") {45 if (dname.indexOf('pm') != -1) { //myanmar class="ZawgyiFont"46 return ('<div class="DictionaryClass" style="' + DictionaryBackground + '"><b style="color:#777777">[' + aryAbbr[dname] + ']</b>&nbsp;<span class="ZawgyiFont">' + meaning_from_dict + '</span></div>');47 } else {48 return ('<div class="DictionaryClass" style="' + DictionaryBackground + '"><b style="color:#777777">[' + aryAbbr[dname] + ']</b>&nbsp;' + meaning_from_dict + '</div>');49 }50 } else {51 return ('');52 }53}54function DeclensionShow(key) {55 var get_data = LookupDictionary(key); 56 57 DeclensionTable(key);58 $("#DeclensionResult").html($("#DeclensionResult").html() + get_data) ;59}60function DeclensionSearch() {61 dict_records = 0;62 var key = toUniRegEx($('#DeclensionKey').val().trim().toLowerCase());63 $('#DeclensionKey').val(key);64 if ( 0 < key.length ) {65 var get_keys = '';66 for (var i = 0; i<ary_dict.length; i++) {67 var d_name = ary_dict[i].substring(1);68 if (ary_dict[i] == 'hee1') {get_keys = get_keys + GetKeys(ee1, d_name, key, get_keys);}69 if (ary_dict[i] == 'hpc1') {get_keys = get_keys + GetKeys(pc1, d_name, key, get_keys);}70 if (ary_dict[i] == 'hpc2') {get_keys = get_keys + GetKeys(pc2, d_name, key, get_keys);}71 if (ary_dict[i] == 'hpd1') {get_keys = get_keys + GetKeys(pd1, d_name, key, get_keys);}72 if (ary_dict[i] == 'hpe1') {get_keys = get_keys + GetKeys(pe1, d_name, key, get_keys);}73 if (ary_dict[i] == 'hpe2') {get_keys = get_keys + GetKeys(pe2, d_name, key, get_keys);}74 if (ary_dict[i] == 'hpe3') {get_keys = get_keys + GetKeys(pe3, d_name, key, get_keys);}75 if (ary_dict[i] == 'hpe4') {get_keys = get_keys + GetKeys(pe4, d_name, key, get_keys);}76 if (ary_dict[i] == 'hpe5') {get_keys = get_keys + GetKeys(pe5, d_name, key, get_keys);}77 if (ary_dict[i] == 'hpe6') {get_keys = get_keys + GetKeys(pe6, d_name, key, get_keys);}78 if (ary_dict[i] == 'hpe7') {get_keys = get_keys + GetKeys(pe7, d_name, key, get_keys);}79 if (ary_dict[i] == 'hpg1') {get_keys = get_keys + GetKeys(pg1, d_name, key, get_keys);}80 if (ary_dict[i] == 'hpi1') {get_keys = get_keys + GetKeys(pi1, d_name, key, get_keys);}81 if (ary_dict[i] == 'hpm1') {get_keys = get_keys + GetKeys(pm1, d_name, key, get_keys);}82 if (ary_dict[i] == 'hpm2') {get_keys = get_keys + GetKeys(pm2, d_name, key, get_keys);}83 if (ary_dict[i] == 'hpm3') {get_keys = get_keys + GetKeys(pm3, d_name, key, get_keys);}84 if (ary_dict[i] == 'hpm4') {get_keys = get_keys + GetKeys(pm4, d_name, key, get_keys);}85 if (ary_dict[i] == 'hps1') {get_keys = get_keys + GetKeys(ps1, d_name, key, get_keys);}86 if (ary_dict[i] == 'hps2') {get_keys = get_keys + GetKeys(ps2, d_name, key, get_keys);}87 if (ary_dict[i] == 'hpv1') {get_keys = get_keys + GetKeys(pv1, d_name, key, get_keys);}88 if (ary_dict[i] == 'hpv2') {get_keys = get_keys + GetKeys(pv2, d_name, key, get_keys);} 89 if (ary_dict[i] == 'hpv3') {get_keys = get_keys + GetKeys(pv3, d_name, key, get_keys);}90 if (ary_dict[i] == 'hse1') {get_keys = get_keys + GetKeys(se1, d_name, key, get_keys);}91 }92 get_keys = get_keys.replace(/\#\#/g, '#');93 var ary = get_keys.split('#');94 ary.sort();95 lenx = Math.min(200, ary.length);96 out = '';97 for (var i = 1; i<lenx; i++) {98 if (ary[i] != '') {99 out = out + '<a href="javascript:void(0);" onClick="DeclensionShow(\'' + ary[i].substring(1) +'\');document.getElementById(\'DeclensionResult\').scrollIntoView();">' + '. ' + toTranslate(ary[i].substring(1)) + '</a><br>';100 }101 }102 //alert(lenx);103 $('#DeclensionTips2').html(out);104 document.getElementById('DeclensionTips2').scrollIntoView();105 }106 if (dict_records == '1') {107 DeclensionShow(key);108 }109}110function DeclensionTable(val) {111 if (val == '') { // from Click of .r1112 var key = localStorage.getItem('DeclensionKey');113 } else {114 var key = val;115 }116 //Search the conjugate directly.117 var outx = conjugate(key, 'x', 'x');118 if (outx != undefined) {119 outx = outx + '<hr>';120 } else {121 outx = '';122 }123 //Search from wordbreakdata124 var outy = "";125 var key2 = wordbreakdata[key];126 if (key2 != undefined) {127 key2 = key2 + '@_@';128 var ary = key2.split('@_@');129 for (var idx in ary) {130 if (ary[idx] != '') {131 var outz = conjugate(ary[idx], 'x', 'x');132 //add red color for key word133 var aryz = outz.split(toTranslate(key));134 outz = '';135 for (idz=0; idz<aryz.length; idz++) {136 var s1 = aryz[idz+1];137 if (s1 != undefined) {138 s1 = toTranslate(s1.substring(0, 1));139 } else {140 s1 = toTranslate('a');141 }142 //if (toTranslate('abcdefghijklmnopqrstuvwxyzāīūṅñṭḍṇḷṃ').indexOf(s1) == -1) {143 if (' ,<'.indexOf(s1) != -1) {144 outz = outz + aryz[idz] + '<span style="color:red;font-weight:900;">' + toTranslate(key) + '</span>';145 } else {146 outz = outz + aryz[idz] + toTranslate(key);147 }148 }149 outy = outy + outz + '<hr>';150 }151 }152 }153 $("#DeclensionResult").html(outx + outy);...

Full Screen

Full Screen

widget_argumants.py

Source:widget_argumants.py Github

copy

Full Screen

1import tkinter as tk2# ---------------- tkinter widget keys -------------------3# Print the allowed widget keys4def get_keys(widget):5 print(f"widget: {widget}\n"6 f"keys : {widget.keys()}\n")7get_keys(tk.Tk())8get_keys(tk.Button())9get_keys(tk.Canvas())10get_keys(tk.Checkbutton())11get_keys(tk.Entry())12get_keys(tk.Frame())13get_keys(tk.Label())14get_keys(tk.Listbox())15get_keys(tk.Menubutton())16get_keys(tk.Menu())17get_keys(tk.Message())18get_keys(tk.Radiobutton())19get_keys(tk.Scale())20get_keys(tk.Scrollbar())21get_keys(tk.Text())22get_keys(tk.Toplevel())23get_keys(tk.Spinbox())24get_keys(tk.PanedWindow())25get_keys(tk.LabelFrame())26# ---------------- tkinter widget key values -------------------27# To find out what arguments are accepted by a widget,28# together with the default/current values, use .config() without any options.29# This returns a dictionary of the allowed arguments which can then be printed out.30#31# The first entry (lowercase) is the option name32# The second item (camelCase) is the option name for database lookuo,33# The third entry (Titlecase) is the option class for database lookup,34# The fourth entry is the default value,35# The fifth item is the current value.36#37# I created a function to make the main program less cluttered,38# and the output more human readable.39# Note the encoding="utf-16" allows the checkmark to be written to the file:...

Full Screen

Full Screen

word_book1.py

Source:word_book1.py Github

copy

Full Screen

1import json 2import time 3from difflib import get_close_matches as gc45get_keys = json.load(open("wordbook.json"))67def find_meaning(user_word):8 if user_word.lower() in get_keys:9 return get_keys[user_word.lower()]10 elif user_word.upper() in get_keys:11 return get_keys[user_word.upper()]12 elif user_word.title() in get_keys:13 return get_keys[user_word.title()]14 elif len(gc(user_word.lower(),get_keys.keys())) > 0:15 close_matches = (gc(user_word.lower(),get_keys.keys())[0]) 16 user_decision = input(17 "🤔 Are you looking for "+"'"+close_matches+"'"+" instead of"+"'"+user_word.lower()+"'"+"❓[Y/N]: ")18 if user_decision.strip().lower() == "y":19 return get_keys[close_matches]20 elif user_decision.strip().lower() == "n":21 print("⚠️ " + "Can't find word, Please check the spelling❗")22 else:23 print("Invalid Input❗❗") 24 elif len(gc(user_word.upper(), get_keys.keys())) > 0:25 close_matches = (gc(user_word.upper(), get_keys.keys())[0])26 user_decision = input(27 "🤔 Are you looking for "+"'"+close_matches+"'"+" instead of"+"'"+user_word.upper()+"'"+"❓[Y/N]: ")28 if user_decision.strip().lower() == "y":29 return get_keys[close_matches]30 elif user_decision.strip().lower() == "n":31 print("⚠️ " + "Can't find word, Please check the spelling❗")32 else:33 print("Invalid Input❗❗")34 elif len(gc(user_word.title(), get_keys.keys())) > 0:35 close_matches = (gc(user_word.title(), get_keys.keys())[0])36 user_decision = input(37 "🤔 Are you looking for "+"'"+close_matches+"'"+" instead of"+"'"+user_word.title()+"'"+"❓[Y/N]: ")38 if user_decision.strip().lower() == "y":39 return get_keys[close_matches]40 elif user_decision.strip().lower() == "n":41 print("⚠️ " + "Can't find word, Please check the spelling❗")42 else:43 print("Invalid Input❗❗")44 else:45 print("❌ Sorry, I can't find meaning")4647user_word = str(input("🚀 Type word to find it's meaning: ")).strip()48output = find_meaning(user_word)4950if type(output) == list:51 for word_meanings in output:52 print("🔹 "+word_meanings)53else: ...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3wpt.get_keys(function(err, data) {4 console.log(data);5});6var wpt = require('webpagetest');7var wpt = new WebPageTest('www.webpagetest.org');8wpt.get_locations(function(err, data) {9 console.log(data);10});11var wpt = require('webpagetest');12var wpt = new WebPageTest('www.webpagetest.org');13wpt.get_testers(function(err, data) {14 console.log(data);15});16var wpt = require('webpagetest');17var wpt = new WebPageTest('www.webpagetest.org');18wpt.get_test_status('140829_3P_3b3a3f1c2f9d9e1c8d2d2b2c', function(err, data) {19 console.log(data);20});21var wpt = require('webpagetest');22var wpt = new WebPageTest('www.webpagetest.org');23wpt.get_test_results('140829_3P_3b3a3f1c2f9d9e1c8d2d2b2c', function(err, data) {24 console.log(data);25});26var wpt = require('webpagetest');27var wpt = new WebPageTest('www.webpagetest.org');28wpt.get_testers(function(err, data) {29 console.log(data);30});31var wpt = require('webpagetest');32var wpt = new WebPageTest('www.webpagetest.org');33wpt.get_testers(function(err, data) {34 console.log(data);35});36var wpt = require('webpagetest

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2var wp = wptools.page('Albert Einstein');3wp.get_keys(function(err, keys) {4 console.log(keys);5});6var wptools = require('wptools');7var wp = wptools.page('Albert Einstein');8wp.get_keys(function(err, keys) {9 console.log(keys);10});11var wptools = require('wptools');12var wp = wptools.page('Albert Einstein');13wp.get_keys(function(err, keys) {14 console.log(keys);15});16var wptools = require('wptools');17var wp = wptools.page('Albert Einstein');18wp.get_keys(function(err, keys) {19 console.log(keys);20});21var wptools = require('wptools');22var wp = wptools.page('Albert Einstein');23wp.get_keys(function(err, keys) {24 console.log(keys);25});26var wptools = require('wptools');27var wp = wptools.page('Albert Einstein');28wp.get_keys(function(err, keys) {29 console.log(keys);30});31var wptools = require('wptools');32var wp = wptools.page('Albert Einstein');33wp.get_keys(function(err, keys) {34 console.log(keys);35});36var wptools = require('wptools');37var wp = wptools.page('Albert Einstein');38wp.get_keys(function(err, keys) {39 console.log(keys);40});41var wptools = require('wptools');42var wp = wptools.page('Albert Einstein');43wp.get_keys(function(err, keys) {44 console.log(keys);45});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt');2var api_key = process.argv[2];3var test_url = process.argv[3];4var location = process.argv[4];5var browser = process.argv[5];6var connection = process.argv[6];7var label = process.argv[7];8var runs = process.argv[8];9var first_view_only = process.argv[9];10var private = process.argv[10];11var notify_email = process.argv[11];12var notify_compare = process.argv[12];13var notify_complete = process.argv[13];14var notify_error = process.argv[14];15var notify_first_view = process.argv[15];16var notify_first_view_complete = process.argv[16];17var notify_first_view_error = process.argv[17];18var notify_first_view_compare = process.argv[18];19var notify_repeat_view = process.argv[19];20var notify_repeat_view_complete = process.argv[20];21var notify_repeat_view_error = process.argv[21];22var notify_repeat_view_compare = process.argv[22];23var notify_video = process.argv[23];24var notify_video_complete = process.argv[24];25var notify_video_error = process.argv[25];

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt.js');2var wpt = new wpt('your api key');3wpt.get_keys(function(data){4 console.log(data);5});6var wpt = require('wpt.js');7var wpt = new wpt('your api key');8wpt.get_locations(function(data){9 console.log(data);10});11var wpt = require('wpt.js');12var wpt = new wpt('your api key');13wpt.get_locations(function(data){14 console.log(data);15});16var wpt = require('wpt.js');17var wpt = new wpt('your api key');18wpt.get_tests(function(data){19 console.log(data);20});21var wpt = require('wpt.js');22var wpt = new wpt('your api key');23wpt.get_test_status('test_id', function(data){24 console.log(data);25});26var wpt = require('wpt.js');27var wpt = new wpt('your api key');28wpt.get_test_results('test_id', function(data){29 console.log(data);30});31var wpt = require('wpt.js');32var wpt = new wpt('your api key');33wpt.get_test_results('test_id', function(data){34 console.log(data);35});36var wpt = require('wpt.js');37var wpt = new wpt('your api key');38wpt.get_test_requests('test_id', function(data){39 console.log(data);40});41var wpt = require('wpt.js');42var wpt = new wpt('your api key');43wpt.get_test_pagespeed_results('test_id', function(data){44 console.log(data);45});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2var page = wptools.page('Albert Einstein');3page.get_keys(function(err, data) {4 console.log(data);5});6var wptools = require('wptools');7var page = wptools.page('Albert Einstein');8page.get(function(err, data) {9 console.log(data);10});11{ pageid: 736,12 extract: 'Albert Einstein (14 March 1879 – 18 April 1955) was a German-born theoretical physicist. He developed the theory of relativity, one of the two pillars of modern physics (alongside quantum mechanics). Einstein\'s work is also known for its influence on the philosophy of science. Einstein is best known in popular culture for his mass–energy equivalence formula E = mc2 (which has been dubbed "the world\'s most famous equation"). He received the 1921 Nobel Prize in Physics "for his services to theoretical physics, and especially for his discovery of the law of the photoelectric effect", a pivotal step in the development of quantum theory.',13 extract_html: '<p><b>Albert Einstein</b> (<a href="/wiki/14_March" title="14 March">14 March</a> <a href="/wiki/1879" title="1879">1879</a> – <a href="/wiki/18_April" title="18 April">18 April</a> <a href="/wiki/1955" title="1955">1955</a>) was a <a href="/wiki/Germany" title="Germany">German-born</a> <a href="/wiki/Theoretical_physics" title="Theoretical physics">theoretical physicist</a>. He

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful