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
Data import test against known values that Maui County, HI should have.
def test_county(self): counties = self.geographies.find({ 'geoid': '15009' }) self.assertEqual(counties.count(), 1) county = counties[0] self.assertEqual(county['sumlev'], config.SUMLEV_COUNTY) self.assertEqual(county['metadata']['NAME'], 'Maui County') self.assertEqua...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_addr_country_good_values(self):\n for input_val, output_val in self.known_values:\n self.line._parse_addr_country(input_val)\n self.assertEqual(output_val, self.line.addr_country)", "def test_addr_city_good_values(self):\n for input_val, output_val in self.known_value...
[ "0.57526296", "0.57103074", "0.5672994", "0.56273186", "0.5606717", "0.5558552", "0.5503273", "0.5499079", "0.54822886", "0.5468548", "0.5458295", "0.5438925", "0.5427252", "0.5384551", "0.5373701", "0.53419626", "0.53152275", "0.530823", "0.5296914", "0.52935106", "0.5282368...
0.5472733
9
Data import test against known values that Hilo CCD County Subdivision, HI should have.
def test_county_subdivision(self): counties = self.geographies.find({ 'geoid': '1500190630' }) self.assertEqual(counties.count(), 1) county = counties[0] self.assertEqual(county['sumlev'], config.SUMLEV_COUNTY_SUBDIVISION) self.assertEqual(county['metadata']['NAME'], 'Hilo CCD...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_census_county_population():\n dataframe = get_county_population_dataframe()\n boulder_county_row = dataframe.loc[dataframe['county_fips'] == 8013]\n boulder_county_population = boulder_county_row.get('county_population')\n assert float(boulder_county_population) == 326196", "def load_unicef_data():\...
[ "0.61219215", "0.58023244", "0.57063735", "0.5699347", "0.56686944", "0.56636924", "0.5659856", "0.5624004", "0.56009614", "0.55768406", "0.55667585", "0.5562145", "0.55168825", "0.546884", "0.54502296", "0.5442449", "0.54413635", "0.5411472", "0.5400325", "0.53584874", "0.53...
0.58564246
1
Data import test against known values that Pearl City CDP, HI should have.
def test_place(self): places = self.geographies.find({ 'geoid': '1562600' }) self.assertEqual(places.count(), 1) place = places[0] self.assertEqual(place['sumlev'], config.SUMLEV_PLACE) self.assertEqual(place['metadata']['NAME'], 'Pearl City CDP') self.assertEqual(plac...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_csv_reader_data_contents(process_data):\n data = process_data(file_name_or_type='clean_map.csv')\n\n # Check row types\n for row in data:\n assert(isinstance(row['Country'], str))\n assert(isinstance(row['City'], str))\n assert(isinstance(row['State_Or_Province'], str))\n ...
[ "0.5883105", "0.5851784", "0.5822447", "0.573256", "0.56518376", "0.56188184", "0.55931056", "0.554107", "0.55332124", "0.550011", "0.5474475", "0.5451759", "0.5421146", "0.5413695", "0.5397356", "0.53928024", "0.5360387", "0.5358236", "0.53577906", "0.53055733", "0.5302389",...
0.0
-1
Data import test against known values that Tract 405, HI should have.
def test_simple_tract(self): tracts = self.geographies.find({ 'geoid': '15007040500' }) self.assertEqual(tracts.count(), 1) tract = tracts[0] self.assertEqual(tract['sumlev'], config.SUMLEV_TRACT) self.assertEqual(tract['metadata']['NAME'], 'Census Tract 405') self.ass...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_import_data():\n\n file_path = os.path.join(CONST_ADVANTICSYS_DIR, CONST_ADVANTICSYS_TEST_1)\n\n # Bring df\n success, log, test_ingress_df = advanticsys_import(file_path)\n assert success, log\n assert isinstance(test_ingress_df, pd.DataFrame)\n\n # Test import function\n success, lo...
[ "0.6001708", "0.5850295", "0.5802427", "0.56824386", "0.56722516", "0.56503046", "0.5641491", "0.56235564", "0.56227165", "0.56190985", "0.5571267", "0.55461514", "0.55448073", "0.5541814", "0.55416083", "0.5525547", "0.55091816", "0.545981", "0.5441447", "0.543235", "0.54276...
0.0
-1
Data import test against known values for Block 3029 in Tract 210.05, HI.
def test_simple_block(self): if config.SUMLEV_BLOCK not in config.SUMLEVS: pass blocks = self.geographies.find({ 'geoid': '150010210053029' }) self.assertEqual(blocks.count(), 1) block = blocks[0] self.assertEqual(block['sumlev'], config.SUMLEV_BLOCK) self...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_parse_import_ticket_data_3(self):\n self.ticket_dict1[\"host_genus\"] = \"retrieve\"\n self.ticket_dict1[\"cluster\"] = \"retrieve\"\n self.ticket_dict1[\"subcluster\"] = \"retrieve\"\n self.ticket_dict1[\"accession\"] = \"retrieve\"\n tkt = tickets.parse_import_ticket_d...
[ "0.57959026", "0.56107974", "0.56101936", "0.55657643", "0.5551291", "0.55362034", "0.54494923", "0.54455864", "0.5443772", "0.5425677", "0.53916776", "0.53899664", "0.5382141", "0.5378087", "0.5374391", "0.53091484", "0.5304576", "0.5296869", "0.52898246", "0.52887756", "0.5...
0.50710976
65
Verify that a split tract is crosswalked correctly.
def test_tract_split(self): # Check that split tract does not exist in 2010 split_tract = self.geographies.find({ 'geoid': '15003003500' }) self.assertEqual(split_tract.count(), 0) # Validate first new tract from the split tract # Tract 35.01 tract1 = self.geographies.fi...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_split_feature(tree):\r\n print(\"test_split_feature()...\", end = \"\")\r\n assert (tree.process_split_feature() == True)\r\n print(\"Passed!\")", "def test_tract_split_housing(self):\n # Validate first new tract from the split tract\n # Tract 35.01\n tract1 = self.geograph...
[ "0.60647726", "0.5963358", "0.5910475", "0.56907934", "0.5444362", "0.5392605", "0.53274345", "0.52772987", "0.5269114", "0.525364", "0.52471393", "0.5222307", "0.5215429", "0.5199001", "0.5181526", "0.51758754", "0.5166498", "0.5156083", "0.5148666", "0.51433253", "0.5138643...
0.6179793
0
Verify that a split tract is crosswalked correctly.
def test_tract_split_housing(self): # Validate first new tract from the split tract # Tract 35.01 tract1 = self.geographies.find({ 'geoid': '15003003501' }) self.assertEqual(tract1.count(), 1) tract1 = tract1[0] split_tract_house_2000 = 3370 tract1_house...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_tract_split(self):\n # Check that split tract does not exist in 2010\n split_tract = self.geographies.find({ 'geoid': '15003003500' })\n self.assertEqual(split_tract.count(), 0)\n\n # Validate first new tract from the split tract\n # Tract 35.01\n tract1 = self.ge...
[ "0.61819786", "0.60660523", "0.59104705", "0.5692221", "0.54465586", "0.5394921", "0.53270775", "0.52783716", "0.5267797", "0.5253086", "0.52491665", "0.5221701", "0.5214855", "0.51995766", "0.5181739", "0.517763", "0.5168872", "0.51568645", "0.51496524", "0.51446146", "0.514...
0.5965284
2
Verify that a merged tract is crosswalked correctly. TODO test housing
def test_tract_merged(self): # Verify that the first dissolved tract no longer exists tract1 = self.geographies.find({ 'geoid': '15003008607' }) self.assertEqual(tract1.count(), 0) tract2 = self.geographies.find({ 'geoid': '15003008608' }) self.assertEqual(tract2.count(), 0) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_block_merged(self):\n # Compute crosswalked values\n block1_pop_2000 = 12 # 150010210011329\n block2_pop_2000 = 27 # 150010210011331\n merged_pop_2000 = block1_pop_2000 + block2_pop_2000\n merged_pop_2010 = 78 \n merged_pop_delta = merged_pop_2010 - merged_pop_2...
[ "0.60011363", "0.59322906", "0.5837479", "0.58345", "0.58085495", "0.56822234", "0.5644508", "0.5596146", "0.55923694", "0.5589906", "0.55234635", "0.5479351", "0.5457161", "0.5450034", "0.54229236", "0.5405898", "0.5401507", "0.53951335", "0.53843933", "0.53771603", "0.53687...
0.68002003
0
Verify that the total population of all blocks adds up to the expected amount.
def test_block_sum(self): blocks = self.geographies.find({ 'sumlev': config.SUMLEV_BLOCK }) pop_2010 = sum([int(block['data']['2010']['P1']['P001001']) for block in blocks]) self.assertEqual(pop_2010, 1360301)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_simple_block(self):\n if config.SUMLEV_BLOCK not in config.SUMLEVS:\n pass\n\n blocks = self.geographies.find({ 'geoid': '150010210053029' })\n\n self.assertEqual(blocks.count(), 1)\n\n block = blocks[0]\n\n self.assertEqual(block['sumlev'], config.SUMLEV_BLOC...
[ "0.66755617", "0.6447338", "0.63877445", "0.63238794", "0.630733", "0.6278169", "0.62258786", "0.6192991", "0.6188777", "0.6168206", "0.6166373", "0.61379033", "0.61377835", "0.61257434", "0.61126506", "0.6111476", "0.60747224", "0.60439485", "0.6043113", "0.6012321", "0.5988...
0.69447994
0
Verify that a split block is crosswalked correctly.
def test_block_split(self): block1 = self.geographies.find({ 'geoid': '150010210051016' }) self.assertEqual(block1.count(), 1) block1 = block1[0] split_block_pop = 448 block1_land_pct = float(184458) / 587158 # AREALAND_INT / AREALAND_2000 block1_pop_2000 = int(block1...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def assert_xblocks_are_good(self, block):\r\n scope_ids = block.scope_ids\r\n self.assertIsNotNone(scope_ids.usage_id)\r\n self.assertIsNotNone(scope_ids.def_id)\r\n\r\n for child_id in block.children:\r\n child = block.runtime.get_block(child_id)\r\n self.assert_x...
[ "0.6441555", "0.6140265", "0.60267013", "0.5991844", "0.59660476", "0.59307206", "0.5927383", "0.58419365", "0.5799914", "0.5759384", "0.5749067", "0.57229954", "0.57199514", "0.57078195", "0.5696112", "0.56438005", "0.56323946", "0.5596334", "0.5545447", "0.5543341", "0.5539...
0.6697141
0
Verify that a merged block is crosswalked correctly. 150010210011329 + 150010210011331 > 150010210051009
def test_block_merged(self): # Compute crosswalked values block1_pop_2000 = 12 # 150010210011329 block2_pop_2000 = 27 # 150010210011331 merged_pop_2000 = block1_pop_2000 + block2_pop_2000 merged_pop_2010 = 78 merged_pop_delta = merged_pop_2010 - merged_pop_2000 ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_block_split(self):\n block1 = self.geographies.find({ 'geoid': '150010210051016' }) \n self.assertEqual(block1.count(), 1)\n block1 = block1[0]\n\n split_block_pop = 448 \n block1_land_pct = float(184458) / 587158 # AREALAND_INT / AREALAND_2000\n block1_pop_2000 ...
[ "0.6599209", "0.6434663", "0.62785393", "0.6059824", "0.60417795", "0.59117043", "0.5910834", "0.5839638", "0.5807155", "0.57834464", "0.5780635", "0.57694", "0.57457066", "0.56926054", "0.56888676", "0.56786174", "0.56585085", "0.564916", "0.5635768", "0.5618506", "0.5567812...
0.78313726
0
Hawaii should have a key for every label. Every label should have a key for Hawaii.
def test_labels_match_geographies(self): geo = self.geographies.find_one({ 'geoid': '15' }) labels = self.labels.find_one({ 'dataset': 'SF1' }) geo_tables = geo['data']['2010'] labels_tables = labels['tables'] self.assertEqual(sorted(geo_tables.keys()), sorted(labels_tables.key...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def keylabels(keyinput):\n labeldic = {}\n labeldic['Zgas'] = 'Z'\n labeldic['logUs'] = 'log(U)'\n labeldic['xid'] = '$\\\\xi_\\\\textrm{d}$'\n labeldic['nh'] = '$n_\\\\textrm{H}$ [cm$^{-3}$]'\n labeldic['COCOsol'] = 'C/O [(C/O)$_\\\\textrm{sun}$]'\n labeldic['mup'] = '...
[ "0.6396237", "0.5798282", "0.57384473", "0.5728252", "0.57172287", "0.5651065", "0.56133306", "0.5584117", "0.5548151", "0.5503141", "0.54735726", "0.5403264", "0.53773135", "0.5331163", "0.5305797", "0.5302422", "0.5288399", "0.52723277", "0.52605987", "0.52517086", "0.52512...
0.536944
13
Test that the tables documented size matches its actual label count.
def test_table_sizes(self): labels_tables = self.labels.find_one({ 'dataset': 'SF1' })['tables'] for label_data in labels_tables.values(): self.assertEqual(label_data['size'], len(label_data['labels']))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_test_data_length(self):\n total_count = 0\n for batch in self._dataset.get_test():\n total_count += len(batch['label'])\n\n self.assertEqual(total_count, self._dataset.get_test_len())", "def test_train_data_length(self):\n total_count = 0\n for batch in self._dataset.get_train():\n ...
[ "0.70430565", "0.65831393", "0.64576143", "0.6415789", "0.6392821", "0.63588977", "0.63588977", "0.6333525", "0.6237331", "0.62271243", "0.6209417", "0.62073797", "0.6188158", "0.61876047", "0.6105959", "0.6100322", "0.6094092", "0.6077378", "0.6064207", "0.60563827", "0.6050...
0.86687344
0
returns True if we need to reoptimize. returns False if we reached a viable solution.
def do_we_need_to_reoptimize(MFE): # check that we found a solution and run optimizer again if not MFE.CalculateMeritFunction() Nop = MFE.NumberOfOperands REOPTIMIZE = False for j in range(6): op = MFE.GetOperandAt(Nop - j) contribution = op.Contribution print("Contribution %...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def did_solve(self):\n return self._solution[\"status\"] == \"optimal\"", "def has_solution(self) -> bool:\n pass", "def is_solved(self):\n self.solved = self.current_pos == self.finish_pos\n return self.solved", "def should_reschedule(self, iteration):\n if not self.max_it...
[ "0.6744845", "0.67123806", "0.6618959", "0.66112566", "0.6573712", "0.6526234", "0.64699936", "0.64646727", "0.64346564", "0.6389327", "0.6386308", "0.6377075", "0.63534486", "0.6308071", "0.63058066", "0.62828004", "0.6271961", "0.62512046", "0.62361073", "0.6218692", "0.621...
0.70585865
0
This is custom assert to compare actual and expected pinterest pin content
def __assert_pinterest_pin(actual_pinterest_pin, expected_pinterest_pin): assert isinstance(actual_pinterest_pin, EPinterestPin) assert actual_pinterest_pin.pin_url == expected_pinterest_pin.pin_url
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_post(self):\n self.assertEqual(self.post.title, \"Ugandan anthem\")\n self.assertEqual(self.post.body, \"George William Kakoma\")\n self.assertEqual(str(self.post), \"Ugandan anthem - George William Kakoma\")", "def _test_html_content(self, xblock, expected_section_tag, expected_bre...
[ "0.59018815", "0.58148205", "0.5752738", "0.5717734", "0.5668471", "0.5617492", "0.5600811", "0.5596509", "0.55932516", "0.55932516", "0.55932516", "0.55932516", "0.55932516", "0.55932516", "0.55932516", "0.55932516", "0.5588442", "0.5588204", "0.5587021", "0.55467755", "0.55...
0.8085749
0
Unable to make this function works because of a API bad enpoint error
def test_getTopAcounts(self, **params): req = Account.getTopAccounts() print(req) self.assertEqual(req['success'], True)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def api(self) -> str:", "def prepare_api(self):\n return None", "def check_eapi(self, eapi):\n\t\treturn True", "def test_get_api_resources(self):\n pass", "def test_AlgorithmsIdHandler_GET_MalformedRequest(self):\n searchedId='xyz' + ' ' + '1'\n response = self.testapp.get('/al...
[ "0.5935919", "0.5736856", "0.5699168", "0.5669888", "0.5661354", "0.56028557", "0.553697", "0.547682", "0.54588556", "0.5419887", "0.53988945", "0.53988945", "0.53988945", "0.53988945", "0.53988945", "0.53964955", "0.5372848", "0.53652304", "0.5361749", "0.5361749", "0.535056...
0.0
-1
Same, should work, but the get function doesn't build correctly the URL I guess
def test_getDelegate(self): r = Delegate.getDelegate(username="dr10") self.assertEqual(r['success'], True)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def url():\n ...", "def _get_url(self, absolute):", "def url(self):\n ...", "def get(self, url):\n super().get(mfacebookToBasic(url))", "def Url(self) -> str:", "def _get_one(self,url):\n pass", "def query(url):", "def _make_url(self):\n ...", "def _get(self, url):\n ...
[ "0.71847", "0.7118711", "0.71015704", "0.69777995", "0.69658864", "0.6951724", "0.68193346", "0.6791511", "0.6776102", "0.6736594", "0.6683729", "0.6672617", "0.66661245", "0.65939236", "0.65708315", "0.6551169", "0.65469515", "0.6544649", "0.64990133", "0.6493355", "0.648037...
0.0
-1
json representation of a class
def to_json_string(list_dictionaries): if not list_dictionaries: return "[]" if (type(list_dictionaries) != list or not all(type(x) == dict for x in list_dictionaries)): raise TypeError("list_dictionaries must be a list of dictionaries") return json.dumps(list_...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cls2json(self):\n return json.dumps(self.__dict__)", "def cls2json(self):\n return json.dumps(self.__dict__)", "def to_json(self):\n obj_dict = self.__dict__\n obj_dict[\"_class_\"] = self.__class__.__name__\n return obj_dict", "def to_json_string(self) -> None:\n ...
[ "0.84269625", "0.84269625", "0.77133346", "0.75966525", "0.7533781", "0.7497457", "0.7497457", "0.7497457", "0.7497457", "0.7497457", "0.7497457", "0.7497457", "0.74472845", "0.7442575", "0.7442575", "0.7409183", "0.72800064", "0.7279", "0.72505313", "0.7241701", "0.723047", ...
0.0
-1
JSON string representation of list_objs to a file
def save_to_file(cls, list_objs): list_dictionaries = [] if list_objs is None or list_objs == []: string_dictionary = "[]" else: for _obj_dict in list_objs: list_dictionaries.append(_obj_dict.to_dictionary()) string_dictionary = Base.to_json_st...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def save_to_file(cls, list_objs):\n l = []\n if list_objs is not None:\n for item in list_objs:\n l.append(item.to_dictionary())\n with open(\"%s.json\" % cls.__name__, mode='w') as f:\n f.write(Base.to_json_string(l))", "def save_to_file(cls, list_objs):...
[ "0.8021217", "0.80143976", "0.7999722", "0.7985439", "0.7923821", "0.7889796", "0.7888717", "0.78478926", "0.7845653", "0.78098357", "0.78060126", "0.77895397", "0.7751209", "0.7748819", "0.772234", "0.7691926", "0.76581436", "0.7604948", "0.75762635", "0.75700843", "0.750737...
0.7555544
20
the list of the JSON string representation json_string
def from_json_string(json_string): if json_string is None or json_string == "": return [] else: return json.loads(json_string)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def json(self):\n return [t.json for t in self.values()]", "def jsons(self):\n if self._jsons is None:\n self.make_jsons()\n return self._jsons", "def from_json_string(json_string):\n lis = []\n # not sure if empty means empty string or len(jstr) < 1\n if js...
[ "0.72202975", "0.69368917", "0.67421", "0.66768175", "0.6645266", "0.6635597", "0.66275007", "0.6596623", "0.65883756", "0.6534859", "0.65097266", "0.649942", "0.6445076", "0.64182377", "0.639221", "0.63367516", "0.63324165", "0.6328018", "0.6289109", "0.62636733", "0.6263069...
0.61519843
29
creates an instance according to dictionary
def create(cls, **dictionary): if cls.__name__ == 'Rectangle': dummy = cls(1, 1) elif cls.__name__ == 'Square': dummy = cls(1) dummy.update(**dictionary) return dummy
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create(cls, dictionary):\n return cls(**dictionary)", "def create(cls, dictionary):\n return cls(**dictionary)", "def from_dict(cls, dictionary: Dict[str, Any]):\n return cls(**dictionary)", "def from_dict(cls, dct):\n return cls(**dct)", "def _from_dict(cls, _dict):\n ...
[ "0.8319628", "0.8319628", "0.7552757", "0.7533553", "0.7414422", "0.7414422", "0.7414422", "0.7414422", "0.7414422", "0.7414422", "0.7414422", "0.7414422", "0.7414422", "0.7414422", "0.7414422", "0.7414422", "0.7414422", "0.7414422", "0.7414422", "0.7414422", "0.7414422", "...
0.0
-1
reads from a file and creates the intances
def load_from_file(cls): list_obj = [] if os.path.exists(cls.__name__ + ".json"): with open(cls.__name__ + ".json", "r") as _file: str_json = _file.read() _file.close() _dict = Base.from_json_string(str_json) for obj in _dict: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_from_file(cls):\n \"\"\"1.- Create the file name, 2.- if path file no exits return []\n 3.- open the file name, 4.- loop through the file\n 5.- return list of ints\"\"\"\n filename = \"{}.json\".format(cls.__name__)\n if not os.path.exists(filename):\n r...
[ "0.6358414", "0.63566375", "0.6336111", "0.6277758", "0.6251878", "0.60657245", "0.60147566", "0.59957486", "0.59948915", "0.5992617", "0.59894", "0.59858894", "0.5941638", "0.58933896", "0.58817434", "0.58768547", "0.5874155", "0.58669645", "0.5833577", "0.57960504", "0.5785...
0.0
-1
JSON string representation of list_objs to a file
def save_to_file_csv(cls, list_objs): list_dictionaries = [] if list_objs is None or list_objs == []: string_dictionary = "[]" else: for _obj_dict in list_objs: list_dictionaries.append(_obj_dict.to_dictionary()) string_dictionary = Base.to_jso...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def save_to_file(cls, list_objs):\n l = []\n if list_objs is not None:\n for item in list_objs:\n l.append(item.to_dictionary())\n with open(\"%s.json\" % cls.__name__, mode='w') as f:\n f.write(Base.to_json_string(l))", "def save_to_file(cls, list_objs):...
[ "0.8021217", "0.80143976", "0.7999722", "0.7985439", "0.7923821", "0.7889796", "0.7888717", "0.78478926", "0.7845653", "0.78098357", "0.78060126", "0.77895397", "0.7751209", "0.7748819", "0.772234", "0.7691926", "0.76581436", "0.7604948", "0.75762635", "0.75700843", "0.755554...
0.69005895
25
reads from a file and creates the intances
def load_from_file_csv(cls): list_obj = [] if os.path.exists(cls.__name__ + ".csv"): with open(cls.__name__ + ".csv", "r") as _file: str_csv = _file.read() _file.close() _dict = Base.from_json_string(str_csv) for obj in _dict: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_from_file(cls):\n \"\"\"1.- Create the file name, 2.- if path file no exits return []\n 3.- open the file name, 4.- loop through the file\n 5.- return list of ints\"\"\"\n filename = \"{}.json\".format(cls.__name__)\n if not os.path.exists(filename):\n r...
[ "0.63567036", "0.6355083", "0.63326615", "0.6274728", "0.62502545", "0.60678226", "0.6013601", "0.5995004", "0.5992842", "0.59915745", "0.59869564", "0.5984891", "0.5938049", "0.5894676", "0.58824164", "0.58747244", "0.5870898", "0.5865954", "0.5832284", "0.57970357", "0.5783...
0.0
-1
Allows user to only connect each core area to its N nearest neighbors, then connect any disjunct clusters ('constellations') of core areas to their nearest neighboring cluster
def STEP4_refine_network(): try: lu.dashline(1) gprint('Running script ' + _SCRIPT_NAME) cfg.gp.Workspace = cfg.OUTPUTDIR linkTableFile = lu.get_prev_step_link_table(step=4) linkTable = lu.load_link_table(linkTableFile) numLinks = linkTable.shape[0] ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_core_bonds(core_xyz, inp):\n core_bonds = []\n\n if inp.core_en:\n dists = cdist(core_xyz, core_xyz)\n if inp.core_shape != \"shell\":\n logger.info(\"\\tBuilding elastic network based on first neighbors...\")\n close_dists = dists <= (2*inp.bead_radius+0.01)\n ...
[ "0.6019846", "0.60152286", "0.5996917", "0.56130326", "0.55830246", "0.55370057", "0.55127627", "0.5473926", "0.54616666", "0.54497075", "0.5434475", "0.54049015", "0.5365641", "0.5363584", "0.5359697", "0.532522", "0.5316786", "0.5285515", "0.5274904", "0.52493495", "0.52436...
0.58778304
3
Initialize the caffe network.
def __init__(self, settings): super(CaffeNet, self).__init__(settings) self._range_scale = 1.0 # not needed; image already in [0,255] #ULF[todo]: explain, make this a setting self._net_channel_swap = (2,1,0) #self._net_channel_swap = None if self._net_chan...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _init_caffe(cfg):\n\n import caffe\n # fix the random seeds (numpy and caffe) for reproducibility\n np.random.seed(cfg.RNG_SEED)\n caffe.set_random_seed(cfg.RNG_SEED)\n # set up caffe\n caffe.set_mode_gpu()\n caffe.set_device(cfg.GPU_ID)", "def _initialize_caffe(deploy_file, input_weight...
[ "0.76390475", "0.7410132", "0.7011024", "0.6723683", "0.6674956", "0.6638482", "0.63359636", "0.6314752", "0.62236017", "0.61924094", "0.61798024", "0.6061521", "0.6030221", "0.59966195", "0.5933557", "0.59283644", "0.5893922", "0.58623326", "0.5858396", "0.5857669", "0.58410...
0.6931407
3
Check if the caffe version provides all required functions. The deep visualization toolbox requires a modified version of caffe, that supports deconvolution. Without this functions, the toolbox is able to run, but will not provide full functionality. This method will issue a warning, if caffe does not provide the requi...
def _check_caffe_version(self, caffe): if 'deconv_from_layer' in dir(caffe.classifier.Classifier): print "debug[caffe]: caffe version provides all required functions. Good!" else: print "warning: Function 'deconv_from_layer' is missing in caffe. Probably you are using a wrong caf...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_supported_features(self):", "def check_model(self):\n layers_map = self.core.query_network(network=self.network,\n device_name=self.device)\n\n unsupported_layers = [\n l for l in self.network.layers.keys() if l not in layers_map\n ...
[ "0.6309257", "0.5592987", "0.5414365", "0.5400118", "0.5359996", "0.5341707", "0.53116417", "0.52959627", "0.524418", "0.52095294", "0.5181111", "0.51800066", "0.5171557", "0.516595", "0.5159423", "0.5142306", "0.51367754", "0.51344347", "0.5122423", "0.5117072", "0.5110706",...
0.86351883
0
Initialize the data mean. The data mean values are loaded from a separate file. Caffe can use thes
def _init_data_mean(self): if isinstance(self.settings.caffevis_data_mean, basestring): # If the mean is given as a filename, load the file try: data_mean = np.load(self.settings.caffevis_data_mean) except IOError: print '\n\nCound not load mea...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _load_train_data(self):\n\n self.train_loader = data.Train_loader(self.N_max, self.n_per_conn,\n self.data_path, self.device)\n self.train_loader.load_data()\n\n # load mean and std\n scc_mean_std = np.loadtxt(\n os.path.join(s...
[ "0.7117414", "0.6322619", "0.6275586", "0.61665565", "0.61113983", "0.6075296", "0.60675895", "0.60323304", "0.6005589", "0.5972925", "0.5936495", "0.593206", "0.5929003", "0.5923068", "0.5913995", "0.5909106", "0.5898676", "0.58928245", "0.5888134", "0.5873146", "0.5871425",...
0.8448032
0
Check the force_backward flag is set in the caffe model definition. Checks whether the given file contains a line with the
def _check_force_backward_true(self): prototxt_file = self.settings.caffevis_deploy_prototxt found = False with open(prototxt_file, 'r') as ff: for line in ff: fields = line.strip().split() if len(fields) == 2 and fields[0] == 'force_backward:' and fi...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validate(self, checkpoint_file_path, output_file):\n\n print('Loading model...')\n self.cfg.data.test.test_mode = True\n self.cfg.model.pretrained = None\n\n model = build_detector(self.cfg.model, train_cfg=None,\n test_cfg=self.cfg.test_cfg)\n f...
[ "0.5316316", "0.5299176", "0.52399695", "0.5212688", "0.518687", "0.5174068", "0.51119065", "0.5104641", "0.508452", "0.5083251", "0.49776924", "0.49598014", "0.49144304", "0.49131376", "0.4904619", "0.48898187", "0.4878091", "0.48573712", "0.48020813", "0.47783345", "0.47759...
0.7716643
0
Get the layer identifiers of the network layers.
def get_layer_ids(self, include_input = True): layers = self.net.blobs.keys() if not include_input: layers = layers[1:] return layers
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def layer_names(self):\n return self._layer_names", "def getLayerNames(self):\n\t\treturn self._fileSystem.getLayerNames()", "def get_layer_ids(\n self,\n ):\n name_to_id = {}\n for n, _ in self.named_parameters():\n name_to_id[n] = 0\n return name_to_id", "de...
[ "0.7665354", "0.7556004", "0.73628604", "0.7221689", "0.70648915", "0.69622135", "0.6921894", "0.68877995", "0.6855709", "0.68437696", "0.68299043", "0.6828836", "0.6798301", "0.6783592", "0.6777249", "0.67631555", "0.67354053", "0.67091215", "0.6681927", "0.6678638", "0.6614...
0.73892903
2
Get the identifier for the input layer.
def get_input_id(self): return self.net.inputs[0]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def layer_name(self) -> pulumi.Input[str]:\n return pulumi.get(self, \"layer_name\")", "def getId(self):\n return _libsbml.Input_getId(self)", "def layer_name(self) -> Optional[pulumi.Input[str]]:\n return pulumi.get(self, \"layer_name\")", "def input_context_id(self) -> uuid.UUID:\n ...
[ "0.7396382", "0.7224933", "0.6950218", "0.678996", "0.6704823", "0.6689467", "0.65569127", "0.65569127", "0.65569127", "0.65165687", "0.65165687", "0.6348905", "0.63131356", "0.63131356", "0.63131356", "0.62872255", "0.62872255", "0.62817043", "0.62789243", "0.6232706", "0.62...
0.7791593
0
Get the shape of the given layer.
def get_layer_shape(self,layer_id): return self.net.blobs[layer_id].data.shape[1:] # Chop off batch size
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def vshape(self, layer_name):\n if (\n layer_name in self.config[\"layers\"]\n and \"vshape\" in self.config[\"layers\"][layer_name]\n ):\n return self.config[\"layers\"][layer_name][\"vshape\"]\n else:\n return None", "def shape(self):\n re...
[ "0.6944331", "0.6796373", "0.6796373", "0.6788921", "0.67862785", "0.6770543", "0.66934526", "0.66934526", "0.66934526", "0.6661691", "0.66413033", "0.65672153", "0.65354097", "0.65207624", "0.6502295", "0.6502295", "0.64716536", "0.64617896", "0.64338744", "0.6427219", "0.63...
0.7470105
0
Provide activation data for a given layer.
def get_layer_data(self, layer_id, unit = None, flatten = False): data = self.net.blobs[layer_id].data return data.flatten() if flatten else (data[0] if unit is None else data[0,unit])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def output_layer_activation(x):\n return x", "def activate(self, input_layer, funcname=None):\n if isinstance(funcname, tuple):\n funcname = funcname[0]\n params = funcname[1:]\n if funcname is None:\n funcname = self.activation_func\n if funcname == 'LINE...
[ "0.6460981", "0.6062723", "0.60399526", "0.5887664", "0.5849229", "0.5708068", "0.5705232", "0.5681533", "0.56690735", "0.56690735", "0.5618413", "0.55843806", "0.5550777", "0.55110264", "0.55081254", "0.5502482", "0.54806435", "0.5478139", "0.5475493", "0.54520005", "0.54329...
0.54616404
19
Provide diff data for a given layer.
def get_layer_diff(self, layer_id, flatten = False): diff = self.net.blobs[layer_id].diff return diff.flatten() if flatten else diff[0]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_diff_dc(self):\n self._diff_dc = tuple(encode_differential(self.data[:, 0, 0]))", "def record_from_diff_layer( self, layer_name, layer, text_category, start_new_doc=True ):\n assert isinstance(text_category, str)\n assert len(text_category) > 0\n if layer_name not in self.dif...
[ "0.6205495", "0.59054196", "0.57996625", "0.57300365", "0.56836796", "0.5591027", "0.55622244", "0.54525185", "0.5411178", "0.5383342", "0.53817004", "0.5350295", "0.52542555", "0.5209332", "0.51370484", "0.5130064", "0.5128682", "0.51156783", "0.51114106", "0.5077166", "0.50...
0.6409963
0
Prepare image data for processing and do forward propagation. Uses caffe.transformer.preprocess and caffe.net.forward
def preproc_forward(self, img, data_hw): appropriate_shape = data_hw + (3,) assert img.shape == appropriate_shape, 'img is wrong size (got %s but expected %s)' % (img.shape, appropriate_shape) #resized = caffe.io.resize_image(img, self.net.image_dims) # e.g. (227, 227, 3) data_blob = s...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def caffe_preprocess_and_compute(pimg, caffe_transformer=None, caffe_net=None,\n output_layers=None):\n import caffe # noqa\n\n if caffe_net is not None:\n\n # Grab the default output names if none were requested specifically.\n if output_layers is None:\n ...
[ "0.72574115", "0.71630454", "0.68571496", "0.68417084", "0.67703617", "0.6742037", "0.66416997", "0.66330516", "0.6609757", "0.6579736", "0.65306133", "0.6512324", "0.64565074", "0.6393043", "0.6366664", "0.6346399", "0.63361263", "0.6304797", "0.628596", "0.62672687", "0.625...
0.76032746
0
Get all marks for a student
def get_marks() -> Union[str, Response]: studentid_ = request.args.get("id") marks = Marks.query.get(studentid_) return render_template("marks.html", marks=marks, id=studentid_)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def students(self):\n\t\treturn self.grade_set.all().distinct()", "def get_students(self) -> List['Student']:\n return self.students.values()", "def list(self, request):\n\n marks = Marks.objects.all()\n\n mark_id_not_appointed = marks.filter(name='Неявка')\n\n records = filter_agai...
[ "0.6977941", "0.6782979", "0.6760504", "0.6710309", "0.67101634", "0.66821915", "0.66705525", "0.66550684", "0.6632196", "0.6598747", "0.6597735", "0.65887266", "0.6547072", "0.6538285", "0.6516437", "0.6514306", "0.64951736", "0.6415864", "0.64110035", "0.6409197", "0.639799...
0.6747031
3
Convert Model object to Dict
def to_dict(self, exclude_relations: bool = False) -> Dict[str, Any]: obj = { "id": self.id_, "oop": self.oop, "ds": self.ds, "dbms": self.dbms, } if not exclude_relations and self.student: obj["student"] = self.student.to_dict(exclude_...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_dict_model(self) -> dict:\n return dict((key, getattr(self, key)) for key in self.__mapper__.c.keys())", "def get_modelDict(self):\n return self.__modelDict", "def as_dict(self):\n data = dict()\n for name in self.fields:\n val = getattr(self, name)\n if isi...
[ "0.7772753", "0.7545338", "0.75007635", "0.7386044", "0.7380451", "0.7360071", "0.7360071", "0.7360071", "0.7360071", "0.7360071", "0.7360071", "0.7360071", "0.7360071", "0.7360071", "0.7360071", "0.7360071", "0.7360071", "0.7360071", "0.7360071", "0.7360071", "0.7360071", ...
0.0
-1
Convert Model object to Dict
def to_dict(self, exclude_relations: bool = False) -> Dict[str, Any]: obj = {"id": self.id_, "name": self.name, "email": self.email} if not exclude_relations and self.marks: obj["marks"] = self.marks.to_dict(exclude_relations=True) return obj
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_dict_model(self) -> dict:\n return dict((key, getattr(self, key)) for key in self.__mapper__.c.keys())", "def get_modelDict(self):\n return self.__modelDict", "def as_dict(self):\n data = dict()\n for name in self.fields:\n val = getattr(self, name)\n if isi...
[ "0.7772314", "0.75445765", "0.7499804", "0.73852074", "0.73797524", "0.73599255", "0.73599255", "0.73599255", "0.73599255", "0.73599255", "0.73599255", "0.73599255", "0.73599255", "0.73599255", "0.73599255", "0.73599255", "0.73599255", "0.73599255", "0.73599255", "0.73599255", ...
0.0
-1
Return a listing of filenames in container `container_name`
def get_full_container_list(container_name, **kwargs): limit = 10000 kwargs['limit'] = limit page = [] seed = [] _, page = get_conn().get_container(container_name, **kwargs) seed.extend(page) while len(page) == limit: # keep getting pages.. kwargs['marker'] = seed[-1]['name'...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def list_files(self, container_name, dir_path):\n blobs = RetryHandler.retry(lambda: self.blob_client.list_blobs(container_name, prefix=dir_path))\n for b in blobs:\n yield b.name", "def ls():\n # TODO: listing all availabe containers form sequence\n return", "def list_container_...
[ "0.70418733", "0.67702264", "0.6769166", "0.66230184", "0.6541029", "0.6491487", "0.635145", "0.63336426", "0.62661844", "0.6246632", "0.6239142", "0.6224878", "0.61673516", "0.607707", "0.60470575", "0.60361683", "0.5994393", "0.59836394", "0.5973972", "0.5932365", "0.592621...
0.6079826
13
remove file `object_name` fronm `container`
def delete_from_objectstore(container, object_name): return get_conn().delete_object(container, object_name)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_file(self, name, container):\r\n try:\r\n cnt = self.get_container(container)\r\n obj = cnt.get_object(name)\r\n obj.delete()\r\n return True\r\n except:\r\n return False", "def cleanup_file(name: str):\n if os.path.exists(name) a...
[ "0.7466576", "0.69941896", "0.6846898", "0.67901576", "0.6699955", "0.66047776", "0.6526113", "0.6439885", "0.643119", "0.6326143", "0.63085794", "0.628274", "0.6274823", "0.6250706", "0.6244471", "0.62241817", "0.6211132", "0.6202511", "0.6191036", "0.6189226", "0.6170251", ...
0.6012785
40
Checks CreateSymbolicLinkW and CreateHardLinkW result
def _errcheck_link(value, func, args): # pylint: disable=W0613 # The windows api returns nonzero if the call was successful if value != 0: return last_error = ctypes.windll.kernel32.GetLastError() # Somehow CreateSymbolicLinkW and CreateHardLinkW retuns zero # and the last error is 2 (The ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _symlink(source, link_name):\n flags = 0\n\n if source is not None and os.path.isdir(source):\n flags = 1\n\n CreateSymbolicLinkW(link_name, source, flags)", "def IsSymlink(info):\n return (info.external_attr >> 16) == 0120777", "def testIsSymlink(self):\r\n P=lambda p:ufsi.NativeUn...
[ "0.66747856", "0.6535924", "0.65076035", "0.63529927", "0.63279533", "0.62025636", "0.6157352", "0.6096215", "0.60850304", "0.6043955", "0.5876485", "0.58321327", "0.5827599", "0.5806281", "0.57590836", "0.56664973", "0.56608623", "0.5647082", "0.5577218", "0.55411834", "0.54...
0.73756194
0
Gets whether the specified path is symlink
def _islink(path): if not os.path.isdir(path): return False if not isinstance(path, str): path = str(path) attributes = ctypes.windll.kernel32.GetFileAttributesW(path) if attributes == INVALID_FILE_ATTRIBUTES: return False return (attributes & FILE_ATTRIBUTE_REPARSE_POINT)...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def IsSymlink(info):\n return (info.external_attr >> 16) == 0120777", "def islink(self, path):\n return os.path.islink(path)", "def is_symlink(self):\n return self._security_class == \"lnk_file\"", "def islink(self):\n return os.path.islink(self.path)", "def testIsSymlink(self):\r\n ...
[ "0.8075467", "0.805757", "0.804531", "0.776759", "0.7659457", "0.76041", "0.7551097", "0.7407655", "0.69485855", "0.68642277", "0.6857747", "0.68385595", "0.6785136", "0.67650145", "0.6695639", "0.66765994", "0.6640182", "0.66331863", "0.6607957", "0.657642", "0.6508227", "...
0.8072735
1
Sends a control code directly to a specified device driver, causing the corresponding device to perform the corresponding operation
def device_io_control(hDevice, ioControlCode, input_buffer, output_buffer): if input_buffer: input_size = len(input_buffer) else: input_size = 0 if isinstance(output_buffer, int): output_buffer = ctypes.create_string_buffer(output_buffer) output_size = len(output_buffer) as...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ControlDevice(self, p_device_obj, p_bridge_obj, p_control):\n pass", "def set_control(self, control):\n self.o.write_register(self.dev_id, CONTROL, control)", "def sendCommand(self, command, code):\r\n if self.visprotocol is not None:\r\n self.visprotocol.RequestArm(command.lowe...
[ "0.7349708", "0.66593874", "0.6332656", "0.62785393", "0.62031806", "0.61990625", "0.6130278", "0.61001945", "0.5950028", "0.58964723", "0.5859239", "0.58460295", "0.5833784", "0.5810393", "0.58021796", "0.58015263", "0.57831764", "0.57640386", "0.5756435", "0.5716313", "0.57...
0.5487066
43
symlink(source, link_name) Creates a symbolic link pointing to source named link_name
def _link(filename, existing_filename): CreateHardLinkW(filename, existing_filename, 0)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _symlink(source, link_name):\n flags = 0\n\n if source is not None and os.path.isdir(source):\n flags = 1\n\n CreateSymbolicLinkW(link_name, source, flags)", "def symlink(source, link_name):\n os_symlink = getattr(os, \"symlink\", None)\n if callable(os_symlink):\n os_symlink(sou...
[ "0.89288247", "0.8876284", "0.85235023", "0.84934396", "0.7926671", "0.7926671", "0.78701025", "0.75577664", "0.74797755", "0.74775594", "0.74321365", "0.74136615", "0.73979497", "0.7368539", "0.73560834", "0.73176056", "0.7311276", "0.7225434", "0.7115252", "0.70262945", "0....
0.6776435
26
symlink(source, link_name) Creates a symbolic link pointing to source named link_name
def _symlink(source, link_name): flags = 0 if source is not None and os.path.isdir(source): flags = 1 CreateSymbolicLinkW(link_name, source, flags)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def symlink(source, link_name):\n os_symlink = getattr(os, \"symlink\", None)\n if callable(os_symlink):\n os_symlink(source, link_name)\n else:\n import ctypes\n csl = ctypes.windll.kernel32.CreateSymbolicLinkW\n csl.argtypes = (ctypes.c_wchar_p, ctypes.c_wchar_p, ctypes.c_uin...
[ "0.8876452", "0.8523786", "0.8494452", "0.792622", "0.792622", "0.78699785", "0.7556373", "0.74791694", "0.7476503", "0.7431358", "0.74118215", "0.73978883", "0.73689723", "0.7355676", "0.7316988", "0.7311006", "0.72249603", "0.71154326", "0.7024773", "0.6996191", "0.69960237...
0.89284223
0
Remove (delete) the file path.
def _unlink(path): if os.path.isdir(path): os.rmdir(path) else: os.remove(path)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_file(self, path):\n pass", "def remove_file(path: str) -> None:\n\tremove(path)", "def remove(path):", "def remove(self, path):\n os.remove(path)", "def remove(path):\r\n os.remove(path)", "def _delete_file(path):\n if os.path.isfile(path):\n os.remove(path)", "def _de...
[ "0.8575248", "0.85514593", "0.8543619", "0.80981344", "0.8039138", "0.80014235", "0.80014235", "0.7996869", "0.7987687", "0.79770964", "0.789871", "0.7896457", "0.779882", "0.774982", "0.7706299", "0.76699555", "0.7597085", "0.7595738", "0.75720495", "0.75447977", "0.752521",...
0.68838435
76
compute the loss by mse.
def compute_mse(y, tx, w): e = y[:, np.newaxis] - tx @ w return (e * e).sum() / (2.0 * len(y))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def loss(self):\n return 'mse'", "def compute_loss(y, tx, w):\n # ***************************************************\n # INSERT YOUR CODE HERE\n # TODO: compute loss by MSE / MAE\n # ***************************************************\n \n # vector e\n e = compute_e(y, tx, w)\n N ...
[ "0.79968905", "0.78112125", "0.77875036", "0.77387816", "0.7710077", "0.7683224", "0.7581481", "0.755235", "0.75481623", "0.75082284", "0.746133", "0.74523973", "0.7419682", "0.7326585", "0.7233692", "0.72229743", "0.719127", "0.71770847", "0.7163547", "0.7153659", "0.7126694...
0.0
-1
apply sigmoid function on t.
def sigmoid(t): empty = np.empty(t.shape) empty[t > 0] = 1/(1+ np.exp(-t[t>0])) empty[t <= 0 ] = np.exp(t[t<=0])/(1+np.exp(t[t<=0])) return empty
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sigmoid(t):\n return np.exp(t)/(1+np.exp(t))", "def sigmoid(t):\n sig=np.exp(t)/(1+np.exp(t))\n return sig", "def sigmoid(t):\n\n return 1.0 / (1.0 + np.exp(-t))", "def sigmoid(t):\n return 1 / (1 + np.exp(-t))", "def sigmoid(t):\n\tprecLim = 10\n\t\n\tt[t<=-precLim] = 0\n\tt[t>-precLim]...
[ "0.9084493", "0.9020642", "0.9009438", "0.89938635", "0.87019694", "0.84522074", "0.82452095", "0.8217517", "0.8187859", "0.8187859", "0.8177547", "0.816389", "0.8141619", "0.8141619", "0.8141619", "0.8141619", "0.8141619", "0.8141619", "0.8134758", "0.8129746", "0.81269675",...
0.83401215
6
compute the cost by negative log likelihood.
def calculate_loss(y, tx, w): txw = np.matmul(tx, w) return np.logaddexp(0.0, txw).sum() - np.dot(y, txw)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def neg_log_likelihood(self,params: ndarray) -> float:\n\n return -self.compute_log_likelihood(params)", "def negative_loglikelihood(targets, estimated_distribution):\n return -estimated_distribution.log_prob(targets)", "def neg_log_prob(self,params: ndarray) -> float:\n return -self.compute_l...
[ "0.7580836", "0.7525892", "0.7487104", "0.7422111", "0.7362807", "0.7279322", "0.72771025", "0.71148443", "0.6981397", "0.6981397", "0.69556177", "0.6937678", "0.6937678", "0.6804322", "0.67947716", "0.67838323", "0.6766242", "0.6715737", "0.6708225", "0.6692491", "0.6668383"...
0.0
-1
compute the gradient of loss.
def calculate_gradient(y, tx, w): return tx.T.dot(sigmoid(tx.dot(w))-np.reshape(y,(len(y),1)))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _compute_func_grad(self, w):\n W = w.reshape((self.X.shape[1], self.Y.shape[1]))\n self.nll_, self.grad_ = calculate_gradient(self.X, self.Y, W, self.prior, self.weighted,0)", "def compute_gradient(self): # TODO: try to change to square loss since it's hessian is easier to obtain\n A = ...
[ "0.771996", "0.7632536", "0.7511436", "0.7478517", "0.7402254", "0.737251", "0.7371333", "0.73623466", "0.733666", "0.73268956", "0.7292868", "0.72923326", "0.72912985", "0.7275123", "0.72715396", "0.72657025", "0.725671", "0.72448146", "0.7228056", "0.7222739", "0.72068405",...
0.67537796
97
Do one step of gradient descent using logistic regression. Return the loss and the updated w.
def learning_by_gradient_descent(y, tx, w, gamma): loss = calculate_loss(y,tx,w) grad = calculate_gradient(y,tx,w) w_new = w - gamma*grad #grad is for debugging purpose return loss, w_new,grad
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def logistic_regression(y, tx, initial_w, max_iters, gamma, verbose=False):\n return gradient_descent(y, tx, initial_w, max_iters, gamma, \n compute_logistic_loss, compute_logistic_gradient, verbose=verbose)", "def logistic_regression(y, tx, initial_w, max_iters, gamma, SGD=False, b...
[ "0.7644181", "0.75494313", "0.75210464", "0.7391002", "0.739028", "0.7340964", "0.7276781", "0.722059", "0.7219143", "0.7217284", "0.71946394", "0.71824235", "0.71739787", "0.71082324", "0.706742", "0.7058422", "0.7055993", "0.70340157", "0.7005264", "0.6962209", "0.6934606",...
0.7177101
12
return the hessian of the loss function.
def calculate_hessian(y, tx, w): txw = tx.dot(w) diag = sigmoid(txw)*(np.ones(txw.shape)-sigmoid(txw)) return np.matmul(np.multiply(tx,diag).T,tx)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_hessian(self):\n return self.tc.hessian_func(\n self.pf.XS[:, :, 0].transpose(),\n self.pf.XS[:, :, 1].transpose(),\n self.pf.WS[:].transpose())", "def _get_hessian(self):\n if not self.sparse:\n hess = numpy.dot(self.jacobian_T, self.jacobian)\n ...
[ "0.834521", "0.790133", "0.76649565", "0.7542769", "0.75271446", "0.74744356", "0.74061686", "0.7341584", "0.7319745", "0.728702", "0.72354007", "0.7213091", "0.6957762", "0.69400805", "0.6881347", "0.6850703", "0.68455654", "0.67746145", "0.66698253", "0.66339695", "0.659485...
0.69072765
14
return the loss, gradient, and hessian.
def penalized_logistic_regression(y, tx, w, lambda_): penality = lambda_*np.linalg.norm(w)**2 diag = np.diag(np.repeat(2*lambda_, len(w))) return calculate_loss(y,tx,w) + penality, calculate_gradient(y,tx,w) + lambda_*2*w, calculate_hessian(y,tx,w) + diag
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_gradients_hessian(self, loss, params):\n params = nest.flatten(params)\n with backend.get_graph().as_default(), backend.name_scope(self._name +\n \"/gradients\"):\n grads = gradients.gradients(loss, params)\n ...
[ "0.6856902", "0.6587197", "0.6514546", "0.6497889", "0.64809215", "0.6430479", "0.6419421", "0.6375835", "0.6317636", "0.6299287", "0.62901235", "0.62769735", "0.6252391", "0.6198472", "0.61468744", "0.61453986", "0.61426014", "0.61353195", "0.6083347", "0.6068446", "0.605627...
0.0
-1
Do one step of gradient descent, using the penalized logistic regression. Return the loss and updated w.
def learning_by_penalized_gradient(y, tx, w, gamma, lambda_): #on test avec Newton loss,gradient,_ = penalized_logistic_regression(y,tx,w,lambda_) w = w - gamma*gradient return loss, w,gradient
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def logistic_regression(y, tx, initial_w, max_iters, gamma, SGD=False, batch_size=-1) :\n w_start = initial_w\n w = w_start\n loss_old = 0.0\n\n for n_iter in range(max_iters):\n loss = compute_logistic_loss(y, tx, w)\n gradient = compute_logistic_gradient(y, tx, w)\n w = w - gamma...
[ "0.73400915", "0.73364216", "0.7324017", "0.7254778", "0.7247224", "0.71955043", "0.71402735", "0.7048719", "0.7041636", "0.7035282", "0.7029137", "0.70200825", "0.6988818", "0.69542164", "0.69512326", "0.6946754", "0.6945803", "0.69186187", "0.6913374", "0.6897523", "0.68823...
0.71503675
6
Generate a minibatch iterator for a dataset. Takes as input two iterables (here the output desired values 'y' and the input data 'tx') Outputs an iterator which gives minibatches of `batch_size` matching elements from `y` and `tx`. Data can be randomly shuffled to avoid ordering in the original data messing with the ra...
def batch_iter(y, tx, batch_size, num_batches=1, shuffle=True): data_size = len(y) if shuffle: shuffle_indices = np.random.permutation(np.arange(data_size)) shuffled_y = y[shuffle_indices] shuffled_tx = tx[shuffle_indices] else: shuffled_y = y shuffled_tx = tx fo...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def batch_iter(y, tx, batch_size, num_batches=1, shuffle=True): \n data_size = len(y)\n\n if shuffle:\n shuffle_indices = np.random.permutation(np.arange(data_size))\n shuffled_y = y[shuffle_indices]\n shuffled_tx = tx[shuffle_indices]\n else:\n shuffled_y = y\n shuffled...
[ "0.77580273", "0.7647815", "0.754106", "0.7499344", "0.746608", "0.7347283", "0.721553", "0.71331227", "0.7097912", "0.68929577", "0.6827464", "0.6823077", "0.6732812", "0.67166024", "0.6689807", "0.66870743", "0.6683438", "0.66705924", "0.65844756", "0.6563109", "0.65422416"...
0.7640046
4
assumes we're using integer x,y that are within the image bounds
def pixelToDegClean(self, x, y): lon = self.minLon + x * self.lonInc lat = self.pixelLat[self.res[1] - 1 - y] return lon,lat
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _in_bounds(self, x, y):\r\n return 0 <= x < 8 and 0 <= y < 8", "def get_pixel(image, x, y):\n x = in_bound(image[\"height\"], x)\n y = in_bound(image[\"width\"], y)\n \n return image['pixels'][ x * image[\"width\"] + y]", "def isInsideImage(x, y, nx, ny, imageNx, imageNy):\r\n return ...
[ "0.684165", "0.67043024", "0.6673661", "0.6622537", "0.6593363", "0.65620965", "0.6542707", "0.65369433", "0.6492049", "0.64885294", "0.64626515", "0.6431025", "0.64090705", "0.638157", "0.6376144", "0.6367209", "0.6340549", "0.6340549", "0.63274217", "0.63184506", "0.631829"...
0.0
-1
Returns the existing unique instance if any, or creates a new one before doing so
def __call__(self, *args, **kwargs): if not self.instance: self.instance = super().__call__(*args, **kwargs) return self.instance
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_unique_instance(type_):\n global unique_object_id\n ret = None\n\n if type_ is tuple:\n ret = tuple([unique_object_id])\n\n unique_object_id += 1\n return ret", "def get_or_create(self, **kwargs):\n kwargs = self._preprocess(**kwargs)\n found = self.first(**kwargs)\n ...
[ "0.7143493", "0.71006346", "0.6911942", "0.6777109", "0.66630805", "0.6536835", "0.6469977", "0.64263636", "0.6366577", "0.6366577", "0.63647413", "0.6363849", "0.63035256", "0.6276719", "0.62716794", "0.6248085", "0.6246898", "0.62277615", "0.61890703", "0.6164096", "0.61426...
0.638062
8
Initializer for logger. Logs some introductory messages
def __init__(self): s = "{0}\n{1:^150}\n{0}\n".format("="*150, "N E B I L A N D") self.log(s) self.table_log("Iteration", "Datetime", "Event", "Entity Affected", "Extra Info") self.log("-"*150)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initLogger(self):\n loglevel = self.loglevels[self.loglevel]\n log_format = '%(asctime)s name=%(name)s loglevel=%(levelname)s message=%(message)s'\n logging.basicConfig(format=log_format,\n level=loglevel)\n \tmultiprocessing.log_to_stderr(loglevel)", "def _...
[ "0.796156", "0.7796052", "0.77478737", "0.77401537", "0.76802033", "0.7661703", "0.76467276", "0.760825", "0.75913095", "0.7587696", "0.7584787", "0.75434154", "0.75162506", "0.74999154", "0.7474488", "0.74718666", "0.74508023", "0.7385292", "0.73413754", "0.7306113", "0.7305...
0.0
-1
Logs the given inputs in tabular form according to the specifications
def table_log(self, iteration, dt, name, entity, extra): s = self.__format.format(iteration, dt, name, entity, extra) self.log(s)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def showInput( Tables, LayersInfo ):\n\n Tables[ \"ElasticModulus\" ].fillTableWithBufferData( \"Input\" )\n Tables[ \"ShearModulus\" ].fillTableWithBufferData( \"Input\")\n Tables[ \"PoissonRatios\" ].fillTableWithBufferData( \"Input\" )\n Tables[ \"MaterialProperties\" ].fillTableWithBufferData( \"In...
[ "0.59025437", "0.5595348", "0.5479879", "0.5442281", "0.5421877", "0.54134625", "0.5390005", "0.533628", "0.53107667", "0.52907676", "0.5278041", "0.52709395", "0.52709395", "0.52679795", "0.5247194", "0.5232541", "0.5192523", "0.51739985", "0.51507646", "0.5137148", "0.51252...
0.56412184
1
Records 'string' to the inner message array
def log(self, string): if self.PRINT: print(string) sys.stdout.flush() self.message_list.append(string)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def message(self, string):\n print (string)", "def __add_data(self, string):\n encoded = string.encode()\n header = NTR('data {}\\n').format(len(encoded))\n self.__append(header.encode() + encoded)", "def add_message_to_list(message):\n messages.append(ast.literal_eval(messag...
[ "0.605422", "0.59752476", "0.59538656", "0.58901", "0.5728579", "0.57223994", "0.5720431", "0.56584924", "0.5648494", "0.5642683", "0.5633131", "0.5604764", "0.55973125", "0.5571379", "0.5537977", "0.55165595", "0.55126595", "0.55072063", "0.547958", "0.54738235", "0.5461688"...
0.60436004
1
Writes all records to file
def write(self): with open("log.txt", 'w') as f: for message in self.message_list: f.write(message + "\n")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def write_all(self):\r\n pass", "def writeAlltoFile(self):\n with open(self._fname, 'w') as f:\n for elem in self.getAll():\n line = self._writeGratoLine(elem)\n f.write(line + \"\\n\")\n f.close()", "def to_file(self, records):\n self._f...
[ "0.7303621", "0.7263717", "0.69641715", "0.6811983", "0.6752459", "0.65664893", "0.6554515", "0.6495277", "0.648081", "0.64806825", "0.6404646", "0.63986415", "0.6398186", "0.6377216", "0.63647765", "0.6357472", "0.6346913", "0.6339491", "0.6328891", "0.63206065", "0.6292219"...
0.0
-1
Converts day and time values to a single integer timestamp. Considers a single week only.
def datetime_to_time(day, time): try: n_day = _day_map.index(day) * 60 * 24 except KeyError as e: raise Exception("Invalid date string '{}'".format(day)) hour = int(time[:2]) if hour > 23: raise Exception("Invalid hour {}".format(hour)) minutes = int(time[3:]) n_time = ho...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def CONST_WEEK_TIMESTAMP() -> int:\n return 604800", "def timestamp(self, t):\n if isinstance(t, datetime):\n t = time.mktime(t.timetuple())\n return t - 631065600", "def unixtimestampformat(value):\n if value is None:\n return 0\n return int(calendar.timegm(value.timet...
[ "0.66671306", "0.6021344", "0.60111976", "0.6006531", "0.59480613", "0.59391356", "0.5931859", "0.59231", "0.5886632", "0.58266985", "0.5825142", "0.5823242", "0.5820634", "0.5817202", "0.5776992", "0.57552594", "0.5744047", "0.57393855", "0.5719624", "0.5710939", "0.57031125...
0.0
-1
Time object used to manage timestamping and time management
def __init__(self, day, hour, minute): self.day = day self.hour = hour self.minute = minute
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def time(self):\n return Time(self.hour, self.minute, self.second)", "def time(self):\n return time(\n self.hour, self.minute, self.second, self.microsecond, fold=self.fold\n )", "def time(self):\n try:\n if self.single_date:\n return self.stime\...
[ "0.76335406", "0.7251305", "0.6828011", "0.6810718", "0.6791283", "0.6786434", "0.6779378", "0.6773202", "0.6726197", "0.67251045", "0.66960126", "0.6662842", "0.66509837", "0.6638317", "0.6638317", "0.6638317", "0.66160846", "0.6589688", "0.65787965", "0.65550697", "0.652202...
0.0
-1
Returns an integer codifying the actual day and time Because we only model a week, the effective maximum value is 90060
def raw(self): return self.day*60*24 + self.hour*60 + self.minute
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _unit_day(self):\n return (self.time_base * 60.0) * 24.0", "def scaledTime():\n #return (time.gmtime().tm_wday, time.gmtime().tm_hour)\n epoch = time.strptime(\"2013-02-21 11:30:00\", \"%Y-%m-%d %H:%M:%S\")\n timeInSec = time.mktime(time.gmtime()) - time.mktime(epoch)\n hourSince = timeInS...
[ "0.6822729", "0.6800442", "0.671761", "0.6645342", "0.6588621", "0.65614766", "0.6522636", "0.64839315", "0.6381843", "0.6367486", "0.6346273", "0.63235843", "0.6287894", "0.62772983", "0.62772983", "0.62371236", "0.62271863", "0.62144136", "0.6200029", "0.6178101", "0.614856...
0.5741346
37
Returns the equivalent timestamp of only the hour and minutes
def time(self): return self.raw() % (60 * 24)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def hour():\r\n\r\n date = datetime.datetime.now()\r\n hours = date.hour\r\n minute = date.minute\r\n\r\n return hours, minute", "def get_timestamp():\n now, s=get_date()\n return (now, \"%s%s%s%s\" % (s, str(now.hour).zfill(2), str(now.minute).zfill(2), str(now.second).zfill(2)))", "def time...
[ "0.6707628", "0.65402037", "0.6537106", "0.65262383", "0.6353101", "0.6348734", "0.63435024", "0.6226907", "0.61625046", "0.61538637", "0.61500865", "0.6146711", "0.614611", "0.6140933", "0.6134986", "0.61103296", "0.609769", "0.6095408", "0.60573125", "0.6056635", "0.605502"...
0.5821346
44
Returns the equivalent timestamp of just the day
def day_ts(self): return self.raw() // (60 * 24)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _make_timestamp(self):\r\n\t\tlogger.debug(\"Get a timestamp\")\r\n\t\treturn time.mktime(datetime.today().timetuple())", "def get_timestamp(self, days=1):\n offset = datetime.datetime.utcnow().date() - datetime.timedelta(days=days-1)\n # est = tz.gettz('Europe/Amsterdam')\n # temporary ...
[ "0.67507184", "0.6686723", "0.66458243", "0.66195476", "0.6554564", "0.651344", "0.6512791", "0.6455556", "0.6454444", "0.6416096", "0.64133775", "0.6387338", "0.6334385", "0.63157105", "0.63127744", "0.6266428", "0.6238006", "0.6220144", "0.6213184", "0.61673725", "0.6166025...
0.76245064
0
Turns an integer timestamp to a Time object
def timestamp_to_time(timestamp): n_day = timestamp // (60*24) n_time = timestamp - n_day * (60*24) n_hour = n_time // 60 n_minutes = n_time - n_hour * 60 return Time(n_day, n_hour, n_minutes)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _time_from_timestamp(timestamp: int) -> time:\n SECONDS_IN_MINUTE = 60\n SECONDS_IN_HOUR = 60 * SECONDS_IN_MINUTE\n\n remaining_time = timestamp\n hour, remaining_time = divmod(remaining_time, SECONDS_IN_HOUR)\n minute, second = divmod(remaining_time, SECONDS_IN_MINUTE)\n\n return time(hour, ...
[ "0.75011736", "0.73684907", "0.73529524", "0.7269059", "0.71579236", "0.71579236", "0.6700021", "0.659858", "0.65557265", "0.65520114", "0.6545578", "0.65429866", "0.6487895", "0.64222044", "0.64216304", "0.641571", "0.6412379", "0.63947934", "0.63376164", "0.6257602", "0.623...
0.76291776
0
Flip the specified image left to right and return the modified image
def flip_horizontal(img): #reading image im = Image.open("filename") #flipping image horizontally newimg = im.transpose(PIL.Image.FLIP_LEFT_RIGHT) return img
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def flip_image(image):\n return cv2.flip(image, flipCode=1)", "def __flip(img, flip, flip_type=Image.FLIP_LEFT_RIGHT):\n if flip:\n return img.transpose(flip_type)\n return img", "def flip_image(image):\n\n return cv2.flip(image, 1)", "def mirrorImage(self):\n\n im = Image.open(self...
[ "0.80972916", "0.8004548", "0.79841244", "0.78248584", "0.77829045", "0.7776855", "0.773181", "0.77152056", "0.76048005", "0.75489193", "0.7479404", "0.7456551", "0.7433488", "0.74209726", "0.74114513", "0.73366135", "0.72746193", "0.7241278", "0.71419924", "0.70937365", "0.7...
0.7879859
3
Apply the sepia tone transformation to the specified image, and return the modified image
def sepia_tone(img): #reading image im = Image.open("filename") #defining sepia sepia = make_linear_ramp((255,240,192)) #converting to grayscale if im.mode != "L": im = im.convert("L") #converting to sepia im.putpalette(sepia) return img
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sepia_filter(image_filename):\n if not os.path.exists(f'{image_filename}'):\n raise FileNotFoundError(f'The input filename, {image_filename}, does not exitst')\n image = cv2.imread(image_filename)\n image_rgb = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)\n sepia_matrix = [[0.393, 0.769, 0.189], [...
[ "0.63036513", "0.62655187", "0.61923456", "0.6135245", "0.60255116", "0.60221195", "0.59708905", "0.59675497", "0.58476627", "0.5686066", "0.5636777", "0.5627934", "0.55913067", "0.555422", "0.55318344", "0.55283034", "0.55268687", "0.5449728", "0.5449728", "0.5435592", "0.54...
0.7549688
0
Apply the gray scale transformation to the specified image, and return the modified image
def convert_to_gray_scale(img): #reading image im = Image.open("filename") if im.mode != "L": im = im.convert("L") return img
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def gray_scale_image(image, *args, **kwargs):\n # TODO: Implement the method\n\n gray_scale = num.dot(image, [0.298, 0.587, 0.114])\n\n return gray_scale", "def gray_scale_img(img):\n if len(img.shape) == 2:\n img_gray = img.copy()\n elif len(img.shape) == 3:\n if img.shape[2] == 1:\...
[ "0.75274485", "0.71785945", "0.6993295", "0.69583297", "0.6955463", "0.69422626", "0.68388724", "0.6832451", "0.6832451", "0.68103856", "0.68103856", "0.67366886", "0.67170113", "0.67103714", "0.66923", "0.66740435", "0.66464615", "0.66390836", "0.66221863", "0.66001034", "0....
0.68675184
6
Flip the specified image upside down and return the modified image
def flip_vertical(img): #reading image im = Image.open("filename") #flipping image vertically newimg = im.transpose(PIL.Image.FLIP_TOP_BOTTOM) return img
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def flip_image(image):\n return cv2.flip(image, flipCode=1)", "def flip_image(image):\n\n return cv2.flip(image, 1)", "def __flip(img, flip, flip_type=Image.FLIP_LEFT_RIGHT):\n if flip:\n return img.transpose(flip_type)\n return img", "def flip_image(img, vert=True):\n if vert:\n ...
[ "0.81318957", "0.8086061", "0.78788996", "0.78750557", "0.7762077", "0.77340347", "0.7647555", "0.75921685", "0.7583455", "0.75695246", "0.75460464", "0.7517043", "0.74985737", "0.74660903", "0.73753077", "0.7333656", "0.7311368", "0.7263419", "0.7192772", "0.71631706", "0.71...
0.78736997
4
Rotate the specified image 90 degrees to the right and return the modified image
def rotate_right_90(img): #reading image im = Image.open("filename") #flipping image 90 degrees newimg = im.transpose(PIL.Image.ROTATE_90) return img
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rotated_image(image):\n orientation = parameter('Orientation',90) # in degrees counter-clockwise\n if orientation == None: orienation = 0\n return image.rotate(orientation)", "def rotate_image(image):\n return tf.image.rot90(image)", "def apply_rotation(image):\n\n\t# Load the image into a new ...
[ "0.81389964", "0.7862073", "0.76297975", "0.74537015", "0.7406075", "0.74016446", "0.73322016", "0.7293305", "0.7235672", "0.72160155", "0.7200374", "0.71974003", "0.71129453", "0.70985675", "0.70875394", "0.70830107", "0.70608974", "0.7029308", "0.70149535", "0.69883496", "0...
0.8637562
0
Apply the red filter transformation to the specified image, and return the modified image
def red_filter(img): #with Image.open(filename) as img: w = img.width h = img.height newimg = Image.new('RGB', (w,h)) for y in range(h): for x in range(w): r, g, b = img.getpixel((x,y)) newimg.putpixel((x, y), (r, 0, 0)) return n...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def transform_image(self):\n im = cv2.imread(\"result.png\", 0)\n im2 = cv2.resize(im, (28, 28))\n im = im2.reshape(28, 28, -1)\n im = im.reshape(1, 1, 28, 28)\n im = cv2.bitwise_not(im)\n im = im.reshape(28,28)\n \n with out:\n clear_output()\n ...
[ "0.6625443", "0.6617209", "0.65860623", "0.65070266", "0.65070266", "0.6466145", "0.6289985", "0.6281362", "0.62701166", "0.62686855", "0.6268338", "0.62629455", "0.62200516", "0.61386067", "0.6090802", "0.60895586", "0.6073873", "0.60302836", "0.6029795", "0.59945774", "0.59...
0.7478904
0
Apply the negative transformation to the specified image, and return the modified image
def negative(img): w = img.width h = img.height newimg = Image.new('RGB', (w,h)) for y in range(h): for x in range(w): p = img.getpixel((x,y)) # in mode RGBA, p is a 4-tuple, in mode RGB a 3-tuple newpixel = (255 - p[0], 255 - p[1], 255...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def negate_image(p):\n img = read_img(p)\n img_negative = negativo(img.reshape((-1)))\n show_imgs([img, img_negative.reshape(img.shape)])", "def transform(self, previousimage):", "def _apply_transform(self, img: np.ndarray): \n img = self.transform(image=img)[\"image\"]\n return img", ...
[ "0.6982764", "0.68320686", "0.66874176", "0.66874176", "0.6649427", "0.6583862", "0.6541176", "0.6463704", "0.6367161", "0.63568556", "0.6352128", "0.6332034", "0.63253516", "0.63253516", "0.63253516", "0.63253516", "0.63253516", "0.6307967", "0.62963116", "0.6240215", "0.623...
0.71091735
0
Returns the name of the CSV file associated with active monitor.
def monitors_file_name(self) -> str: result = ctypes.c_char_p(self.dss_obj.MonitorsS(ctypes.c_int32(0), ctypes.c_int32(0))) return result.value.decode('ascii')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getActiveName(self):\n aw = self.activeWindow()\n if aw:\n return aw.getFileName()\n else:\n return None", "def _get_csv_path(name):\n return os.path.join(cwd, 'output/app_info', name)", "def filename(self):\n return self.system.fileName()", "def monit...
[ "0.60110694", "0.58750284", "0.5766104", "0.56713307", "0.559028", "0.5538154", "0.5519725", "0.55033624", "0.54591256", "0.5454045", "0.5453486", "0.54391897", "0.5412839", "0.5412839", "0.53502816", "0.5346869", "0.5337917", "0.53117466", "0.5284131", "0.5263165", "0.526074...
0.69333947
0
Returns the active Monitor object by name.
def monitors_read_name(self) -> str: result = ctypes.c_char_p(self.dss_obj.MonitorsS(ctypes.c_int32(1), ctypes.c_int32(0))) return result.value.decode('ascii')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_object(self, name):\n return self._internal.objects[name]", "def monitor(self):\n if self._monitor is None:\n self._monitor = Monitor(self)\n return self._monitor", "def get_obj_by_name(name: str) -> Any:\r\n module, obj_name = Onrolux.get_module_from_obj_name(nam...
[ "0.634177", "0.60703844", "0.60287845", "0.5986897", "0.5893533", "0.58250064", "0.5818918", "0.58065873", "0.57917553", "0.5720034", "0.57120705", "0.56297845", "0.55813944", "0.552004", "0.5505871", "0.5485105", "0.5470712", "0.54648685", "0.5443235", "0.5422984", "0.540945...
0.5568832
13
Sets the active Monitor object by name.
def monitors_write_name(self, argument) -> str: result = ctypes.c_char_p(self.dss_obj.MonitorsS(ctypes.c_int32(2), argument.encode('ascii'))) return result.value.decode('ascii')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def assignMonitoringTo(owner, objName):\n\n obj = MonitoredEnviron(getattr(owner, objName))\n setattr(owner, objName, obj)", "def SetActiveObject(self):", "def change_to(name):\n global screen_manager\n screen_manager.current = name", "def setMonitorParam(self, monName, *params):\n monitor...
[ "0.6686268", "0.6580047", "0.6451499", "0.63658905", "0.6082705", "0.60824007", "0.602823", "0.5998562", "0.59191376", "0.5818893", "0.5809507", "0.57683945", "0.5763107", "0.57524186", "0.57296056", "0.57296056", "0.5712642", "0.5712642", "0.5712642", "0.5712642", "0.5700079...
0.0
-1
Returns the full name of element being monitored by the active Monitor.
def monitors_read_element(self) -> str: result = ctypes.c_char_p(self.dss_obj.MonitorsS(ctypes.c_int32(3), ctypes.c_int32(0))) return result.value.decode('ascii')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getElementName(self):\n return _libsbml.Event_getElementName(self)", "def getElementName(self):\n return _libsbml.Port_getElementName(self)", "def getElementName(self):\n return _libsbml.Compartment_getElementName(self)", "def getElementName(self):\n return _libsbml.SBase_getE...
[ "0.7450548", "0.7423249", "0.7340012", "0.73263264", "0.7272811", "0.72024053", "0.7173537", "0.71433705", "0.7129742", "0.7111007", "0.70952076", "0.70849293", "0.70838827", "0.70769614", "0.701259", "0.700048", "0.6998356", "0.6996207", "0.69908535", "0.6989184", "0.6982886...
0.66672796
53
Sets the full name of element being monitored by the active Monitor.
def monitors_write_element(self, argument) -> str: result = ctypes.c_char_p(self.dss_obj.MonitorsS(ctypes.c_int32(4), argument.encode('ascii'))) return result.value.decode('ascii')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setName(self, name):\n self.name = str(name)", "def set_name(self, name):\n\t\tself.name_ = name", "def setName(self, name):\n self._name = name", "def setName(self, name):\n self._name = name", "def set_name(self, newname=\"\"):\n self.name = newname", "def setName(self, ...
[ "0.698972", "0.69490653", "0.6934929", "0.6934929", "0.69271183", "0.69211125", "0.6878148", "0.6878148", "0.6878148", "0.6878148", "0.6835848", "0.68147045", "0.68110657", "0.6795679", "0.678603", "0.67782116", "0.67782116", "0.67782116", "0.67782116", "0.67782116", "0.67709...
0.0
-1
Sends HTTP requests to create mock data according to the given command line options.
def main(option_list: List[str]): if "verbose" in option_list: verbose = True option_list.remove("verbose") else: verbose = False for option in option_list: if option == "mock-departments": create_departments(MOCK_DEPARTMENTS, verbose) elif option == "mo...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _setup_http_mock(self):\n if self.http_mock is not None:\n return\n\n filename = glob(f\"{DATASET_DIR}/{DATASETS[self.dataset]['file_pattern']}\")\n with open(filename[0]) as csv_file:\n csv_reader = csv.DictReader(csv_file, delimiter=DATASETS[self.dataset]['delimiter...
[ "0.59420115", "0.5708873", "0.5603419", "0.55786556", "0.55075824", "0.5487022", "0.54423136", "0.5397772", "0.53794146", "0.53646374", "0.5362348", "0.53264755", "0.52982754", "0.52700907", "0.52610075", "0.5255256", "0.5237482", "0.5213639", "0.52105945", "0.5188251", "0.51...
0.61405534
0
Shows the usage page.
def show_usage(): usage_screen = "\nUsage:\n" \ f" {basename(argv[0])} <mock_1> [<mock_2> ...]\n" \ "\nOptions:\n" \ " mock-departments Send HTTP requests to create some mock departments in the backend.\n" \ " mock-employees ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def usage(self):\n\n # header\n self.usage_header()\n\n print _(\"\"\"Screen: %(screen)s\nDescription: %(description)s\n\nUsage: %(app_name)s %(screen)s [options]\"\"\") % {\n 'app_name': constants.App.NAME,\n 'screen': self.name,\n 'description': self...
[ "0.7663705", "0.72211075", "0.71782374", "0.7141825", "0.7141825", "0.71395475", "0.6931156", "0.6856943", "0.682497", "0.682497", "0.67693937", "0.6674766", "0.6567316", "0.6556882", "0.6544864", "0.65298975", "0.64678466", "0.6466399", "0.64388704", "0.63979626", "0.6389301...
0.69470173
6
Try to ensure glyph has a unicode value used by FDK to make OTFs.
def setUnicodeValue(glyph, glyphList): if glyph.name in glyphList: glyph.unicode = int(glyphList[glyph.name], 16) else: uvNameMatch = re.match("uni([\dA-F]{4})$", glyph.name) if uvNameMatch: glyph.unicode = int(uvNameMatch.group(1), 16)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def testUnicodeValue(glyph):\n font = wrapFont(glyph.font)\n layer = font.getLayer(glyph.layer.name)\n glyph = layer[glyph.name]\n report = []\n uni = glyph.unicode\n name = glyph.name\n # test for uniXXXX name\n m = uniNamePattern.match(name)\n if m is not None:\n uniFromName = m...
[ "0.74028057", "0.67609125", "0.65352976", "0.65352976", "0.64183146", "0.64183146", "0.63388956", "0.6322815", "0.62906355", "0.62906355", "0.62733185", "0.6263178", "0.6125339", "0.61233383", "0.6100233", "0.6100233", "0.60960364", "0.6059608", "0.6047981", "0.6033652", "0.6...
0.62196726
12
Allows the return value to be optionally returned as json output with the 'json' flag. When a command fails but still has data to be printed as json, a Two1Error should be raised because it takes an optional json param. This means we can pass any json data using the Two1Error as a vehicle to "return" the json data to t...
def json_output(f): @click.option('--json', default=False, is_flag=True, help='Uses JSON output.') @click.pass_context def _json_output(ctx, json, *args, **kwargs): """ This wrapper disables logging when json is set and restores it after print json value In order for this to work ALL o...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _json_output(ctx, json, *args, **kwargs):\n # call early if --json wasn't given as a cmd line arg\n if not json:\n return f(ctx, *args, **kwargs)\n\n # gets the original level so the decorator can restore it\n original_level = logging.getLogger('').manager.disable\n\n ...
[ "0.7699958", "0.652651", "0.61536723", "0.61089456", "0.59036016", "0.58828914", "0.5818656", "0.58150786", "0.58132255", "0.58130234", "0.5793484", "0.5730432", "0.57149374", "0.56762546", "0.56458783", "0.56127894", "0.56077045", "0.55681086", "0.55615586", "0.5533116", "0....
0.6707917
1
This wrapper disables logging when json is set and restores it after print json value In order for this to work ALL output printed to console needs to be done through a logger.
def _json_output(ctx, json, *args, **kwargs): # call early if --json wasn't given as a cmd line arg if not json: return f(ctx, *args, **kwargs) # gets the original level so the decorator can restore it original_level = logging.getLogger('').manager.disable # disable...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def json_output(f):\n\n @click.option('--json', default=False, is_flag=True, help='Uses JSON output.')\n @click.pass_context\n def _json_output(ctx, json, *args, **kwargs):\n \"\"\" This wrapper disables logging when json is set and restores it after print json value\n\n In order for thi...
[ "0.6563427", "0.637549", "0.5867237", "0.57501084", "0.5654326", "0.5630194", "0.5569698", "0.555525", "0.5553591", "0.55344504", "0.55321467", "0.5526902", "0.55174536", "0.54873204", "0.54290414", "0.54219997", "0.5353988", "0.5306761", "0.5289048", "0.5284649", "0.52789533...
0.6480132
1
Checks whether user has any notifications
def check_notifications(func): def _check_notifications(ctx, *args, **kwargs): config = None client = None # protect against early cli failures if ctx.obj and 'config' in ctx.obj and 'client' in ctx.obj: config = ctx.obj['config'] client = ctx.obj['client'] ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "async def check_new_user_notifications(self) -> bool:\n async with self.web_session.get(self._api_new_notifications_url, headers=self._headers) as resp:\n if self.check_status(resp.status, self._api_new_notifications_url):\n data = await resp.json()\n has_new = data....
[ "0.6971195", "0.674084", "0.65773916", "0.6475425", "0.6475425", "0.64009696", "0.636893", "0.6334019", "0.6280624", "0.62731403", "0.62668693", "0.6202266", "0.6130567", "0.60454637", "0.60297847", "0.60204643", "0.5990522", "0.5943133", "0.5930073", "0.5903938", "0.5880897"...
0.6418087
5
Wraps a 21 CLI command in a function that logs usage statistics
def capture_usage(func): def _capture_usage(ctx, *args, **kwargs): """ Captures usages and sends stastics to the 21 api if use opted in Args: ctx (click.Context): cli context object args (tuple): tuple of args of the fuction kwargs (dict): keyword args of the fun...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cmd_stat(args):", "def usage():", "def usage():", "def usage():\n pass", "def usage():\n return _usage", "def execute_usage_command() -> MarkdownString:\n return execute_help_command(\"usage\")", "def print_usage_command(self):\n print self.get_usage_command()", "def print_usage_c...
[ "0.70189947", "0.6885436", "0.6885436", "0.67559195", "0.6703775", "0.6688787", "0.65517044", "0.65517044", "0.6463498", "0.6448686", "0.6387754", "0.6387754", "0.63705873", "0.63705873", "0.63705873", "0.63705873", "0.63705873", "0.63705873", "0.63705873", "0.63705873", "0.6...
0.70451176
0
Captures usages and sends stastics to the 21 api if use opted in
def _capture_usage(ctx, *args, **kwargs): # protect against early cli failures if not ctx.obj or 'config' not in ctx.obj: return func(ctx, *args, **kwargs) config = ctx.obj['config'] # return early if they opted out of sending usage stats if hasattr(config, "collect...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def capture_usage(func):\n def _capture_usage(ctx, *args, **kwargs):\n \"\"\" Captures usages and sends stastics to the 21 api if use opted in\n\n Args:\n ctx (click.Context): cli context object\n args (tuple): tuple of args of the fuction\n kwargs (dict): keyword ...
[ "0.6009255", "0.58890975", "0.5492466", "0.54340786", "0.53964245", "0.53716946", "0.5301626", "0.525373", "0.5182369", "0.5139871", "0.51171815", "0.51171815", "0.5106569", "0.5103247", "0.5097086", "0.50797015", "0.5072051", "0.5062991", "0.5062991", "0.5062991", "0.5044803...
0.0
-1
Adds a safety net to functions that catches all exceptions
def catch_all(func): def _catch_all(ctx, *args, **kwargs): """ Catches all exceptions and prints the stacktrace if an environment variable is set Args: ctx (click.Context): cli context object args (tuple): tuple of args of the fuction kwargs (dict): keyword args ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def picklable_exception_safe_function(function):\n if is_testing():\n setattr(function, _ATTRIBUTE_EXCEPTION_SAFE, True)\n\n return update_wrapper_extended(functools.partial(_safe_function, function), function)", "def safe_call(func):\r\n\r\n @wraps(func)\r\n def _func(*args, **kwargs):\r\n ...
[ "0.6511669", "0.63944566", "0.6295365", "0.6199513", "0.6188797", "0.61368275", "0.61063725", "0.60871845", "0.60851955", "0.60365736", "0.5980536", "0.5963954", "0.5951777", "0.5935309", "0.5889965", "0.5889297", "0.58591264", "0.5847972", "0.58372027", "0.58354133", "0.5827...
0.5764383
25
Catches all exceptions and prints the stacktrace if an environment variable is set
def _catch_all(ctx, *args, **kwargs): try: return func(ctx, *args, **kwargs) except click.Abort: # on SIGINT click.prompt raise click.Abort logger.error('') # just to get a newline # raise all click exceptions because they are used to bail and print a message...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def printerror():\n print(traceback.format_exc())", "def handle_error():\n print \"An error occurred. Trace:\\n\"\n traceback.print_exc()", "def exceptionTraceback(self, alwaysPrint = False):\n self.logPre( traceback.format_exc(), alwaysPrint )", "def print_unable_to_run(exc: \"CalledProcessE...
[ "0.65385914", "0.64173245", "0.6388171", "0.6359726", "0.63305074", "0.6191586", "0.61365366", "0.6127015", "0.6108177", "0.6099531", "0.6068325", "0.600188", "0.5999518", "0.59936404", "0.59410065", "0.5931565", "0.5926041", "0.59225166", "0.5917758", "0.58921725", "0.586768...
0.0
-1
Helper function to ensure that the tested function generates a matplotlib plot
def mpl_plot_was_rendered(): figs_before = plt.gcf().number yield figs_after = plt.gcf().number assert figs_after > figs_before
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def plot_test(func):\n\n @wraps(func)\n def wrapper(*args, **kwargs):\n\n plt.close('all')\n\n func(*args, **kwargs)\n\n ax = plt.gca()\n assert ax.has_data()\n\n return wrapper", "def test_make_plot_custom(self):\n print(sys._getframe().f_code.co_name)\n try:\n...
[ "0.7756797", "0.7440159", "0.7249045", "0.7127405", "0.7098636", "0.7028343", "0.69793504", "0.68431765", "0.67383975", "0.67240345", "0.670985", "0.6641951", "0.6598055", "0.6490778", "0.6450548", "0.6431349", "0.64284074", "0.6425319", "0.64250547", "0.64030474", "0.6386928...
0.61337847
42
Decodes a polyline that was encoded using the Google Maps method.
def decode_line(encoded): encoded_len = len(encoded) index = 0 array = [] lat = 0 lng = 0 while index < encoded_len: b = 0 shift = 0 result = 0 while True: b = ord(encoded[index]) - 63 index = index + 1 result |= (b & 0x1f) <...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def decode_polyline(polyline_str):\n index, lat, lng = 0, 0, 0\n coordinates = []\n changes = {'latitude': 0, 'longitude': 0}\n\n # Coordinates have variable length when encoded, so just keep\n # track of whether we've hit the end of the string. In each\n # while loop iteration, a single coordina...
[ "0.7402233", "0.6901411", "0.5904311", "0.5880292", "0.5487252", "0.54839", "0.5478701", "0.54305345", "0.54305345", "0.54179376", "0.5407914", "0.5333655", "0.52993774", "0.52456075", "0.5218623", "0.51564485", "0.5149373", "0.5131272", "0.51058567", "0.50917256", "0.5087812...
0.669921
2
Lists the first 50 persons in the database
def list_people(): conn = get_db() try: cur = conn.cursor() try: # Note: don't use prefixes like "oktatas." above for tables # within your own schema, as it ruins portability. # This table has 10k rows, so we intentionally limit the result set to 50 ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_all_from_top_ten(title,users,max = 3):\n \"\"\" ten prolific users \"\"\"\n \"\"\" max : number of user with related followers \"\"\"\n getAllUsers(users,all_users,users_set,proceeded_users,max,user_cpt,title)\n for data in users_set:\n print(data.id)", "def persons(self, start=None, ...
[ "0.6173848", "0.6156629", "0.6009959", "0.5966629", "0.5958406", "0.5893955", "0.5868789", "0.585206", "0.57906085", "0.57502455", "0.57330745", "0.5730837", "0.56636137", "0.56529856", "0.5650073", "0.56474364", "0.5642941", "0.5633974", "0.5620123", "0.56165886", "0.5583520...
0.5878848
7
Shows the details of a single person by szemelyi_szam
def show_person(szemelyi_szam): conn = get_db() try: cur = conn.cursor() try: # Note: don't use prefixes like "oktatas." above for tables # within your own schema, as it ruins portability cur.execute('SELECT nev FROM oktatas.szemelyek WHERE szemelyi_szam = :sz...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show_person(uuid=None, fanchart=False):\n t0 = time.time()\n uuid = request.args.get(\"uuid\", uuid)\n fanchart_shown = request.args.get(\"fanchart\", fanchart)\n dbg = request.args.get(\"debug\", None)\n u_context = UserContext(user_session, current_user, request)\n\n with PersonReaderTx(\"r...
[ "0.5745826", "0.57102567", "0.56153953", "0.5596609", "0.5504312", "0.54718465", "0.5425698", "0.54069406", "0.5363168", "0.53174984", "0.53056276", "0.527947", "0.52716875", "0.52642244", "0.5243467", "0.52137864", "0.52009374", "0.5176038", "0.51611185", "0.5152382", "0.514...
0.6907046
1
Demonstrates handling dates from databases and formatting it according to ISO 8601
def date_test(): conn = get_db() try: cur = conn.cursor() try: # Note: don't use prefixes like "oktatas." above for tables # within your own schema, as it ruins portability # http://www.oracle.com/technetwork/articles/dsl/prez-python-timesanddates-093014.html ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def format_date(self, data):\r\n if self.datetime_formatting == 'rfc-2822':\r\n return format_date(data)\r\n\r\n return data.isoformat()", "def _format_date(input_date, day_flag, sep_char=\"-\"):\n date_iso = input_date[6:10] + sep_char + input_date[0:2]\n if day_flag:\n dat...
[ "0.6510499", "0.639002", "0.6309903", "0.62802225", "0.62619835", "0.6219158", "0.6108398", "0.6045131", "0.60228324", "0.60067165", "0.5989051", "0.5973081", "0.5963054", "0.5956423", "0.59526604", "0.592741", "0.58984554", "0.5884534", "0.5882484", "0.5879356", "0.58635175"...
0.6469771
2
Lets you test HTTP verbs different from GET, expects and returns data in JSON format
def verb_test(): # it also shows you how to access the method used and the decoded JSON data return jsonify(method=request.method, data=request.get_json(), url=request.url)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_get(self):\n return self.doRequest(self.url, method=\"GET\", body=self.input)", "def test_two_legged_get(self):\n resp, content = self._two_legged(\"GET\")\n self.assertEqual(int(resp['status']), 200)", "def test_get_method(self):\n self.getPage('/')\n self.assertSta...
[ "0.7386842", "0.7203227", "0.7170921", "0.7162372", "0.7118212", "0.70815897", "0.7051631", "0.69784915", "0.6888869", "0.68721557", "0.68026114", "0.68026114", "0.6785055", "0.6744668", "0.6738315", "0.6706094", "0.6701752", "0.6701752", "0.6683287", "0.6681289", "0.6639867"...
0.7727215
1
Connects to the RDBMS and returns a connection object
def get_db(): # when used with a `file` object, `with` ensures it gets closed # pylint: disable=no-member with file('config.json') as config_file: config = json.load(config_file) return cx_Oracle.connect(config['user'], config['pass'], config['host'])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_connection():\r\n try:\r\n conn = sq.connect(DBClass.db_name)\r\n except sq.Error as e:\r\n raise e\r\n \r\n return conn", "def connect(self):\n\n self.logger.debug(\"creating DB connection\")\n conn = sql.connect(**self.connection_ar...
[ "0.82264274", "0.820609", "0.80544895", "0.79573506", "0.7930705", "0.78931075", "0.78464866", "0.78337723", "0.783104", "0.7814106", "0.7799209", "0.7782497", "0.77747947", "0.7774143", "0.7763462", "0.7760851", "0.7752136", "0.7742119", "0.77221674", "0.77209747", "0.769587...
0.0
-1
Return the angular siredshifte corresponding to physical siredshifte in kpc.
def kpc_to_arcsec(kpc, redshift, cosmo): da = cosmo.angular_diameter_distance(redshift).to_value("kpc") rad = kpc / da arcsec = rad * (180/np.pi) * 3600 return arcsec
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def angular_diameter_distance_to_earth_in_kpc_from(self, redshift: float) -> float:\r\n angular_diameter_distance_kpc = self.angular_diameter_distance(z=redshift).to(\r\n \"kpc\"\r\n )\r\n\r\n return angular_diameter_distance_kpc.value", "def skystat(self):\n return self._s...
[ "0.53680843", "0.5208067", "0.51444", "0.50971395", "0.5088788", "0.4927151", "0.4859474", "0.48444283", "0.47980583", "0.4787145", "0.4768976", "0.4757736", "0.4737302", "0.4727443", "0.47191295", "0.47163853", "0.47005206", "0.46974427", "0.46957412", "0.46910194", "0.46822...
0.46264875
27
Return the angular siredshifte corresponding to physical siredshifte in kpc.
def arcsec_to_kpc(arcsec, redshift, cosmo): rad = arcsec / ((180/np.pi) * 3600) da = cosmo.angular_diameter_distance(redshift).to_value("kpc") kpc = rad * da return kpc
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def angular_diameter_distance_to_earth_in_kpc_from(self, redshift: float) -> float:\r\n angular_diameter_distance_kpc = self.angular_diameter_distance(z=redshift).to(\r\n \"kpc\"\r\n )\r\n\r\n return angular_diameter_distance_kpc.value", "def skystat(self):\n return self._s...
[ "0.53660977", "0.520697", "0.51441437", "0.5096801", "0.5089956", "0.4926018", "0.4859852", "0.48425972", "0.47972086", "0.4787122", "0.47675774", "0.47565952", "0.47354773", "0.47273144", "0.4720621", "0.47147405", "0.47020546", "0.4695628", "0.4695049", "0.46910024", "0.468...
0.0
-1
applies desired filter and returns a new image
def apply_filter(image, filter): filteredImage = create_image(image) # Apply Filter: # FIXME! return filteredImage
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def apply_filter(self, image):\n pass", "def apply(filter_fn, img):\n width, height = img.size\n newimg = Image.new(\"RGB\", (width, height))\n for j in range(1, height - 1):\n for i in range(1, width - 1):\n newimg.putpixel((i, j), filter_fn(img, i, j))\n return newimg", "...
[ "0.7991067", "0.7453954", "0.72541666", "0.70461065", "0.70124483", "0.67743874", "0.6765661", "0.67387867", "0.67131186", "0.66427565", "0.66376305", "0.6634414", "0.65986735", "0.65206426", "0.65076965", "0.649829", "0.6451336", "0.64409816", "0.6418331", "0.639753", "0.633...
0.8058654
0
Produces permutations with adjacent chars swapped. For short (4 or 5 letters) words produces
def swapchar(word: str) -> Iterator[str]: if len(word) < 2: return for i in range(0, len(word) - 1): yield word[:i] + word[i+1] + word[i+1] + word[i+2:] # try double swaps for short words # ahev -> have, owudl -> would if len(word) in [4, 5]: yield word[1] + word[0] + (wo...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def word_perms(word):\n\t# Question 4a: Generates all strings that are permutations of the letters in word\n\treturn {''.join(w) for w in permutations(word)}", "def permute(s):\n output = []\n if len(s) <= 1:\n return s\n\n for i, letter in enumerate(s):\n # strip current letter from s and...
[ "0.7224716", "0.7143022", "0.65844995", "0.6435983", "0.633398", "0.63314575", "0.6309901", "0.63076025", "0.6285997", "0.62018263", "0.61910725", "0.61650455", "0.6142188", "0.6106567", "0.6081747", "0.60533714", "0.602227", "0.5983695", "0.59833705", "0.5982094", "0.5953144...
0.6630932
2