query stringlengths 9 9.05k | document stringlengths 10 222k | metadata dict | negatives listlengths 30 30 | negative_scores listlengths 30 30 | document_score stringlengths 4 10 | document_rank stringclasses 2
values |
|---|---|---|---|---|---|---|
Checks if two shards overlap. | def _check_shard_metadata_pair_overlap(shard1: ShardMetadata, shard2: ShardMetadata):
# For each dim of each shard, check if one shard resides on the other
# end of second shard with respect to that dim. As an example for a 2D
# shard, we would check if one shard is above or on the left of the
# other ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def can_overlap(self):\n return False",
"def overlaps(self, other): # -> bool:\n ...",
"def check_overlap(a, b):\n if a[0] >= b[2] or a[1] >= b[3] or a[2] <= b[0] or a[3] <= b[1]:\n return False\n return True",
"def span_overlap(a: Tuple[int, int], b: Tuple[int, int]) -> bool:\n ... | [
"0.72638744",
"0.7062225",
"0.7060286",
"0.69966316",
"0.6907729",
"0.68349934",
"0.6770295",
"0.6767552",
"0.67658687",
"0.6728309",
"0.66423035",
"0.6638168",
"0.66367257",
"0.6632385",
"0.66321814",
"0.6605467",
"0.6596014",
"0.65437245",
"0.65411097",
"0.6536112",
"0.6519... | 0.7538921 | 0 |
Ensures none of the shards overlap with each other. | def validate_non_overlapping_shards_metadata(shards: List[ShardMetadata]):
# TODO: evaluate optimizing this if needed.
for i in range(len(shards)):
for j in range(i + 1, len(shards)):
if _check_shard_metadata_pair_overlap(shards[i], shards[j]):
raise ValueError(f'Shards {shar... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def can_overlap(self):\n return False",
"def _check_shard_metadata_pair_overlap(shard1: ShardMetadata, shard2: ShardMetadata):\n\n # For each dim of each shard, check if one shard resides on the other\n # end of second shard with respect to that dim. As an example for a 2D\n # shard, we would che... | [
"0.6780764",
"0.66072226",
"0.6300442",
"0.62059945",
"0.62039727",
"0.618798",
"0.6161772",
"0.61248296",
"0.60674876",
"0.60540277",
"0.59775466",
"0.59660643",
"0.5925951",
"0.59135264",
"0.58842605",
"0.58602405",
"0.5835803",
"0.5722045",
"0.5703409",
"0.57028174",
"0.56... | 0.7294196 | 0 |
Checks if the shards_metadata is compatible with the provided tensor dims. | def check_tensor(shards_metadata, tensor_dims) -> None:
# If the tensor's volume matches the total volume of all shards and
# all shard boundaries are within tensor dims, we have a compatible
# sharding spec for this tensor. Note that we have already verified
# we don't have overlapping shards.
ten... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_dims(xobj, dims, kind):\n if isinstance(dims, str):\n dims = [dims]\n\n if not all(dim in xobj.dims for dim in dims):\n raise DimensionError(\n f'Your {kind} object must contain the '\n f'following dimensions at the minimum: {dims}'\n )\n return True",
... | [
"0.70428336",
"0.6533978",
"0.6469752",
"0.6321749",
"0.6268698",
"0.6185657",
"0.6185021",
"0.605668",
"0.5926702",
"0.5918645",
"0.5908207",
"0.58480775",
"0.57827824",
"0.5772328",
"0.5762425",
"0.57193136",
"0.57082486",
"0.5685897",
"0.5651482",
"0.5640664",
"0.562222",
... | 0.83699447 | 0 |
Process newly submitted GeoPost entry... PROCEEDURE 1) Get data from POST body 2) Validate form 3) Upload photo to bucket 4) Make WFS transaction with GeoServer | def post(self, request):
# GET REQUEST DATA
fid = request.POST.get('fid', False)
uuid = request.POST.get('uuid', False)
title_text = request.POST.get('title', False)
body = request.POST.get('body', False)
photo = request.FILES.get('photo', False) # FOR STORAGE
wf... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def do_POST(self):\n global pages, devices, settings\n try:\n ctype, pdict = cgi.parse_header(self.headers.getheader('content-type'))\n if ctype == 'application/x-www-form-urlencoded':\n length = int(self.headers.getheader('content-length'))\n postv... | [
"0.6062715",
"0.59630567",
"0.58975375",
"0.58711004",
"0.5809544",
"0.5728217",
"0.5689963",
"0.55832034",
"0.5559245",
"0.5515752",
"0.54731184",
"0.54603994",
"0.54473406",
"0.5440826",
"0.5434373",
"0.54309976",
"0.5366671",
"0.53177875",
"0.5264689",
"0.5257757",
"0.5244... | 0.8015848 | 0 |
Download pdf of VanTechy presentation slideshow. | def vantechy(request):
return FileResponse(open('/files/presentation.pdf', 'rb')) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fetch_pdf(url, browser):\n\tpass\n\n\t# grab link page\n\n\t# search soup for pdf file\n\n\t# grab pdf file and return it",
"def download(filename):\n return send_from_directory(directory='pdf', filename=filename)",
"def download(request, ef_id):\n ef = get_object_or_404(ExamFile, id=ef_id)\n path... | [
"0.63570714",
"0.6327665",
"0.6183838",
"0.60757995",
"0.6060038",
"0.60584295",
"0.6054394",
"0.59414095",
"0.586487",
"0.5839018",
"0.5790814",
"0.57728595",
"0.57418793",
"0.57275844",
"0.57084584",
"0.56971765",
"0.56889516",
"0.5683005",
"0.56304324",
"0.5624967",
"0.559... | 0.658064 | 0 |
List all available charts | def list_charts():
charts_root = Path(R".\charm\data\charts")
charts = list(charts_root.rglob("*.chart"))
return charts | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_charts(self, app):\n return self._list(self._path() + '?app_name=' + app, 'charts')",
"def charts(self):\n return self.container['charts']",
"def list(self, **params):\n\n _, _, account_charts = self.http_client.get(\"/accountcharts\", params=params)\n return account_charts... | [
"0.7755798",
"0.7449958",
"0.71319413",
"0.7110359",
"0.66801405",
"0.6495061",
"0.63652325",
"0.6342188",
"0.6272101",
"0.62555903",
"0.6250946",
"0.6006704",
"0.60066587",
"0.6001703",
"0.597355",
"0.59719837",
"0.58516073",
"0.5850192",
"0.5838608",
"0.5827216",
"0.5812616... | 0.8125694 | 0 |
r""" Convert a chart Path object to a string path relative to .\charm\data\charts | def strch(chart):
charts_root = Path(R".\charm\data\charts")
return str(chart.relative_to(charts_root)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_data_path(path):\n\n data_path = Path(self.kard.meta.get('data_path', 'data'))\n\n if data_path.is_absolute():\n return str(data_path / path)\n\n return str(self.kard_folder_path / self.kard.name / data_path /\n path)",
"def get_path(s... | [
"0.6196704",
"0.5926172",
"0.5841862",
"0.56423295",
"0.56181204",
"0.5596763",
"0.5596409",
"0.5583181",
"0.5562562",
"0.55594707",
"0.552106",
"0.55162907",
"0.55162907",
"0.54929805",
"0.54887694",
"0.54884666",
"0.54857177",
"0.5473863",
"0.5469934",
"0.54631054",
"0.5450... | 0.7617498 | 0 |
Set the map grid cell as obstacle | def set_obstacle(self, pos: tuple):
if self.within_map(pos):
self.map[round(pos[0]), round(pos[1])] = OBSTACLE
return True
else:
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_obstacle(self, x, y):\n self.BOARD[y][x].traversable = False\n self.board_array[y][x] = 1",
"def add_obstacle(self, x, y):\n self.BOARD[y][x].traversable = False\n self.board_array[y][x] = 1",
"def update_obstacles(self, new_obs):\n self.obstacles = new_obs",
"def s... | [
"0.6904903",
"0.6904903",
"0.6622904",
"0.6531364",
"0.6457762",
"0.6457762",
"0.6451341",
"0.6433322",
"0.6425923",
"0.6391529",
"0.637739",
"0.63555276",
"0.63377327",
"0.6329692",
"0.62948984",
"0.6285746",
"0.62847567",
"0.625142",
"0.62377983",
"0.62250537",
"0.6216072",... | 0.7163415 | 0 |
This is the main script for the bigmacc process. It iteartes through various CEA and bigmacc operations for each key (i.e. 01011101). It ends by saving a sample of the hourly results across the key for each building in a netcdf and then wiping the project files to reset them for the next iteration. | def run(config):
locator = cea.inputlocator.InputLocator(config.scenario)
print('Key in run')
print(config.bigmacc.key)
i = config.bigmacc.key
print(i)
# SCENARIO SETUP ---
config.general.project = os.path.join(config.bigmacc.data, config.general.parent, i)
print(config.general.project)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def go():\n ##########\n #\n # MB19284\n #\n ##########\n\n ##########\n # Kp-band reduction\n ##########\n\n target = 'mb19284'\n sci_files = ['i200822_a011{0:03d}_flip'.format(ii) for ii in range(2, 5+1)]\n sci_files += ['i200822_a012{0:03d}_flip'.format(ii) for ii in range(2, 25... | [
"0.6137783",
"0.610961",
"0.6097006",
"0.6071778",
"0.59867096",
"0.5944537",
"0.59281546",
"0.5890876",
"0.5888353",
"0.58699083",
"0.5863766",
"0.5852129",
"0.58403766",
"0.58233374",
"0.58191043",
"0.5813233",
"0.5811937",
"0.5777856",
"0.5767777",
"0.5765127",
"0.57320464... | 0.6892021 | 0 |
returns if postcode like | def is_postal_code(elem):
return 'post' in elem.attrib['k'] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def postcode(self):\n return self._postcode",
"def postcode(self):\n return self._postcode",
"def validate_postcode_format(self):\n\n assert type(self.postcodes) == str, \"To use this method, the postcode cannot be an iterable.\"\n pcd = self.postcodes.replace(' ', '')\n # Th... | [
"0.65805596",
"0.65805596",
"0.6374579",
"0.63254106",
"0.6238786",
"0.6128216",
"0.6051144",
"0.60343444",
"0.586208",
"0.58339965",
"0.5811099",
"0.57576764",
"0.57576764",
"0.5754006",
"0.5704175",
"0.56964314",
"0.56823075",
"0.56657773",
"0.5656511",
"0.5651277",
"0.5647... | 0.7000855 | 0 |
Remove journal entry at position `pos`. | def remove_entry(self, pos: int) -> None:
del self.entries[pos] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_pos(self, pos):\n yield from self.command('delete {}'.format(pos))\n return True",
"def delete(self, pos):\n if self.is_playing() and self.current_position() == pos:\n self.x.playback_stop().wait()\n self.x.playlist_remove_entry(pos).wait()",
"def delete_ro... | [
"0.6454446",
"0.6282452",
"0.6261571",
"0.61265475",
"0.6009769",
"0.59815764",
"0.58335143",
"0.57944274",
"0.5689213",
"0.5677288",
"0.56020075",
"0.55991143",
"0.55826235",
"0.55457",
"0.55305755",
"0.55185974",
"0.5401358",
"0.5388663",
"0.5358339",
"0.5331406",
"0.530921... | 0.81650764 | 0 |
Save journal entries into a file. | def save(journal: Journal, file: Path) -> None:
with open(file, "w") as output:
output.writelines(f"{entry}\n" for entry in journal.get_entries()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_txt():\n # open file and append, if it doesn't exist then create it.\n with open('journal_entries.txt', 'a+') as f:\n # .get the input in text widget at the first line, '0th' character, then read until the end\n f.write(\"\\n\" + get_date_time())\n for i in range(len(entries)):\... | [
"0.71133924",
"0.70640576",
"0.68299794",
"0.68087065",
"0.6638848",
"0.6473705",
"0.64459836",
"0.61746615",
"0.61529505",
"0.61082065",
"0.6088982",
"0.60406435",
"0.60406435",
"0.5983607",
"0.5972086",
"0.59578437",
"0.5955684",
"0.59284395",
"0.58410317",
"0.58036464",
"0... | 0.8384327 | 0 |
Load journal entries from a file. | def load(journal: Journal, file: Path) -> None: | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load(name):\n jrn_path = build_path(name)\n if not os.path.exists(jrn_path):\n print(f'... journal file \\'{jrn_path}\\' does not exist ...')\n print('... initializing new journal ...')\n with open(jrn_path, 'w') as file:\n pass\n return []\n else:\n print... | [
"0.7394419",
"0.64924157",
"0.62799805",
"0.6213144",
"0.6060179",
"0.6032827",
"0.5937667",
"0.5873339",
"0.5792897",
"0.57746816",
"0.57655644",
"0.57224065",
"0.56214803",
"0.5567517",
"0.5565053",
"0.5565053",
"0.5560204",
"0.55173564",
"0.54818314",
"0.54786164",
"0.5453... | 0.81673855 | 0 |
Load journal entries from a URI. | def load_from_web(journal: Journal, uri: str) -> None: | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load(name):\n jrn_path = build_path(name)\n if not os.path.exists(jrn_path):\n print(f'... journal file \\'{jrn_path}\\' does not exist ...')\n print('... initializing new journal ...')\n with open(jrn_path, 'w') as file:\n pass\n return []\n else:\n print... | [
"0.6321398",
"0.6246365",
"0.5560296",
"0.5538123",
"0.53121865",
"0.5294257",
"0.5108225",
"0.51056397",
"0.50977325",
"0.50559926",
"0.5041016",
"0.49502626",
"0.49426818",
"0.49289203",
"0.49164444",
"0.48940632",
"0.48866275",
"0.48804903",
"0.48804903",
"0.48515296",
"0.... | 0.75825113 | 0 |
Spawning next generation of collection by selecting n pairs of distinct forests from previous generation and them over. | def _next_generation(self, previous_generation):
self._fullInput, self._fullOutput = previous_generation.get_data()
self.power = self.settings.population_count
for forest_iteration in range(self.power):
first, second = previous_generation.selection()
print 'selected for c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def step(self):\n # amt_selected = \\\n # int(self.population_size * self.part_selected) \n\n # spawning_pool = [] # list of dna selected for reproduction\n new_data =[]\n \n sorted_dna = sorted(self.data, \n key=lambda dna: dna.fitness_fun... | [
"0.66252106",
"0.61852103",
"0.61620736",
"0.6136829",
"0.61138487",
"0.6082674",
"0.6079343",
"0.6030366",
"0.6008962",
"0.5985152",
"0.5984775",
"0.5952923",
"0.58702976",
"0.5806566",
"0.57817847",
"0.5779176",
"0.57665956",
"0.57347685",
"0.57222146",
"0.5704095",
"0.5702... | 0.6936438 | 0 |
Executing every forest in collection, activating their networks. By the way collecting data about best fitness function. | def execute(self):
process_list = []
forests_queue = Queue(self.power)
iterational = 0
print '| |-starting evaluation, training and validation'
for one_forest in self._forests:
process_list.append(
Process(target=main_async_method,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mutate(self):\n for forest in self._forests:\n forest.mutate(self._fullInput)",
"def run(self, num_iterations = 50, **kwargs):\n \n #setup system\n self.cost_calculator = t.CostCalculator(self.suppliers_allcards, self.all_ensembles_dict)\n bounds = np.array(self.... | [
"0.66012484",
"0.62504995",
"0.61932045",
"0.6135642",
"0.6134355",
"0.61263996",
"0.6049594",
"0.5867963",
"0.5865974",
"0.5832648",
"0.581788",
"0.5802029",
"0.57808244",
"0.5779419",
"0.5708533",
"0.56901664",
"0.5634386",
"0.56181246",
"0.558044",
"0.553923",
"0.55354095"... | 0.7236054 | 0 |
Just mutating every forest in collection. | def mutate(self):
for forest in self._forests:
forest.mutate(self._fullInput) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unifyPreviewNodes(self):\n\n self.leaves.update(self.forced)\n self.forced = set()",
"def update(self):\n map(lambda x: x.update(), self._children.values())",
"def update (self) :\n for met in self.gene :\n met(self)",
"def update(self, list_of_sets):\n for s in list... | [
"0.59149694",
"0.5712289",
"0.54862785",
"0.54687923",
"0.5425373",
"0.54242694",
"0.5323184",
"0.5317251",
"0.52714866",
"0.5256046",
"0.525473",
"0.524264",
"0.52372867",
"0.5176812",
"0.51745",
"0.5156172",
"0.51512945",
"0.51447666",
"0.50903946",
"0.5075218",
"0.5069291"... | 0.7783784 | 0 |
Query a SGL di un sensore del traffico Vedi query_ensor() per sensorURI, fromTime e toTime | def get_traffic_sensor_df(sensorURI: str, fromTime: str, toTime: str, resampleFreq: str = None, remove_outliers=False):
values = ["count", "sumSpeed"]
result = None
for v in values:
# data = query_ensor(sensorURI, fromTime, toTime, v)
data = multiday_query(sensorURI, fromTime, toTime, v)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def query_ensor(sensorURI, fromTime, toTime, valueName):\n\n s = f\"https://smartgardalake.snap4.eu/ServiceMap/api/v1/?serviceUri={sensorURI}&fromTime={fromTime}&toTime={toTime}&valueName={valueName}\"\n print(s)\n response = requests.get(s)\n data = response.json()\n values = []\n try:\n ... | [
"0.78036326",
"0.56300086",
"0.56219053",
"0.54439676",
"0.5414489",
"0.5369397",
"0.53085774",
"0.5199531",
"0.5161808",
"0.51520276",
"0.5134034",
"0.5122384",
"0.510574",
"0.50754833",
"0.50372785",
"0.5034987",
"0.5008669",
"0.50082725",
"0.5000846",
"0.49865463",
"0.4974... | 0.59702265 | 1 |
Plot time points given in data file and compare to x3 | def plot_data(fname):
if not os.path.isfile(fname):
print('No data has been generated yet, aborting...')
sys.exit(1)
with open(fname, 'r') as fd:
data = json.load(fd)
x = np.arange(0, max(data, key=lambda e: e[0])[0], 1)
const = .55e-8
func = lambda x: const * x**3
pl... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def example3():\n arrive_time=example2() # Get packets arrive time using example1\n time_series.plot_time_series(arrive_time) # Plot time series using packets arrive time",
"def _figure_3():\n\n dataset_id = 3\n pkl_file = _pkl_file_path(dataset_id)\n with open(pkl_file, 'rb... | [
"0.65714025",
"0.64165264",
"0.64107704",
"0.63405186",
"0.631422",
"0.6297773",
"0.6248544",
"0.615319",
"0.60817546",
"0.607438",
"0.60634214",
"0.60446906",
"0.60240567",
"0.601342",
"0.6000441",
"0.5957452",
"0.5925133",
"0.59175897",
"0.5905955",
"0.5905455",
"0.5882972"... | 0.6902801 | 0 |
Push the item in the front of the deque | def enqueue_front(self, item):
self._items.insert(0, item) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def push(self, item):\n super().add_item_to_front(item)",
"def push_front(self, e):\n if(self.size_ >= self.capacity_):#If our Deque is full we need to resize it first\n self.resize_front()\n self.data_[self.front_]= e#New Front\n self.size_+=1\n # print(\... | [
"0.7934391",
"0.79339534",
"0.7679568",
"0.74891657",
"0.74482065",
"0.7417094",
"0.7404675",
"0.7363072",
"0.7294415",
"0.72747624",
"0.7242487",
"0.7242487",
"0.72093624",
"0.71174246",
"0.707182",
"0.7052566",
"0.70389926",
"0.70353955",
"0.701858",
"0.70012",
"0.6997899",... | 0.8026828 | 0 |
Pop the item in the front of the deque. Raise IndexError if the deque is empty. | def dequeue_front(self):
try:
return self._items.pop(0)
except:
raise IndexError('The deque is empty') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pop_front(self):\n # set temp to deque's front for return\n temp = self.front\n # if deque is empty\n if self.size == 0:\n # raise IndexError\n raise IndexError()\n # if deque has one element\n elif self.size == 1:\n # empty the deque c... | [
"0.7918459",
"0.7688422",
"0.7626735",
"0.76226133",
"0.7617293",
"0.7505443",
"0.7500941",
"0.7439415",
"0.740664",
"0.7395839",
"0.73582757",
"0.73489094",
"0.7289233",
"0.7263663",
"0.7241764",
"0.724081",
"0.7221747",
"0.71959555",
"0.7189014",
"0.7156972",
"0.7149371",
... | 0.81932133 | 0 |
Pop the item in the end of the deque. Raise IndexError if the deque is empty. | def dequeue_rear(self):
try:
return self._items.pop()
except:
raise IndexError('The deque is empty') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pop(self):\r\n try:\r\n return self.pop_from_deque()\r\n except IndexError:\r\n return None",
"def pop(self):\n try:\n return self._values.pop()\n except IndexError:\n raise IndexError('Cannot pop from empty deque.')",
"def pop(self):\... | [
"0.77415574",
"0.76645964",
"0.76196545",
"0.7619073",
"0.74518174",
"0.73892117",
"0.7347819",
"0.73183465",
"0.72986156",
"0.7289281",
"0.7255884",
"0.7225652",
"0.721948",
"0.721712",
"0.72019696",
"0.71845245",
"0.7174988",
"0.7146664",
"0.7139901",
"0.71300745",
"0.71008... | 0.7715742 | 1 |
Returns an array of full paths for a relative path with globs | def expand_path(__file__, path_with_globs):
return glob.glob(relative_path(__file__, path_with_globs)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_paths(file_path):\n return glob(path.join(file_path, '*'))",
"def glob(path: str) -> list[str]:\n fs, relative_path = url_to_fs(path)\n return cast(list[str], fs.glob(relative_path))",
"def get_paths(pattern):\n if not in_source_tree:\n pattern = '../' + pattern\n\n files = glob.g... | [
"0.78830874",
"0.74837524",
"0.73281705",
"0.7273039",
"0.7240019",
"0.7209716",
"0.7107599",
"0.7090277",
"0.70357305",
"0.69723034",
"0.69063663",
"0.68546826",
"0.68303967",
"0.6820884",
"0.68082666",
"0.6802939",
"0.6779365",
"0.67275643",
"0.6712124",
"0.67007935",
"0.66... | 0.7740084 | 1 |
One solution would be to do an inorder traversal and sum the values along the way (or just recursive sum along the tree). => O(N) but in case the range [lo,hi] is small, this is wasteful. | def rangeSumBST(self, root: TreeNode, lo: int, hi: int) -> int:
def visit(node: TreeNode) -> int:
if not node:
return 0
if node.val < lo:
return visit(node.right)
elif hi < node.val:
return visit(node.left)
else:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getSum(root, level, h):\n if root == None:\n return\n \n h[level] = root.data\n \n getSum(root.left, level+1, h)\n getSum(root.right, level+1, h)",
"def sum_tree(t):\n \"*** YOUR CODE HERE ***\"\n if is_leaf(t):\n return entry(t)\n total = entry(t)\n for subtree in... | [
"0.6729964",
"0.66551703",
"0.64795923",
"0.6404012",
"0.63082033",
"0.6260686",
"0.6228508",
"0.6228508",
"0.6228508",
"0.6228508",
"0.6228508",
"0.61943024",
"0.6178861",
"0.61783046",
"0.61113393",
"0.6107871",
"0.6049075",
"0.604374",
"0.6043456",
"0.603119",
"0.5992261",... | 0.7450429 | 0 |
Loops over arrays in the arrays_iterator and evaluates the cut_function at the cut_values. Returns a list of efficiences, passed events/objects, and total events/objects. cut_function is expected to return a tuple (n_pass, n_total) with input (arrays, cut_value). | def get_eff(arrays_iterator, cut_function, cut_values):
n_cuts = len(cut_values)
n_total = np.zeros(n_cuts)
n_pass = np.zeros(n_cuts)
for arrays, dataset in arrays_iterator:
weight = dataset.get_weight()
for i_cut, cut in enumerate(cut_values):
this_n_pass, this_n_total = cut... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __cut_arrays(data_array, maximum_time, arrays_to_cut):\n\n try:\n begin_time = data_array[arrays_to_cut[0]][0][0]\n end_time = data_array[arrays_to_cut[0]][0][-1]\n delta_time = (\n data_array[arrays_to_cut[0]][0][1]\n ... | [
"0.56539094",
"0.52569467",
"0.5236992",
"0.5231127",
"0.5104325",
"0.5093013",
"0.5085143",
"0.5064352",
"0.4961732",
"0.49305794",
"0.49301794",
"0.4917983",
"0.48857465",
"0.4866057",
"0.48591626",
"0.48007303",
"0.47892055",
"0.47815204",
"0.4772867",
"0.47728154",
"0.476... | 0.77393055 | 0 |
Expects a list of signals and a list of bkgs (Dataset objects), and a cut_function and cut_values. | def roccurve(signals, bkgs, cut_function, cut_values):
eff_sig, n_pass_sig, n_total_sig = get_eff(svjflatanalysis.iterate(signals), cut_function, cut_values)
eff_bkg, n_pass_bkg, n_total_bkg = get_eff(svjflatanalysis.iterate(bkgs), cut_function, cut_values)
return eff_sig, eff_bkg, n_pass_sig, n_pass_bkg, n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_cuts(data, args, verbose):\n\n if args['experiment']['cut_finding'] == CutFinding.features:\n\n values = (data.xs == True).T\n return Cuts(values=values)\n\n if args['experiment']['cut_finding'] == CutFinding.binning:\n\n values, names = binning(xs=data.xs,\n ... | [
"0.55629873",
"0.5544333",
"0.54654413",
"0.53966707",
"0.5293295",
"0.5175403",
"0.5154368",
"0.50937045",
"0.5059277",
"0.5027049",
"0.50096345",
"0.49881732",
"0.49795693",
"0.4978986",
"0.49496424",
"0.4933744",
"0.4921186",
"0.49105307",
"0.49013457",
"0.48807377",
"0.48... | 0.6186934 | 0 |
Basic plotting style for a single roccurve, based on multiple signal and bkgs samples. Expects an ax object to be given, this function is not standalone | def plot_roccurve(signals, bkgs, cut_function, cut_values, ax):
eff_sig, eff_bkg, n_pass_sig, n_pass_bkg, n_total_sig, n_total_bkg = roccurve(signals, bkgs, cut_function, cut_values)
return _draw_roccurve(eff_sig, eff_bkg, cut_values, ax) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_single_roccurve(signals, bkgs, cut_function, cut_values, ax=None):\n # Get a default ax if none is given\n if ax is None:\n import matplotlib.pyplot as plt\n fig = plt.figure(figsize=(8,8))\n ax = fig.gca()\n # Plot the base line\n ax.plot([0.0,1.0], [0.0,1.0], linestyle='... | [
"0.7304228",
"0.6550803",
"0.6549476",
"0.63300985",
"0.631119",
"0.6244181",
"0.614794",
"0.61184627",
"0.611656",
"0.6109644",
"0.60801786",
"0.6004628",
"0.59819883",
"0.595841",
"0.5869724",
"0.58628213",
"0.5857794",
"0.5838128",
"0.5826333",
"0.58193934",
"0.5785737",
... | 0.6976897 | 1 |
Main routine for plotting a single roccurve | def plot_single_roccurve(signals, bkgs, cut_function, cut_values, ax=None):
# Get a default ax if none is given
if ax is None:
import matplotlib.pyplot as plt
fig = plt.figure(figsize=(8,8))
ax = fig.gca()
# Plot the base line
ax.plot([0.0,1.0], [0.0,1.0], linestyle='--', color='... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_roccurve(signals, bkgs, cut_function, cut_values, ax):\n eff_sig, eff_bkg, n_pass_sig, n_pass_bkg, n_total_sig, n_total_bkg = roccurve(signals, bkgs, cut_function, cut_values)\n return _draw_roccurve(eff_sig, eff_bkg, cut_values, ax)",
"def roc_curve(model, X_train, y_train, X_test, y_test, train=... | [
"0.7373159",
"0.7010362",
"0.6923584",
"0.6742388",
"0.66598225",
"0.65181124",
"0.6510751",
"0.6500974",
"0.64510316",
"0.6430082",
"0.6429037",
"0.6416149",
"0.63878846",
"0.63805693",
"0.6365573",
"0.63452685",
"0.63356173",
"0.6325078",
"0.6313239",
"0.6286145",
"0.628332... | 0.7444382 | 0 |
Plots the roccurve per background category. Assumes signals are all datasets of the same signal. | def plot_roccurves_per_bkg(signals, bkgs, cut_function, cut_values, ax=None):
# Get a default ax if none is given
if ax is None:
import matplotlib.pyplot as plt
fig = plt.figure(figsize=(8,8))
ax = fig.gca()
# Get signal efficieny once
eff_sig, n_pass_sig, n_total_sig = get_eff(s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Make_Binned_ANN_ROC_Curves(title,Signal_title,Background_title,bins,log=False):\n #hsv = plt.get_cmap('hsv')\n #color = hsv(np.linspace(0,1.0,len(bins)-1))\n #color = ['b', 'g', 'r', 'c', 'm', 'y']\n if len(bins)<=6:\n color = ['red','green','blue','orange','brown']\n... | [
"0.6300367",
"0.61281216",
"0.6091596",
"0.60315055",
"0.59216946",
"0.5900686",
"0.5838783",
"0.5722116",
"0.55689114",
"0.5540599",
"0.5525509",
"0.5439819",
"0.54131126",
"0.540916",
"0.5403627",
"0.53976256",
"0.53795195",
"0.53759587",
"0.53333044",
"0.53327256",
"0.5321... | 0.6172026 | 1 |
Fills a coffea.hist.Hist for a single distribution. Takes a list of Dataset objects, and a function `get_array` that should return a numpylike array when given an arrays object. Also requires a string `name` to know in which hist to fill it | def hist_single_distribution(
arrays_iterator, get_array,
varname='somevar', vartitle=None, distrname='somedistr', distrtitle=None,
hist=None, left=-1., right=1., nbins=50
):
if hist is None:
import coffea.hist
vartitle = varname if vartitle is None else vartitle
hist = coffe... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Fill(self, *args, **kwargs):\n self._varexp = kwargs.get(\"varexp\")\n self._cuts = kwargs.get(\"cuts\", [])\n self._weight = kwargs.get(\"weight\", \"1\")\n if len(args) == 1 and isinstance(args[0], (str, unicode)):\n IOManager.FillHistogram(self, args[0], **kwargs)\n ... | [
"0.6048329",
"0.59464675",
"0.5933661",
"0.5887746",
"0.58725816",
"0.57364476",
"0.5714648",
"0.5633713",
"0.56145376",
"0.5604098",
"0.5588111",
"0.5546958",
"0.554628",
"0.55081207",
"0.549454",
"0.54831433",
"0.5475002",
"0.5430655",
"0.54043436",
"0.53916496",
"0.5367704... | 0.73073107 | 0 |
Takes a cut function and tries to return a title for it | def get_title(fn):
title = fn.name if hasattr(fn, 'name') else fn.__name__
title = title.replace('_cut_function','')
suffix = []
# if 'JetsAK15_subleading_' in title:
# suffix.append(r'$j^{\mathrm{AK15}}_{\mathrm{subl}}$')
title = title.replace('JetsAK15_subleading_', '').replace('subleading... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_title():",
"def make_title(words):",
"def getTitle(test:str) -> str:\n return test[5:].strip()",
"def PROPER(text):\n return text.title()",
"def test_title(names):",
"def title(value):\r\n title_word = lambda w: w if RE_UPPERCASE.search(w) else old_title(w)\r\n return re.sub('(\\S+)', l... | [
"0.70298654",
"0.6522897",
"0.6284885",
"0.61326414",
"0.60484356",
"0.6029634",
"0.6029412",
"0.6012764",
"0.59930116",
"0.598101",
"0.5968265",
"0.59671205",
"0.5940044",
"0.59055644",
"0.58885586",
"0.5842299",
"0.5840335",
"0.58212703",
"0.58197415",
"0.5815073",
"0.57954... | 0.78655964 | 0 |
The Windows version of base.processInterrupt Note! This doesn't work terribly well with a lot of processes. | def processInterrupt(uPid):
try:
# pylint: disable=no-member
win32console.GenerateConsoleCtrlEvent(win32con.CTRL_BREAK_EVENT, uPid);
#GenerateConsoleCtrlEvent = ctypes.windll.kernel32.GenerateConsoleCtrlEvent
#rc = GenerateConsoleCtrlEvent(1, uPid);
#reporter.log('GenerateCon... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_process_interrupted(exc: \"KeyboardInterrupt\"):\n _print(f\"\\nInterrupted. {exc}\")",
"def stop(self):\n # trying this instead of SIGTERM\n # http://stackoverflow.com/a/6659191/3380530\n # self._process.send_signal(SIGINT)\n # Or not. SIGINT doesn't exist on Windows\n ... | [
"0.63215697",
"0.5775936",
"0.57586217",
"0.5744429",
"0.5740155",
"0.5561683",
"0.5558111",
"0.5497653",
"0.5479278",
"0.54543006",
"0.54173666",
"0.541069",
"0.5367018",
"0.53545386",
"0.5337776",
"0.53182185",
"0.5305628",
"0.52493083",
"0.522078",
"0.5160787",
"0.51373094... | 0.67192686 | 0 |
Posts a WM_CLOSE message to the specified thread. | def postThreadMesssageClose(uTid):
fRc = False;
try:
win32api.PostThreadMessage(uTid, win32con.WM_CLOSE, 0, 0); # pylint: disable=no-member
fRc = True;
except:
reporter.logXcpt('uTid=%s' % (uTid,));
return fRc; | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def postThreadMesssageQuit(uTid):\n fRc = False;\n try:\n win32api.PostThreadMessage(uTid, win32con.WM_QUIT, 0x40010004, 0); # DBG_TERMINATE_PROCESS # pylint: disable=no-member\n fRc = True;\n except:\n reporter.logXcpt('uTid=%s' % (uTid,));\n return fRc;",
"def close(self):\n\n... | [
"0.65258104",
"0.647808",
"0.6194087",
"0.6059737",
"0.6028249",
"0.5981587",
"0.59607416",
"0.5957837",
"0.5957837",
"0.5957837",
"0.5957837",
"0.5846168",
"0.58057123",
"0.57886297",
"0.574851",
"0.5722326",
"0.5718076",
"0.57172066",
"0.5709524",
"0.5701404",
"0.5693792",
... | 0.7335398 | 0 |
Posts a WM_QUIT message to the specified thread. | def postThreadMesssageQuit(uTid):
fRc = False;
try:
win32api.PostThreadMessage(uTid, win32con.WM_QUIT, 0x40010004, 0); # DBG_TERMINATE_PROCESS # pylint: disable=no-member
fRc = True;
except:
reporter.logXcpt('uTid=%s' % (uTid,));
return fRc; | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def postThreadMesssageClose(uTid):\n fRc = False;\n try:\n win32api.PostThreadMessage(uTid, win32con.WM_CLOSE, 0, 0); # pylint: disable=no-member\n fRc = True;\n except:\n reporter.logXcpt('uTid=%s' % (uTid,));\n return fRc;",
"def quit(self, mess... | [
"0.6247474",
"0.6094396",
"0.58557373",
"0.57782835",
"0.57772505",
"0.5738489",
"0.5506181",
"0.5447505",
"0.5402179",
"0.5354124",
"0.5341512",
"0.5266031",
"0.5251934",
"0.52516365",
"0.52507806",
"0.5238659",
"0.5238613",
"0.5237029",
"0.5236302",
"0.5228808",
"0.522184",... | 0.7239463 | 0 |
The Windows version of base.processKill | def processKill(uPid):
return processTerminate(uPid); | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def kill(self):\r\n try:\r\n if self.process:\r\n self.process.kill()\r\n self.process.wait()\r\n except WindowsError:\r\n # kill may not be available under windows environment\r\n pass",
"def _KillProcess(self, pid):\n if sys.platfo... | [
"0.726238",
"0.6810974",
"0.6760341",
"0.6577071",
"0.63967526",
"0.63236195",
"0.63068575",
"0.6289544",
"0.6275234",
"0.6238362",
"0.62296176",
"0.6153977",
"0.6149264",
"0.6146983",
"0.6144532",
"0.61424387",
"0.6141811",
"0.60982275",
"0.60788274",
"0.6070093",
"0.6050515... | 0.74643934 | 0 |
The Windows version of base.processCheckPidAndName | def processCheckPidAndName(uPid, sName):
fRc = processExists(uPid);
if fRc is True:
try:
from win32com.client import GetObject; # pylint: disable=F0401
oWmi = GetObject('winmgmts:');
aoProcesses = oWmi.InstancesOf('Win32_Process');
for oProcess in aoProces... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def exe_match(expected_name):\n # expected_name = expected_name.encode('ascii')\n def f(win):\n n = conv(win.process_name)\n return n == expected_name\n return f",
"def check_process_for_pid(pid, process_name):\n pid = int(pid)\n proc = psutil.Process(pid)\n return proc.name() == ... | [
"0.6427718",
"0.627324",
"0.6176712",
"0.6168791",
"0.61007553",
"0.6070687",
"0.60217047",
"0.60116947",
"0.5992538",
"0.5970814",
"0.59083015",
"0.5876524",
"0.58620656",
"0.5821407",
"0.5805197",
"0.57778066",
"0.5776582",
"0.5765953",
"0.57581586",
"0.57557404",
"0.573748... | 0.71424156 | 0 |
Logs windows memory stats. | def logMemoryStats():
class MemoryStatusEx(ctypes.Structure):
""" MEMORYSTATUSEX """
kaFields = [
( 'dwLength', ctypes.c_ulong ),
( 'dwMemoryLoad', ctypes.c_ulong ),
( 'ullTotalPhys', ctypes.c_ulonglong ),
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_memory_stats(location_tag=\"undef\"):\n try:\n import psutil\n p = psutil.Process(os.getpid())\n rm, vm = p.get_memory_info()\n print \"MEM_STAT (%s) rm=%s, vm=%s\" % (location_tag, rm, vm)\n except ImportError:\n print \"psutil module not available\"",
"def log... | [
"0.70418596",
"0.6867534",
"0.643289",
"0.6419121",
"0.6389766",
"0.6379068",
"0.59949344",
"0.5943068",
"0.5942947",
"0.5925752",
"0.5925409",
"0.5925409",
"0.5925409",
"0.5925409",
"0.5925409",
"0.5925409",
"0.5925409",
"0.59162056",
"0.58963734",
"0.5882967",
"0.5870274",
... | 0.798583 | 0 |
Calls HeapValidate(GetProcessHeap(), 0, NULL); | def checkProcessHeap():
# Get the process heap.
try:
hHeap = ctypes.windll.kernel32.GetProcessHeap();
except:
reporter.logXcpt();
return False;
# Check it.
try:
fIsOkay = ctypes.windll.kernel32.HeapValidate(hHeap, 0, None);
except:
reporter.logXcpt();
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def precheck(self):\n if self.__memory_size is None:\n self.logger.exception(\"[Memory] Please set memory size.\")\n raise ArgsNotCorrect(\"Please set memory size.\")",
"def test_func_heap(self):\n cmd = \"deref $_heap()\"\n target = _target(\"heap\")\n self.asse... | [
"0.5956563",
"0.5820966",
"0.5391256",
"0.5279991",
"0.52643716",
"0.52414745",
"0.5221388",
"0.51908994",
"0.5157347",
"0.51529896",
"0.5116927",
"0.50405",
"0.50393564",
"0.5023326",
"0.5012351",
"0.5010514",
"0.5008411",
"0.50031483",
"0.4997377",
"0.49946463",
"0.49777916... | 0.76484793 | 0 |
Runs the component. The Annual Total Savings,Annual Costs, Annual Net Benefit, NPV Benefits, NPV Costs, NPV Net Benefits, Benefit Cost Ratio, Levelized Cost of Energy, and Internal Rate of Return will all be calculated. There must be a known Heat Recovery project for this component to run. | def run (self, scalers = {'capital costs':1.0}):
self.was_run = True
self.reason = "OK"
tag = self.cd['file id'].split('+')
if len(tag) > 1 and tag[1] != 'transmission':
self.was_run = False
self.reason = "Not a transmission project."
return
i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run (self, scalers = {'capital costs':1.0}):\n\n self.was_run = True\n self.reason = \"OK\"\n tag = self.cd['file id'].split('+')\n if len(tag) > 1 and tag[1] != 'wind':\n self.was_run = False\n self.reason = \"Not a Wind project\"\n return\n\n ... | [
"0.69873667",
"0.64584976",
"0.6378536",
"0.63241583",
"0.63009036",
"0.62177217",
"0.6204553",
"0.6156644",
"0.6136159",
"0.6083111",
"0.6052154",
"0.6037782",
"0.60245705",
"0.60139",
"0.5996558",
"0.599415",
"0.5984706",
"0.59628487",
"0.59623754",
"0.59618145",
"0.5958885... | 0.68490684 | 1 |
Calculate the Average Diesel load of the current system Attributes | def calc_average_load (self):
#~ self.generation = self.forecast.generation_by_type['generation diesel']\
#~ [self.start_year]
self.average_load = \
self.forecast.yearly_average_diesel_load.ix[self.start_year] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calc_average_load (self):\n if self.comp_specs['proposed capacity'] != UNKNOWN:\n self.average_load = None\n self.generation = self.forecast.generation['generation diesel']\\\n [self.start_year]\n self.average_load = \\\... | [
"0.7328244",
"0.64413404",
"0.6380107",
"0.63506234",
"0.6312014",
"0.6299931",
"0.618164",
"0.6149521",
"0.6113699",
"0.608994",
"0.6078722",
"0.59945375",
"0.5977917",
"0.5886562",
"0.5843336",
"0.5759978",
"0.5727464",
"0.565973",
"0.5629968",
"0.56079954",
"0.5549923",
... | 0.7217842 | 1 |
Calculate the generation offset by connecting a transmission line to the community to connect to. Attributes | def calc_intertie_offset_generation (self):
self.generation = \
self.forecast.get_generation(self.start_year,self.end_year)
dist = self.comp_specs['distance to community']
self.annual_transmission_loss = \
1 - (
(1- (self.comp_specs['transmission loss ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate_and_set_propagation_distances(self):\n\n self.l_edge = self.calculate_distance_edge()\n self.l_int = self.calculate_distance_interaction()",
"def calculate_module_offsets(self):\n \n # These aren't for instantiating, but we use them to get the dimensions\n self.po... | [
"0.5927528",
"0.57913303",
"0.5498828",
"0.54520005",
"0.5265909",
"0.52382195",
"0.520508",
"0.5108444",
"0.50968987",
"0.5064629",
"0.5039651",
"0.5012671",
"0.4999943",
"0.4968546",
"0.4968546",
"0.49591216",
"0.4952447",
"0.49499637",
"0.49423927",
"0.49011195",
"0.489852... | 0.62144107 | 0 |
Calculate the heat recovery | def calc_lost_heat_recovery (self):
if not self.cd['heat recovery operational']:
self.lost_heat_recovery = [0]
else:
gen_eff = self.cd["diesel generation efficiency"]
self.lost_heat_recovery = \
(self.generation / gen_eff )* .10 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calc_loss_heat_recovery (self):\n hr_used = self.cd['heat recovery operational']\n self.loss_heat_recovery = 0\n if hr_used:# == 'Yes':\n self.loss_heat_recovery = self.electric_diesel_reduction * \\\n (self.comp_specs['percent heat recovered'] / 100.0)\n #... | [
"0.72527164",
"0.6295159",
"0.6292347",
"0.62802047",
"0.6267784",
"0.60749567",
"0.59754294",
"0.59540564",
"0.58983105",
"0.5896097",
"0.589459",
"0.5840689",
"0.56996167",
"0.56794786",
"0.5667763",
"0.5648994",
"0.56376565",
"0.56210124",
"0.5620937",
"0.55695546",
"0.554... | 0.75004613 | 0 |
Calculate the capital costs. Attributes | def calc_capital_costs (self):
road_needed = 'road needed'
if self.cd['on road system']:
road_needed = 'road not needed'
dist = self.comp_specs['distance to community']
self.capital_costs = self.comp_specs['est. intertie cost per mile']\
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calc_capital_costs (self):\n self.capital_costs = self.max_boiler_output * \\\n self.comp_specs[\"cost per btu/hrs\"]\n #~ print self.capital_costs",
"def calc_capital_costs (self):\n powerhouse_control_cost = 0\n if not self.cd['switchgear suitable ... | [
"0.7806206",
"0.74040896",
"0.6545671",
"0.64966065",
"0.64836544",
"0.6464849",
"0.63642645",
"0.6326284",
"0.63027006",
"0.62339413",
"0.62284034",
"0.6213556",
"0.6188633",
"0.61863375",
"0.6160501",
"0.61119217",
"0.60997415",
"0.60323167",
"0.599988",
"0.5985151",
"0.595... | 0.7694785 | 1 |
Calculate annual electric savings created by the project. Attributes | def calc_annual_electric_savings (self):
costs = self.comp_specs['diesel generator o&m']
for kW in costs.keys():
try:
if self.average_load < int(kW):
maintenance = self.comp_specs['diesel generator o&m'][kW]
break
except Va... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calc_annual_electric_savings (self):\n price = self.diesel_prices\n #TODO add rural v non rural\n self.base_generation_cost = self.electric_diesel_reduction * price\n\n\n self.proposed_generation_cost = self.maintenance_cost\n\n self.annual_electric_savings = self.base_genera... | [
"0.7408717",
"0.6447516",
"0.61507213",
"0.56581444",
"0.56386214",
"0.56319666",
"0.56268173",
"0.5622094",
"0.55830747",
"0.55610895",
"0.55515134",
"0.5541858",
"0.5536161",
"0.5518753",
"0.54845977",
"0.5477718",
"0.54517406",
"0.54387516",
"0.54357356",
"0.54199076",
"0.... | 0.70783615 | 1 |
Calculate annual heating savings created by the project. Attributes | def calc_annual_heating_savings (self):
price = self.diesel_prices + self.cd['heating fuel premium']
maintenance = self.comp_specs['heat recovery o&m']
self.annual_heating_savings = -1 * \
(maintenance + (self.lost_heat_recovery * price)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calc_annual_heating_savings (self):\n price = (self.diesel_prices + self.cd['heating fuel premium'])\n\n #~ self.base_heating_cost =\n\n #~ self.proposed_heating_cost =\n\n\n\n\n self.annual_heating_savings = self.reduction_diesel_used * price\n #~ print 'self.annual_heating_... | [
"0.7293272",
"0.65816814",
"0.64126164",
"0.5913036",
"0.59082484",
"0.55546623",
"0.55409116",
"0.5488795",
"0.54877865",
"0.5483977",
"0.54786175",
"0.5446557",
"0.54036194",
"0.5401703",
"0.53986675",
"0.53903943",
"0.53836673",
"0.538216",
"0.537716",
"0.5362062",
"0.5353... | 0.69910264 | 1 |
Get total fuel saved. Returns float the total fuel saved in gallons | def get_fuel_total_saved (self):
#~ print self.lost_heat_recovery
#~ print self.intertie_offset_generation_fuel_used
#~ print self.pre_intertie_generation_fuel_used
#~ gen_eff = self.cd["diesel generation efficiency"]
#~ fuel_used = self.intertie_offset_generation / gen_eff
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_fuel_total_saved (self):\n return self.electric_diesel_reduction + self.reduction_diesel_used",
"def get_total_energy(parameters):\n return orm.Float(parameters.get_attribute('energy'))",
"def total_energy(self):\n return self._total_energy",
"def totalValue(self):\n\n\t\tvalue = 0\n... | [
"0.824919",
"0.67309505",
"0.67212445",
"0.6641931",
"0.6640454",
"0.65572923",
"0.64542156",
"0.6337531",
"0.6322669",
"0.6316941",
"0.6301916",
"0.6281241",
"0.62791896",
"0.6275253",
"0.6265616",
"0.61895245",
"0.6137895",
"0.61320716",
"0.61031145",
"0.6087333",
"0.607770... | 0.7722197 | 1 |
Get your current running jobs on the Sherlock cluster | def running_jobs_sherlock():
user = os.environ['USER']
return subprocess.check_output(['squeue', '-u',user,'-o','%Z']).split()[1:] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_current_jobs(ssh):\n stdin, stdout, stderr = ssh.exec_command('qstat')\n\n running_jobs = []\n for line in stdout.readlines():\n if '.awonmgr2' in line:\n jobid = line.split('.awonmgr2')[0]\n running_jobs.append(jobid)\n \n return running_jobs",
"async def get_... | [
"0.7408034",
"0.72631824",
"0.7173004",
"0.6856391",
"0.6788189",
"0.6787631",
"0.6698274",
"0.6687841",
"0.6678214",
"0.6678214",
"0.66645783",
"0.6657631",
"0.66119254",
"0.65800935",
"0.6543887",
"0.65284514",
"0.64695036",
"0.6460383",
"0.64549667",
"0.64276236",
"0.63949... | 0.76263565 | 0 |
simply sends a message to the client address specified. | def send_net_message_client(message, client_addr):
serverSocket.sendto(message, client_addr) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def msg_client(msg, client):\r\n client.send(bytes(str(msg), \"utf-8\"))",
"def sendToClient(self, client_id, message_type, message):\n if not client_id in self.client_to_socket:\n raise ValueError(\"The client with id {} does not exist\".format(client_id))\n self.sendToSocket(self.cl... | [
"0.7387198",
"0.6993373",
"0.6930433",
"0.69239",
"0.6904713",
"0.68367815",
"0.6811525",
"0.67738485",
"0.6729188",
"0.6701323",
"0.6656938",
"0.6642157",
"0.66237146",
"0.6605746",
"0.6597053",
"0.6596277",
"0.6579792",
"0.65749264",
"0.6560786",
"0.6554997",
"0.65531754",
... | 0.82171863 | 0 |
Sets the payee_wallet_id of this EscrowTransactionResponse. | def payee_wallet_id(self, payee_wallet_id):
self._payee_wallet_id = payee_wallet_id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def payer_wallet_id(self, payer_wallet_id):\n\n self._payer_wallet_id = payer_wallet_id",
"def payor_id(self, payor_id):\n\n self._payor_id = payor_id",
"def payee_zip(self, payee_zip):\n\n self._payee_zip = payee_zip",
"def set_merchant_transaction_id(self, transaction_id):\n sel... | [
"0.7311907",
"0.573136",
"0.54004514",
"0.53062975",
"0.53006345",
"0.5269258",
"0.5153421",
"0.5153421",
"0.4994353",
"0.4974469",
"0.49704325",
"0.49286303",
"0.49132255",
"0.4910477",
"0.4855245",
"0.48479044",
"0.48479044",
"0.48479044",
"0.48202246",
"0.47650665",
"0.474... | 0.81508285 | 0 |
Sets the payer_wallet_id of this EscrowTransactionResponse. | def payer_wallet_id(self, payer_wallet_id):
self._payer_wallet_id = payer_wallet_id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def payee_wallet_id(self, payee_wallet_id):\n\n self._payee_wallet_id = payee_wallet_id",
"def payor_id(self, payor_id):\n\n self._payor_id = payor_id",
"def set_merchant_transaction_id(self, transaction_id):\n self.merchant_transaction_id = transaction_id",
"def merchant_id(self, mercha... | [
"0.7696529",
"0.60767055",
"0.56332916",
"0.56299317",
"0.5272401",
"0.5272401",
"0.5213051",
"0.5161533",
"0.51283133",
"0.5097511",
"0.4929194",
"0.48645753",
"0.48536748",
"0.48232916",
"0.4775775",
"0.47211295",
"0.47165722",
"0.4694163",
"0.46884617",
"0.4682201",
"0.465... | 0.84063405 | 0 |
Sets the withdrawn of this EscrowTransactionResponse. | def withdrawn(self, withdrawn):
self._withdrawn = withdrawn | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def withdrawMoney(self, withdraw_amount):\r\n if (self.balance_amt - withdraw_amount) > 0:\r\n self.balance_amt = self.balance_amt - withdraw_amount\r\n else:\r\n raise WithdrawError #Exception('Overdraft withdrawal Error. Cannot withdraw more than amount in account balance: {}'... | [
"0.5891516",
"0.5690135",
"0.5676766",
"0.5597701",
"0.55876815",
"0.55855316",
"0.55006677",
"0.5495458",
"0.5472348",
"0.54654574",
"0.5433065",
"0.53317225",
"0.5330039",
"0.5313943",
"0.5277022",
"0.52171",
"0.51859295",
"0.51577157",
"0.5134747",
"0.5110238",
"0.5054822"... | 0.78851956 | 0 |
Sets the escrow_address of this EscrowTransactionResponse. | def escrow_address(self, escrow_address):
self._escrow_address = escrow_address | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_address(self, address):\n pass",
"def address(self, address: object):\n\n self._address = address",
"def address(self, address):\n\n self._address = address",
"def address(self, address):\n\n self._address = address",
"def address(self, address):\n\n self._address... | [
"0.60267246",
"0.5820161",
"0.57166636",
"0.57166636",
"0.57166636",
"0.57166636",
"0.57166636",
"0.57166636",
"0.57166636",
"0.57166636",
"0.56964433",
"0.5556428",
"0.55402744",
"0.55071515",
"0.5419375",
"0.5411141",
"0.54009694",
"0.538831",
"0.5359071",
"0.53501517",
"0.... | 0.83312446 | 0 |
Sets the record_status of this EscrowTransactionResponse. | def record_status(self, record_status):
self._record_status = record_status | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _set_status(self):\n result = self._get_status()\n if result and result[0]['state'] == 'aborted':\n raise Exception(\"Aborted because the status flag is set to 'aborted' in dynamodb\")\n\n # record the status\n self.status['timestamp'] = time.strftime(\"%Y-%m-%dT%H:%M:%SZ... | [
"0.5884911",
"0.5822956",
"0.5775433",
"0.56188405",
"0.56188405",
"0.56188405",
"0.561294",
"0.55961376",
"0.5581018",
"0.5559708",
"0.5559708",
"0.5559708",
"0.5559708",
"0.5559708",
"0.5559708",
"0.5559708",
"0.5553998",
"0.5553998",
"0.5553998",
"0.5553998",
"0.5553998",
... | 0.783832 | 0 |
Sets the update_date of this EscrowTransactionResponse. | def update_date(self, update_date):
self._update_date = update_date | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def updated_date(self, updated_date):\n\n self._updated_date = updated_date",
"def updated_date(self, updated_date):\n\n self._updated_date = updated_date",
"def updated_date(self, updated_date):\n self._updated_date = updated_date",
"def updated_date(self, updated_date):\n if upd... | [
"0.72074246",
"0.72074246",
"0.7175995",
"0.6495363",
"0.62919956",
"0.6009002",
"0.57752734",
"0.5506892",
"0.5506892",
"0.5489573",
"0.5442477",
"0.54176337",
"0.54176337",
"0.54176337",
"0.5408546",
"0.5396654",
"0.5396654",
"0.5396654",
"0.5396654",
"0.5396654",
"0.539665... | 0.7807129 | 1 |
Helper to log the failed SQS records metric | def _log_failed(cls, count):
MetricLogger.log_metric(FUNCTION_NAME, MetricLogger.SQS_FAILED_RECORDS, count) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def log_failures(self):\n for exception in self.queue_manager.failure_descriptions():\n self.logger.info(exception)",
"def test_failed_deliveries_logging(self):\n sms = SMS.objects.create(to='+6280000000000', status=STATUS.queued,\n backend_alias='error')\... | [
"0.65698266",
"0.6314558",
"0.6210403",
"0.6180184",
"0.61691684",
"0.6075002",
"0.6070457",
"0.6059748",
"0.6040478",
"0.598686",
"0.5963177",
"0.5926306",
"0.5920489",
"0.5919631",
"0.58492374",
"0.5753404",
"0.5748351",
"0.5638719",
"0.5619237",
"0.56000847",
"0.55767053",... | 0.8446626 | 0 |
Segment the records into batches that conform to SQS restrictions This will log any single record that is too large to send, and skip it. | def _message_batches(cls, records):
# Dump the records to a list of minimal json
records_json = [
json.dumps(record, separators=(',', ':')) for record in records
]
current_batch_size = 0
current_batch = []
for record in records_json:
line_len = le... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _log_process(self, log_req):\n rq_size = log_req.multipart_size\n with self._lock:\n if self._payload_size + rq_size >= self.max_payload_size:\n if len(self._batch) > 0:\n self._send_batch()\n self._batch.append(log_req)\n self._p... | [
"0.61672634",
"0.61136776",
"0.55916774",
"0.55586743",
"0.55274945",
"0.5349872",
"0.5317542",
"0.5314152",
"0.51939815",
"0.519289",
"0.5187157",
"0.51492345",
"0.5112248",
"0.50969017",
"0.5063732",
"0.5059225",
"0.5043429",
"0.5042894",
"0.5032821",
"0.49991766",
"0.49933... | 0.62689286 | 0 |
Inspect the response and remove any records records that have successfully to sent For each record, the index of the response element is the same as the index used in the request array. | def _strip_successful_records(cls, messages, response):
success_ids = {
item['Id'] for item in response['Successful']
}
LOGGER.info('Removing sucessful message indices from batch: %s', success_ids)
for success_id in success_ids:
# Get the successful message by I... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clean_none_response(self):\n\n print(\"# Rows before non response are removed: {} \".format(len(self.data)))\n self.data = self.data[self.data['names'].map(lambda d: len(d) > 0)]\n print(\"# Rows after non response are removed: {} \".format(len(self.data)))",
"def _finalize(self, respons... | [
"0.6261296",
"0.5926714",
"0.5847716",
"0.58347917",
"0.5816505",
"0.568727",
"0.5628807",
"0.55821556",
"0.55515593",
"0.5497828",
"0.5445062",
"0.5384468",
"0.5301025",
"0.52775407",
"0.5272712",
"0.52238524",
"0.5213868",
"0.51214164",
"0.51052916",
"0.50793844",
"0.507387... | 0.7417818 | 0 |
Send a list of records to SQS, batching as necessary | def send(self, payloads):
records = self._payload_messages(payloads)
# SQS only supports up to 10 messages so do the send in batches
for message_batch in self._message_batches(records):
response = self._send_messages(message_batch)
self._finalize(response, message_batch) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _message_batches(cls, records):\n # Dump the records to a list of minimal json\n records_json = [\n json.dumps(record, separators=(',', ':')) for record in records\n ]\n\n current_batch_size = 0\n current_batch = []\n for record in records_json:\n ... | [
"0.6739715",
"0.66852796",
"0.6401511",
"0.63491935",
"0.6338009",
"0.63261616",
"0.63134557",
"0.63052964",
"0.6195632",
"0.6183819",
"0.6173889",
"0.61398053",
"0.6103908",
"0.6066584",
"0.6057908",
"0.60467565",
"0.6021644",
"0.6018628",
"0.5985069",
"0.5927403",
"0.588516... | 0.7458315 | 0 |
Method to add a user as friends that is, to create a bidirectional link that connects the two users. | def add_friends(self, user1_index, user2_index):
if user1_index >= self.num_users or user2_index >= self.num_users:
raise ValueError(
f"Number of users is {self.num_users}, but indices "
f"{user1_index} and {user2_index} were requested."
)
if self.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_friend(self, User):\n if not User in self.friends.all():\n self.friend.add(User)\n #self.save()",
"def addfriend(self, second_user_id):\n second_user = User.objects.get(id=second_user_id)\n new_friendship = Friendship.objects.create(friend_user=self, friend=seco... | [
"0.7621462",
"0.7019252",
"0.69413483",
"0.69305646",
"0.69305646",
"0.69305646",
"0.6898999",
"0.68216527",
"0.67973375",
"0.67016155",
"0.6672114",
"0.6542767",
"0.6497178",
"0.6497178",
"0.6497178",
"0.6497178",
"0.6441999",
"0.6441999",
"0.6441999",
"0.6441999",
"0.643866... | 0.7181159 | 1 |
Render the Lilypond music expression lily using lilypond. | def render_lily(self, lily):
shasum = "%s.png" % sha(lily.encode('utf-8')).hexdigest()
relfn = posixpath.join(self.builder.imgpath, 'lily', shasum)
outfn = path.join(self.builder.outdir, '_images', 'lily', shasum)
if path.isfile(outfn):
return relfn
if hasattr(self.builder, '_lilypng_warned... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def display(self, format=\"png\"):\n from .core.transforms import lilypond\n seq = HSeq(self) | lilypond()\n\n lily_output = write_lilypond.lily_format(seq)\n if not lily_output.strip():\n #In the case of empty lily outputs, return self to get a textual display\n r... | [
"0.62011886",
"0.60662764",
"0.5725134",
"0.5563053",
"0.5401194",
"0.52068543",
"0.51799726",
"0.51762205",
"0.5175516",
"0.5059088",
"0.4895712",
"0.4883887",
"0.48677018",
"0.4829131",
"0.47872004",
"0.4744463",
"0.47235727",
"0.4710764",
"0.47090602",
"0.4685067",
"0.4676... | 0.7580346 | 0 |
This function places an order for "context.index" in the amount required to neutralize the beta exposure of the portfolio. Note that additional leverage in the account is taken on, however, net market exposure is reduced. | def hedge_portfolio(context, data):
factors = get_alphas_and_betas(context, data)
beta_exposure = 0.0
count = 0
for asset in context.portfolio.positions:
if asset in factors and asset != context.index:
if not np.isnan(factors[asset].beta):
beta_exposure += fact... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_alphas_and_betas(context, data):\r\n all_assets = context.portfolio.positions.keys()\r\n if context.index not in all_assets:\r\n all_assets.append(context.index)\r\n prices = data.history(all_assets, 'price', context.lookback, '1d')\r\n returns = prices.pct_change()[1:]\r\n # index_re... | [
"0.5514604",
"0.5256099",
"0.5154788",
"0.50738245",
"0.50134844",
"0.5007411",
"0.4994111",
"0.49798325",
"0.4962537",
"0.4952547",
"0.4933376",
"0.49214765",
"0.49075228",
"0.49000627",
"0.4870517",
"0.48602587",
"0.4830687",
"0.48236924",
"0.47850198",
"0.47702926",
"0.474... | 0.55305976 | 0 |
returns a dataframe of 'alpha' and 'beta' exposures for each asset in the current universe. | def get_alphas_and_betas(context, data):
all_assets = context.portfolio.positions.keys()
if context.index not in all_assets:
all_assets.append(context.index)
prices = data.history(all_assets, 'price', context.lookback, '1d')
returns = prices.pct_change()[1:]
# index_returns = returns[c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_alphas(portfolio_returns,risk_free,market_returns,betas):\r\n \r\n R = portfolio_returns\r\n Rf = risk_free\r\n Beta = betas\r\n Rm = market_returns\r\n alpha = R - Rf - (Beta*(Rm-Rf))\r\n \r\n return alpha",
"def transparency(\n et: pd.DataFrame, alpha_by: Hashable, alpha_boun... | [
"0.571466",
"0.5539759",
"0.5527638",
"0.5383794",
"0.53507555",
"0.5238355",
"0.51728773",
"0.5134495",
"0.5117016",
"0.50879073",
"0.50690675",
"0.5064041",
"0.5010054",
"0.49698728",
"0.49637634",
"0.49520984",
"0.49412426",
"0.4937754",
"0.4913756",
"0.49073732",
"0.48986... | 0.7166975 | 0 |
Removes charracters listed in self.custom_chars | def _remove_custom_chars(self, text: str) -> str:
patterns = "|".join([x for x in self.custom_chars])
return re.sub(patterns, "", str(text), flags=re.IGNORECASE) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def removeSpecialChars(self) -> None:\n self.text = re.sub('[^a-zA-z0-9\\n\\.\\s]', '', self.text)",
"def _remove_special_chars(self, text: str) -> str:\n pattern = re.compile(self.special_chars_pattern)\n text = re.sub(pattern, \" \", text)\n return text",
"def strip_other_charcter... | [
"0.7372764",
"0.7265707",
"0.7070031",
"0.6986273",
"0.69196767",
"0.68504214",
"0.67211777",
"0.66895443",
"0.6674223",
"0.6622369",
"0.662198",
"0.66078997",
"0.65977836",
"0.6588692",
"0.65562934",
"0.65343094",
"0.6528675",
"0.6523658",
"0.6516981",
"0.650481",
"0.6504477... | 0.8835553 | 0 |
Removes strings starting with http | def _remove_urls(self, text: str) -> str:
pattern = r"http\S+"
return re.sub(pattern, " ", str(text)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_URL(sample):\n return re.sub(r\"http\\S+\", \"\", sample)",
"def remove_urls(self, text):\n return re.sub(r'http.?://[^\\s]+[\\s]?', '', text)",
"def remove_url(txt):\n\n return \" \".join(re.sub(\"([^0-9A-Za-z \\t])|(\\w+:\\/\\/\\S+)\", \"\", txt).split())",
"def remove_url(text):\n... | [
"0.78006214",
"0.7698079",
"0.7578181",
"0.74963003",
"0.7458265",
"0.74112725",
"0.73307616",
"0.72641194",
"0.72031736",
"0.7188069",
"0.71281874",
"0.70712876",
"0.7058085",
"0.7049562",
"0.7030817",
"0.69787",
"0.6963308",
"0.69407505",
"0.6912276",
"0.68773633",
"0.68092... | 0.780052 | 1 |
Removes isolated block of digits | def _remove_digit_blocks(self, text: str) -> str:
return re.sub(r"\b\d+\b", " ", str(text)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_free_digits(text):\n return RegexFilters.replace_free_digits(text, \" \")",
"def remove_nums(self, text):\r\n return text.translate(None, digits)",
"def remove_nums(self, text):\r\n return text.translate(None, digits)",
"def remove_nums(self, text):\r\n return text.tran... | [
"0.7002717",
"0.6815302",
"0.6815302",
"0.6815302",
"0.6682333",
"0.6597962",
"0.6564372",
"0.6525351",
"0.6459419",
"0.6430528",
"0.6379692",
"0.63564974",
"0.6303089",
"0.6271742",
"0.6265842",
"0.6203773",
"0.6179784",
"0.6123884",
"0.6112976",
"0.610751",
"0.6047446",
"... | 0.7632309 | 0 |
Removes special characters as defined by the pattern in self.special_chars_pattern | def _remove_special_chars(self, text: str) -> str:
pattern = re.compile(self.special_chars_pattern)
text = re.sub(pattern, " ", text)
return text | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def removeSpecialChars(self) -> None:\n self.text = re.sub('[^a-zA-z0-9\\n\\.\\s]', '', self.text)",
"def remove_special_characters(text, remove_digits=False):\n pattern = r'[^a-zA-z0-9\\s]' if not remove_digits else r'[^a-zA-z\\s]'\n text = re.sub(pattern, '', text)\n return text",
"def remove... | [
"0.8309218",
"0.7856203",
"0.7768344",
"0.76876336",
"0.7650726",
"0.76494753",
"0.76118165",
"0.7510932",
"0.74934494",
"0.7467364",
"0.74673146",
"0.72453177",
"0.72366244",
"0.71997553",
"0.7166965",
"0.71665037",
"0.7158556",
"0.7108985",
"0.70958817",
"0.6979312",
"0.688... | 0.85286283 | 0 |
Return data (tuple of classes, params) for a given host. | def get_host_data(hostname, gettype='walk'):
filteredNodes = Node.objects.filter(hostname=hostname)
if (filteredNodes.count() == 1):
node = filteredNodes[0]
exclusions = get_exclusions(node)
if gettype == 'work':
(classes, params) = work_tree(node, exclusions=exclusions)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_host_data(self):\n\n raise NotImplementedError",
"def get_host_variables(self, host):\n vars = {}\n for i in self.parsers:\n vars.update(i.get_host_variables(host))\n return vars",
"def loadAllHostinfo():\n hidata={}\n str=\"\"\n keytypes=loadHostinfoKeys... | [
"0.6268357",
"0.5708121",
"0.5704203",
"0.5604825",
"0.5533057",
"0.5413477",
"0.54038036",
"0.53823394",
"0.52971464",
"0.5290275",
"0.5289944",
"0.52613753",
"0.52593875",
"0.5238726",
"0.52148",
"0.5184951",
"0.5168947",
"0.51548314",
"0.51526666",
"0.5109809",
"0.5093862"... | 0.652414 | 0 |
Adds a node entry definition if there is no lower depth definition. Raises RuntimeError if the depth matches. | def add_entry(self, key, value, depth):
current = self.entries.get(key, None)
if current is None or current.depth > depth:
self.entries[key] = NodeEntry(key, value, depth)
elif current.depth == depth:
raise RuntimeError('Col... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_entry(self, entry): # Hashmap.add_entry\n\n if entry.hexdigest in self.contentHash:\n self.contentHash[entry.hexdigest].append(entry)\n else:\n self.contentHash[entry.hexdigest] = [ entry ]\n\n if entry.depth < self.minDepth:\n self.minD... | [
"0.55656815",
"0.5325866",
"0.5322028",
"0.52112687",
"0.5193852",
"0.5172305",
"0.5172305",
"0.51599175",
"0.5064102",
"0.49744448",
"0.4960249",
"0.49437156",
"0.49024606",
"0.48839802",
"0.48804682",
"0.4869079",
"0.48573893",
"0.48446208",
"0.48397067",
"0.48307618",
"0.4... | 0.6691731 | 0 |
Adds all the entries in objs at the current depth. | def add_entries(self, objs, keyname, valuename, depth):
add_entry = self.add_entry
for obj in objs:
key = getattr(obj, keyname, None)
if key is None:
continue
value = getattr(obj, valuenam... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def addAll(self, objs):\n self.getSession().add_all(objs)\n self.commit() # paranoially\n return objs",
"def add(self, fetchables, depth=1):\n if fetchables:\n if isinstance(fetchables, collections.Sequence):\n for fetchable in fetchables:\n ... | [
"0.61764467",
"0.60474694",
"0.57324225",
"0.56951404",
"0.55937594",
"0.55879956",
"0.558788",
"0.54297394",
"0.5391662",
"0.53283435",
"0.53044546",
"0.52996117",
"0.5273503",
"0.5259931",
"0.52462256",
"0.5240757",
"0.52057797",
"0.51749694",
"0.5160668",
"0.5155546",
"0.5... | 0.76109475 | 0 |
Returns the entries as a key => value dict. | def as_dict(self):
return dict((key, value) for key, value, depth in self.entries.itervalues()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_dict(self):\n d = {}\n i = 0\n for entry in self.entries:\n d[i] = {}\n attributes = self.get_attribute_list()\n print (attributes)\n for data in attributes:\n d[i][data] = entry.__getattribute__(data)\n i = i + 1\n ... | [
"0.7613547",
"0.7377054",
"0.67987955",
"0.63767034",
"0.6352516",
"0.6342387",
"0.63202107",
"0.6266719",
"0.62579256",
"0.6247313",
"0.623333",
"0.6207049",
"0.62052894",
"0.61866677",
"0.61613494",
"0.61424756",
"0.613092",
"0.61234504",
"0.6120027",
"0.6097869",
"0.609334... | 0.73771703 | 1 |
Determine if a sysfs_gpu_name file indicates an AMD device | def _is_amd(sysfs_gpu_name):
with open(sysfs_gpu_name) as src:
return src.read().strip() == 'amdgpu' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_gpu_device_if_present():\n d = dpctl.SyclDevice(\"gpu,cpu\")\n print(\"Selected \" + (\"GPU\" if d.is_gpu else \"CPU\") + \" device\")",
"def is_system_usable_block_device(pydev_device):\n if pydev_device.get(\"ID_BUS\") == \"usb\":\n # Skip USB devices\n return False\n if py... | [
"0.6442702",
"0.6077788",
"0.60640377",
"0.60526884",
"0.6037231",
"0.6019427",
"0.601595",
"0.599092",
"0.5918574",
"0.5823835",
"0.5786603",
"0.5764074",
"0.5732489",
"0.5730832",
"0.5723959",
"0.5701175",
"0.56283104",
"0.5625314",
"0.56229156",
"0.56229156",
"0.5601314",
... | 0.83339846 | 0 |
Determine the gpu index given a sysfs_gpu_name | def _amd_index(sysfs_gpu_name):
drop_prefix = sysfs_gpu_name.strip()[len(_SYSFS_PREFIX):]
return drop_prefix.split('/')[0] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _next_device(self):\n if self._num_gpus == 0:\n return ''\n dev = '/gpu:%d' % self._cur_gpu\n if self._num_gpus > 1:\n self._cur_gpu = (self._cur_gpu + 1) % (self._num_gpus-1)\n return dev",
"def deviceid(gpu):\n\n # Return if this is already a torch device\n # pylint: dis... | [
"0.68445116",
"0.6772102",
"0.6700925",
"0.6621827",
"0.65894985",
"0.6331592",
"0.62258136",
"0.62258136",
"0.62258136",
"0.61923295",
"0.61809945",
"0.6132849",
"0.6131118",
"0.61252695",
"0.6123489",
"0.6101626",
"0.6023584",
"0.6001534",
"0.5931374",
"0.59023625",
"0.5886... | 0.786728 | 0 |
Configures logging logging_config.json should have been placed in the directory AUTOMINE_LOG_DIR, to which this process must have read and write access | def _configure_logger():
try:
log_dir = os.environ['AUTOMINE_LOG_DIR']
log_name = _log_name()
cfg_path = os.path.join(log_dir, 'logging_config.json')
with open(cfg_path) as src:
cfg = json.load(src)
handlers = cfg.get('handlers')
for handler in ite... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup_logging():\n name_json = 'logging_config.json'\n path_json = os.path.join(os.path.dirname(__file__), name_json)\n with open(path_json, 'r') as f_json:\n dict_config = json.load(f_json)\n logging.config.dictConfig(dict_config)",
"def setup_logging(save_dir, log_config='logger/logger_c... | [
"0.82155377",
"0.75840616",
"0.73912275",
"0.7389693",
"0.72844446",
"0.7030196",
"0.70190215",
"0.7017492",
"0.7016571",
"0.6946439",
"0.69230664",
"0.68668836",
"0.6850633",
"0.6848561",
"0.6812513",
"0.6809024",
"0.6786257",
"0.6777338",
"0.6761215",
"0.6757546",
"0.674431... | 0.81726515 | 1 |
Endpoint to display create item page. | def create_item_page():
catagories = [c.name for c in Catagory.fetch_all()]
return render_template('add_item.html', catagories=catagories, values={}) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def newItem():\n if request.method == 'POST':\n db.createItem(\n title=request.form['title'],\n description=request.form['description'],\n category_id=request.form['category'],\n user_id=login_session['user_id'])\n flash(\"New catalog item created!\", 's... | [
"0.74668145",
"0.71456575",
"0.6886429",
"0.6816857",
"0.68146276",
"0.6764137",
"0.65232",
"0.6477503",
"0.6445127",
"0.6436602",
"0.6388984",
"0.6381548",
"0.634037",
"0.6285156",
"0.6273723",
"0.624713",
"0.62171143",
"0.6188557",
"0.6186302",
"0.61858845",
"0.61284363",
... | 0.7436075 | 1 |
Post endpoint to create an item. If form is invalid will return create item page with errors displayed, otherwise create item and redirect to item page. | def create_item():
name = request.form['name']
catagory = request.form['catagory']
description = request.form['description']
errors = form_errors(request.form)
if errors:
catagories = [c.name for c in Catagory.fetch_all()]
values = {
'name': name, 'catagory': catagory, 'd... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new_item():\n form = ItemForm()\n user = current_user\n\n # If the form is validated, add its data to the database\n if form.validate_on_submit():\n\n # Check that an item with the same name and sport does not\n # already exist, or send a flash message and do not add the\n # ne... | [
"0.7512342",
"0.74192584",
"0.7168803",
"0.7162308",
"0.6992464",
"0.68776226",
"0.6828334",
"0.67595434",
"0.6719401",
"0.67075944",
"0.66212463",
"0.66060036",
"0.65833145",
"0.65363026",
"0.6523961",
"0.6484986",
"0.6414084",
"0.6341097",
"0.6312691",
"0.6282003",
"0.62772... | 0.7602898 | 0 |
Endpoint to display update item page. | def update_item_page(item_name, catagory_name):
item = Item.fetch_by_name_and_catagory_name(item_name, catagory_name)
catagories = [c.name for c in Catagory.fetch_all()]
return render_template(
'edit_item.html',
catagories=catagories,
values={
'name': item.name,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def item_update(request):\n if request.method == 'POST':\n item_to_update = get_object_or_404(StockItem, pk=request.POST['id'])\n item_to_update.name = request.POST['name']\n item_to_update.count = int(request.POST['count'])\n item_to_update.date_of_expiration = request.POST['exp']\n... | [
"0.6676208",
"0.64609563",
"0.64174616",
"0.63904625",
"0.63857603",
"0.6339873",
"0.6314984",
"0.62889534",
"0.6269479",
"0.6255692",
"0.6253654",
"0.624584",
"0.62428105",
"0.6238067",
"0.62355477",
"0.6230332",
"0.62169313",
"0.6211939",
"0.62091535",
"0.61984015",
"0.6185... | 0.675567 | 0 |
Return dict containing form validation errors for create / update item. | def form_errors(form):
errors = {}
max_name_length = Item.name.property.columns[0].type.length
if not form.get('name', None):
errors['name'] = 'Please enter a name.'
elif len(form['name']) > max_name_length:
errors['name'] = (
'Name must be less than %s characters.' % max_nam... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_form_error(self):\n errors = {}\n if self._form_error:\n errors[\"base\"] = self._form_error\n self._form_error = None\n return errors",
"def errors(self):\n _errors = {}\n # pylint: disable=no-member\n for name, field in self._fields.items... | [
"0.7247966",
"0.65767854",
"0.65024495",
"0.6369957",
"0.62522954",
"0.6153304",
"0.6130591",
"0.6103089",
"0.6074817",
"0.6054684",
"0.5964537",
"0.5951978",
"0.594963",
"0.59282666",
"0.59004563",
"0.58859175",
"0.5877393",
"0.5859856",
"0.58356667",
"0.5771657",
"0.5703528... | 0.7545022 | 0 |
r"""Chooses a BoTorch `MarginalLogLikelihood` class using the given `Model` class. | def choose_mll_class(
model_class: Type[Model],
state_dict: Optional[Dict[str, Tensor]] = None,
refit: bool = True,
) -> Type[MarginalLogLikelihood]:
# NOTE: We currently do not support `ModelListGP`. This code block will only
# be relevant once we support `ModelListGP`.
if (state_dict is None o... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, likelihood, model):\n if not isinstance(likelihood, GaussianLikelihood):\n raise RuntimeError(\"Likelihood must be Gaussian for exact inference\")\n super(ExactMarginalLogLikelihood, self).__init__(likelihood, model)",
"def from_botorch(\n cls,\n model: M... | [
"0.6100431",
"0.5624646",
"0.55522686",
"0.55522686",
"0.536249",
"0.53345406",
"0.5269471",
"0.52394426",
"0.5220503",
"0.51793855",
"0.51639843",
"0.508774",
"0.50566566",
"0.505593",
"0.50103873",
"0.50024384",
"0.49973372",
"0.4989311",
"0.49551207",
"0.49261236",
"0.4925... | 0.74493885 | 0 |
r"""Chooses a BoTorch `AcquisitionFunction` class. | def choose_botorch_acqf_class() -> Type[AcquisitionFunction]:
# NOTE: In the future, this dispatch function could leverage any
# of the attributes of `BoTorchModel` or kwargs passed to
# `BoTorchModel.gen` to intelligently select acquisition function.
return qNoisyExpectedImprovement | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, acquisition_functions):\n self.acquisition_functions = acquisition_functions",
"def _optimise_acquisition(acq_fn, acq_optimiser, anc_data):\n return acq_optimiser(acq_fn, anc_data.max_evals)",
"def _optimise_acquisition(acq_fn, acq_optimiser, anc_data):\n if anc_data.acq_opt_method ... | [
"0.6058467",
"0.5935972",
"0.58589655",
"0.5788014",
"0.548214",
"0.5331167",
"0.53201264",
"0.53140235",
"0.53060716",
"0.5304556",
"0.5121495",
"0.5052555",
"0.5037035",
"0.50274396",
"0.500004",
"0.49999496",
"0.49726632",
"0.49604744",
"0.49250162",
"0.48792323",
"0.48333... | 0.73012865 | 0 |
Construct a `TrainingData` object based on sizes of Xs, Ys, and Yvars, and the type of model, for which the training data is intended. | def construct_training_data(
Xs: List[Tensor], Ys: List[Tensor], Yvars: List[Tensor], model_class: Type[Model]
) -> TrainingData:
if not isclass(model_class): # pragma: no cover
raise ValueError(
f"Expected `Type[Model]`, got: {model_class} "
f"(type: {type(model_class)})."
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def data_creator(config):\n train_dataset, val_dataset = LinearDataset(2, 5), LinearDataset(2, 5)\n train_loader = DataLoader(train_dataset, batch_size=config[\"batch_size\"])\n val_loader = DataLoader(val_dataset, batch_size=config[\"batch_size\"])\n return train_loader, val_loader",
"def _unpack_tr... | [
"0.62350506",
"0.6225271",
"0.6160196",
"0.6157232",
"0.6134622",
"0.61098945",
"0.6080254",
"0.606203",
"0.60147977",
"0.60086304",
"0.59555346",
"0.5948243",
"0.5919351",
"0.59027153",
"0.5900304",
"0.58960056",
"0.5879972",
"0.58337307",
"0.5829074",
"0.5811363",
"0.580975... | 0.8095568 | 0 |
Validates that Xs, Ys, Yvars, and metric names all have equal lengths. | def validate_data_format(
Xs: List[Tensor], Ys: List[Tensor], Yvars: List[Tensor], metric_names: List[str]
) -> None:
if len({len(Xs), len(Ys), len(Yvars), len(metric_names)}) > 1:
raise ValueError( # pragma: no cover
"Lengths of Xs, Ys, Yvars, and metric_names must match. Your "
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_consistent_length(y_true: List[List[str]], y_pred: List[List[str]]):\n len_true = list(map(len, y_true))\n len_pred = list(map(len, y_pred))\n is_list = set(map(type, y_true)) | set(map(type, y_pred))\n\n if len(y_true) != len(y_pred) or len_true != len_pred:\n message = 'Found input v... | [
"0.6732428",
"0.65989214",
"0.65425104",
"0.64392585",
"0.6399168",
"0.63487905",
"0.6343038",
"0.62423515",
"0.61932313",
"0.6176423",
"0.6091993",
"0.6081119",
"0.60686547",
"0.6042439",
"0.603004",
"0.60111535",
"0.601055",
"0.60092235",
"0.59968686",
"0.5972382",
"0.59626... | 0.8259363 | 0 |
Extract acquisition and optimizer options from `model_gen_options`. | def construct_acquisition_and_optimizer_options(
acqf_options: TConfig, model_gen_options: Optional[TConfig] = None
) -> Tuple[TConfig, TConfig]:
acq_options = acqf_options.copy()
opt_options = {}
if model_gen_options:
acq_options.update(
checked_cast(dict, model_gen_options.get(Key... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_build_options(cls, opt: Opt):\n query_model = 'bert'\n document_model = 'bert'\n query_path = opt['model_file']\n document_path = opt['model_file']\n try:\n # determine if loading a RAG model\n loaded_opt = Opt.load(f\"{query_path}.opt\")\n ... | [
"0.6497855",
"0.6085382",
"0.57732934",
"0.56216425",
"0.55810773",
"0.5563721",
"0.54467785",
"0.54459274",
"0.54262084",
"0.54096705",
"0.53853124",
"0.5346946",
"0.5331329",
"0.53296965",
"0.53257495",
"0.5312863",
"0.5310399",
"0.52858835",
"0.52766055",
"0.52655095",
"0.... | 0.6829646 | 0 |
Return the hash digest as a bytes object. This is the bigendian representation of the value returned by ``intdigest()`` and is equivalent to the output of the ``XXH64_canonicalFromHash()`` function in the `reference implementation`_ applied to the value returned by ``intdigest()``. | def digest(self):
# For discussion of big-endian vs little-endian for the hash
# digest of XXHASH algorithms, see
# https://github.com/Cyan4973/xxHash/issues/45
return struct.pack(">Q", self.intdigest()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hexdigest(self):\n return self.hashObject.hexdigest()",
"def digest(self):\n return self._hash",
"def hash(self) -> bytes:",
"def digest(self):\n return digest_tools.sha256_digest(self._payload.as_encoded_str())",
"def hash(self):\n return Hash.dhash(bytes(self))",
"def he... | [
"0.69930434",
"0.69264513",
"0.67882836",
"0.6712462",
"0.66841334",
"0.66802466",
"0.6673555",
"0.6600667",
"0.6553306",
"0.6533125",
"0.6499518",
"0.6499283",
"0.6481292",
"0.6456057",
"0.6456057",
"0.64141536",
"0.6401427",
"0.6399107",
"0.638602",
"0.63651985",
"0.6290785... | 0.78258497 | 0 |
Return the hash digest as a string of hexidecimal digits. This is the value returned by ``digest()`` expressed as a printable hex string for easy display. | def hexdigest(self):
# bytes.hex() is simpler, but not available For Python <= 3.4
return "".join("{0:0>2x}".format(b) for b in self.digest()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hexdigest(self):\r\n return ''.join(['%02x' % ord(c) for c in self.digest()])",
"def hexdigest(self):\n return \"\".join(\"%02x\" % ord(x)\n for x in MegaCrypto.a32_to_str(self.digest()))",
"def hexdigest(self):\n return self.hashObject.hexdigest()",
"de... | [
"0.8446957",
"0.8241606",
"0.8034233",
"0.7728154",
"0.7493876",
"0.72516394",
"0.7215683",
"0.70375633",
"0.6966864",
"0.69554013",
"0.6895401",
"0.6893466",
"0.6879853",
"0.6794466",
"0.6791125",
"0.6765434",
"0.67632526",
"0.67488396",
"0.6718266",
"0.6668175",
"0.6663794"... | 0.8364801 | 1 |
Check if the specified instance matches the service's model. | def _isinstance(self, instance, raise_error=True):
if isinstance(instance, self.__model__):
return True
elif raise_error:
raise ValueError('{} is not of type {}.'.format(
instance, self.__model__,
))
else:
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def checkModel(self, model):\n # TODO",
"def test_valid_model(self):\n model_cls = ModelContainer(APP_LABEL, TestModel2._meta.db_table).model_cls\n self.assertTrue(model_cls.__class__.__name__ is models.Model.__class__.__name__)",
"def have_this_instance(self, instance):\n for i in ... | [
"0.6658003",
"0.6365422",
"0.63516694",
"0.59845364",
"0.59756815",
"0.59461135",
"0.5938544",
"0.59184885",
"0.5915191",
"0.59148186",
"0.5906111",
"0.59015507",
"0.5884941",
"0.585603",
"0.5847129",
"0.58132994",
"0.57774276",
"0.57701457",
"0.5730501",
"0.57222885",
"0.572... | 0.650044 | 1 |
Converts the provided integer 'n' into a valid insertion point in the string 's', ie the current index locations or at the end | def gen_index_via_mod(s, n):
if len(s) == 0:
return 0
return n % (len(s) + 1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def move_to_end(s, n):\n first=s[0:n]\n return s[n:] + first",
"def string(self,pos_0,pos_1,n):\r\n n=int(n)\r\n if pos_0 <10:\r\n pos_0=\"00\"+str(pos_0)\r\n elif pos_0<100:\r\n pos_0=\"0\"+str(pos_0)\r\n\r\n if n <10:\r\n n=\"0\"+str((n))\r\n ... | [
"0.63267386",
"0.6178822",
"0.61630845",
"0.6155788",
"0.6115236",
"0.6103694",
"0.6012176",
"0.6011193",
"0.594181",
"0.593987",
"0.5923727",
"0.5884271",
"0.580508",
"0.5737656",
"0.5725076",
"0.5623249",
"0.5594806",
"0.55564487",
"0.5525483",
"0.55181396",
"0.5496168",
... | 0.6202475 | 1 |
Gets all announcements on the server | def get(self):
announcements = Announcement.query.all()
announcements = announcements_schema.dump(announcements)
if not announcements:
return {'status': 'success', 'announcements': announcements}, 206 # Partial Content Served
return {'status': 'success', 'announcements': a... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def getAnnouncements(self, body=\"\"):\n payload = {}\n \n # Parameter validation\n schema = ContentValidator.getAnnouncements()\n schema.dump(schema.load(payload))\n \n\n url_with_params = await create_url_with_params(api_url=self._urls[\"getAnnouncements\"],... | [
"0.67929053",
"0.6228621",
"0.61567163",
"0.6098976",
"0.5930889",
"0.59122926",
"0.58568746",
"0.5851314",
"0.58407116",
"0.5822206",
"0.5804673",
"0.5770579",
"0.57031876",
"0.56998605",
"0.5559147",
"0.5553164",
"0.5529305",
"0.55254424",
"0.55103004",
"0.5502346",
"0.5491... | 0.6474763 | 1 |
delete a announcement by ID | def delete(self, announcementID):
announcement = Announcement.query.filter_by(announcementID=announcementID)
if not announcement.first():
return {'status': 'fail', 'message': 'No announcement with ID ' + str(announcementID) + ' exists'}, 404
announcement.delete()
db.sessio... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete(self, _id):",
"def delete(self, id):\n raise NotImplementedError",
"def delete(self,id):\r\n return delete(id=id)",
"def delete(self, id):\n\n ns.abort(404, 'This API is not supported yet.')",
"def delete(self, id):\n return delete_msg(id)",
"def delete(self, id):\n... | [
"0.7832141",
"0.7315442",
"0.718373",
"0.71590054",
"0.715206",
"0.7093981",
"0.7008346",
"0.6998064",
"0.6946827",
"0.6931493",
"0.6922772",
"0.68966997",
"0.6869891",
"0.6861729",
"0.6804666",
"0.6804666",
"0.6804666",
"0.6804666",
"0.6804666",
"0.6717501",
"0.6696411",
"... | 0.79569536 | 0 |
Function that converts category name to Python module name Eg. rwgeneric to RwGenericYang | def get_module_name_from_log_category(log_category):
words = log_category.split('-')
words.append('yang')
return ''.join(word.capitalize() for word in words) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normalize_module_name(layer_name):\n modules = layer_name.split('.')\n try:\n idx = modules.index('module')\n except ValueError:\n return layer_name\n del modules[idx]\n return '.'.join(modules)",
"def module_name(self):\n return \"py{0:s}\".format(self.library_name[3:])",
"... | [
"0.6348545",
"0.62357664",
"0.6161529",
"0.6005554",
"0.59594476",
"0.5909393",
"0.58015877",
"0.576444",
"0.5749584",
"0.5743478",
"0.57170683",
"0.57096314",
"0.5701094",
"0.56758934",
"0.5675464",
"0.5667408",
"0.56373435",
"0.5630453",
"0.55773044",
"0.5576993",
"0.556977... | 0.7726592 | 0 |
Set Log category name to be used. | def set_category(self, category_name):
try:
module_name = get_module_name_from_log_category(category_name)
log_yang_module = importlib.import_module('gi.repository.' + module_name)
if not log_yang_module:
logger.error("Module %s is not found to be added as log... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rider_category_name(self, rider_category_name):\n\n self._rider_category_name = rider_category_name",
"def category(self, category: str):\n\n self._category = category",
"def set_scribe_category(category):\r\n LogOptions._SCRIBE_CATEGORY = category",
"def set_category(self, category):\n\... | [
"0.71033996",
"0.656124",
"0.6451363",
"0.64011025",
"0.63785875",
"0.6319959",
"0.6303118",
"0.6279708",
"0.6278118",
"0.61796457",
"0.608429",
"0.608429",
"0.608429",
"0.608429",
"0.608429",
"0.60362625",
"0.6006342",
"0.59686434",
"0.5840249",
"0.57967573",
"0.57849914",
... | 0.7935372 | 0 |
Tests whether ``TextInputStyle`` instance values are all the expected value type. | def test__TextInputStyle__value():
for instance in TextInputStyle.INSTANCES.values():
vampytest.assert_instance(instance.value, TextInputStyle.VALUE_TYPE) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test__TextInputStyle__name():\n for instance in TextInputStyle.INSTANCES.values():\n vampytest.assert_instance(instance.name, str)",
"def _check_value_type(self, value):\n if value is not None and self.value_type is not None:\n valid = isinstance(value, self.value_type)\n ... | [
"0.61332947",
"0.59603673",
"0.5806856",
"0.5770944",
"0.57419115",
"0.5711008",
"0.5696463",
"0.567288",
"0.5661682",
"0.5579446",
"0.55630475",
"0.5551327",
"0.55341244",
"0.5487145",
"0.54515827",
"0.5438341",
"0.54083705",
"0.54033923",
"0.5351363",
"0.5323914",
"0.531121... | 0.741814 | 0 |
Tests that example.com was in the dashboard. | def test_link_list(self):
response = self.client.get('/tests/dashboard/')
self.assertEqual(response.status_code, 200)
self.assertContains(response, "example.com") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_dashboard_page(self):\r\n\r\n result = self.client.get(\"/dashboard\", follow_redirects = True)\r\n self.assertNotIn(b\"Family Ties - Dashboard\", result.data)",
"def test_dashboard_is_up(dashboard_address):\n response = requests.get(f\"{dashboard_address}/health\")\n assert response... | [
"0.7439744",
"0.71425265",
"0.6988231",
"0.69753",
"0.6952687",
"0.69291663",
"0.69152224",
"0.69117343",
"0.68734396",
"0.68194866",
"0.67331254",
"0.673261",
"0.6697194",
"0.66839606",
"0.66659987",
"0.66591775",
"0.6643598",
"0.66313016",
"0.6605587",
"0.65915424",
"0.6585... | 0.7536914 | 0 |
Tests that the admin list found the User and Group admins | def test_admin_list(self):
response = self.client.get('/tests/dashboard/')
self.assertEqual(response.status_code, 200)
self.assertContains(response, '<a href="/admin/auth/group/">Group</a>', html=True)
self.assertContains(response, '<a href="/admin/auth/user/">User</a>', html=True) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_admin_calendar_user_admin_list(self):\n response = self.client.get(\"/admin/auth/calendaruser/\")\n self.assertEqual(response.status_code, 200)",
"def test_cannot_remove_all_admins(self):\n r = self.app.get('/admin/groups/')\n admin_holder = r.html.find(\n 'table',... | [
"0.7459246",
"0.7412557",
"0.74001384",
"0.7367604",
"0.7157066",
"0.70924866",
"0.70496404",
"0.70242584",
"0.70158803",
"0.7010552",
"0.69874895",
"0.696997",
"0.69406426",
"0.6914392",
"0.6912082",
"0.6910139",
"0.69032836",
"0.68800515",
"0.68568987",
"0.6850447",
"0.6785... | 0.79272 | 0 |
Backup the git refs. | def backup_ref(self):
# Back ourselves up!
backup_ref="refs/backups/{0}-{1}-{2}".format(self.ref_type, self.ref_name, int( time.time() ))
command = ("git", "update-ref", backup_ref, self.old_sha1)
process = subprocess.Popen(command, shell=False, stdout=subprocess.PIPE,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def backup(self):\n\n\t\twith temp_dir(self.path):\n\t\t\t# only if changes made\n\t\t\tcheck = sp.check_output(['git', 'status', '--porcelain'])\n\t\t\t# check if untracked files\n\t\t\tuntracked = sp.check_output(['git', 'ls-files', '--others', '--exclude-standard'])\n\n\t\t\tif check:\n\t\t\t\tif untracked:\n\t... | [
"0.6952309",
"0.6250587",
"0.6083144",
"0.6023908",
"0.6018048",
"0.5927529",
"0.5912871",
"0.58550334",
"0.5830668",
"0.5823843",
"0.5808333",
"0.5635343",
"0.5619511",
"0.5558526",
"0.5550184",
"0.54987204",
"0.54584205",
"0.54354334",
"0.54245806",
"0.53884566",
"0.5356423... | 0.7884595 | 0 |
Whether the audit failed (True) or passed (False). | def audit_failed(self):
return self.__failed | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hasFailed(self):\n record = self.getRunRecord().getRecord(\"run\")\n return record.state is FAIL",
"def is_failed(self):\n\n return self._state == \"FAILED\"",
"def is_failed(self):\n with settings(hide('running', 'stdout', 'stderr', 'warnings'), warn_only=True):\n re... | [
"0.70987207",
"0.7077051",
"0.6967613",
"0.6923564",
"0.68601596",
"0.6790287",
"0.67796767",
"0.6752796",
"0.67493594",
"0.67102164",
"0.6676905",
"0.667684",
"0.6542292",
"0.64718133",
"0.6417293",
"0.64025366",
"0.63911164",
"0.634746",
"0.6297389",
"0.62367797",
"0.623135... | 0.76317364 | 0 |
Audit the commit for proper endofline characters. The UNIX type EOL is the only allowed EOL character. | def audit_eol(self):
# Regex's....
re_commit = re.compile("^\xff(.+)\xff$")
re_filename = re.compile("^diff --(cc |git a\/.+ b\/)(.+)$")
blocked_eol = re.compile(r"(?:\r\n|\n\r|\r)$")
# Bool to allow special files such as vcards to bypass the check
eol_allowed = False
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def eol(self):\n if self.current not in EOL:\n self.on_parser_error(\"EOL expected\")\n self.maybe_eol()",
"def _output_commit_line(self): # noqa: C901, E501 pylint: disable=too-many-branches\n seen_this = False\n chars_written = 0\n for i in range(self.num_columns ... | [
"0.6151211",
"0.6065239",
"0.57468516",
"0.5741316",
"0.5723494",
"0.5639385",
"0.5574638",
"0.5561204",
"0.5554823",
"0.55486727",
"0.553186",
"0.5530341",
"0.55275774",
"0.5481987",
"0.54660696",
"0.540383",
"0.5398025",
"0.5388231",
"0.53565466",
"0.53498983",
"0.5348075",... | 0.83223575 | 0 |
Audit the file names in the commit. | def audit_filename(self):
for commit in self.repository.commits.values():
for filename in commit.files_changed:
if commit.files_changed[ filename ]["change"] not in ["A","R","C"]:
continue
for restriction in self.filename_limits:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def audit_names_in_metadata(self):\n\n # Iterate over commits....\n for commit in self.repository.commits.values():\n for name in [ commit.committer_name, commit.author_name ]:\n # Is the name whitelisted?\n if name in self.FullNameWhitelist:\n ... | [
"0.67635244",
"0.63775945",
"0.6034091",
"0.5988995",
"0.58283305",
"0.5755764",
"0.5654512",
"0.56192213",
"0.5432775",
"0.5430367",
"0.52749014",
"0.5257821",
"0.52496487",
"0.5248489",
"0.5241954",
"0.5239385",
"0.5227689",
"0.5223898",
"0.5222077",
"0.52184683",
"0.521339... | 0.7895987 | 0 |
Audit names in commit metadata. Names which do not have a first name and a surname are extremely uncommon and when present are therefore generally invalid. As we want people to use their actual name when committing we do some checks to make sure that what looks like an actual name is present. | def audit_names_in_metadata(self):
# Iterate over commits....
for commit in self.repository.commits.values():
for name in [ commit.committer_name, commit.author_name ]:
# Is the name whitelisted?
if name in self.FullNameWhitelist:
continue... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def audit_filename(self):\n\n for commit in self.repository.commits.values():\n for filename in commit.files_changed:\n if commit.files_changed[ filename ][\"change\"] not in [\"A\",\"R\",\"C\"]:\n continue\n for restriction in self.filename_limits... | [
"0.62963563",
"0.6226209",
"0.6223605",
"0.6148646",
"0.6140524",
"0.61402285",
"0.6099476",
"0.60691816",
"0.6056856",
"0.6056856",
"0.6024149",
"0.6016685",
"0.5969354",
"0.5957472",
"0.5951923",
"0.5932206",
"0.5932206",
"0.5906392",
"0.59056324",
"0.589487",
"0.58702075",... | 0.8450045 | 0 |
Audit commit metadata. Invalid hostnames such as localhost or (none) will be caught by this auditor. This will ensure that invalid email addresses or users will not show up in commits. | def audit_emails_in_metadata(self):
# Iterate over commits....
disallowed_domains = ["localhost", "localhost.localdomain", "(none)", "bombardier.com", "rail.bombardier.com"]
for commit in self.repository.commits.values():
for email_address in [ commit.committer_email, commit.author_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def audit_names_in_metadata(self):\n\n # Iterate over commits....\n for commit in self.repository.commits.values():\n for name in [ commit.committer_name, commit.author_name ]:\n # Is the name whitelisted?\n if name in self.FullNameWhitelist:\n ... | [
"0.6614517",
"0.5485047",
"0.5467171",
"0.54115015",
"0.5338054",
"0.5191764",
"0.5172768",
"0.5139828",
"0.5138755",
"0.5125162",
"0.50731736",
"0.5002091",
"0.49640554",
"0.49508968",
"0.49492618",
"0.49048898",
"0.49002182",
"0.4897812",
"0.4882828",
"0.4845588",
"0.482522... | 0.7368635 | 0 |
Helper function to construct an address header for emails as Python stuffs it up | def address_header(self, name, email):
fixed_name = Header( name ).encode()
return unicode("{0} <{1}>").format(fixed_name, email) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def encode_rfc2822_address_header(header_text):\n def encode_addr(addr):\n name, email = addr\n # If s is a <text string>, then charset is a hint specifying the\n # character set of the characters in the string. The Unicode string\n # will be encoded using the following charsets in o... | [
"0.69923276",
"0.67900985",
"0.67680126",
"0.6404634",
"0.6254018",
"0.62328947",
"0.615882",
"0.61046",
"0.6023781",
"0.6022702",
"0.5986854",
"0.5960331",
"0.59242094",
"0.5905854",
"0.5892792",
"0.58512026",
"0.58358437",
"0.5810467",
"0.57352096",
"0.5722051",
"0.57130855... | 0.7850054 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.