function
stringlengths
11
56k
repo_name
stringlengths
5
60
features
list
def get_actions(self, run_config, controller): """Get actions from the UI, apply to controller, and return an ActionCmd.""" if not self._initialized: return ActionCmd.STEP for event in pygame.event.get(): ctrl = pygame.key.get_mods() & pygame.KMOD_CTRL shift = pygame.key.get_mods() & pyga...
deepmind/pysc2
[ 7691, 1151, 7691, 50, 1501006617 ]
def camera_action_raw(self, world_pos): """Return a `sc_pb.Action` with the camera movement filled.""" action = sc_pb.Action() world_pos.assign_to(action.action_raw.camera_move.center_world_space) return action
deepmind/pysc2
[ 7691, 1151, 7691, 50, 1501006617 ]
def camera_action_observer_player(self, player_id): """Return a `sc_pb.ObserverAction` with the camera movement filled.""" action = sc_pb.ObserverAction() action.camera_follow_player.player_id = player_id return action
deepmind/pysc2
[ 7691, 1151, 7691, 50, 1501006617 ]
def select_idle_worker(self, ctrl, shift): """Select an idle worker.""" action = sc_pb.Action() mod = sc_ui.ActionSelectIdleWorker if ctrl: select_worker = mod.AddAll if shift else mod.All else: select_worker = mod.Add if shift else mod.Set action.action_ui.select_idle_worker.type = ...
deepmind/pysc2
[ 7691, 1151, 7691, 50, 1501006617 ]
def select_warp_gates(self, shift): """Select all warp gates.""" action = sc_pb.Action() action.action_ui.select_warp_gates.selection_add = shift return action
deepmind/pysc2
[ 7691, 1151, 7691, 50, 1501006617 ]
def control_group(self, control_group_id, ctrl, shift, alt): """Act on a control group, selecting, setting, etc.""" action = sc_pb.Action() select = action.action_ui.control_group mod = sc_ui.ActionControlGroup if not ctrl and not shift and not alt: select.action = mod.Recall elif ctrl an...
deepmind/pysc2
[ 7691, 1151, 7691, 50, 1501006617 ]
def _abilities(self, fn=None): """Return the list of abilities filtered by `fn`.""" out = {} for cmd in self._obs.observation.abilities: ability = _Ability(cmd, self._static_data.abilities) if not fn or fn(ability): out[ability.ability_id] = ability return list(out.values())
deepmind/pysc2
[ 7691, 1151, 7691, 50, 1501006617 ]
def _units_in_area(self, rect): """Return the list of units that intersect the rect.""" player_id = self._obs.observation.player_common.player_id return [u for u, p in self._visible_units() if rect.intersects_circle(p, u.radius) and u.owner == player_id]
deepmind/pysc2
[ 7691, 1151, 7691, 50, 1501006617 ]
def draw_units(self, surf): """Draw the units and buildings.""" unit_dict = None # Cache the units {tag: unit_proto} for orders. tau = 2 * math.pi for u, p in self._visible_units(): if self._camera.intersects_circle(p, u.radius): fraction_damage = clamp((u.health_max - u.health) / (u.heal...
deepmind/pysc2
[ 7691, 1151, 7691, 50, 1501006617 ]
def draw_effects(self, surf): """Draw the effects.""" for effect in self._obs.observation.raw_data.effects: color = [ colors.effects[effect.effect_id], colors.effects[effect.effect_id], colors.PLAYER_ABSOLUTE_PALETTE[effect.owner], ] name = self.get_unit_name( ...
deepmind/pysc2
[ 7691, 1151, 7691, 50, 1501006617 ]
def draw_selection(self, surf): """Draw the selection rectange.""" select_start = self._select_start # Cache to avoid a race condition. if select_start: mouse_pos = self.get_mouse_pos() if (mouse_pos and mouse_pos.surf.surf_type & SurfType.SCREEN and mouse_pos.surf.surf_type == select...
deepmind/pysc2
[ 7691, 1151, 7691, 50, 1501006617 ]
def draw_build_target(self, surf): """Draw the build target.""" round_half = lambda v, cond: round(v - 0.5) + 0.5 if cond else round(v) queued_action = self._queued_action if queued_action: radius = queued_action.footprint_radius if radius: pos = self.get_mouse_pos() if pos:...
deepmind/pysc2
[ 7691, 1151, 7691, 50, 1501006617 ]
def draw_overlay(self, surf): """Draw the overlay describing resources.""" obs = self._obs.observation player = obs.player_common surf.write_screen( self._font_large, colors.green, (0.2, 0.2), "Minerals: %s, Vespene: %s, Food: %s / %s" % ( player.minerals, player.vespene, pla...
deepmind/pysc2
[ 7691, 1151, 7691, 50, 1501006617 ]
def draw_help(self, surf): """Draw the help dialog.""" if not self._help: return def write(loc, text): surf.write_screen(self._font_large, colors.black, loc, text) surf.surf.fill(colors.white * 0.8) write((1, 1), "Shortcuts:") max_len = max(len(s) for s, _ in self.shortcuts) f...
deepmind/pysc2
[ 7691, 1151, 7691, 50, 1501006617 ]
def draw_commands(self, surf): """Draw the list of upgrades and available commands.""" line = itertools.count(2) def write(loc, text, color=colors.yellow): surf.write_screen(self._font_large, color, loc, text) def write_line(x, *args, **kwargs): write((x, next(line)), *args, **kwargs) ...
deepmind/pysc2
[ 7691, 1151, 7691, 50, 1501006617 ]
def draw_panel(self, surf): """Draw the unit selection or build queue.""" left = -14 # How far from the right border line = itertools.count(3) def unit_name(unit_type): return self._static_data.units.get(unit_type, "<unknown>") def write(loc, text, color=colors.yellow): surf.write_sc...
deepmind/pysc2
[ 7691, 1151, 7691, 50, 1501006617 ]
def draw_actions(self): """Draw the actions so that they can be inspected for accuracy.""" now = time.time() for act in self._past_actions: if act.pos and now < act.deadline: remain = (act.deadline - now) / (act.deadline - act.time) if isinstance(act.pos, point.Point): size =...
deepmind/pysc2
[ 7691, 1151, 7691, 50, 1501006617 ]
def prepare_actions(self, obs): """Keep a list of the past actions so they can be drawn.""" now = time.time() while self._past_actions and self._past_actions[0].deadline < now: self._past_actions.pop(0) def add_act(ability_id, color, pos, timeout=1): if ability_id: ability = self._s...
deepmind/pysc2
[ 7691, 1151, 7691, 50, 1501006617 ]
def draw_base_map(self, surf): """Draw the base map.""" hmap_feature = features.SCREEN_FEATURES.height_map hmap = hmap_feature.unpack(self._obs.observation) if not hmap.any(): hmap = hmap + 100 # pylint: disable=g-no-augmented-assignment hmap_color = hmap_feature.color(hmap) out = hmap_co...
deepmind/pysc2
[ 7691, 1151, 7691, 50, 1501006617 ]
def draw_mini_map(self, surf): """Draw the minimap.""" if (self._render_rgb and self._obs.observation.HasField("render_data") and self._obs.observation.render_data.HasField("minimap")): # Draw the rendered version. surf.blit_np_array(features.Feature.unpack_rgb_image( self._obs.obs...
deepmind/pysc2
[ 7691, 1151, 7691, 50, 1501006617 ]
def draw_rendered_map(self, surf): """Draw the rendered pixels.""" surf.blit_np_array(features.Feature.unpack_rgb_image( self._obs.observation.render_data.map))
deepmind/pysc2
[ 7691, 1151, 7691, 50, 1501006617 ]
def draw_feature_layer(self, surf, feature): """Draw a feature layer.""" layer = feature.unpack(self._obs.observation) if layer is not None: surf.blit_np_array(feature.color(layer)) else: # Ignore layers that aren't in this version of SC2. surf.surf.fill(colors.black)
deepmind/pysc2
[ 7691, 1151, 7691, 50, 1501006617 ]
def draw_raw_layer(self, surf, from_obs, name, color): """Draw a raw layer.""" if from_obs: layer = getattr(self._obs.observation.raw_data.map_state, name) else: layer = getattr(self._game_info.start_raw, name) layer = features.Feature.unpack_layer(layer) if layer is not None: surf...
deepmind/pysc2
[ 7691, 1151, 7691, 50, 1501006617 ]
def render(self, obs): """Push an observation onto the queue to be rendered.""" if not self._initialized: return now = time.time() self._game_times.append( (now - self._last_time, max(1, obs.observation.game_loop - self._obs.observation.game_loop))) self._last_time = now s...
deepmind/pysc2
[ 7691, 1151, 7691, 50, 1501006617 ]
def render_obs(self, obs): """Render a frame given an observation.""" start_time = time.time() self._obs = obs self.check_valid_queued_action() self._update_camera(point.Point.build( self._obs.observation.raw_data.player.camera)) for surf in self._surfaces: # Render that surface. ...
deepmind/pysc2
[ 7691, 1151, 7691, 50, 1501006617 ]
def calculate_iou(bbox1, bbox2): """Calculates the Intersection-Over-Union of two bounding boxes. IOU is a ratio for determining how much two bounding boxes match. Args: bbox1: The first bounding box. bbox2: The bounding box to compare with. Returns: The IOU as a float from 0.0 to 1.0 (1.0 being ...
google/automl-video-ondevice
[ 51, 22, 51, 4, 1566359607 ]
def __init__(self, allowed_staleness=10, min_iou=0.6): """Constructor for MediaPipeTrackValidator. Args: allowed_staleness: How many updates the track can linger for until it is determined to be stale. min_iou: How much the detection box must match a tracked box to be determined as ...
google/automl-video-ondevice
[ 51, 22, 51, 4, 1566359607 ]
def update_tracks(self, managed_tracks): """Updates tracks stored in the validator with new tracking data. Also adds new tracks if the validator does not know about the track yet. Args: managed_tracks: Tracks managed by mediapipe. """ for track in managed_tracks: if track.track_id in s...
google/automl-video-ondevice
[ 51, 22, 51, 4, 1566359607 ]
def reset_tracks_with_detections(self, detections): """Resets the staleness of tracks if there are associated detections. Args: detections: List of raw detections created from inferencing. """ for detection in detections: max_iou = 0 associated_track = None for track in self._tr...
google/automl-video-ondevice
[ 51, 22, 51, 4, 1566359607 ]
def main(argv=sys.argv[1:]): parser = argparse.ArgumentParser( description='Invoke the build tool on a workspace while enabling and ' 'running the tests') parser.add_argument( '--rosdistro-name', required=True, help='The name of the ROS distro to identify the ...
ros-infrastructure/ros_buildfarm
[ 70, 86, 70, 43, 1412023694 ]
def config(self): return {"url": self.url, "endpointurl": self.TEST_AWS_ENDPOINT_URL}
dmpetrov/dataversioncontrol
[ 11197, 1036, 11197, 597, 1488615393 ]
def should_test(): do_test = env2bool("DVC_TEST_AWS", undefined=None) if do_test is not None: return do_test if os.getenv("AWS_ACCESS_KEY_ID") and os.getenv( "AWS_SECRET_ACCESS_KEY" ): return True return False
dmpetrov/dataversioncontrol
[ 11197, 1036, 11197, 597, 1488615393 ]
def _get_storagepath(): return ( TEST_AWS_REPO_BUCKET + "/" + "dvc_test_caches" + "/" + str(uuid.uuid4()) )
dmpetrov/dataversioncontrol
[ 11197, 1036, 11197, 597, 1488615393 ]
def get_url(): return "s3://" + S3._get_storagepath()
dmpetrov/dataversioncontrol
[ 11197, 1036, 11197, 597, 1488615393 ]
def _s3(self): import boto3 return boto3.client("s3", endpoint_url=self.config["endpointurl"])
dmpetrov/dataversioncontrol
[ 11197, 1036, 11197, 597, 1488615393 ]
def is_dir(self): path = (self / "").path resp = self._s3.list_objects(Bucket=self.bucket, Prefix=path) return bool(resp.get("Contents"))
dmpetrov/dataversioncontrol
[ 11197, 1036, 11197, 597, 1488615393 ]
def mkdir(self, mode=0o777, parents=False, exist_ok=False): assert mode == 0o777 assert parents
dmpetrov/dataversioncontrol
[ 11197, 1036, 11197, 597, 1488615393 ]
def read_bytes(self): data = self._s3.get_object(Bucket=self.bucket, Key=self.path) return data["Body"].read()
dmpetrov/dataversioncontrol
[ 11197, 1036, 11197, 597, 1488615393 ]
def fs_path(self): return self.bucket + "/" + self.path.lstrip("/")
dmpetrov/dataversioncontrol
[ 11197, 1036, 11197, 597, 1488615393 ]
def s3_fake_creds_file(monkeypatch): # https://github.com/spulec/moto#other-caveats import pathlib aws_dir = pathlib.Path("~").expanduser() / ".aws" aws_dir.mkdir(exist_ok=True) aws_creds = aws_dir / "credentials" initially_exists = aws_creds.exists() if not initially_exists: aws_...
dmpetrov/dataversioncontrol
[ 11197, 1036, 11197, 597, 1488615393 ]
def s3_server(test_config, docker_compose, docker_services): import requests test_config.requires("s3") port = docker_services.port_for("motoserver", 5000) endpoint_url = TEST_AWS_ENDPOINT_URL.format(port=port) def _check(): try: r = requests.get(endpoint_url) retu...
dmpetrov/dataversioncontrol
[ 11197, 1036, 11197, 597, 1488615393 ]
def s3(test_config, s3_server, s3_fake_creds_file): test_config.requires("s3") workspace = S3(S3.get_url()) workspace._s3.create_bucket(Bucket=TEST_AWS_REPO_BUCKET) yield workspace
dmpetrov/dataversioncontrol
[ 11197, 1036, 11197, 597, 1488615393 ]
def testRuns(self): with mock.patch.object(dataset, 'load', new=fake_mnist_data): train.train( batch_size=1, learning_rate=0.1, num_training_iters=10, validation_steps=5) train.train( batch_size=2, learning_rate=0.1, num_training_iter...
google/trax
[ 7391, 769, 7391, 106, 1570288154 ]
def gen_examples(num_examples): x = np.array( np.random.randn(num_examples, 784), copy=False, dtype=np.float32) y = np.zeros((num_examples, 10), dtype=np.float32) y[:][0] = 1. return (x, y)
google/trax
[ 7391, 769, 7391, 106, 1570288154 ]
def catkin_success(args, env={}): orig_environ = dict(os.environ) try: os.environ.update(env) catkin_main(args) except SystemExit as exc: ret = exc.code if ret != 0: import traceback traceback.print_exc() finally: os.environ = orig_environ ...
catkin/catkin_tools
[ 149, 135, 149, 91, 1393292582 ]
def __init__(self, expected, expected_regex=None): self.expected = expected self.expected_regex = expected_regex
catkin/catkin_tools
[ 149, 135, 149, 91, 1393292582 ]
def __exit__(self, exc_type, exc_value, tb): if self.expected is None: if exc_type is None: return True else: raise if exc_type is None: try: exc_name = self.expected.__name__ except AttributeError: ...
catkin/catkin_tools
[ 149, 135, 149, 91, 1393292582 ]
def __enter__(self): self.original_stdout = sys.stdout self.original_stderr = sys.stderr self.out = StringIO() self.err = StringIO() sys.stdout = self.out sys.stderr = self.err return self.out, self.err
catkin/catkin_tools
[ 149, 135, 149, 91, 1393292582 ]
def __init__(self, prefix=''): self.prefix = prefix self.delete = False
catkin/catkin_tools
[ 149, 135, 149, 91, 1393292582 ]
def __exit__(self, exc_type, exc_value, traceback): if self.delete and self.temp_path and os.path.exists(self.temp_path): print('Deleting temporary testind directory: %s' % self.temp_path) shutil.rmtree(self.temp_path) if self.original_cwd and os.path.exists(self.original_cwd): ...
catkin/catkin_tools
[ 149, 135, 149, 91, 1393292582 ]
def decorated(*args, **kwds): with temporary_directory() as directory: from inspect import getargspec # If it takes directory of kwargs and kwds does already have # directory, inject it if 'directory' not in kwds and 'directory' in getargspec(f)[0]: ...
catkin/catkin_tools
[ 149, 135, 149, 91, 1393292582 ]
def run(args, **kwargs): """ Call to Popen, returns (errcode, stdout, stderr) """ print("run:", args) p = subprocess.Popen( args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True, cwd=kwargs.get('cwd', os.getcwd())) print("P==", p....
catkin/catkin_tools
[ 149, 135, 149, 91, 1393292582 ]
def assert_cmd_failure(cmd, **kwargs): """ Asserts that running a command returns non-zero. returns: stdout """ print(">>>", cmd, kwargs) (r, out, err) = run(cmd, withexitstatus=True, **kwargs) print("<<<", str(out)) assert 0 != r, "cmd succeeded, but it should fail: %s result=%u\noutpu...
catkin/catkin_tools
[ 149, 135, 149, 91, 1393292582 ]
def test_configuration_subclass_inherits_items(self): class BaseConfig(schema.Schema): base = schema.BooleanItem(default=True, required=True) class SubClassedConfig(BaseConfig): hungry = schema.BooleanItem( title="Hungry", description="Are you hungry?", required=...
saltstack/salt
[ 13089, 5388, 13089, 3074, 1298233016 ]
def test_optional_requirements_config(self): class BaseRequirements(schema.Schema): driver = schema.StringItem(default="digitalocean", format="hidden") class SSHKeyFileSchema(schema.Schema): ssh_key_file = schema.StringItem( title="SSH Private Key", ...
saltstack/salt
[ 13089, 5388, 13089, 3074, 1298233016 ]
def test_optional_requirements_config_validation(self): class BaseRequirements(schema.Schema): driver = schema.StringItem(default="digitalocean", format="hidden") class SSHKeyFileSchema(schema.Schema): ssh_key_file = schema.StringItem( title="SSH Private Key", ...
saltstack/salt
[ 13089, 5388, 13089, 3074, 1298233016 ]
def test_boolean_config_validation(self): class TestConf(schema.Schema): item = schema.BooleanItem(title="Hungry", description="Are you hungry?") try: jsonschema.validate({"item": False}, TestConf.serialize()) except jsonschema.exceptions.ValidationError as exc: ...
saltstack/salt
[ 13089, 5388, 13089, 3074, 1298233016 ]
def test_string_config_validation(self): class TestConf(schema.Schema): item = schema.StringItem(title="Foo", description="Foo Item") try: jsonschema.validate({"item": "the item"}, TestConf.serialize()) except jsonschema.exceptions.ValidationError as exc: sel...
saltstack/salt
[ 13089, 5388, 13089, 3074, 1298233016 ]
def test_email_config_validation(self): class TestConf(schema.Schema): item = schema.EMailItem(title="Item", description="Item description") try: jsonschema.validate( {"item": "nobody@nowhere.com"}, TestConf.serialize(), format_che...
saltstack/salt
[ 13089, 5388, 13089, 3074, 1298233016 ]
def test_ipv4_config_validation(self): class TestConf(schema.Schema): item = schema.IPv4Item(title="Item", description="Item description") try: jsonschema.validate( {"item": "127.0.0.1"}, TestConf.serialize(), format_checker=jsonsc...
saltstack/salt
[ 13089, 5388, 13089, 3074, 1298233016 ]
def test_ipv6_config_validation(self): class TestConf(schema.Schema): item = schema.IPv6Item(title="Item", description="Item description") try: jsonschema.validate( {"item": salt.utils.stringutils.to_str("::1")}, TestConf.serialize(), ...
saltstack/salt
[ 13089, 5388, 13089, 3074, 1298233016 ]
def test_hostname_config_validation(self): class TestConf(schema.Schema): item = schema.HostnameItem(title="Item", description="Item description") try: jsonschema.validate( {"item": "localhost"}, TestConf.serialize(), format_checke...
saltstack/salt
[ 13089, 5388, 13089, 3074, 1298233016 ]
def test_datetime_config_validation(self): class TestConf(schema.Schema): item = schema.DateTimeItem(title="Item", description="Item description") try: jsonschema.validate( {"item": "2015-07-01T18:05:27+01:00"}, TestConf.serialize(), ...
saltstack/salt
[ 13089, 5388, 13089, 3074, 1298233016 ]
def test_uri_config(self): item = schema.UriItem(title="Foo", description="Foo Item") self.assertDictEqual( item.serialize(), { "type": "string", "title": item.title, "description": item.description, "format": item.f...
saltstack/salt
[ 13089, 5388, 13089, 3074, 1298233016 ]
def test_uri_config_validation(self): class TestConf(schema.Schema): item = schema.UriItem(title="Item", description="Item description") try: jsonschema.validate( {"item": "ssh://localhost"}, TestConf.serialize(), format_checker=js...
saltstack/salt
[ 13089, 5388, 13089, 3074, 1298233016 ]
def test_number_config_validation(self): class TestConf(schema.Schema): item = schema.NumberItem(title="How many dogs", description="Question") try: jsonschema.validate({"item": 2}, TestConf.serialize()) except jsonschema.exceptions.ValidationError as exc: se...
saltstack/salt
[ 13089, 5388, 13089, 3074, 1298233016 ]
def test_integer_config_validation(self): class TestConf(schema.Schema): item = schema.IntegerItem(title="How many dogs", description="Question") try: jsonschema.validate({"item": 2}, TestConf.serialize()) except jsonschema.exceptions.ValidationError as exc: ...
saltstack/salt
[ 13089, 5388, 13089, 3074, 1298233016 ]
def test_array_config_validation(self): class TestConf(schema.Schema): item = schema.ArrayItem( title="Dog Names", description="Name your dogs", items=schema.StringItem(), ) try: jsonschema.validate( {"i...
saltstack/salt
[ 13089, 5388, 13089, 3074, 1298233016 ]
def test_dict_config_validation(self): class TestConf(schema.Schema): item = schema.DictItem( title="Poligon", description="Describe the Poligon", properties={"sides": schema.IntegerItem()}, ) try: jsonschema.validate({...
saltstack/salt
[ 13089, 5388, 13089, 3074, 1298233016 ]
def test_oneof_config_validation(self): class TestConf(schema.Schema): item = schema.ArrayItem( title="Hungry", description="Are you hungry?", items=schema.OneOfItem( items=( schema.StringItem(title="Yes", en...
saltstack/salt
[ 13089, 5388, 13089, 3074, 1298233016 ]
def test_anyof_config_validation(self): class TestConf(schema.Schema): item = schema.ArrayItem( title="Hungry", description="Are you hungry?", items=schema.AnyOfItem( items=( schema.StringItem(title="Yes", en...
saltstack/salt
[ 13089, 5388, 13089, 3074, 1298233016 ]
def test_allof_config_validation(self): class TestConf(schema.Schema): item = schema.ArrayItem( title="Hungry", description="Are you hungry?", items=schema.AllOfItem( items=( schema.StringItem(min_length=2), ...
saltstack/salt
[ 13089, 5388, 13089, 3074, 1298233016 ]
def test_not_config_validation(self): class TestConf(schema.Schema): item = schema.ArrayItem( title="Hungry", description="Are you hungry?", items=schema.NotItem(item=schema.BooleanItem()), ) try: jsonschema.validate({"...
saltstack/salt
[ 13089, 5388, 13089, 3074, 1298233016 ]
def test_config_name_override_class_attrname(self): class TestConf(schema.Schema): item = schema.BooleanItem(title="Hungry", description="Are you hungry?") class TestConf2(schema.Schema): a_name = TestConf(name="another_name") expected = { "$schema": "http:/...
saltstack/salt
[ 13089, 5388, 13089, 3074, 1298233016 ]
def test_complex_schema_item_serialize(self): obj = copy.deepcopy(self.obj) expected_serialized = {"$ref": "#/definitions/ComplexSchemaItem"} self.assertDictEqual(obj.serialize(), expected_serialized)
saltstack/salt
[ 13089, 5388, 13089, 3074, 1298233016 ]
def test_complex_complex_schema_item_definition(self): complex_obj = copy.deepcopy(self.complex_obj) expected_def = { "type": "object", "title": "ComplexComplexSchemaItem", "properties": { "hungry": { "type": "boolean", ...
saltstack/salt
[ 13089, 5388, 13089, 3074, 1298233016 ]
def test_one_of_complex_definition_schema(self): serialized = salt.utils.yaml.safe_load( salt.utils.json.dumps(self.one_of_schema.serialize()) ) expected = { "$schema": "http://json-schema.org/draft-04/schema#", "title": "Test OneOf Complex Definitions Schema"...
saltstack/salt
[ 13089, 5388, 13089, 3074, 1298233016 ]
def test_dict_complex_definition_schema(self): serialized = salt.utils.yaml.safe_load( salt.utils.json.dumps(self.dict_schema.serialize()) ) expected = { "$schema": "http://json-schema.org/draft-04/schema#", "title": "Test Dict Complex Definitions Schema", ...
saltstack/salt
[ 13089, 5388, 13089, 3074, 1298233016 ]
def test_complex_schema_item_thirsty_valid(self): serialized = self.schema.serialize() try: jsonschema.validate({"complex_item": {"thirsty": True}}, serialized) except jsonschema.exceptions.ValidationError as exc: self.fail("ValidationError raised: {}".format(exc))
saltstack/salt
[ 13089, 5388, 13089, 3074, 1298233016 ]
def test_complex_schema_item_thirsty_invalid(self): serialized = self.schema.serialize() with self.assertRaises(jsonschema.exceptions.ValidationError) as excinfo: jsonschema.validate({"complex_item": {"thirsty": "Foo"}}, serialized) expected = "'Foo' is not of type 'boolean'" ...
saltstack/salt
[ 13089, 5388, 13089, 3074, 1298233016 ]
def test_complex_complex_schema_item_hungry_valid(self): serialized = self.complex_schema.serialize() try: jsonschema.validate({"complex_complex_item": {"hungry": True}}, serialized) except jsonschema.exceptions.ValidationError as exc: self.fail("ValidationError raised: ...
saltstack/salt
[ 13089, 5388, 13089, 3074, 1298233016 ]
def test_both_complex_complex_schema_all_items_valid(self): serialized = self.complex_schema.serialize() try: jsonschema.validate( { "complex_complex_item": { "hungry": True, "complex_item": {"thirsty": True}...
saltstack/salt
[ 13089, 5388, 13089, 3074, 1298233016 ]
def test_complex_complex_schema_item_hungry_invalid(self): serialized = self.complex_schema.serialize() with self.assertRaises(jsonschema.exceptions.ValidationError) as excinfo: jsonschema.validate({"complex_complex_item": {"hungry": "Foo"}}, serialized) expected = "'Foo' is not of t...
saltstack/salt
[ 13089, 5388, 13089, 3074, 1298233016 ]
def test_complex_complex_schema_item_inner_thirsty_invalid(self): serialized = self.complex_schema.serialize() with self.assertRaises(jsonschema.exceptions.ValidationError) as excinfo: jsonschema.validate( { "complex_complex_item": { ...
saltstack/salt
[ 13089, 5388, 13089, 3074, 1298233016 ]
def main(): settings = get_settings_from_env() server = server_factory(**settings) server.serve_forever()
kubeflow/pipelines
[ 3125, 1400, 3125, 892, 1526085107 ]
def server_factory(visualization_server_image, visualization_server_tag, frontend_image, frontend_tag, disable_istio_sidecar, minio_access_key, minio_secret_key, kfp_default_pipeline_root=None, url="", controller_port=8080): """ Returns...
kubeflow/pipelines
[ 3125, 1400, 3125, 892, 1526085107 ]
def _parse_time(t): global calendar parsed, code = calendar.parse(t) if code != 2: raise ValueError("Could not parse {}!".format(t)) parsed = datetime.fromtimestamp(time.mktime(parsed)) return (parsed - datetime.now()).total_seconds()
RedHatQE/wait_for
[ 15, 14, 15, 1, 1440750364 ]
def is_lambda_function(obj): return isinstance(obj, LambdaType) and obj.__name__ == "<lambda>"
RedHatQE/wait_for
[ 15, 14, 15, 1, 1440750364 ]
def check_result_in_fail_condition(fail_condition, result): return result in fail_condition
RedHatQE/wait_for
[ 15, 14, 15, 1, 1440750364 ]
def _get_failcondition_check(fail_condition): if callable(fail_condition): return fail_condition elif isinstance(fail_condition, set): return partial(check_result_in_fail_condition, fail_condition) else: return partial(check_result_is_fail_condition, fail_condition)
RedHatQE/wait_for
[ 15, 14, 15, 1, 1440750364 ]
def wait_for_decorator(*args, **kwargs): """Wrapper for :py:func:`utils.wait.wait_for` that makes it nicer to write testing waits. It passes the function decorated to to ``wait_for`` Example: .. code-block:: python @wait_for_decorator(num_sec=120) def my_waiting_func(): retur...
RedHatQE/wait_for
[ 15, 14, 15, 1, 1440750364 ]
def __init__(self, time_for_refresh=300, callback=None, *args, **kwargs): self.callback = callback or self.it_is_time self.time_for_refresh = time_for_refresh self.args = args self.kwargs = kwargs self._is_it_time = False self.start()
RedHatQE/wait_for
[ 15, 14, 15, 1, 1440750364 ]
def it_is_time(self): self._is_it_time = True
RedHatQE/wait_for
[ 15, 14, 15, 1, 1440750364 ]
def __init__(self, method, url, **kwargs): self.response = httpx.get(url)
stencila/hub
[ 30, 4, 30, 195, 1447281243 ]
def __enter__(self, *args, **kwargs): return self
stencila/hub
[ 30, 4, 30, 195, 1447281243 ]
def test_extension_from_mimetype(tempdir): with working_directory(tempdir.path): files = pull_http({"url": "https://httpbin.org/get"}) assert files["get.json"]["mimetype"] == "application/json" files = pull_http({"url": "https://httpbin.org/image/png"}, path="image") assert files["i...
stencila/hub
[ 30, 4, 30, 195, 1447281243 ]
def test_encrypt_default_noop_secret_engine(self): self.assertEqual(encrypt(b"le temps des cerises", yolo=1, fomo=2), "noop$bGUgdGVtcHMgZGVzIGNlcmlzZXM=")
zentralopensource/zentral
[ 671, 87, 671, 23, 1445349783 ]
def test_decrypt_default_noop_secret_engine(self): self.assertEqual(decrypt("noop$bGUgdGVtcHMgZGVzIGNlcmlzZXM=", yolo=1, fomo=2), b"le temps des cerises")
zentralopensource/zentral
[ 671, 87, 671, 23, 1445349783 ]
def __init__(self): super(JSApiExample, self).__init__() self._toBeUpdatedFromThread = None self._startThread = None self._running = Label('') self.setSpacing(True) javascript = Label("<h3>Run Native JavaScript</h3>", Label.CONTENT_XHTML) self.a...
rwl/muntjac
[ 43, 14, 43, 5, 1316308871 ]
def __init__(self, component, script): self._component = component self._script = script
rwl/muntjac
[ 43, 14, 43, 5, 1316308871 ]