How to use none_of method in pyshould

Best Python code snippet using pyshould_python

test_query.py

Source:test_query.py Github

copy

Full Screen

1import pytest2from ukbcc import query3def test_basic_query_creation(main_csv, gp_csv):4 cohort_criteria = {'all_of': [('6070', '1')], 'any_of': [], 'none_of': []}5 obs_query = query.create_queries(cohort_criteria,6 main_filename=main_csv,7 gpc_path=gp_csv)8 exp_query={'gp_clinical': {'all_of': '', 'any_of': '', 'none_of': ''}, 'main': {'all_of': "(t6070_0_0 == '1')", 'any_of': '', 'none_of': ''}}9 assert obs_query == exp_query10#Check all of with a single field works11def test_all_query_basic(main_csv, gp_csv):12 cohort_criteria = {'all_of': [('6070', "1")], 'any_of': [], 'none_of': []}13 gen_query = query.create_queries(cohort_criteria,14 main_filename=main_csv,15 gpc_path=gp_csv)16 ids = query.query_databases(cohort_criteria=cohort_criteria,17 queries=gen_query, main_filename=main_csv,18 write_dir=None, gpc_path=gp_csv,19 out_filename=None, write=False)20 exp_ids = set(["1041796", "1037058", "1024938", "1016017", "1038882", "1030520", "1003670", "1027017"])21 assert exp_ids == set(ids)22#Check that "all of" works over fields with multiple columns23def test_all_multiple_columns(main_csv, gp_csv):24 cohort_criteria = {'all_of': [('6148', "4")], 'any_of': [], 'none_of': []}25 gen_query = query.create_queries(cohort_criteria,26 main_filename=main_csv,27 gpc_path=gp_csv)28 ids = query.query_databases(cohort_criteria=cohort_criteria,29 queries=gen_query, main_filename=main_csv,30 write_dir=None, gpc_path=gp_csv,31 out_filename=None, write=False)32 exp_ids = set(["1037918", "1033149", "1016017", "1033388", "1030520", "1003670"])33 assert exp_ids == set(ids)34#Check any of with a single field works35def test_any_singleton_query(main_csv, gp_csv):36 cohort_criteria = {'any_of': [('6070', "1")], 'all_of': [], 'none_of': []}37 gen_query = query.create_queries(cohort_criteria,38 main_filename=main_csv,39 gpc_path=gp_csv)40 ids = query.query_databases(cohort_criteria=cohort_criteria,41 queries=gen_query, main_filename=main_csv,42 write_dir=None, gpc_path=gp_csv,43 out_filename=None, write=False)44 exp_ids = set(["1041796", "1037058", "1024938", "1016017", "1038882", "1030520", "1003670", "1027017"])45 assert exp_ids == set(ids)46#Check that any of works over fields with multiple columns47def test_any_multiple_columns(main_csv, gp_csv):48 cohort_criteria = {'any_of': [('6148', "4")], 'all_of': [], 'none_of': []}49 gen_query = query.create_queries(cohort_criteria,50 main_filename=main_csv,51 gpc_path=gp_csv)52 ids = query.query_databases(cohort_criteria=cohort_criteria,53 queries=gen_query, main_filename=main_csv,54 write_dir=None, gpc_path=gp_csv,55 out_filename=None, write=False)56 exp_ids = set(["1037918", "1033149", "1016017", "1033388", "1030520", "1003670"])57 assert exp_ids == set(ids)58#Check any of with two values for the same field returns their union59def test_any_pair_same_field_query(main_csv, gp_csv):60 cohort_criteria = {'any_of': [('6070', "1"), ('6070', "2")], 'all_of': [], 'none_of': []}61 gen_query = query.create_queries(cohort_criteria,62 main_filename=main_csv,63 gpc_path=gp_csv)64 ids = query.query_databases(cohort_criteria=cohort_criteria,65 queries=gen_query, main_filename=main_csv,66 write_dir=None, gpc_path=gp_csv,67 out_filename=None, write=False)68 exp_ids = set(["1037918", "1041796", "1037058", "1024938", "1016017", "1038882", "1030520", "1003670", "1027017"])69 assert exp_ids == set(ids)70#Check any of with two fields returns their union71def test_any_pair_diff_field_query(main_csv, gp_csv):72 cohort_criteria = {'any_of': [('6070', "1"), ('6119', "1")], 'all_of': [], 'none_of': []}73 gen_query = query.create_queries(cohort_criteria,74 main_filename=main_csv,75 gpc_path=gp_csv)76 ids = query.query_databases(cohort_criteria=cohort_criteria,77 queries=gen_query, main_filename=main_csv,78 write_dir=None, gpc_path=gp_csv,79 out_filename=None, write=False)80 exp_ids = set(["1041796", "1037058", "1024938", "1016017", "1038882", "1030520", "1003670", "1027017"])81 assert exp_ids == set(ids)82# Check if a none only query returns values83def test_none_basic(main_csv, gp_csv):84 cohort_criteria = {'none_of': [('6070', "1")], 'all_of': [], 'any_of': []}85 gen_query = query.create_queries(cohort_criteria,86 main_filename=main_csv,87 gpc_path=gp_csv)88 print(gen_query)89 ids = query.query_databases(cohort_criteria=cohort_criteria,90 queries=gen_query, main_filename=main_csv,91 write_dir=None, gpc_path=gp_csv,92 out_filename=None, write=False)93 print(ids)94 exp_ids = set(["1037918", "1033149", "1033388", "1031625", "1031595", "1008947"])95 assert exp_ids == set(ids)96#Check that "all of" and "none_of" works over fields with multiple columns97def test_all__none_multiple_columns(main_csv, gp_csv):98 cohort_criteria = {'all_of': [('6148', "4")], 'any_of': [], 'none_of': [("6070", "2")]}99 gen_query = query.create_queries(cohort_criteria,100 main_filename=main_csv,101 gpc_path=gp_csv)102 ids = query.query_databases(cohort_criteria=cohort_criteria,103 queries=gen_query, main_filename=main_csv,104 write_dir=None, gpc_path=gp_csv,105 out_filename=None, write=False)106 exp_ids = set([ "1033149", "1016017", "1033388", "1030520", "1003670"])107 assert exp_ids == set(ids)108#Check that "none_of" returns empty fields.109def test_none_returns_empty(main_csv, gp_csv):110 cohort_criteria = {'all_of': [('6148', "4")], 'any_of': [], 'none_of': [("6070", "2"), ("6070", "1")]}111 gen_query = query.create_queries(cohort_criteria,112 main_filename=main_csv,113 gpc_path=gp_csv)114 ids = query.query_databases(cohort_criteria=cohort_criteria,115 queries=gen_query, main_filename=main_csv,116 write_dir=None, gpc_path=gp_csv,117 out_filename=None, write=False)118 exp_ids = set(["1033149", "1033388"])119 assert exp_ids == set(ids)120#Check fields with spaces121def test_fields_with_spaces(main_csv, gp_csv):122 cohort_criteria = {'all_of': [('41270', "Block H40-H42")], 'any_of': [], 'none_of': []}123 gen_query = query.create_queries(cohort_criteria,124 main_filename=main_csv,125 gpc_path=gp_csv)126 ids = query.query_databases(cohort_criteria=cohort_criteria,127 queries=gen_query, main_filename=main_csv,128 write_dir=None, gpc_path=gp_csv,129 out_filename=None, write=False)130 exp_ids = set(["1033149", "1041796"])131 assert exp_ids == set(ids)132#What do we do with fields that don't exist133def test_missing_fields(main_csv, gp_csv):134 cohort_criteria = {'all_of': [('DoesNotExist', "X")], 'any_of': [], 'none_of': []}135 gen_query = query.create_queries(cohort_criteria,136 main_filename=main_csv,137 gpc_path=gp_csv)138 ids = query.query_databases(cohort_criteria=cohort_criteria,139 queries=gen_query, main_filename=main_csv,140 write_dir=None, gpc_path=gp_csv,141 out_filename=None, write=False)142 exp_ids = set([])143 assert exp_ids == set(ids)144#What do we do when we query nan?145def test_missing_fields(main_csv, gp_csv):146 cohort_criteria = {'all_of': [('6070', "nan")], 'any_of': [], 'none_of': []}147 gen_query = query.create_queries(cohort_criteria,148 main_filename=main_csv,149 gpc_path=gp_csv)150 ids = query.query_databases(cohort_criteria=cohort_criteria,151 queries=gen_query, main_filename=main_csv,152 write_dir=None, gpc_path=gp_csv,153 out_filename=None, write=False)154 exp_ids = set([])155 assert exp_ids == set(ids)156#Can we do a query on read2 at all?157def test_all_gp_clinical_read2(main_csv, gp_csv):158 cohort_criteria = {'all_of': [('read_2', "4662.")], 'any_of': [], 'none_of': []}159 gen_query = query.create_queries(cohort_criteria,160 main_filename=main_csv,161 gpc_path=gp_csv)162 ids = query.query_databases(cohort_criteria=cohort_criteria,163 queries=gen_query, main_filename=main_csv,164 write_dir=None, gpc_path=gp_csv,165 out_filename=None, write=False)166 exp_ids = set(["1041796"])167 assert exp_ids == set(ids)168#Can we read read2 when multiple entries per person169def test_all_gp_clinical_read_2_multiple(main_csv, gp_csv):170 cohort_criteria = {'all_of': [('read_2', "XE0of")], 'any_of': [], 'none_of': []}171 gen_query = query.create_queries(cohort_criteria,172 main_filename=main_csv,173 gpc_path=gp_csv)174 ids = query.query_databases(cohort_criteria=cohort_criteria,175 queries=gen_query, main_filename=main_csv,176 write_dir=None, gpc_path=gp_csv,177 out_filename=None, write=False)178 exp_ids = set(["1016017"])179 assert exp_ids == set(ids)180#Can we read read3181def test_all_gp_clinical_read_3(main_csv, gp_csv):182 cohort_criteria = {'all_of': [('read_3', "XE0Gu")], 'any_of': [], 'none_of': []}183 gen_query = query.create_queries(cohort_criteria,184 main_filename=main_csv,185 gpc_path=gp_csv)186 ids = query.query_databases(cohort_criteria=cohort_criteria,187 queries=gen_query, main_filename=main_csv,188 write_dir=None, gpc_path=gp_csv,189 out_filename=None, write=False)190 exp_ids = set(["1037918"])191 assert exp_ids == set(ids)192#Can we query 2 and 3?193def test_all_gp_clinical_read2and3(main_csv, gp_csv):194 cohort_criteria = {'all_of': [], 'any_of': [('read_2', "XE0of"), ('read_3', 'XE0Gu')], 'none_of': []}195 gen_query = query.create_queries(cohort_criteria,196 main_filename=main_csv,197 gpc_path=gp_csv)198 ids = query.query_databases(cohort_criteria=cohort_criteria,199 queries=gen_query, main_filename=main_csv,200 write_dir=None, gpc_path=gp_csv,201 out_filename=None, write=False)202 exp_ids = set(["1016017", "1037918"])203 assert exp_ids == set(ids)204#Complex query, use gp_clinical and main, and use all, not and any205def test_any_pair_same_field_query(main_csv, gp_csv):206 cohort_criteria = {'any_of': [('41270', "Block H40-H42"), ('6119', "3"), ('6148','4')], 'all_of': [(('6070', "1"))], 'none_of': [('read_2', "XE0of")]}207 gen_query = query.create_queries(cohort_criteria,208 main_filename=main_csv,209 gpc_path=gp_csv)210 ids = query.query_databases(cohort_criteria=cohort_criteria,211 queries=gen_query, main_filename=main_csv,212 write_dir=None, gpc_path=gp_csv,213 out_filename=None, write=False)214 exp_ids = set(["1041796", "1037058", "1030520", "1003670"])...

Full Screen

Full Screen

prim.py

Source:prim.py Github

copy

Full Screen

...59 return PrimitiveParser(f, pattern)60# def char() -> Parser:61# """Char function."""62# return regex(r"\S")63def none_of(s: str) -> Parser:64 """none_of function.65 As the dual of oneOf, none_of(cs) succeeds if the current character66 not in the supplied list of characters cs. Returns the parsed character.67 Example68 -------69 >>> from simpleparser import none_of, choice, token, many, transform, seq70 >>> p = none_of("abcdefg")71 >>> p.exec("hello")72 ['h']73 >>> chars = choice(token('""'), none_of('",'))74 >>> p = transform(many(chars), lambda x: ["".join(x)])75 >>> text = r'Shirt with ""Haskell"" text'76 >>> p.exec(text)77 ['Shirt with ""Haskell"" text']78 >>> dq = token('"')79 >>> p2 = transform(seq(dq, p, dq), lambda x: ["".join(x)])80 >>> text = r'"Shirt with ""Haskell"" text"'81 >>> p2.exec(text)82 ['"Shirt with ""Haskell"" text"']83 """ # noqa: E50184 name: str = f"none_of {s}"85 def f(target: str, position: int = 0) -> ParseResult:86 exists: bool = False87 targetChar: str = target[position:position + 1]...

Full Screen

Full Screen

query.py

Source:query.py Github

copy

Full Screen

1from __future__ import annotations2from typing import *3from ecstremity.bit_util import *4from functools import reduce5if TYPE_CHECKING:6 from ecstremity.component import Component7 from ecstremity.world import World8def from_name(world: World, component_name: str) -> Component:9 return world.engine.components[component_name]10class Query:11 _cache = []12 def __init__(13 self,14 world: World,15 any_of: Optional[List[Union[Component, str]]] = None,16 all_of: Optional[List[Union[Component, str]]] = None,17 none_of: Optional[List[Union[Component, str]]] = None18 ) -> None:19 self._cache = []20 self.world = world21 self.any_of = any_of if any_of is not None else []22 self.all_of = all_of if all_of is not None else []23 self.none_of = none_of if none_of is not None else []24 self._any = reduce(lambda a, b: add_bit(a, b.cbit), self.any_of, 0)25 self._all = reduce(lambda a, b: add_bit(a, b.cbit), self.all_of, 0)26 self._none = reduce(lambda a, b: add_bit(a, b.cbit), self.none_of, 0)27 self.refresh()28 def idx(self, entity):29 try:30 return self._cache.index(entity)31 except ValueError:32 return -133 def matches(self, entity):34 bits = entity.cbits35 any_of = self._any == 0 or bit_intersection(bits, self._any) > 036 all_of = bit_intersection(bits, self._all) == self._all37 none_of = bit_intersection(bits, self._none) == 038 return any_of & all_of & none_of39 def candidate(self, entity):40 idx = self.idx(entity)41 is_tracking = idx >= 042 if self.matches(entity):43 if not is_tracking:44 self._cache.append(entity)45 return True46 if is_tracking:47 del self._cache[idx]48 return False49 def refresh(self):50 self._cache = []51 for entity in self.world.entities:52 self.candidate(entity)53 @property54 def result(self):...

Full Screen

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 pyshould 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