query
stringlengths
9
3.4k
document
stringlengths
9
87.4k
metadata
dict
negatives
listlengths
4
101
negative_scores
listlengths
4
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
Makes an IGVstyle drawing with colors
def make_line_plot(the_sets, params): bed_filename = params['bed_filename'] coords = get_read_coordinates(bed_filename, normalize=True) gapset, spanset, preset, postset = the_sets colors = node_set_colors(coords.keys(), gapset, spanset, preset, postset) y_increment = (1. / float(len(coords))) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _style_colours(self):\n\n pass", "def _color(self, args):", "def show_vertex_colors():\n if bpy.app.version > (2, 80, 0):\n for area in bpy.context.screen.areas:\n if area.type == 'VIEW_3D':\n for space in area.spaces:\n if space.type == 'VIEW_3...
[ "0.624505", "0.62064", "0.6150767", "0.60509986", "0.6041359", "0.6030837", "0.5991825", "0.5965499", "0.596378", "0.59161466", "0.5888834", "0.58749616", "0.5782469", "0.5722621", "0.5711476", "0.5706236", "0.5691816", "0.56374407", "0.56123173", "0.5612097", "0.560385", "...
0.0
-1
Generates four graphs for the structural variant defined by merged_filename
def make_four_pdf(args): params = make_four_params(args) m4_filename = params['m4_filename'] prefix = params['prefix'] min_matching_length = params['min_matching_length'] output_prefix = params['output_prefix'] # if there are fewer than threshold reads then skip it threshold = 25 # threshol...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sixteen_graphs(the_dir):\n # TODO change to deprecation warning\n warnings.warn(\"Does not call sv_pipeline functoins correctly\", DeprecationWarning)\n\n plb.rcParams['figure.figsize'] = 30, 30\n plt.clf()\n plt.figure(1)\n\n # should look like: read_data/all_files/chr4_124,017,492_124,029,0...
[ "0.62337637", "0.6031929", "0.5773707", "0.569177", "0.5651232", "0.55629456", "0.5511487", "0.5491815", "0.5481452", "0.5463038", "0.5419759", "0.5395845", "0.5369272", "0.5366786", "0.53644574", "0.5349286", "0.53409547", "0.53354126", "0.53175104", "0.53075373", "0.5303393...
0.0
-1
generates graphs for each structual variant
def sixteen_graphs(the_dir): # TODO change to deprecation warning warnings.warn("Does not call sv_pipeline functoins correctly", DeprecationWarning) plb.rcParams['figure.figsize'] = 30, 30 plt.clf() plt.figure(1) # should look like: read_data/all_files/chr4_124,017,492_124,029,032_merged.txt ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def gen_graph(self):", "def populate_graph(self):", "def build_graph(self):\n pass", "def _build_graph(self):\n pass", "def generate_subgraph(format):\n\n # get business information\n directorypath = genpath+directory\n if os.path.isfile(directorypath):\n \n bizdata = pd...
[ "0.7290527", "0.65085155", "0.6410746", "0.6359326", "0.6265157", "0.62437093", "0.62147", "0.6130856", "0.6063134", "0.6014573", "0.5913868", "0.58793896", "0.58649206", "0.5789208", "0.57693243", "0.5733632", "0.5728531", "0.56909496", "0.5682795", "0.5681683", "0.5664425",...
0.54853797
38
Generates four graphs for each structural variant in the directory formerly
def four_graphs(the_dir, min_matching_length, output_prefix, sw_window_size): files = get_files(the_dir) print('Looking in directory %s*.m4' % (the_dir)) print('There are %d files' % (len(files))) zipped = zip(files, itertools.repeat(the_dir), itertools.repeat(min_match...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_subgraph(format):\n\n # get business information\n directorypath = genpath+directory\n if os.path.isfile(directorypath):\n \n bizdata = pd.read_csv( directorypath, escapechar='\\\\')\n\n #create a directory of page-id and object-ids\n tempdf = bizdata.set_index('pag...
[ "0.659347", "0.64899665", "0.6482556", "0.6280894", "0.61621535", "0.60121584", "0.59992623", "0.59135026", "0.58882594", "0.58695626", "0.5819254", "0.5776892", "0.57706445", "0.57308894", "0.57188094", "0.56933165", "0.5661808", "0.5643725", "0.56388", "0.5616771", "0.56149...
0.5689229
16
Validates an email address. >>> is_email_address("test.com") True >>> is_email_address("test.this.domain.example.me") True >>> is_email_address("test.gmail.style+tag.com") True >>> is_email_address("invalid") False >>> is_email_address("invalid&domain.com") False >>> is_email_address("test@.domain.com") Actually seen i...
def is_email_address(value): return _COMPILED[EMAIL].match(value) != None
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validate_email_address(email_address: str):\n email_regex = \"^[a-z0-9]+[\\\\._]?[a-z0-9]+[@]\\\\w+[.]\\\\w{2,3}$\"\n if re.search(email_regex, email_address):\n return True\n return False", "def is_valid_email_address (email):\n return valid_email.search(email)", "def is_v...
[ "0.8575625", "0.84851384", "0.83953494", "0.83473897", "0.83036774", "0.8301605", "0.8282927", "0.8255866", "0.80955577", "0.803546", "0.7959708", "0.7903979", "0.789488", "0.7892206", "0.7866369", "0.785021", "0.78347176", "0.78037316", "0.77615976", "0.7758334", "0.7695697"...
0.7941021
11
Create a ProducerFactory object.
def __init__(self, connection, topic, args, kargs): self.__args__ = args self.__kargs__ = kargs self.__topic__ = topic self.__conn__ = connection
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def kafka_producer_factory(kafka_broker, request):\n _producer = [None]\n\n def factory(**kafka_producer_params):\n params = {} if kafka_producer_params is None else kafka_producer_params.copy()\n params.setdefault('client_id', 'producer_%s' % (request.node.name,))\n _producer[0] = next(...
[ "0.7025217", "0.68390906", "0.6834584", "0.6776398", "0.6401017", "0.6385152", "0.62134594", "0.61186343", "0.6028576", "0.5980782", "0.59188235", "0.5901068", "0.5899369", "0.5796073", "0.569973", "0.5683468", "0.567076", "0.5631843", "0.55990684", "0.5586578", "0.5585444", ...
0.0
-1
Create a producer. Calls pykafka.topic.Topic.get_producer to create the producer Returns pykafka.producer.Producer
def create(self): topic = self.__conn__.create_topic(self.__topic__) return topic.get_producer(*self.__args__, **self.__kargs__)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_producer(self, topic_id: str) -> Producer:\n backend = None\n if self.vendor == 'kafka':\n backend = KafkaClient(topic_id, self.configs['kafka_servers'])\n else:\n project_id = os.getenv(\"GOOGLE_CLOUD_PROJECT\")\n subscription_id = os.getenv(\"GOOGL...
[ "0.77851456", "0.72549456", "0.6957942", "0.6930621", "0.69090855", "0.68014026", "0.66531676", "0.66403145", "0.6623068", "0.6583257", "0.6494753", "0.6437796", "0.63862807", "0.6300328", "0.6213889", "0.6204735", "0.60279506", "0.59126776", "0.58620876", "0.58424014", "0.58...
0.77106583
1
Return a string representation. Returns str returns a string representation of itself
def __str__(self): return f"topic: {self.__topic__}"
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_str(self) -> str:", "def toString(self) -> str:\n raise NotImplementedError", "def toString():", "def to_string(self):\r\n return self.__str__()", "def __str__(self):\n buf = StringIO()\n self.write_to(buf)\n return buf.getvalue()", "def __str__(self) -> str:\n ...
[ "0.83085304", "0.8040051", "0.80097175", "0.78801274", "0.7878785", "0.77915126", "0.77915126", "0.77915126", "0.7749101", "0.7697228", "0.76855636", "0.76847416", "0.7681851", "0.7667078", "0.76651454", "0.75902957", "0.75799274", "0.7561032", "0.75398624", "0.75385803", "0....
0.0
-1
All messages to the server must be JSONserialisable.
def send(self, msg): self.ws.send(json.dumps(msg))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validate_json(self):\n pass", "def send_jsonified(self, msg, stats=True):\n raise NotImplemented()", "def _send_json(self, data):\n return self.sendMessage(json.dumps(data).encode(\"utf-8\"))", "def json_serialize(self):\n raise NotImplementedError('json_serialize must be over...
[ "0.6654911", "0.6630986", "0.65368146", "0.6442708", "0.62427086", "0.61884284", "0.6152484", "0.6149814", "0.61469465", "0.6071603", "0.591953", "0.5882717", "0.58408344", "0.58157843", "0.574765", "0.573589", "0.57143545", "0.5693478", "0.5688369", "0.56881183", "0.5675443"...
0.0
-1
All messages from the server are valid JSON.
def recv(self): msg = self.ws.recv() print(msg) return ( json.loads(msg) if msg else msg )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validate_json(self):\n pass", "def construct_json(self):\n\n if 'message' not in self.data:\n self.data['message'] = self.message\n\n if self.status == 200:\n self.data['status'] = 'OK'\n else:\n self.data['status'] = 'Not OK'\n\n return jso...
[ "0.6554427", "0.64114743", "0.60908055", "0.6054486", "0.5964556", "0.5874959", "0.5825551", "0.5794578", "0.57911843", "0.5787778", "0.5780893", "0.576939", "0.57630444", "0.57298136", "0.5708723", "0.5703407", "0.5702239", "0.5669806", "0.5662018", "0.56608593", "0.56513697...
0.5448092
45
Assert that the correct message is received.
def recv_type(self, type_): msg = self.recv() assert msg and msg['type'] == type_, msg return msg
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_message(self):\n\n message = typhoonae.websocket.Message(\n {'from': 0, 'body': 'Message body'})\n\n self.assertEqual(0, message.socket)\n self.assertEqual('Message body', message.body)", "def test_send(self):\n self.inverter.send(b\"\\x00\\x01\\x02\", b\"\")\n ...
[ "0.7479688", "0.7339858", "0.72840655", "0.7169065", "0.7160685", "0.7150704", "0.70198834", "0.70130646", "0.6920468", "0.691517", "0.68666226", "0.6832248", "0.67956877", "0.67729837", "0.6744708", "0.6733483", "0.6730778", "0.6692171", "0.66914153", "0.66856384", "0.666463...
0.0
-1
Return a pretty string representation of the board.
def render_state(self, state, is_first_player_black): MOVES_STR = { -1 if is_first_player_black else 1: '▒▒', 0: ' ', 1 if is_first_player_black else -1: '██', } numbers = ' ' + ''.join( str(i) + (' ' if i < 10 else '') for i in ran...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def board_string(self):\n s = \"\"\n for i, v in enumerate(self.board):\n # if i % 81 == 0:\n # s += \"\\n\"\n if v is None:\n s += \"0\"\n else:\n if v.color == StoneColor.black:\n s += \"1\"\n ...
[ "0.8255606", "0.82497513", "0.81109965", "0.8038326", "0.8034061", "0.7885153", "0.78684336", "0.783711", "0.78338665", "0.7774994", "0.7771326", "0.7763116", "0.77425283", "0.7736104", "0.7733884", "0.7731785", "0.76850206", "0.76814973", "0.76664", "0.7656324", "0.76460916"...
0.0
-1
A simple memoryless implementation of a Gomoku gameplaying bot. Modify this if you want to do something fancy. (The first player is 1, the second player is 1).
def play_game(self, is_first_player): state = [0] * (self.SIZE * self.SIZE) turn_number = 0 player_number = -1 if is_first_player else 1 print('Your bot is playing {} ({})'.format( 'first' if is_first_player else 'second', 'black' if self.index == 0 else 'white' ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def play_game():\n pass", "def oneGame():\n playOneGame()", "def play_game():\n pass", "async def playing(self, ctx: commands.Context, *, game: str = None):\n\n global _ # MyPy was complaining this was a unresolved reference until global was called\n game_name = _(\"what\")\n ...
[ "0.66748965", "0.6540396", "0.6504868", "0.63579094", "0.6345802", "0.63275534", "0.6317963", "0.62635875", "0.62507284", "0.6207458", "0.61773705", "0.6171212", "0.6160435", "0.6150239", "0.61368304", "0.6126107", "0.61235934", "0.6106824", "0.61023647", "0.61023176", "0.609...
0.61000913
20
Check that broken __unicode__/__str__ actually raises an error.
def test_force_text_exception(self): class MyString(object): def __str__(self): return b'\xc3\xb6\xc3\xa4\xc3\xbc' __unicode__ = __str__ # str(s) raises a TypeError on python 3 if the result is not a text type. # python 2 fails when it tries converting f...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _validate_unicode(data, err=\"Input not valid unicode\"):\n try:\n if not isinstance(data, str) and not isinstance(data, str):\n raise UnicodeError(err)\n # In some cases we pass the above, but it's still inappropriate utf-8.\n str(data)\n except UnicodeError:\n rai...
[ "0.7820335", "0.712562", "0.7090174", "0.6981514", "0.6951635", "0.67255706", "0.66341805", "0.6598654", "0.6582145", "0.6511867", "0.6404797", "0.6359545", "0.6332364", "0.6303237", "0.6299061", "0.6286056", "0.6273976", "0.62645805", "0.6254592", "0.6227654", "0.62090826", ...
0.74112284
1
Test that force_bytes knows how to convert to bytes an exception containing nonASCII characters in its args.
def test_force_bytes_exception(self): error_msg = "This is an exception, voilà" exc = ValueError(error_msg) result = force_bytes(exc) self.assertEqual(result, error_msg.encode('utf-8'))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_nonASCIIBytesToString(self):\n self.assertRaises(UnicodeError, nativeString, b\"\\xFF\")", "def test_py2_transaction_exception_message_bytes_implicit_encoding_non_english():\n try:\n\n # Bytes literal with non-ascii compatible characters only allowed in\n # python 2\n\n ra...
[ "0.77594966", "0.7754345", "0.748256", "0.74188924", "0.7351609", "0.7313225", "0.7176732", "0.71660197", "0.71446127", "0.71294063", "0.7124105", "0.71056265", "0.7031364", "0.70092523", "0.6898177", "0.6873759", "0.68179154", "0.6805716", "0.6797002", "0.67729616", "0.67559...
0.81311226
0
Entry point of Lambda function.
def lambda_handler(event, context): # Generate json from base64-encoded image. data = generate_json_from_base64_image(event['image']) # Get response from Cloud Vision API response = get_response_from_cv_api(data) # Load response text as json. text_result = json.loads(response.text) # Extr...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def lambda_handler(event, context):\n return", "def lambda_handler(event, context):\n return", "def lambda_handler(event, context):\n return dispatch(event)", "def lambda_method(self,t): \n return 5*math.sin(2*math.pi*1*t) # I don't see the value of 1 here but this is how lamda is defi...
[ "0.7117734", "0.7117734", "0.69204116", "0.6426233", "0.62977284", "0.62949", "0.62714696", "0.6236613", "0.6165585", "0.6155875", "0.60868734", "0.6073085", "0.60661924", "0.5978792", "0.5955426", "0.5945215", "0.59250873", "0.5917553", "0.58179045", "0.57982415", "0.5794267...
0.0
-1
Translates the input file into a json text.
def generate_json_from_base64_image(base64_image): # Content image content_json_obj = {'content': base64_image} # Detection type. feature_json_obj = [{'type': get_detection_type(5), 'maxResults': 50, } ] # Now add it to the re...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read_json(self, inputfile):\n transtransfile = json.load(inputfile)\n self.language = transfile['lang']\n self.translations = transfile['strings']", "def _read_json(cls, input_file):\n with open(input_file) as f:\n return json.load(f)", "def _read_json(cls, input_file):\n ...
[ "0.7513639", "0.68007874", "0.68007874", "0.66803414", "0.66803414", "0.65688586", "0.65220004", "0.6511892", "0.6482155", "0.6418868", "0.6394679", "0.63921416", "0.63604486", "0.6353644", "0.6273617", "0.6259363", "0.6204062", "0.6163943", "0.6163943", "0.613355", "0.610954...
0.0
-1
Return the Vision API symbol corresponding to the given number.
def get_detection_type(detect_num): detect_num = int(detect_num) if 0 < detect_num < len(DETECTION_TYPES): return DETECTION_TYPES[detect_num] else: return DETECTION_TYPES[0]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def number_to_symbol(number):\n return [x for x in _atomic_number if _atomic_number[x] == number][0]", "def getSymbolAt(self, address: ghidra.program.model.address.Address) -> ghidra.program.model.symbol.Symbol:\n ...", "def getSymbolAt(self, address: ghidra.program.model.address.Address, name: unico...
[ "0.66408694", "0.6473042", "0.637004", "0.6256942", "0.62465554", "0.6236463", "0.62076956", "0.6110681", "0.60870695", "0.60536915", "0.5998216", "0.5983382", "0.592511", "0.59117895", "0.59070474", "0.5850959", "0.58061606", "0.578223", "0.5773515", "0.5768813", "0.5754112"...
0.0
-1
Get response from Cloud Vision API.
def get_response_from_cv_api(data): url = 'https://vision.googleapis.com/v1/images:annotate?key={}'.format(API_KEY) response = requests.post(url=url, data=data, headers={'Content-Type': 'application/json'}) return response
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_response(image):\n encoded = base64.b64encode(image.read())\n GOOGLE_CLOUD_VISION_API_URL = 'https://vision.googleapis.com/v1/images:annotate?key='\n API_KEY = 'AIzaSyCKFsYnfYoLFeD2OHpvcjky9opfhHKFnP0'\n api_url = GOOGLE_CLOUD_VISION_API_URL + API_KEY\n header = {'Content-Type': 'application...
[ "0.6588146", "0.641112", "0.61037785", "0.57874006", "0.571129", "0.5638207", "0.5509912", "0.54499793", "0.5273775", "0.52694327", "0.5254997", "0.52453876", "0.5232203", "0.52142817", "0.519771", "0.51782495", "0.51781756", "0.51781756", "0.51781756", "0.51781756", "0.51781...
0.7367046
0
Constructor method. Initializes the client.
def __init__(self, host: str, port: int): self.__host: str = host self.__port: int = port
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, client=None):\n self._client = client", "def __init__(self, client):\n self._client = client", "def __init__(self, client):\n\n self.client = client", "def __init__(self, client):\n self.client = client", "def client_setup(self):\n self.client = Client(...
[ "0.8327685", "0.8319791", "0.8300767", "0.8265125", "0.8112874", "0.8045332", "0.78123504", "0.76885706", "0.7643811", "0.75182176", "0.73752475", "0.7280026", "0.7264783", "0.7245352", "0.72363025", "0.722842", "0.722842", "0.722842", "0.722842", "0.722842", "0.7146238", "...
0.0
-1
Creates a new connection to the authentication server.
def __get_connection(self) -> HTTPConnection: return HTTPConnection(self.__host, self.__port)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def connect(self, host, auth):\n return Connection(host, auth)", "def _create_connection(self):\n if not self.connection:\n log.info(\"{}: Creating connection with address={}\".format(\n self.container_id, self.address.geturl()))\n self.connection = Connection(\...
[ "0.7142276", "0.6768396", "0.67655563", "0.66948736", "0.66659343", "0.6585904", "0.6562106", "0.65490437", "0.6543258", "0.65032685", "0.645694", "0.6453362", "0.644213", "0.6427064", "0.64152914", "0.6409475", "0.63966775", "0.63941807", "0.63804245", "0.63536394", "0.63535...
0.0
-1
Determines whether a given user from the authentication server has a certain right or not.
def has_right(self, username: str, right: str) -> bool: form: str = urlencode({'username': username, 'right': right}) headers: dict = { 'Content-type': 'application/x-www-form-urlencoded' } connection: HTTPConnection = self.__get_connection() connection.request('GET',...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def user_roles_check(request):\n logger.debug('right_user_check')\n options = {\n 'api_file': {'GET': True, 'POST': False}\n }\n url_name = request.request.resolver_match.url_name\n if not request.request.user.is_authenticated:\n return False\n user_have_right = options[url_name][re...
[ "0.6864294", "0.6832401", "0.6566839", "0.65181917", "0.650468", "0.6478974", "0.64769286", "0.64769286", "0.6463664", "0.64017993", "0.6368617", "0.634587", "0.6326526", "0.63013756", "0.6293979", "0.62584096", "0.62548155", "0.62485784", "0.62485784", "0.6244719", "0.624461...
0.7994539
0
Initialize TCP Protocol object.
def __init__(self, test_stream=None, no_delay=False, window=None, server=None): self._transport = None self._socket = None self._stream = test_stream self._logger = logging.getLogger('py3iperf3') self._sock_id = None self._no_delay = no_delay self._window = window...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, af: int=AF_INET, type: int=SOCK_STREAM,\n proto: int=IPPROTO_TCP) -> None:\n ...", "def __init__(self, protocol):\r\n self._protocol = protocol", "def __init__(self):\n # Create a TCP/IP socket\n self.client_socket = socket.socket(socket.AF_INET, s...
[ "0.71132845", "0.70866555", "0.70138896", "0.6893583", "0.6840369", "0.68216836", "0.68001693", "0.6701732", "0.6666578", "0.66378766", "0.6552398", "0.65229064", "0.64933044", "0.6475642", "0.64572215", "0.6449293", "0.64326483", "0.642818", "0.6422145", "0.6418033", "0.6411...
0.6103575
57
Update owner to test from server once ready
def set_owner(self, owner, is_stream=False): if is_stream: self._logger.debug('TCP Proto Stream is set!') self._stream = owner else: self._server = owner
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_owner(self, owner):\n self.settings[\"owner\"] = owner", "def set_owner(self, data):\n self._owner = self._uni(data)\n self.add_payload('owner', data)", "def test_patch_project_owner(self):\n new_owner = self.make_user('new_owner')\n url = reverse(\n 'proje...
[ "0.6797942", "0.659154", "0.6493841", "0.6467483", "0.6394063", "0.6364081", "0.63616765", "0.6348624", "0.6277065", "0.6234481", "0.62229526", "0.6220377", "0.62035775", "0.61991775", "0.6164376", "0.61599797", "0.6117153", "0.6114377", "0.6114377", "0.6114377", "0.6114377",...
0.0
-1
Connection from the client established to the server
def connection_from_client(self, transport): peer_data = transport.get_extra_info('peername') self._logger.info('[%s] incomming connection from %s port %s', self._sock_id, peer_data[0], peer_data[1]) self._server.tcp_connection_established(self)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _establish_connection(self):\n self.conn = self.listener.accept()", "def connectToServer(self):\n self.client = Client(base_url = self.server)\n self.ping()", "def connect_to_server(self):\r\n self.client_socket.connect((SERVER_IP, SERVER_PORT))\r\n print('[CLIENT] connec...
[ "0.7680837", "0.7548338", "0.7450128", "0.7296759", "0.72919726", "0.7278883", "0.7217436", "0.7145088", "0.713979", "0.7058609", "0.70077366", "0.69932455", "0.6990394", "0.6990394", "0.69863665", "0.6966686", "0.69573164", "0.6947758", "0.6946488", "0.6913199", "0.68871427"...
0.67098856
35
Connecton to the server established
def connection_to_server_made(self, transport): local_data = self._socket.getsockname() peer_data = transport.get_extra_info('peername') self._logger.info('[%s] local %s:%s connected to %s:%s', self._sock_id, local_data[0], local_data[1], pee...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def connect():", "def connect_to_server(self):\n\n\t\tself.__logs.append('-- connecting to server ...')\n\t\tself.connect_to_ssh_server.emit(self.__ip.text(), int(self.__port.text()),\\\n\t\t\tself.__username.text(), self.__pwd.text())", "def connectToServer(self):\n self.client = Client(base_url = self...
[ "0.7862597", "0.76363", "0.76069903", "0.75337553", "0.75265294", "0.7431935", "0.7408243", "0.73457116", "0.73268795", "0.7316221", "0.73118395", "0.72880214", "0.72818154", "0.7272668", "0.7272488", "0.72519034", "0.72483194", "0.7231158", "0.7217925", "0.7170677", "0.71644...
0.0
-1
Callback on connection lost.
def connection_lost(self, exc): if self._stream.done: # Stream is done, no need to panic pass else: self._logger.debug('[%s] Connection lost!', self._sock_id, exc_info=exc)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def connectionLost(reason):", "def loseConnection(self):\n self.lost_connection.callback(self)\n return None", "def connectionLost(self,reason):\n pass", "async def connection_lost(self):\n logging.info('connection dropped')", "def connectionLost(self, reason):\n self.set...
[ "0.8439273", "0.8378254", "0.8260436", "0.8224796", "0.79659545", "0.7914527", "0.79005694", "0.7887815", "0.7828399", "0.78213745", "0.77782845", "0.777723", "0.77576625", "0.7752954", "0.7751443", "0.77181697", "0.7660339", "0.76011044", "0.7588255", "0.7577671", "0.7528674...
0.7628913
17
Write data to transport.
def send_data(self, data): self._transport.write(data)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def write(self, data, timeout_ms=None, **kwargs):\n raise NotImplementedError(\"implement in derived transport class\")", "def send_message(self, data):\n self.transport.write(data)", "def write(self, data):\n if self.closed:\n raise ConnectionResetError(\n 'Trans...
[ "0.7657331", "0.76417875", "0.76139855", "0.7602521", "0.7583665", "0.75793827", "0.75037515", "0.7470128", "0.74523485", "0.739304", "0.73432237", "0.7279804", "0.7269122", "0.7266278", "0.72515565", "0.72349596", "0.7186108", "0.71751815", "0.7171012", "0.7165056", "0.70937...
0.8111547
0
Pause writing callback from transport.
def pause_writing(self): self._stream.pause_writing()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def resume_writing(self):\n self._stream.resume_writing()", "def _write(self, chunk):\n if self.consumer and not self.stop_event.is_set():\n self.consumer.write(chunk)", "def write(self, data):\n if self.closed:\n raise ConnectionResetError(\n 'Transpor...
[ "0.6722218", "0.6428597", "0.6101962", "0.6073248", "0.60059124", "0.59187335", "0.59112674", "0.5894187", "0.58766466", "0.5876161", "0.5810171", "0.5754038", "0.5754038", "0.57490945", "0.5720258", "0.57075626", "0.5706053", "0.5704085", "0.56786174", "0.56786174", "0.56483...
0.7620428
0
Resume writing callback from transport.
def resume_writing(self): self._stream.resume_writing()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def resume_reading(self):\n raise NotImplementedError", "def resume_reading(self):\n if not self._paused_reading:\n raise RuntimeError('Not paused')\n self._paused_reading = False\n if not self._closing:\n self._loop.add_reader(self._sock_fd)", "def pause_writi...
[ "0.66734207", "0.6322468", "0.6029015", "0.60129535", "0.5927665", "0.5927665", "0.5844039", "0.5816916", "0.5816916", "0.5816916", "0.5802818", "0.57859164", "0.578517", "0.57731336", "0.5732798", "0.5677215", "0.56752896", "0.5654607", "0.5628291", "0.5628291", "0.5628291",...
0.76703745
0
run time code. Always indent under function
def main(): # print 'red string' in red print(crayons.red('red string')) # Red White and Blue text #print('{} white {}'.format(crayons.red('red'), crayons.blue('blue'))) # format string (old ver of str templating) print(f"{crayons.red('red')} white {crayons.blue('blue')}") # f-string (newest vers...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def code():", "def main_code():\n pass", "def sth():", "def smarter():\r\n pass", "def func():", "def my_function1():\n \n ## Your code here\n ## Add comments to clarify what the code is doing", "def main():\n\tpass", "def example():\n print \"\"\"\n \"\"\"", "def example():\n pri...
[ "0.7658427", "0.72334856", "0.64985275", "0.6444914", "0.64356536", "0.64256144", "0.636132", "0.63579184", "0.63579184", "0.6322875", "0.6236482", "0.6220282", "0.62160146", "0.6209243", "0.6209243", "0.6209243", "0.6209243", "0.6209243", "0.6209243", "0.6209243", "0.6209243...
0.0
-1
Report the member's replica set state Submit a service check. Create an event on state change.
def _report_replica_set_state(self, state, clean_server_name, replset_name, agentConfig): last_state = self._last_state_by_server.get(clean_server_name, -1) self._last_state_by_server[clean_server_name] = state if last_state != state and last_state != -1: return self.create_event(las...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def query_member_status():\n notify_member_status()\n logger.info('signal sent for status report')", "def send_event(instance_config, status, output):\n # This function assumes the input is a string like \"mumble.main\"\n monitoring_overrides = instance_config.get_monitoring()\n if 'alert_after' n...
[ "0.6125251", "0.60838777", "0.59746987", "0.544692", "0.54446894", "0.5343415", "0.5315016", "0.5272492", "0.5270251", "0.52520496", "0.52330935", "0.5200511", "0.519126", "0.5157797", "0.51535314", "0.5149566", "0.5147222", "0.51382697", "0.5132011", "0.5124594", "0.5110116"...
0.6736493
0
Return a reasonable hostname for a replset membership event to mention.
def hostname_for_event(self, clean_server_name, agentConfig): uri = urlsplit(clean_server_name) if '@' in uri.netloc: hostname = uri.netloc.split('@')[1].split(':')[0] else: hostname = uri.netloc.split(':')[0] if hostname == 'localhost': hostname = sel...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def hostname(self) -> str:\n _args: list[Arg] = []\n _ctx = self._select(\"hostname\", _args)\n return _ctx.execute_sync(str)", "def get_host_name():\n return socket.gethostname()", "def get_hostname(self):\n return self.name", "def get_hostname(self):\n prompt = self.se...
[ "0.6662921", "0.6660988", "0.6594623", "0.6580937", "0.65463096", "0.65075785", "0.650404", "0.64858186", "0.64726937", "0.64697844", "0.64234984", "0.64135784", "0.6406523", "0.63904727", "0.6379771", "0.63460785", "0.6342044", "0.6332148", "0.63308704", "0.63301355", "0.632...
0.73296475
0
Create an event with a message describing the replication state of a mongo node
def create_event(self, last_state, state, clean_server_name, replset_name, agentConfig): status = self.get_state_description(state) short_status = self.get_state_name(state) last_short_status = self.get_state_name(last_state) hostname = self.hostname_for_event(clean_server_name, agentCo...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def printstatechange(self, event):\n print('printstatechange; event: %s, %s->%s' % (event.event, event.src, event.dst))\n try:\n self.mqttclient.publish(\"{}/{}/events\".format(self.config['MQTT']['TOPICBASE'],\n self.config['CLIENTI...
[ "0.53126144", "0.5274733", "0.5268226", "0.52290887", "0.52170926", "0.5165227", "0.51233536", "0.5103651", "0.50933707", "0.50899076", "0.50673026", "0.4976149", "0.49485195", "0.48921156", "0.48767117", "0.48721194", "0.48523217", "0.4849296", "0.48433527", "0.47988123", "0...
0.61032283
0
Build the metric list to collect based on the instance preferences.
def _build_metric_list_to_collect(self, additional_metrics): metrics_to_collect = {} # Defaut metrics for default_metrics in self.DEFAULT_METRICS.itervalues(): metrics_to_collect.update(default_metrics) # Additional metrics metrics for option in additional_metrics: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_metrics_to_collect(self, instance_key, additional_metrics):\n if instance_key not in self.metrics_to_collect_by_instance:\n self.metrics_to_collect_by_instance[instance_key] = \\\n self._build_metric_list_to_collect(additional_metrics)\n return self.metrics_to_colle...
[ "0.65387714", "0.6310117", "0.62119526", "0.5793617", "0.57547987", "0.57211876", "0.56583136", "0.5615191", "0.55901927", "0.5546556", "0.5533608", "0.5482031", "0.5463035", "0.5445631", "0.5387678", "0.53774405", "0.5351017", "0.53399146", "0.5310214", "0.52838415", "0.5282...
0.6790621
0
Return and cache the list of metrics to collect.
def _get_metrics_to_collect(self, instance_key, additional_metrics): if instance_key not in self.metrics_to_collect_by_instance: self.metrics_to_collect_by_instance[instance_key] = \ self._build_metric_list_to_collect(additional_metrics) return self.metrics_to_collect_by_inst...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def metrics(self):\n self.metrics = []\n \n self.clients()\n\n if len(self.metrics) > 0:\n return self.metrics\n else:\n return []", "def __get_metrics_list(self):\n metrics = metrics_calculator.MetricsCalculator(self.processor)\n metric_list...
[ "0.7655766", "0.72332054", "0.7133441", "0.7121115", "0.70482403", "0.6939825", "0.6939825", "0.69326377", "0.6834937", "0.6780733", "0.67768204", "0.67722744", "0.67699736", "0.67531794", "0.6749277", "0.6653984", "0.66414446", "0.6635117", "0.66295934", "0.6618553", "0.6590...
0.6690178
15
Return the submit method and the metric name to use.
def _resolve_metric(self, original_metric_name, metrics_to_collect, prefix=""): submit_method = metrics_to_collect[original_metric_name][0] \ if isinstance(metrics_to_collect[original_metric_name], tuple) \ else metrics_to_collect[original_metric_name] metric_name = metrics_to_c...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def method(self) -> pulumi.Input[str]:\n return pulumi.get(self, \"method\")", "def metric_name(self) -> pulumi.Input[str]:\n return pulumi.get(self, \"metric_name\")", "def metric_name(self) -> pulumi.Input[str]:\n return pulumi.get(self, \"metric_name\")", "def metric_name(self) -> pul...
[ "0.60242224", "0.5900693", "0.5900693", "0.5900693", "0.5900693", "0.5900693", "0.5900693", "0.5900693", "0.5900693", "0.5900693", "0.5779224", "0.5709764", "0.56761044", "0.5673215", "0.56213224", "0.5533348", "0.550876", "0.54920304", "0.5490709", "0.5478249", "0.5478249", ...
0.6122732
0
Replace casesensitive metric name characters, normalize the metric name, prefix and suffix according to its type.
def _normalize(self, metric_name, submit_method, prefix): metric_prefix = "mongodb." if not prefix else "mongodb.{0}.".format(prefix) metric_suffix = "ps" if submit_method == RATE else "" # Replace case-sensitive metric name characters for pattern, repl in self.CASE_SENSITIVE_METRIC_NAM...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sanitize_metric_name(name: str) -> str:\n name = name.replace(\":\", \"-\")\n return name", "def normalize_label(label: str) -> str:\n label = re.sub(r\"['\\\"`]+\", \"\", label) # remove apostrophes\n label = re.sub(r\"[-/\\\\ \\t_]+\", \" \", label) # normalize separators\n low...
[ "0.6782942", "0.6727968", "0.6660268", "0.65970635", "0.6492408", "0.63663113", "0.63579243", "0.62790793", "0.6254779", "0.6217546", "0.6214412", "0.61892366", "0.6164987", "0.6164987", "0.6164987", "0.60686266", "0.602515", "0.60172975", "0.5997466", "0.59772354", "0.597167...
0.7554459
0
Authenticate to the database.
def _authenticate(self, database, username, password, use_x509, server_name, service_check_tags): authenticated = False try: # X.509 if use_x509: self.log.debug( u"Authenticate `%s` to `%s` using `MONGODB-X509` mechanism", ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def authenticate(self):\n self.connection.authenticate()", "def authenticate(self):\n self.login(closet.app.config['USERNAME'],\n closet.app.config['PASSWORD'])", "def authenticate(self, username, password):\n user = self.db.get_user(username)\n print(user)\n\n ...
[ "0.8034163", "0.7336118", "0.71159965", "0.7013732", "0.68405634", "0.6696718", "0.66948277", "0.6579576", "0.65778863", "0.6499458", "0.6477201", "0.6470728", "0.6464623", "0.6462387", "0.6462387", "0.6457548", "0.6450114", "0.6425771", "0.64103705", "0.6391898", "0.63897616...
0.6341946
23
Collect indexes statistics for all collections in the configuration. This use the "$indexStats" command.
def _collect_indexes_stats(self, instance, db, tags): for coll_name in instance.get('collections', []): try: for stats in db[coll_name].aggregate([{"$indexStats": {}}], cursor={}): idx_tags = tags + [ "name:{0}".format(stats.get('name', 'un...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_index_stats(self):\n #Create Index\n self.run_multi_operations(buckets = self.buckets,\n query_definitions = self.query_definitions,\n create_index = True, drop_index = False)\n #Check Index Stats\n self.sleep(30)\n index_map = self.get_index_stats(...
[ "0.7033326", "0.6837621", "0.66362005", "0.65313584", "0.626018", "0.62069684", "0.6138566", "0.612696", "0.6071093", "0.58983314", "0.58849525", "0.58647007", "0.5845978", "0.58452255", "0.5805989", "0.57855815", "0.577376", "0.5711172", "0.5703516", "0.56850964", "0.5676570...
0.78779423
0
Returns a dictionary that looks a lot like what's sent back by db.serverStatus()
def check(self, instance): def total_seconds(td): """ Returns total seconds of a timedelta in a way that's safe for Python < 2.7 """ if hasattr(td, 'total_seconds'): return td.total_seconds() else: return ( ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_server_status(fields=[]):\n return get_dict_from_db(key='status', fields=fields)", "def status() -> Dict[str, Any]:", "def status(self):\n now = int(time())\n return {\n 'smrt': {\n 'smrt_version': '1.0.0',\n 'app_loaded': True,\n ...
[ "0.80077225", "0.75977504", "0.7279898", "0.7164739", "0.7101741", "0.70730436", "0.69886345", "0.6890773", "0.6871693", "0.6844543", "0.6762656", "0.67537475", "0.67115015", "0.6665098", "0.66358525", "0.66358525", "0.66328067", "0.6618087", "0.6522873", "0.6517588", "0.6512...
0.0
-1
Returns total seconds of a timedelta in a way that's safe for Python < 2.7
def total_seconds(td): if hasattr(td, 'total_seconds'): return td.total_seconds() else: return ( lag.microseconds + (lag.seconds + lag.days * 24 * 3600) * 10**6 ) / 10.0**6
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def total_seconds(delta):\n try:\n return delta.total_seconds()\n except AttributeError:\n return ((delta.days * 24 * 3600) + delta.seconds +\n float(delta.microseconds) / (10 ** 6))", "def total_seconds(td):\n return (td.microseconds + (td.seconds + td.days * 24 * 3600) * 1...
[ "0.78919387", "0.78847253", "0.783023", "0.78134507", "0.76809853", "0.7531021", "0.7426013", "0.73222214", "0.7240662", "0.72142905", "0.705758", "0.70381075", "0.6971049", "0.69674176", "0.69023997", "0.6851663", "0.68447584", "0.6843502", "0.6830019", "0.6829389", "0.68122...
0.74855494
6
Test case for upload_area
def test_upload_area(self): area = areamsg query_string = [('deliveryAckEndPoint', 'https://localhost:8002')] response = self.client.open('/area', method='POST', data=area, query_string=qu...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_multi_area(self):\n pass", "def test_upload_file(self):\n pass", "def test_upload_file1(self):\n pass", "def test_upload_job_description_file_post(self):\n pass", "def test_upload(self):\n with self.client:\n file = dict(\n file=(BytesIO...
[ "0.68717897", "0.67497677", "0.64811105", "0.6158702", "0.61027944", "0.60922873", "0.59541386", "0.59376353", "0.5898766", "0.5843938", "0.58039546", "0.5802995", "0.5782079", "0.5776933", "0.5713552", "0.56940377", "0.5679234", "0.5669817", "0.56505054", "0.56200916", "0.56...
0.67986137
1
Test case for upload_area cleanup
def test_upload_area_cleanup(self): vis2_uvid='urn:mrn:stm:service:instance:furuno:vis2' p = Path('import') files = list(p.glob('**/urn:mrn:s124:*')) for item in files: print(item) os.remove(str(item)) pass
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_final_cleanup():\n cleanup_file(\"tfsaves\")", "def tearDown(self):\n self.tmp.cleanup()", "def cleanup():", "def _cleanup(self):\n pass", "def test_cleanup(self):\n imgurl = \"{}spei03.nc\".format(self.processor.base_url)\n httpretty.register_uri(httpretty.GET, imgurl,\...
[ "0.6206157", "0.6140681", "0.6071183", "0.6062651", "0.6050911", "0.6030279", "0.6009838", "0.6004148", "0.6004148", "0.6004148", "0.6001869", "0.5971952", "0.5948387", "0.59369427", "0.59284383", "0.5869602", "0.5861927", "0.5838485", "0.5838485", "0.5813883", "0.5788908", ...
0.6698037
0
Takes in a trajectory file and uploads it to the database
def upload_trajectory(cls, trajectory_file): # extract the attributes from the file name pitch, roll, u0 = cls.extract_pitch_roll_velocity( trajectory_file) # get or create a database object with those attributes trajectory, created = SolvedTrajectory.objects.get_or_create(...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def save_trajectory(trajectory):\n query = \"INSERT INTO trajectories (idUser, startTime, endTime) VALUES (%(id_user)s, %(start_time)s, %(end_time)s)\"\n\n trajectory_data = {\n 'id_user': trajectory.id_user,\n 'start_time': trajectory.start_time,\n 'end_time': trajectory.end_time\n }...
[ "0.67590135", "0.6199504", "0.60810244", "0.5968449", "0.5886125", "0.5864965", "0.58335364", "0.5823321", "0.58050644", "0.5799841", "0.57324755", "0.57312024", "0.57259333", "0.57164156", "0.5702718", "0.569988", "0.5675204", "0.5665265", "0.5634949", "0.5631133", "0.563033...
0.7878746
0
Iterates through every trajectory that has been solved for and then uploads the trajectory that has been solved for
def sync_dir(self): # mark the trajectories that we have seen trajectories = os.listdir(self.trajectory_dir) for trajectory_file in trajectories: if trajectory_file not in self.seen_trajectories: created = self.upload_trajectory(trajectory_file) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def build(self, trajectory):\n #TODO Implement?", "def build(self, trajectory):\n pass", "def compute_trajectory():\n pass", "def _insertAllSteps(self): \n self.uMics = self.inputCoordinatesTiltedPairs.get().getUntilted().getMicrographs()\n self.tMics = self.inputCoordina...
[ "0.59522563", "0.59471226", "0.5912256", "0.5899517", "0.5856624", "0.5813247", "0.57508117", "0.57315934", "0.5581307", "0.55410546", "0.5502698", "0.54654527", "0.5458855", "0.53929365", "0.53702384", "0.5347481", "0.5322975", "0.53141", "0.52880365", "0.5242809", "0.524104...
0.6943155
0
returns a list of classes and titles, parsing through 'html'
def get_classes(html): # elements = html.find_all("span", "code") # titles = html.find_all("span", "title") # classes = [] # for i in range(len(elements)): # item = elements[i] # tit = titles[i] # classes += [(item.text.replace('\xa0', ' '), tit.text.replace('\xa0', ' '))] # ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def EnrolledClasses(self,html): \n classes = []\n soup = BeautifulSoup(html)\n for element in soup.find_all(\"input\"):\n if element[\"name\"] == \"TITLE\" and element[\"value\"]:\n classes.append(element.get(\"value\"))\n return classes", "def extract_all_tags(final_link, driver):\n\n ...
[ "0.8052008", "0.6688938", "0.6265724", "0.6265724", "0.61887735", "0.6152137", "0.60088265", "0.5969638", "0.5957513", "0.59506553", "0.59392065", "0.59321856", "0.5919949", "0.5894865", "0.5883525", "0.5863221", "0.5795686", "0.5791473", "0.57911634", "0.5790925", "0.5789725...
0.80175537
1
Download master cdf file from cdaweb for 'dataset'
def _download_metafile(dataset, path=None): if not path: path = sunpy.config.get('downloads', 'sample_dir') base_url = 'https://spdf.gsfc.nasa.gov/pub/software/cdawlib/0MASTERS/' fname = dataset.lower() + '_00000000_v01.cdf' url = base_url + fname try: downloaded_file = pooch.retriev...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def downloadFile()-> None:\n logging.info(f\"Downloading current data set {getTime()}\")\n with open(DATA_FILE,\"wb\") as f:\n f.write(get(\"https://covid.ourworldindata.org/data/owid-covid-data.csv\").text.encode())\n logging.info(f\"Finished Downloading current data set {getTime()}\")", "def do...
[ "0.6694223", "0.6588644", "0.65666646", "0.65666646", "0.6565688", "0.64363176", "0.64334583", "0.6366243", "0.63625884", "0.63276845", "0.6297841", "0.6201097", "0.61550426", "0.61423147", "0.61154634", "0.6100518", "0.6091457", "0.60131127", "0.5990933", "0.5977136", "0.591...
0.71092033
0
Downloads Wind/3DP CDF files via SunPy/Fido from CDAWeb
def wind3dp_download_fido(dataset, startdate, enddate, path=None, max_conn=5): trange = a.Time(startdate, enddate) cda_dataset = a.cdaweb.Dataset(dataset) try: result = Fido.search(trange, cda_dataset) filelist = [i[0].split('/')[-1] for i in result.show('URL')[0]] filelist.sort() ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def download_engine(fcsd): #fcsd = first comic strip date\n\n url_list = get_comic_strip_url(fcsd)\n\n for url in url_list:\n session = requests.Session()\n response = session.get(url)\n download_url = get_image_comic_url(session, response)\n# download_dilbert(session, download_ur...
[ "0.6992597", "0.6586604", "0.6586604", "0.62284845", "0.62214994", "0.6183709", "0.6142462", "0.61349034", "0.60533696", "0.6041575", "0.6032721", "0.601811", "0.5998015", "0.5983272", "0.59466475", "0.5895252", "0.5893261", "0.5883837", "0.58763474", "0.58670187", "0.5820259...
0.6681552
1
Download a single Wind/3DP level 2 data file from SRL Berkeley to local path
def wind3dp_single_download(file, path=None): # add a OS-specific '/' to end end of 'path' if path: if not path[-1] == os.sep: path = f'{path}{os.sep}' else: path = sunpy.config.get('downloads', 'download_dir') + os.sep data = file.split('_')[1] # e.g. 'sfsp' year = fi...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def download_hess_dr1_data():\n download_data_files(FILENAMES_HESS_DR1)", "def download():\r\n reader = GSODDataReader()\r\n year_list = range(2001, 2012)\r\n austin = reader.collect_data(year_list, exact_station=True,\r\n station_name='AUSTIN CAMP MABRY', state='TX', country='US')\r\n hous...
[ "0.67398626", "0.6583231", "0.6520613", "0.6331625", "0.6304204", "0.6291874", "0.6226741", "0.62254614", "0.62199074", "0.61869997", "0.60891455", "0.60750973", "0.6024186", "0.60179967", "0.60074246", "0.5984744", "0.59611046", "0.5960039", "0.5954429", "0.5950052", "0.5932...
0.69402546
0
Downloads Wind/3DP CDF files via SunPy/Fido from CDAWeb
def wind3dp_download(dataset, startdate, enddate, path=None, **kwargs): trange = a.Time(startdate, enddate) cda_dataset = a.cdaweb.Dataset(dataset) try: result = Fido.search(trange, cda_dataset) filelist = [i[0].split('/')[-1] for i in result.show('URL')[0]] filelist.sort() ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def download_engine(fcsd): #fcsd = first comic strip date\n\n url_list = get_comic_strip_url(fcsd)\n\n for url in url_list:\n session = requests.Session()\n response = session.get(url)\n download_url = get_image_comic_url(session, response)\n# download_dilbert(session, download_ur...
[ "0.69927144", "0.6681631", "0.6586002", "0.6586002", "0.6227894", "0.6220564", "0.6184514", "0.61419713", "0.6135068", "0.60416824", "0.60323346", "0.6019162", "0.59976286", "0.5984312", "0.59463805", "0.58946854", "0.589323", "0.5883891", "0.5876614", "0.5867642", "0.5821249...
0.60538065
9
Loadin data for Wind/3DP instrument. Provides released data obtained by SunPy through CDF files from CDAWeb. Returns data as Pandas dataframe.
def wind3dp_load(dataset, startdate, enddate, resample="1min", multi_index=True, path=None, threshold=None, **kwargs): files = wind3dp_download(dataset, startdate, enddate, path) if len(files) > 0: df = _wind3dp_load(files, resample, threshold) # download master file from CDAWe...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _read_cdf_wind3dp(fname, ignore_vars=[]):\n import astropy.units as u\n from cdflib.epochs import CDFepoch\n from packaging.version import Version\n from sunpy import log\n from sunpy.timeseries import GenericTimeSeries\n from sunpy.util.exceptions import warn_user\n cdf = cdflib.CDF(str(f...
[ "0.6468716", "0.64177483", "0.63601965", "0.6326345", "0.6200869", "0.6196842", "0.6185922", "0.6155612", "0.6130087", "0.6104664", "0.6011164", "0.60078377", "0.6003299", "0.59791", "0.59743065", "0.5966459", "0.596409", "0.5956343", "0.59252155", "0.59170336", "0.5893538", ...
0.6185055
7
Read a CDF file that follows the ISTP/IACG guidelines.
def _read_cdf_wind3dp(fname, ignore_vars=[]): import astropy.units as u from cdflib.epochs import CDFepoch from packaging.version import Version from sunpy import log from sunpy.timeseries import GenericTimeSeries from sunpy.util.exceptions import warn_user cdf = cdflib.CDF(str(fname)) #...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read_dicom_file(fname):\n fo = open(fname)\n try:\n preamble = fo.read(128)\n magic = fo.read(4)\n if len(preamble) != 128 or magic != 'DICM':\n raise InvalidDicomError\n fo.seek(0)\n do = dicom.read_file(fo)\n finally:\n fo.close()\n return do",...
[ "0.60510045", "0.604307", "0.5898858", "0.5860045", "0.5791958", "0.5680922", "0.5642261", "0.5582769", "0.5567393", "0.5543166", "0.5474913", "0.54198694", "0.54080296", "0.53842884", "0.5370347", "0.53613174", "0.53224874", "0.5320849", "0.53164923", "0.53088623", "0.530528...
0.0
-1
Get the indices of words where all keywords occur most closely together Takes one keyword, and performs binary search for each index of that keyword for other keywords. Absolute distance is added, result is sorted and top `K` are extracted
def get_closest(occurences, content, k=25): result = [] o = occurences[0] #get first for idx in o: res = 0 for i in range(1, len(occurences)): #other than first oo = occurences[i] where = bisect_left(oo, idx) #try both, after and before the binary searched...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def top_k(indices, words, k):\n inds = np.argpartition(indices, -k)[-k:]\n topkwords = words[inds]\n topkvals = indices[inds]\n top = [(word, val) for word, val in zip(topkwords, topkvals)]\n top = sorted(top, key=lambda t: t[1], reverse=True)\n return top", "def topKSimilar(self,word,k = 5,max...
[ "0.70105875", "0.69487935", "0.6726304", "0.6642951", "0.6558925", "0.6321629", "0.6267497", "0.6247251", "0.62325543", "0.6175135", "0.6156061", "0.60509574", "0.60417193", "0.6032859", "0.6018945", "0.5914206", "0.58785915", "0.58734584", "0.58478695", "0.5831793", "0.58169...
0.6156018
11
Find all occurences of a keyword progressively, until it isn't present anymore
def get_all_occurences(s, word): res = [0] print("Searching for " + word) while True: try: idx = s.index(word, res[-1]) res.append(idx+1) #print("found at ", idx) except ValueError: break return res[1:]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fetchRelatedkeywords(self, keyword, meta_keyword):\n prefix = [\"how\", \"which\", \"why\", \"where\", \"who\", \"when\", \"are\", \"what\"]\n suffix = [\"\", \"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\",\n \"m\", \"n\", \"o\", \"p\", \"q\", ...
[ "0.5892223", "0.56149435", "0.5609027", "0.5558268", "0.5548612", "0.54912615", "0.54362696", "0.54015934", "0.53735536", "0.53658015", "0.53658015", "0.5305467", "0.5299855", "0.5296011", "0.5276156", "0.52694416", "0.5258406", "0.52114064", "0.52089685", "0.5205524", "0.517...
0.5443021
6
Returns the current state of the gameboard and the two player's colors. Returns np.ndarray a flat 1D representation of the gameboard appended by the two players' colors
def get_state(self): return np.append(self.game.game_board.get_board(), [self.game.player_1.color, self.game.player_2.color])[None, :]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_current_game_state(board):\n return np.concatenate((_get_pieces_one_hot(board, color=False),\n _get_pieces_one_hot(board, color=True)),\n axis=-1)", "def return_state(board):\r\n state = np.array(INIT_ARRAY)\r\n for pos in BOARD_POSITIO...
[ "0.6973377", "0.6708354", "0.6522196", "0.651381", "0.651381", "0.6499365", "0.6218236", "0.6212448", "0.6204406", "0.61157256", "0.6032963", "0.60149604", "0.6009506", "0.59559596", "0.5954081", "0.5951532", "0.58624077", "0.58483106", "0.58110374", "0.57483196", "0.5746821"...
0.8583118
0
Performs the specified action in the environment and returns the observation, \ reward, and if the game is over.
def step(self, action): self.game.play_single_turn([action]) next_obs = self.get_state() reward = self.game.player_1.score - self.game.turn_count done = self.game.check_for_end_of_game() or self.game.turn_count > 25 if done: if self.game.player_1.score > self.game.pl...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def perform_action(self, action):\n \n assert self.is_valid_action(action)\n \n # Save the action.\n self.action = action\n \n #the slight strategy of the opponent\n if self.reward==rLose :\n observation = self.observation\n else:\n ...
[ "0.7654873", "0.75809324", "0.73705", "0.7285594", "0.7201223", "0.710793", "0.7067227", "0.70066214", "0.6996156", "0.69719476", "0.6938891", "0.69306713", "0.6914033", "0.6892272", "0.6873118", "0.68673706", "0.68626064", "0.68542176", "0.685064", "0.6846933", "0.68432224",...
0.0
-1
Returns the possible color options that can be played. Returns list a list of the possible color options (as integers)
def get_color_options(self): mask = (self.all_colors != self.player_1.color) & (self.all_colors != self.player_2.color) return self.all_colors[mask]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_player_colors() -> List[Tuple[float, float, float]]:\n return PLAYER_COLORS", "def supported_color_modes(self) -> set[str] | None:\n color_modes = [COLOR_MODE_ONOFF]\n if self.dp_code_bright in self.tuya_device.status:\n color_modes.append(COLOR_MODE_BRIGHTNESS)\n\n if ...
[ "0.70465565", "0.65711427", "0.6478505", "0.64456594", "0.6323879", "0.62680316", "0.61799985", "0.6158194", "0.61572695", "0.61044914", "0.6100955", "0.60627854", "0.60627854", "0.60460067", "0.60313606", "0.59857523", "0.59533656", "0.5913804", "0.5863346", "0.58114314", "0...
0.75890493
0
Checks if the game is over. The game is over if the players' scores are greater than the number of cells. Returns bool True if the game is over, False otherwise
def check_for_end_of_game(self): return self.player_1.score + self.player_2.score >= self.number_of_cells
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def game_over(self) -> bool:\n for row in range(9):\n for col in range(9):\n if self._grid_sol[row][col] != self.get_cell(row, col):\n return False\n return True", "def _check_game_over(self):\n return self.game_board.check_game_over()", "def is...
[ "0.8031195", "0.79091746", "0.78659517", "0.783071", "0.77987564", "0.7613732", "0.7612134", "0.7563146", "0.7546135", "0.75450456", "0.75265986", "0.7522862", "0.7521878", "0.7511197", "0.75016576", "0.74913526", "0.7444311", "0.7433588", "0.7423347", "0.7408691", "0.7385972...
0.77203864
5
Completes a single turn by showing the gameboard, playing each of the players' turns, and printing the result. The former and latter are only done if the game type is RL.
def play_single_turn(self, action=None): self.turn_count += 1 if self.save_images_suffix: self.game_board.graphical_output(save=True, display=False, image_suffix=f'{self.save_images_suffix}_{self.turn_count}') if self.game_type == self.gam...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def finishTurn(self):\n print \"go\"\n sys.stdout.flush()", "def play(self, turn):\n # global black_prompt, white_prompt, res, pi, board\n if turn % 2 == 0:\n prompt, requests_add, responses_add, color_to_play = self.bp, self.bp, self.wp, BLACK\n print(\"pure\")\...
[ "0.688064", "0.66935813", "0.6467623", "0.64412105", "0.6440219", "0.6420127", "0.63784677", "0.6366233", "0.635333", "0.62903583", "0.62639993", "0.62625086", "0.6251562", "0.6237911", "0.6230091", "0.6221477", "0.62081194", "0.6202306", "0.616118", "0.6145242", "0.6123327",...
0.67183626
1
Completes the entire game by playing turns until the game is over and then prints the result.
def play_game(self, early_finish=False): automated = self.game_type == self.game_types['vs_ai'] while not (self.check_for_end_of_game() or (early_finish and self.check_for_early_finish())): self.play_single_turn() if automated: input('Press any key to continue.\n'...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def finishTurn(self):\n print \"go\"\n sys.stdout.flush()", "def _do_outputs(self):\n self._puzzle.display_revealed_puzzle()\n hint = self._puzzle.get_hint()\n self._console.write(hint)\n print(\"\")\n self._jumper.draw_jumper()\n print(\"\")\n\n # T...
[ "0.7868776", "0.722649", "0.68513465", "0.6713279", "0.67080253", "0.66717774", "0.6625295", "0.6593353", "0.6520406", "0.65030307", "0.6463218", "0.6455685", "0.6454045", "0.6443304", "0.6435754", "0.6430937", "0.6429039", "0.6426349", "0.63851017", "0.6380919", "0.6375855",...
0.0
-1
Outputs the gameboard as text.
def text_output(self): print(self.board) print()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def display_board(self):\n print(self.game_board)", "def render_board(self):\n print \"\"\n for row in self._board:\n print row", "def draw(self):\n res = ''\n # ANSI code to clear the screen\n #res += chr(27) + \"[2J\"\n for position, value in enumer...
[ "0.76990277", "0.7684276", "0.7571131", "0.75571936", "0.75506896", "0.75325507", "0.7497205", "0.7475444", "0.74271286", "0.7372031", "0.7361939", "0.73593736", "0.7353311", "0.73500687", "0.7348999", "0.7339537", "0.73229283", "0.73167104", "0.7309406", "0.7297968", "0.7288...
0.8650465
0
Outputs the gameboard in a MatPlotLib window that is updated everytime this function is called. The 2D numpy array is converted to colors using the COLORS dictionary and then repeated to create an image.
def graphical_output(self, block=False, save=False, display=True, folder_name='output', image_suffix=None): masks = [np.where(self.board == i, True, False) for i in range(self.number_of_colors)] output = np.zeros((self.height, self.width, 3), dtype=np.int) for mask, color in zip(masks, list(COLO...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def visualize_board():\n count = 0\n cars = {}\n cmap = colors.ListedColormap(['white','purple', 'brown', 'red', 'pink', 'black', 'beige', 'yellow', 'turquoise', 'coral', 'grey', 'navy', 'indigo', 'cyan', 'olive', 'maroon', 'silver', 'lime', 'teal', 'tan', 'aquamarine', 'violet', 'magenta', 'chartreuse', ...
[ "0.7340595", "0.6782643", "0.6562929", "0.6523237", "0.64797074", "0.6475668", "0.6462612", "0.6370303", "0.6243013", "0.62422794", "0.6232159", "0.6221264", "0.62133884", "0.6183281", "0.61543", "0.61533546", "0.6152027", "0.61465985", "0.6143385", "0.6136374", "0.61292225",...
0.66855747
2
Gets the color at the specified coordinates on the gameboard.
def get_color(self, coord): return self.board[coord[0], coord[1]]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_color(self, _pos):\n return self.__framebuffer[_pos]", "def _get_color(self, r, g, b):\n clr = (r, g, b)\n return clr", "def get_colour(self, x, y):\n if x >= self.width or y >= self.height:\n return (0, 0, 0)\n\n return self.env_img.get_at((int(x), int(y))...
[ "0.6995972", "0.67755926", "0.6742886", "0.6678613", "0.66424483", "0.6595865", "0.65444714", "0.6500604", "0.6482022", "0.64749384", "0.64731526", "0.6466952", "0.6460171", "0.6415692", "0.6340766", "0.6315026", "0.63021356", "0.6299288", "0.62905073", "0.62475747", "0.62238...
0.81525886
0
Sets the color at the specified cells on the gameboard.
def set_color(self, color, filled): for cell in filled: self.board[cell[0], cell[1]] = color
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def change_color(board, tile, color):\n for el in tile:\n el_x = el[0]\n el_y = el[1]\n board[el_x,el_y] = color", "def set(self, row: int, col: int, color: Color) -> None:\n super(ColorGrid, self).set(row, col, color)", "def change_cell_bgcolor(self, cell: tuple, color: str = \"...
[ "0.66752845", "0.6670882", "0.6661175", "0.6591124", "0.6471529", "0.6251041", "0.61291766", "0.61236733", "0.61236733", "0.60985804", "0.60878223", "0.60815275", "0.60369647", "0.6032888", "0.6024978", "0.60133576", "0.60054994", "0.59898573", "0.5964465", "0.59419614", "0.5...
0.7248661
0
Checks if the new cell has the same color. If so, then it will be added to filled_edges.
def check_if_filled(self, new_cell, cell_color, filled_edges, filled_surrounded): new_cell_color = self.get_color(new_cell) if new_cell_color != cell_color: return False if new_cell not in filled_edges + filled_surrounded: filled_edges.append(new_cell) return Tr...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_filled(self, filled_edges, filled_surrounded):\n surrounded_cells = []\n for cell in filled_edges:\n coord_x = cell[1]\n coord_y = cell[0]\n color = self.get_color(cell)\n surrounded = True\n\n # up\n if coord_y - 1 >= 0:\n ...
[ "0.68136656", "0.6298156", "0.62293226", "0.61843455", "0.60629505", "0.6019774", "0.5996726", "0.59899193", "0.59833056", "0.59146136", "0.58846736", "0.58377993", "0.57722366", "0.5716285", "0.5706663", "0.56588453", "0.5620642", "0.5616831", "0.56144696", "0.56116164", "0....
0.8191558
0
Updates the list of cells that belong to the player. The edge cells will be checked to see if adjoining cells have the same color. If a cell is surrounded by the same color, then it will be moved to the surrounded cells list and not be checked further.
def update_filled(self, filled_edges, filled_surrounded): surrounded_cells = [] for cell in filled_edges: coord_x = cell[1] coord_y = cell[0] color = self.get_color(cell) surrounded = True # up if coord_y - 1 >= 0: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update(self):\n for player in self.players:\n player.update()\n player.last_seen = player.current_cell\n\n self.in_cell()\n for player in self.players:\n if player.current_cell != player.last_seen:\n self.player_paths.add(player.last_seen)\n ...
[ "0.72930026", "0.68095976", "0.6565382", "0.63855034", "0.623758", "0.6231316", "0.62005574", "0.615561", "0.61323214", "0.6109885", "0.6100814", "0.6096795", "0.6084608", "0.60593855", "0.59803164", "0.59193355", "0.5863843", "0.58529425", "0.5852107", "0.58215886", "0.57433...
0.6750988
2
Counts the number of adjacent cells of the specified color.
def get_color_count(self, color, filled): count = 0 for cell in filled: coord_x = cell[1] coord_y = cell[0] # up if coord_y - 1 >= 0: new_cell = (coord_y-1, coord_x) cell_up_color = self.get_color(new_cell) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def count_colors(board, color):\n n = 0\n for cell in board:\n if cell == color:\n n += 1\n elif cell == cinv(color):\n n -= 1\n return n", "def countDiff(self, color):\n count = 0\n for y in range(self.n):\n for x in range(self.n):\n ...
[ "0.7808628", "0.7358172", "0.7177182", "0.6915037", "0.6702927", "0.66539484", "0.634662", "0.6150625", "0.60990244", "0.6096208", "0.6083482", "0.59975606", "0.5963964", "0.59438294", "0.5927667", "0.5881134", "0.58247036", "0.58202237", "0.5811849", "0.5797079", "0.57578915...
0.74115384
1
Flattens the gameboard and returns it as a 1D array. Returns np.ndarray a flat 1D representation of the gameboard
def get_board(self): return self.board.copy()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def flatten_numpy(ndarray):\n return np.reshape(ndarray, (-1,), 'F')", "def flatten_rows(self, arr: np.array) -> torch.Tensor:\n snake_ = []\n k = 1\n for row in arr:\n snake_ += list(row[::k])\n k *= -1\n return torch.tensor(snake_).unsqueeze(-1)", ...
[ "0.62531096", "0.61981404", "0.61488134", "0.6146238", "0.6139373", "0.61236525", "0.61006224", "0.605742", "0.6032158", "0.58906454", "0.58046883", "0.57959795", "0.57739055", "0.5723731", "0.57159185", "0.56728446", "0.5669656", "0.5646378", "0.5644627", "0.5641197", "0.563...
0.0
-1
Trace decorator for use with recursive functions.
def trace(f): indent = ' ' def _f(*args): signature = '%s(%s)' % (f.__name__, ', '.join(map(repr, args))) print '%s--> %s' % (trace.level*indent, signature) trace.level += 1 try: result = f(*args) print '%s<-- %s == %s' % ((trace.level-1)*indent, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def trace(func):\n @wraps(func)\n def tracer(*args, **kwargs):\n name = func.__name__\n stack_size = int(len(inspect.stack(0)) / 2) # @wraps(func) is also increasing the size\n indent = stack_size*'\\t'\n print(f'{indent} > Entering \"{name}\": args: {args}')\n result = fu...
[ "0.7315188", "0.7188264", "0.70268303", "0.688243", "0.688243", "0.6847975", "0.68394035", "0.6646007", "0.63865286", "0.6358532", "0.6295772", "0.6160866", "0.60975045", "0.60519403", "0.59872144", "0.59862864", "0.5976006", "0.5974944", "0.59432507", "0.5927856", "0.5881031...
0.66391844
8
Once proper file has been found, get it.
def download_it(fw, acquisition, file_name, input_path): safe = make_file_name_safe(file_name, replace_str='_') full_path = input_path + safe if acquisition.timestamp: if acquisition.timezone: created = acquisition.original_timestamp.isoformat() else: created = acq...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get(name):\n\n filename = find(name)\n if filename == None:\n return name\n return open(filename).read()", "def _fs_get_file(url, working_dir):\n if not os.path.isabs(url) and working_dir:\n url = os.path.join(working_dir, url)\n\n try:\n with codecs.open(u...
[ "0.7244406", "0.7236674", "0.709632", "0.7088684", "0.68636674", "0.6847282", "0.6831245", "0.6783735", "0.67528933", "0.671292", "0.6656482", "0.6624175", "0.6588251", "0.65659696", "0.6486953", "0.64499605", "0.64499605", "0.64179486", "0.6409363", "0.6396551", "0.63920933"...
0.0
-1
Find apropriate files for the subject and download them Search through all files for all acquisitions for all sessions for this subject and download only the T1 nifti files. If file names are repeated a number is prepended. Troublesome characters in the file name are replaced with "_". The file's original name, full pa...
def find_and_download_files(context): input_path = 'input/' if os.path.isdir(input_path): log.debug('Path already exists: ' + input_path) else: log.debug('Creating: ' + input_path) os.mkdir(input_path) fw = context.client if 'classification_measurement' in context.config:...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def download_subject(self, subject_ID):\r\n hcp_data_path = os.path.join(self.hcp_directory, str(subject_ID))\r\n\r\n if not os.path.exists(hcp_data_path):\r\n os.makedirs(hcp_data_path)\r\n\r\n print('Downloading data to {}'.format(hcp_data_path))\r\n\r\n counter = 0\r\n ...
[ "0.6075932", "0.5923535", "0.58468294", "0.5837011", "0.57766956", "0.5741573", "0.5726924", "0.5726823", "0.56845653", "0.56502473", "0.556752", "0.55647373", "0.5562809", "0.55589074", "0.5542313", "0.55303603", "0.5507099", "0.54877055", "0.54732233", "0.5440725", "0.54362...
0.64693093
0
Set destination's 'info' to indicate what's happening
def update_gear_status(key, value): fw = context.client dest_container = fw.get(context.destination['id']) kwargs = {key: value} dest_container.update_info(kwargs) log.info(repr(kwargs))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def info(self, info: str):\n\n self._info = info", "def info(self, info):\n\n self._info = info", "def log_info(self, obj, message):\n super().log_info(obj=obj, message=message)", "def set_info(self, msg):\n logger.debug(\"Setting info: %s\", msg)\n self.vars[\"info\"].set(...
[ "0.6143804", "0.61416364", "0.61075276", "0.6027803", "0.60268867", "0.6010292", "0.59295946", "0.589257", "0.5882718", "0.5719608", "0.5704234", "0.5674577", "0.56674504", "0.56561124", "0.5644978", "0.56406033", "0.56371397", "0.5615866", "0.5614427", "0.5540901", "0.553031...
0.0
-1
Set final status to last line of reconallstatus.log.
def set_recon_all_status(subject_dir): path = context.gear_dict['output_analysisid_dir'] + '/' + \ subject_dir + '/scripts/recon-all-status.log' if os.path.exists(path): with open(path, 'r') as fh: for line in fh: pass last_line = line else: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def final_status(self, final_status):\n\n self._final_status = final_status", "def after_epoch(self):\n line = ' '.join([str(k) + ': ' + str(v) for k, v in self.trainer.status.items()])\n with open(os.path.join(self.root_path, 'log.txt'), 'a+') as fout:\n fout.write(line + '\\n')...
[ "0.6525308", "0.63573575", "0.61293614", "0.5867392", "0.58495337", "0.5713314", "0.56992143", "0.5678644", "0.5619614", "0.5558952", "0.5548329", "0.55442154", "0.54692274", "0.54651254", "0.5439889", "0.54174083", "0.53965306", "0.5389551", "0.53609776", "0.53462833", "0.53...
0.71194637
0
Set destination's 'info' to indicate what's happening
def update_gear_status(key, value): fw = context.client dest_container = fw.get(context.destination['id']) kwargs = {key: value} dest_container.update_info(kwargs) log.info(repr(kwargs))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def info(self, info: str):\n\n self._info = info", "def info(self, info):\n\n self._info = info", "def log_info(self, obj, message):\n super().log_info(obj=obj, message=message)", "def info(self, msg, *args, **kwargs):\n pass", "def set_info(self, msg):\n logger.debug(\"S...
[ "0.61399955", "0.6138113", "0.6105326", "0.60246885", "0.60241956", "0.6006875", "0.5932573", "0.5896946", "0.58830565", "0.57182986", "0.5707436", "0.56726485", "0.56645304", "0.56543434", "0.5644393", "0.5642732", "0.5640949", "0.56155336", "0.5612505", "0.55384743", "0.552...
0.0
-1
Set final status to last line of reconallstatus.log.
def set_recon_all_status(subject_dir): path = context.gear_dict['output_analysisid_dir'] + '/' + \ subject_dir + '/scripts/recon-all-status.log' if os.path.exists(path): with open(path, 'r') as fh: for line in fh: pass last_line = line else: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def final_status(self, final_status):\n\n self._final_status = final_status", "def after_epoch(self):\n line = ' '.join([str(k) + ': ' + str(v) for k, v in self.trainer.status.items()])\n with open(os.path.join(self.root_path, 'log.txt'), 'a+') as fout:\n fout.write(line + '\\n')...
[ "0.65249884", "0.6357503", "0.61292785", "0.58676416", "0.5849602", "0.57127684", "0.56986594", "0.56790066", "0.56193364", "0.55592257", "0.5547861", "0.5544232", "0.54690313", "0.5465183", "0.543945", "0.54176474", "0.53966546", "0.5389639", "0.5360609", "0.5345862", "0.533...
0.71203095
1
Download scans to run on
def set_up_data(context, log): try: if context.gear_dict['run_level'] == 'project': msg = 'This gear must be run at the subject, '+\ 'not project level' context.gear_dict['errors'].append(msg) raise Exception(msg) elif context.gear_dic...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run(self):\n download(self.attempt)", "def download_files(self):", "def download():\n raise NotImplementedError", "def download(self):\n pass", "def download(self):\n pass", "def download(all):\n print(\"Downloading\")", "def download():\n try:\n cli.run(\n ...
[ "0.68915814", "0.68358505", "0.65526867", "0.6551495", "0.6551495", "0.64888924", "0.6438649", "0.6431932", "0.6431932", "0.6384153", "0.631998", "0.62750447", "0.6221688", "0.6210655", "0.6185226", "0.6155247", "0.61521363", "0.6148834", "0.6130831", "0.6113376", "0.6106293"...
0.0
-1
Check if the given value is "close enough" to the desired value Because sometimes MagneticFieldStrength can be provide in mT (3000, 1500) or something like 2.9721T
def field_strength_close_enough(field_strength, desired_value): if field_strength > 100: # assume it is in mT instead of Teslas field_strength /= 1000 # and turn it into Teslas diff = abs(field_strength - desired_value) if diff < 0.2: return True else: return False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def above_threshold(self, value):\n # We use floating point number here so we have to take care\n return finf(value,self.min) or finf(self.max,value)", "def check_value(value, sensor):\n if not GraphModel.check_if_int(value):\n return False\n\n return (sensor == 't' and ba....
[ "0.6649637", "0.6314969", "0.6307575", "0.6263273", "0.621036", "0.61276513", "0.61120135", "0.60805684", "0.6008309", "0.59797776", "0.59608775", "0.59385926", "0.59351903", "0.5876801", "0.5854414", "0.5851238", "0.58508086", "0.58508086", "0.58364314", "0.58322096", "0.582...
0.788576
0
Run the Freesurfer Longitudinal Pipeline
def execute(context, log): try: # Don't run if there were errors or if this is a dry run ok_to_run = True dry = False ret = [] # return codes from all runs return_code = 1 # assume the worst if len(context.gear_dict['errors']) > 0: ok_to_run = False ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run(mu_v, Sigma_w, Sigma_z, a_mu, l_sensor):\n N = 1000\n # Init tracking\n mu_x = np.zeros(N) # Belief or estimation of hidden state \n F = np.zeros(N) # Free Energy of AI neuron\n mu_y = np.zeros(N) # Belief or prediction of sensory signal \n x = np.zeros(N) # True hidden state\n y = np....
[ "0.57218367", "0.5423614", "0.53331274", "0.527583", "0.5265408", "0.5264002", "0.5260391", "0.52263385", "0.5207814", "0.52057993", "0.5197902", "0.5194441", "0.5166975", "0.5135886", "0.5120619", "0.51003754", "0.508593", "0.50717276", "0.506908", "0.50658154", "0.5045627",...
0.0
-1
Powers or unpowers the bells.
def power_bells(state): if not pinlessMode: if state: for pin in bellPins: GPIO.output(pin, GPIO.HIGH) elif not state: for pin in bellPins: GPIO.output(pin, GPIO.LOW) else: logging.debug("Bell state: " + str(state))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def handlePowers(self):\n self.player.sprite.handlePowers(self.get_remaining_time())", "def poweroff(self) -> None:\n pass", "def poweroff(self):\n raise NotImplementedError()", "def set_powers(self, power_1, power_2):\n pass", "def power_off(self):\n raise NotImplemented...
[ "0.64014935", "0.6041298", "0.5899135", "0.5873446", "0.58522767", "0.5775622", "0.5713468", "0.5671503", "0.5662006", "0.56604326", "0.56582326", "0.5653668", "0.56442696", "0.5575584", "0.5575584", "0.55735165", "0.55625665", "0.5539788", "0.55348086", "0.5527003", "0.55260...
0.6172118
1
Rings the school bells in a pattern for the given schedule/time.
def ring_bells(): # Need to get the pattern for this time slot and apply it. curTime = time.strftime("%H:%M") if curTime not in jsonConfig["schedules"][curSchedule]: logging.error("Couldn't find time record for time " + curTime + " in schedule " + curSchedule) return # Obtain the patter...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tick(self) -> None:\n\n bell = self._row[self._place]\n user_controlled = self._user_assigned_bell(bell)\n\n self._rhythm.wait_for_bell_time(time.time(), bell, self._row_number, self._place,\n user_controlled, self.stroke)\n\n if not user_contr...
[ "0.5695601", "0.5432977", "0.5410973", "0.5381197", "0.53569686", "0.51683617", "0.5059934", "0.50112706", "0.49925143", "0.49726513", "0.49589247", "0.49199778", "0.49188292", "0.4897901", "0.48784587", "0.48409376", "0.48267853", "0.4821929", "0.4812405", "0.47980654", "0.4...
0.72606444
0
Reloads the schedule from our json file.
def reload_schedule(): global jsonConfig global curSchedule jsonConfig = None curSchedule = None # Clear currently scheduled bells. schedule.clear("current") logging.debug("Reloading schedule...") with open(jsonFile) as jsonFileHandle: jsonConfig = json.load(jsonFileHandle) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reload(self):\n with open(self._config) as f:\n self.data = json.load(f)", "def reload(self):\n try:\n with open(self.__file_path, 'r') as f:\n for key, value in json.load(f).items():\n self.__objects[key] = eval(key.split('.')[0])(**value...
[ "0.719504", "0.69318056", "0.6864976", "0.67585194", "0.6752321", "0.6690034", "0.66177434", "0.6605925", "0.65952766", "0.6545089", "0.64971936", "0.6459408", "0.6386498", "0.632974", "0.62427646", "0.62313604", "0.62149954", "0.61784226", "0.61701703", "0.6152167", "0.61414...
0.7724108
0
Calculates average climatology for annual data either Jan to Dec or accummulation period
def precip_stats_to_climatology(fili, start_year=1981, end_year=2015): nyear = end_year - start_year + 1 ds = xr.open_dataset(fili) year = ds['time'].dt.year #dsMsk = ds.isel( time=( (year >= start_year) & (year <= end_year) ) ).count(dim='time') dsClm = ds.isel( time=( (year >= start_year) &...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mean_annual_cycle(data):\n ntime, nlat, nlon = data.shape\n # reshape from [nmonth,nlat,nlon] to [nyear,12,nlat,nlon]\n work = MA.reshape(data,(-1,12,nlat,nlon))\n # compute mean annual cycle\n mean_data = MA.average(work,0)\n return mean_data", "def monthly_avgs(HC):\n monthlies = np.ze...
[ "0.6993821", "0.6731715", "0.65855527", "0.6528531", "0.65122795", "0.6510179", "0.64892894", "0.64774054", "0.6472804", "0.63967705", "0.63076663", "0.63015807", "0.6238311", "0.6189327", "0.61609685", "0.61545795", "0.61481494", "0.6128874", "0.61187685", "0.61106884", "0.6...
0.5866293
28
Undistort the image using distortion coefficients
def undistort_image(mtx_, dist_, img_): dst = cv2.undistort(img_, mtx_, dist_, None, mtx_) return dst
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def undistort(self, image):\n return cv2.undistort(image, self.camera_matrix, self.distortion_coeffs, None, self.camera_matrix)", "def undistort(self, image):\n dst = cv2.undistort(image, self.mtx, self.dist_coeff, None)\n\n if self.args.is_test:\n self.image_logger.save_image(dst...
[ "0.7884479", "0.7551686", "0.7374037", "0.7349525", "0.7250263", "0.72426575", "0.71945417", "0.7146802", "0.7065099", "0.671219", "0.66244733", "0.6621529", "0.64361244", "0.6337158", "0.6207002", "0.6132985", "0.6115165", "0.59107697", "0.59106004", "0.5851052", "0.5788503"...
0.7565127
1
Calculate Perspective and Inverse Perspective Transform Matrices
def calc_transform(src_, dst_): M_ = cv2.getPerspectiveTransform(src_, dst_) Minv_ = cv2.getPerspectiveTransform(dst_, src_) return M_, Minv_
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def perspective_transform():\n src = np.float32([(220,720), (1110, 720), (570, 470), (722, 470)]) # Manually get these numbers from plot\n dst = np.float32([[320, 720], [920, 720], [320, 1], [920, 1]])\n M = cv2.getPerspectiveTransform(src, dst)\n Minv = cv2.getPerspectiveTransform(dst, src)\n\n re...
[ "0.77655315", "0.6772391", "0.67308986", "0.669059", "0.6618192", "0.65587133", "0.64216304", "0.6264239", "0.6257005", "0.62168366", "0.6215676", "0.6160854", "0.6142326", "0.6108185", "0.6086129", "0.6077356", "0.60574424", "0.6047167", "0.6012863", "0.599367", "0.5987706",...
0.7251248
1
Extract all Non Zero Pixels and return X, Y Coordinates
def extract_pixels(img_): non_zero_pixels = np.argwhere(0 < img_) x = non_zero_pixels.T[0].astype(np.float32) y = non_zero_pixels.T[1].astype(np.float32) return x, y
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __create_xyz_points(raster, no_data=-9999):\n y, x = np.where(raster != no_data)\n z = np.extract(raster != no_data, raster)\n\n return x, y, z", "def find_pixels(self):\n ref_image=Image.open('sample0000.png')\n imarray=np.array(ref_image)\n ref_image.close()\n ...
[ "0.655391", "0.64457804", "0.6414161", "0.63365555", "0.6304538", "0.62975013", "0.6216841", "0.62149465", "0.6204824", "0.61987865", "0.6195701", "0.6187824", "0.61301506", "0.60819465", "0.6074533", "0.60721606", "0.60360277", "0.6013827", "0.59923506", "0.597244", "0.59497...
0.81292105
0
Get x intercepts for given y value
def get_intercepts(fit, y): x = fit[0] * (y * y) + fit[1] * y + fit[2] return x
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_x_y_for_line(bounds, y_intercept, slope): \n\n x = np.sort(bounds)\n\n y = y_intercept + (slope * x)\n\n return x, y", "def intercept(x1, y1, x2, y2):\r\n m = slope(x1, y1, x2, y2)\r\n return y1 - m*x1", "def get_fit_x(self, y):\n if self.line_fit_m.size == 0:\n retu...
[ "0.63922507", "0.6389413", "0.6266955", "0.6237579", "0.62286144", "0.609001", "0.60876924", "0.6066772", "0.605182", "0.605182", "0.6022421", "0.59712934", "0.5959732", "0.5946199", "0.5945855", "0.5922003", "0.59173673", "0.5792059", "0.57911325", "0.57743794", "0.57610834"...
0.7766451
0
Get Left_x, Right_x, Left_y, Right_y, Image , return Image with Polygon
def draw_polygon(left_x, right_x, left_y, right_y, img_): pts_left = np.array([np.flipud(np.transpose(np.vstack([left_x, left_y])))]) pts_right = np.array([np.transpose(np.vstack([right_x, right_y]))]) pts = np.hstack((pts_left, pts_right)) img_ = cv2.polylines(img_, np.int_([pts]), isClosed=False, colo...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def draw_image(self):\n dir_ship = self.direction\n dir_cannon=self.cannon_dir\n temp_image = self.base_image.copy()\n pygame.draw.polygon(temp_image, (0,0,0), [(2,2),(2,3),(3,3),(3,2)])\n if dir_cannon == dir_ship:\n pygame.draw.polygon(temp_image, (60,60,60), [(4,3),...
[ "0.65409863", "0.6449552", "0.62613237", "0.61531603", "0.61507094", "0.6134605", "0.5918344", "0.5892853", "0.58924294", "0.58919007", "0.58887494", "0.58701646", "0.58659583", "0.5839686", "0.58155435", "0.5813019", "0.581092", "0.5798064", "0.57906735", "0.5779135", "0.576...
0.7396713
0
Convert parameters from X,Y plane to Image Plane Points
def coordinates_to_imgpts(x, y): pts = np.array([np.flipud(np.transpose(np.vstack([x, y])))]) return pts
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def project_points_plane(points, plane):\n return [project_point_plane(point, plane) for point in points]", "def xyz2plane(x,y,z, new_x=[], plane=[], origin=None):\n # preliminary stuff\n if origin != None: x = x - origin\n a,b,c,d = plane\n bottom = np.sqrt(a*a + b*b + c*c) # normalize\n a,b...
[ "0.65616685", "0.64299065", "0.6374554", "0.63244987", "0.6322487", "0.6310065", "0.6286317", "0.6259193", "0.62357223", "0.6208368", "0.6159411", "0.60882986", "0.6084627", "0.60737157", "0.60300255", "0.60300255", "0.6017754", "0.5987526", "0.5984642", "0.59726226", "0.5969...
0.59584945
21
Draw Polylines for points with given thickness specified by Window Size
def draw_polylines(input_img, pts, window_size): return cv2.polylines(input_img, np.int_([pts]), isClosed=False, color=(255, 255, 255), thickness=2 * window_size)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def draw_lines(self, color, points, width = 1, closed = False):\n color = spyral.color._determine(color)\n pygame.draw.aalines(self._surf, color, closed, points)", "def drawLines(self):\n\t\tintersections = [[], []]\n\t\tfor l in self.lines:\n\t\t\tif l.direction == 'v':\n\t\t\t\tif l.rtc:\n\t\t\t\...
[ "0.6230124", "0.61896694", "0.61215425", "0.6083533", "0.5963582", "0.5954477", "0.58733976", "0.58443934", "0.5826821", "0.58263594", "0.58262116", "0.5811678", "0.57939386", "0.573556", "0.5720824", "0.5711357", "0.57111347", "0.57054645", "0.56073576", "0.557913", "0.55431...
0.69677657
0
Use polyfit from the mask points for smoothening them
def smoothen_masks(fit, img_, window_size): img_size = img_.shape mask_poly = np.zeros_like(img_) # Get top to Bottom for refactoring # mask_y = np.linspace(0, img_size[0] - 1, img_size[0]) mask_x = get_intercepts(fit, mask_y) # Smoothen the mask # pts = coordinates_to_imgpts(mask_x, mask_y...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sigclip_polyfit(p, xx, yy, degree, weight = None):\n # read constants from p\n sigclip = p['WAVE_SIGCLIP']\n # initialise the while loop\n sigmax = sigclip + 1\n # initialise mask\n mask = np.ones_like(xx, dtype='Bool')\n while sigmax > sigclip:\n # Need to mask weight here if not N...
[ "0.62117845", "0.62038964", "0.60165256", "0.5831612", "0.5827311", "0.57904327", "0.572582", "0.5706521", "0.56874967", "0.56852", "0.56852", "0.56852", "0.56538486", "0.5650198", "0.5639281", "0.5617409", "0.5605478", "0.5585841", "0.557275", "0.55547965", "0.5492608", "0...
0.7063888
0
Polynomial search based on previous fit
def limited_search(img_, window_size, flag='L'): # Initialize Mask with Same Size as Image # mask_poly = np.zeros_like(img_) # Get previous Coefficients # fit = get_last_fit(flag=flag) if fit is not None: mask_poly_smooth = smoothen_masks(fit, img_, window_size) return mask_poly_smoo...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_expected_polynomial_coefs(y, degree, with_intercept=True):\n poly_matrix = np.vander(np.arange(len(y)), degree + 1)\n if not with_intercept:\n poly_matrix = poly_matrix[:, :-1]\n return np.linalg.lstsq(poly_matrix, y.to_numpy(), rcond=None)[0]", "def fit_polynomial(self, ym_per_pix, xm_pe...
[ "0.6252983", "0.60985476", "0.60769516", "0.6001327", "0.59808683", "0.5978871", "0.59773546", "0.5953325", "0.59510887", "0.5937711", "0.593213", "0.58654374", "0.58370185", "0.58306885", "0.57615274", "0.57519823", "0.57093227", "0.5706699", "0.5706699", "0.5706699", "0.570...
0.52596563
94
Get the mean value of fit "Left" and "Right" based on flag
def get_mean_fit(flag='L'): if flag == 'L': return np.mean(np.vstack(l_coeff_queue), axis =0) if len(l_coeff_queue)>1 else l_coeff_queue[-1] else: return np.mean(np.vstack(r_coeff_queue), axis =0) if len(r_coeff_queue)>1 else r_coeff_queue[-1]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _mask_and_avg(values, padding_mask):\n\tdec_lens = torch.sum(padding_mask,dim=1)\n\tlosses = torch.stack(values, dim=1)\n\tlosses = losses * padding_mask\n\tvalues_per_ex = torch.sum(losses, dim=1)/dec_lens\n\treturn torch.sum(values_per_ex)", "def mean(self):\n\n\t\tif not self._masked:\n\t\t\t\n\t\t\tretur...
[ "0.60307616", "0.59903556", "0.5989535", "0.5927027", "0.58250964", "0.58250463", "0.58083445", "0.5792237", "0.57348174", "0.57280666", "0.57189894", "0.571298", "0.56587595", "0.5591607", "0.5536695", "0.55357367", "0.5512962", "0.55089694", "0.5496177", "0.5463986", "0.545...
0.7186115
0
Gets the Last Fit depending on the flag
def get_last_fit(flag='L'): if flag == 'L': return l_coeff_queue[-1] else: return r_coeff_queue[-1]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getFit(self):\n if self.fits.has_key('default'):\n return self.fits['default']\n else:\n return None", "def last_fmeasure(self):\n return self.get_fvalue(self.last_position())", "def get_last_saved_estimation(self):\n return None", "def get_fit(self, spac...
[ "0.6239705", "0.6228102", "0.6141779", "0.6008824", "0.59334695", "0.5871821", "0.5755246", "0.5743263", "0.5716989", "0.57042426", "0.5698672", "0.56794965", "0.56396884", "0.56118524", "0.55922616", "0.55794775", "0.55546254", "0.55316406", "0.55230576", "0.5493914", "0.547...
0.8070429
0
Verify if number of pixels are satisfactory for a confident fit and then fit
def check_and_fit(x, y, flag='L', threshold=1000): confidence_index = len(x) if IsLaneFound is False: threshold =500 if confidence_index < threshold: fit = None foundFlag = False else: fit, cov = curve_fit(lambda x, a, b, c:a*x*x+b*x + c , x, y) foundFlag = T...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _check_is_fitted(self):\n check_is_fitted(self, ['w', 'b'])", "def will_data_fit(bit_num, image, bits_per_pix):\r\n max_bits = reduce(lambda x, y: x * y, image.size) * bits_per_pix\r\n return bit_num <= max_bits", "def _check_is_fitted(self):\n # Do not check `b` as some classifiers do ...
[ "0.72636896", "0.6932754", "0.66202956", "0.66143525", "0.65346766", "0.63944054", "0.6253365", "0.6242172", "0.62324864", "0.62324864", "0.6188465", "0.6146149", "0.6145773", "0.61280084", "0.6103189", "0.6067273", "0.60213757", "0.6007816", "0.5982442", "0.59745777", "0.596...
0.5679916
43
Mask the Images and then return the equation of the lane lines
def mask_and_fit(mask, binary_warped, flag): img = cv2.bitwise_and(binary_warped, binary_warped, mask=mask) x, y = extract_pixels(img) fit, foundFlag, confidence_index = check_and_fit(x, y, flag) return fit, foundFlag, confidence_index
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def calcmask(self, *args, **kwargs):\n return _image.image_calcmask(self, *args, **kwargs)", "def set_lanes(left_lines, right_lines, image):\n \n Y_LANE_EXTRAP = 35 # percent up from bottom of image to extrapolate lane lines\n \n image_wk = np.copy(image) # working copy\n image_lines = np.c...
[ "0.6409335", "0.6389279", "0.63278013", "0.6144017", "0.61208165", "0.61032546", "0.6092377", "0.60494506", "0.60046375", "0.60025907", "0.5973677", "0.5961888", "0.5948796", "0.59485275", "0.5888697", "0.5870006", "0.58533627", "0.58333975", "0.58228105", "0.5813124", "0.580...
0.0
-1
Use The current values of Curvature and Offset from Left and Right Lanes to decide if Lanes are sane
def curvature_sanity(left_curvature, left_offset, right_curvature, right_offset): if return_queue_len(flag='L') >= 1 and return_queue_len(flag='R') >= 1: offset = center_position - (left_offset + right_offset) / 2. offset_measure = np.abs(overall_offset - offset) return True if offset_measur...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _curvature(self):\n y_eval = self.left_fitx.shape[0] - 10\n left_curverad = (((1 + (2 * self.left_fit[0] * y_eval + self.left_fit[1]) ** 2) ** 1.5) /\n np.absolute(2 * self.left_fit[0]))\n right_curverad = (((1 + (2 * self.right_fit[0] * y_eval + self.right_fit[1]) ...
[ "0.63404727", "0.6133634", "0.6060749", "0.58401936", "0.56271565", "0.5616536", "0.5516699", "0.5483635", "0.54565936", "0.5450176", "0.5428849", "0.54229635", "0.540363", "0.54026043", "0.53971386", "0.5384905", "0.53581065", "0.5353302", "0.53430974", "0.5340143", "0.53293...
0.70147413
0
Use the left and right fit
def update_lanewidth(left_fit, right_fit, img_): img_size = img_.shape y_eval = np.linspace(0, img_size[0], 20) left_x = get_intercepts(left_fit, y_eval) right_x = get_intercepts(right_fit, y_eval) return np.clip(right_x - left_x, 400, 800)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __call__(self, left, mode, right, size=None, **kwargs):\n return super().__call__(left, mode, right, size=size, **kwargs)", "def hflip(self):\n self.leftimg, self.rightimg = self.rightimg, self.leftimg", "def rightbox(self):\r\n pass", "def check_extent(self):\n if self.lower_...
[ "0.5895596", "0.5836528", "0.5623411", "0.55394584", "0.5525405", "0.5424819", "0.53840476", "0.53774345", "0.53398556", "0.53164613", "0.52830184", "0.5280889", "0.5272965", "0.52709484", "0.52354926", "0.51937866", "0.51937866", "0.51937866", "0.51937866", "0.51937866", "0....
0.6062885
0
Create an ISO 6346 shipping container code.
def create(owner_code, serial, category='U'): if not (len(owner_code) == 3 and owner_code.isalpha()): raise ValueError("Invalid ISO 6346 owner code '{}'".format(owner_code)) if category not in ('U', 'J', 'Z', 'R'): raise ValueError("Invalid ISO 6346 category identifier '{}'".format(category)) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def USCode(self, short):\n states = {\n 'AK': 'Alaska',\n 'AL': 'Alabama',\n 'AR': 'Arkansas',\n 'AS': 'American Samoa',\n 'AZ': 'Arizona',\n 'CA': 'California',\n 'CO': 'Colorado',\n 'CT': 'Connecticut',\n 'D...
[ "0.5175448", "0.5125011", "0.50932604", "0.49715528", "0.49012083", "0.48026282", "0.48011735", "0.47937286", "0.47771695", "0.47705403", "0.47160998", "0.47139278", "0.47057864", "0.47034556", "0.46948606", "0.46944666", "0.4689189", "0.4687901", "0.46823987", "0.46695173", ...
0.5852458
0
Compute the check digit for an ISO 6346 code without that digit
def check_digit(raw_code): s = sum(code(char) * 2**index for index, char in enumerate(raw_code)) return s % 11 % 10
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def checkdigit(code):\n check = sum((i+1)*int(code[i]) for i in range(9)) % 11\n return 'X' if check == 10 else str(check)", "def calc_check_digit_issn(issn):\n\n total = 0\n lissn = list(issn.replace('-', ''))\n\n for i, v in enumerate(lissn[:-1]):\n total = total + ((8-i) * int(v))\n\n ...
[ "0.6888133", "0.6631145", "0.6620832", "0.6535597", "0.6298015", "0.6270086", "0.6102347", "0.6022895", "0.6003835", "0.59928644", "0.5986576", "0.59091353", "0.58925956", "0.5891122", "0.5886155", "0.5840528", "0.58109224", "0.5803279", "0.5776782", "0.5743615", "0.5738659",...
0.697806
0