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 |
|---|---|---|---|---|---|---|
Return a user by phone_num | def get_user_by_phone(phone_num):
user = db.session.query(User).filter(phone_num == User.phone_num).first()
return user
# SELECT * FROM users WHERE phone_num == phone_num
# User.query.filter(User.phone_num == phone_num).one() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_user_by_phone(phone_num):\n\n user = db.session.query(User).filter(phone_num == User.phone_num)\n return user\n \n # User.query.filter(User.phone_num == phone_num).one()",
"def get_user_by_phone(self, phone):\n sql = 'select id ,first_name' \\\n ',last_name' \\\n ... | [
"0.84271127",
"0.83181894",
"0.79030603",
"0.77142286",
"0.76056916",
"0.74515444",
"0.7231632",
"0.70186967",
"0.6720994",
"0.66531473",
"0.6642142",
"0.6481888",
"0.6426293",
"0.63712114",
"0.6245403",
"0.6233911",
"0.620776",
"0.6156473",
"0.6141519",
"0.6140055",
"0.61278... | 0.8424238 | 1 |
Delete a user from DB by phone num | def remove_user(user):
# user.confirmed = False
# user = get_user_by_phone(phone_num)
db.session.delete(user)
db.session.commit()
return user
# DELETE FROM users WHERE user.phone_num == phone) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def deleterecord(phones,username,phonenum):\r\n if username in phones:\r\n del phones[username]\r\n else:\r\n raise ValueError(\"This username are not exist\")",
"def delete_user():",
"def delete_user(id):\n pass",
"def delete_user():\n #TODO user delete\n pass",
"def delete(se... | [
"0.7692403",
"0.7642171",
"0.7386278",
"0.7218295",
"0.69013256",
"0.6894429",
"0.6786851",
"0.6780384",
"0.6767511",
"0.66952723",
"0.66802424",
"0.66753626",
"0.663638",
"0.66360664",
"0.6624687",
"0.65962803",
"0.6593279",
"0.65769345",
"0.65746725",
"0.6572516",
"0.656204... | 0.7751427 | 0 |
Merge two sorted lists. Returns a new sorted list containing all of the elements that are in both list1 and list2. This function can be iterative. | def merge(list1, list2):
answer = []
assert answer == sorted(answer)
idx1 = 0
idx2 = 0
while (idx1 < len(list1)) and (idx2 < len(list2)):
if list1[idx1] < list2[idx2]:
answer.append(list1[idx1])
idx1 += 1
elif list1[idx1] > list2[idx2]:
answer.app... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def merge(list1: list, list2: list) -> list:\r\n result = []\r\n i = 0\r\n j = 0\r\n # Iterate through each element and append the smaller element of each list to the resulting list.\r\n while i < len(list1) and j < len(list2):\r\n if list1[i] < list2[j]:\r\n result.append(list1[i... | [
"0.83323663",
"0.8261311",
"0.8246922",
"0.8237985",
"0.82039124",
"0.81994414",
"0.81919336",
"0.8135797",
"0.81266",
"0.81188804",
"0.80913657",
"0.8061905",
"0.7968006",
"0.79673326",
"0.7962454",
"0.7873351",
"0.7739397",
"0.7723716",
"0.7709938",
"0.7707734",
"0.76907146... | 0.8383289 | 0 |
Override initializer for Grid, add queue to store boundary of fire | def __init__(self, grid_height, grid_width):
poc_grid.Grid.__init__(self, grid_height, grid_width)
self._fire_boundary = poc_queue.Queue() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def on_init(self, queue=None, **kwargs):\n self.queue = queue if queue else Queue()",
"def __init__(self) -> None:\n self._queue = []",
"def __init__(self):\n self._grid = [[None]]",
"def __init__(self):\n self.queue = Queue()",
"def __init__(self):\n self.queue = []",
... | [
"0.6840169",
"0.6793105",
"0.6785803",
"0.67526734",
"0.6619239",
"0.6619239",
"0.6619239",
"0.6619239",
"0.6619239",
"0.6547735",
"0.653138",
"0.653138",
"0.65267134",
"0.65173596",
"0.6460772",
"0.64500934",
"0.64124566",
"0.64041156",
"0.63946074",
"0.6388912",
"0.63709074... | 0.82730323 | 0 |
Return the size of the boundary of the fire | def boundary_size(self):
return len(self._fire_boundary) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def length(self):\n return pyvista.Box(self.bounds).length",
"def _rect_size(self):\n bnd = self._bounds\n return (bnd[1][0] - bnd[0][0], bnd[1][1] - bnd[0][1])",
"def size(self):\n bbox = self.bbox\n return bbox[1] - bbox[0]",
"def length(self):\n return float(np.ma... | [
"0.73574746",
"0.71820253",
"0.71315867",
"0.70857227",
"0.7034427",
"0.7019021",
"0.6930683",
"0.6853269",
"0.6830643",
"0.67914754",
"0.6754808",
"0.6728078",
"0.67057216",
"0.67057216",
"0.67057216",
"0.67057216",
"0.6703964",
"0.66926634",
"0.66926634",
"0.66926634",
"0.6... | 0.811731 | 0 |
Generator for the boundary of the fire | def fire_boundary(self):
for cell in self._fire_boundary:
yield cell
# alternative syntax
#return (cell for cell in self._fire_boundary) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def boundary(self): # -> BaseGeometry:\n ...",
"def boundaries_next(*args):\n return _ida_hexrays.boundaries_next(*args)",
"def make_boundaries(self):\n p = self.project\n c = p[0]\n outlet = p.NewOutlet('GW', c.x, c.y, c.z - c.soildepth)\n cmf.FreeDrainagePercolation(c.lay... | [
"0.66496694",
"0.59829056",
"0.5887077",
"0.58223045",
"0.5735941",
"0.57314575",
"0.5677762",
"0.5677131",
"0.5668234",
"0.56558734",
"0.56557745",
"0.5644102",
"0.56180614",
"0.5571235",
"0.55560315",
"0.5545058",
"0.55429775",
"0.5520432",
"0.5505475",
"0.5489425",
"0.5470... | 0.7614882 | 0 |
Function that spreads the wild fire using one step of BFS Updates both the cells and the fire_boundary | def update_boundary(self):
cell = self._fire_boundary.dequeue()
neighbors = self.four_neighbors(cell[0], cell[1])
#neighbors = self.eight_neighbors(cell[0], cell[1])
for neighbor in neighbors:
if self.is_empty(neighbor[0], neighbor[1]):
self.set_full(neighbor... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_fireball():\n # build the right part\n build_rightpart()\n\n # copy it to 4.\n copy(0, 4)\n\n # build the left part, now it's in 0\n build_leftpart()\n\n # copy right part from 4 to 1.\n copy(4, 1)\n # smash together for whole fireball.\n smash()",
"def simulate_fire(self,... | [
"0.6349423",
"0.63270336",
"0.6020645",
"0.5898426",
"0.5608068",
"0.5601368",
"0.5590194",
"0.5546037",
"0.55457413",
"0.5523806",
"0.55145603",
"0.55054224",
"0.5476916",
"0.54490596",
"0.5432119",
"0.53815204",
"0.5355134",
"0.53444767",
"0.5340942",
"0.53302777",
"0.53175... | 0.6963751 | 0 |
Class invariant that checks whether every cell on the boundary also has the corresponding grid cell set to FULL | def boundary_invariant(self):
for cell in self.fire_boundary():
if self.is_empty(cell[0], cell[1]):
print "Cell " + str(cell) + " in fire boundary is empty."
return False
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_grid_full(self):\n for row in self.game_state:\n for e in row:\n if e is None:\n return False\n return True",
"def fullGrid(state):\n return not ((state[:, :, 0] + state[:, :, 1]) == 0).any()",
"def full(self):\n for x in range(0,3)... | [
"0.71920717",
"0.70023197",
"0.67449224",
"0.66790205",
"0.6631955",
"0.6613186",
"0.6605032",
"0.6601281",
"0.6562532",
"0.65374047",
"0.6527449",
"0.6509587",
"0.6494093",
"0.64925843",
"0.64523965",
"0.6358073",
"0.63485545",
"0.63382304",
"0.631841",
"0.6313765",
"0.63030... | 0.7699241 | 0 |
Returns a range from a to b, including both endpoints | def from_inclusive(a, b):
c = int(b > a)*2-1
return range(a, b+c, c) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _bi_range(start, end):\n if start == end:\n return (start,)\n\n elif end < start:\n return reversed(range(end, start + 1))\n\n else:\n return range(start, end + 1)",
"def range_inclusive(start, stop):\n return range(start, stop + 1)",
"def calculate_ranges(a, b):\n try:\... | [
"0.77354187",
"0.73943543",
"0.7353963",
"0.7293135",
"0.72048956",
"0.68755573",
"0.6775559",
"0.6761502",
"0.6750063",
"0.67284167",
"0.66356015",
"0.66242915",
"0.66224957",
"0.6580224",
"0.6560372",
"0.6533194",
"0.6526771",
"0.65064925",
"0.64840794",
"0.6469163",
"0.640... | 0.8278248 | 0 |
Returns the chunk at given chunk coordinates | def get_chunk(self, x: int, z: int) -> EmptyChunk:
if not self.inside(x, 0, z, chunk=True):
raise OutOfBoundsCoordinates(f'Chunk ({x}, {z}) is not inside this region')
return self.chunks[z % 32 * 32 + x % 32] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_block(self, chunk, coords):\n\n return chunk.get_block(coords)",
"def getchunk(self, *args, **kwargs):\n return _image.image_getchunk(self, *args, **kwargs)",
"def sync_get_block(self, chunk, coords):\n\n return chunk.get_block(coords)",
"def chunk_coords_to_block_coords(\n x:... | [
"0.71494114",
"0.6753957",
"0.67533576",
"0.6625385",
"0.65714836",
"0.6403521",
"0.640261",
"0.6368248",
"0.62888116",
"0.6236681",
"0.61390483",
"0.6115911",
"0.60418653",
"0.6006928",
"0.59817696",
"0.59290576",
"0.58626676",
"0.5813215",
"0.5805423",
"0.5748618",
"0.57186... | 0.6806264 | 1 |
Adds given chunk to this region. Will overwrite if a chunk already exists in this location | def add_chunk(self, chunk: EmptyChunk):
if not self.inside(chunk.x, 0, chunk.z, chunk=True):
raise OutOfBoundsCoordinates(f'Chunk ({chunk.x}, {chunk.z}) is not inside this region')
self.chunks[chunk.z % 32 * 32 + chunk.x % 32] = chunk | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_chunk(self, chunk):\n self.chunkbuffer.appendleft(chunk)",
"def add(self, chunkOrToken):\n chunkOrToken.setParent(self)\n self.dtrs.append(chunkOrToken)\n self.positionCount += 1",
"def _add_cached_chunk(self, offset, data):\n if (\n self._cached_chunk_posi... | [
"0.7879799",
"0.67803276",
"0.6672726",
"0.6668966",
"0.64762497",
"0.62061226",
"0.616433",
"0.60951906",
"0.60454017",
"0.6009306",
"0.596302",
"0.5851554",
"0.5826008",
"0.57065004",
"0.56892127",
"0.56521547",
"0.56358415",
"0.55565655",
"0.5546457",
"0.5528825",
"0.54930... | 0.79272586 | 0 |
Adds section to chunk at (x, z). Same as ``EmptyChunk.add_section(section)`` | def add_section(self, section: EmptySection, x: int, z: int, replace: bool=True):
if not self.inside(x, 0, z, chunk=True):
raise OutOfBoundsCoordinates(f'Chunk ({x}, {z}) is not inside this region')
chunk = self.chunks[z % 32 * 32 + x % 32]
if chunk is None:
chunk = Empty... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_section(self, section_name: str) -> None:\n pass",
"def add_section(self, section_name: str) -> None:\n pass",
"def add_section(self, section):\n if section.lower() == \"default\":\n raise ValueError, 'Invalid section name: %s' % section\n\n if section in self._se... | [
"0.6537357",
"0.6537357",
"0.6398103",
"0.6397857",
"0.6276737",
"0.6092696",
"0.58850425",
"0.58581275",
"0.5814254",
"0.57519996",
"0.5741328",
"0.57047933",
"0.56777245",
"0.5639013",
"0.55746704",
"0.5516169",
"0.5390092",
"0.5364603",
"0.5347104",
"0.5342008",
"0.5234331... | 0.84367806 | 0 |
Helper function that only sets the block if ``self.inside(x, y, z)`` is true | def set_if_inside(self, block: Block, x: int, y: int, z: int):
if self.inside(x, y, z):
self.set_block(block, x, y, z) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def in_block(x, y, input_suduko_3d):\n block_id = 100\n\n if x < 3 and y < 3: # First if statements defines into which block the element of given x,y values is, this are\n # from 0-8 representing the 9 boxes\n block_id = 0\n if 6 > x >= 3 > 0 <= y:\n block_id = 3\n if 6 <= x <= 8 ... | [
"0.64218473",
"0.63526237",
"0.6153189",
"0.6030201",
"0.60202265",
"0.59773934",
"0.59161836",
"0.5609168",
"0.558946",
"0.55853575",
"0.5523145",
"0.5518083",
"0.54748404",
"0.5467124",
"0.545464",
"0.5417525",
"0.5356588",
"0.5327588",
"0.5282958",
"0.5258888",
"0.5206799"... | 0.8620236 | 0 |
Fills in blocks from ``(x1, y1, z1)`` to ``(x2, y2, z2)`` in a rectangle. | def fill(self, block: Block, x1: int, y1: int, z1: int, x2: int, y2: int, z2: int, ignore_outside: bool=False):
if not ignore_outside:
if not self.inside(x1, y1, z1):
raise OutOfBoundsCoordinates(f'First coords ({x1}, {y1}, {z1}) is not inside this region')
if not self.in... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fill_rect(self, value, x1, y1, x2, y2):\n self.fill(x1, y1, x2-x1, y2-y1)",
"def fill_triangle(self, x0, y0, x1, y1, x2, y2, color=Color['white']):\n pointlist = [(x0, y0), (x1, y1), (x2, y2)]\n pygame.draw.polygon(self.display, color, pointlist)",
"def fill(self, xrange=range(0,16), y... | [
"0.6759221",
"0.66726756",
"0.6315122",
"0.6239038",
"0.6214571",
"0.61948085",
"0.6184842",
"0.6096984",
"0.60784644",
"0.6054093",
"0.5992815",
"0.5992283",
"0.5988265",
"0.59807956",
"0.5937357",
"0.5853239",
"0.57890373",
"0.57832766",
"0.5764153",
"0.5758203",
"0.5757633... | 0.761372 | 0 |
Return the last element from an iterator. | def last(iterator):
item = None
for item in iterator:
pass
return item | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def last(iterable):\n it = iter(iterable)\n item = next(it)\n for item in it:\n pass\n return item",
"def return_last(iter):\n for thing in iter:\n pass\n return thing",
"def last(iterable):\n d = deque(iterable, maxlen=1)\n try:\n return d.pop()\n except IndexEr... | [
"0.81704766",
"0.8126013",
"0.7631656",
"0.7508389",
"0.7461644",
"0.72906893",
"0.7239407",
"0.7238677",
"0.7135802",
"0.71334594",
"0.7124381",
"0.70423234",
"0.7003483",
"0.6959612",
"0.6933803",
"0.6911308",
"0.69061714",
"0.686835",
"0.6841431",
"0.68262434",
"0.68242246... | 0.8675218 | 0 |
Initializes population, cache and storage | def initialize(self):
self.population.initialize()
self.cache.initialize()
if self.storage:
self.storage.initialize() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_population(self):\n pass",
"def init(self, **kwargs):\n self._d = {}\n self._th = None\n self._run = True\n self.load()",
"def __init__(self):\n self._datastore = dict()",
"def initialise(self):",
"def init(self):\n pass",
"def init(self):\n ... | [
"0.7593586",
"0.73463607",
"0.73275894",
"0.7324741",
"0.7172695",
"0.7172695",
"0.7172695",
"0.7172695",
"0.7172695",
"0.7172695",
"0.7172695",
"0.7172695",
"0.71597743",
"0.7140536",
"0.7140536",
"0.70901275",
"0.70898193",
"0.7082336",
"0.7082336",
"0.7082336",
"0.7082336"... | 0.883915 | 0 |
Store an individual in the storage backend. | def store_individual(self, hash, individual):
if self.storage:
self.storage.write_individual(hash, self.generation, individual ) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save(self):\r\n if self._storage:\r\n self._storage.store(self, *self._storage_args)\r\n else:\r\n raise StorageNotSetError()",
"def put(self, name, obj, lifetime=ObjectLifetime.Event):\n\n # check if object with the same name is already stored?\n if name in ... | [
"0.6551306",
"0.6530587",
"0.64019746",
"0.6363247",
"0.6284706",
"0.6276256",
"0.6260118",
"0.6160291",
"0.61023945",
"0.6091016",
"0.6070906",
"0.6041757",
"0.60393125",
"0.6016974",
"0.6006164",
"0.5992561",
"0.5963782",
"0.59499836",
"0.59499836",
"0.5940263",
"0.5908173"... | 0.74466157 | 0 |
Returns best individual in population (relies on Population method) | def best_individual(self):
return self.population.best_individual() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _best_individual(self):\n return max(self._population, key=attrgetter(\"fitness\"))",
"def get_best_individual(population: List[IndividualType]) -> IndividualType:\n best_individual = population[0]\n for individual, rating in population:\n if rating < best_individual[1]:\n ... | [
"0.84718853",
"0.81538415",
"0.81047726",
"0.7823421",
"0.7633607",
"0.74540997",
"0.7401855",
"0.7353317",
"0.7279851",
"0.7126376",
"0.709254",
"0.7077304",
"0.68827885",
"0.67887175",
"0.6566941",
"0.6518445",
"0.64974064",
"0.64597523",
"0.64550704",
"0.64477754",
"0.6445... | 0.8571775 | 0 |
creates a new population with population.evolve, sets the new population as the current and increment generation. After this the population in the previous generation is lost | def evolve_population(self, **options):
new_population = self.population.evolve(**options)
self.population = new_population
self.generation = new_population.generation_number | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_new_population(self):\n self.check_for_generation_cap()\n pop_container = list()\n for chromosome in self.population:\n partner = bm.select_partner(\n self.fitness_scores, self.population)\n child = bm.mutate(bm.crossover(chromosome, partner))\n ... | [
"0.7709369",
"0.7311488",
"0.7299069",
"0.7189038",
"0.7013157",
"0.6869076",
"0.67646176",
"0.6729715",
"0.66529423",
"0.66127074",
"0.66050977",
"0.65951574",
"0.65723693",
"0.6494388",
"0.6463658",
"0.6457739",
"0.64527386",
"0.64378035",
"0.642856",
"0.6409268",
"0.640652... | 0.78997153 | 0 |
Performs the evolution cycle. This is the main method that should be normally called. Evolution goes on until a termination criterium becomes True. At the end the best individual is returned. | def evolve(self, **options):
if not self.termination_criteria:
raise TypeError("You Must set one or more termination criteria")
self.initialize()
self.evaluate_population(**options)
while 1:
if self.should_terminate():
break
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def evolve(self):\n self.generation = 0\n start_time = time.time()\n\n # while the termination criteria is not satisfied, makes another generation\n while not self.termination_criteria.satisfied(self.generation, time.time()-start_time, self.population):\n self.generation += 1... | [
"0.6539778",
"0.64894867",
"0.6374142",
"0.63138235",
"0.62839043",
"0.6255625",
"0.61972564",
"0.615336",
"0.6120255",
"0.60814714",
"0.60222733",
"0.6005586",
"0.6002664",
"0.59978247",
"0.59944457",
"0.5991057",
"0.59831536",
"0.59788215",
"0.5916169",
"0.5911512",
"0.5872... | 0.7172024 | 0 |
Allows user to place bets, returns None. | def get_player_bet(self) -> None:
print("Please enter the amount you want to bet.")
while self.user.bet == 0:
input_ = input(">>> ")
try:
input_ = float(input_)
self.user.bet = input_
except ValueError as e:
print(str(e)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def place_bet(self) -> None:\n amount = self.get_bet()\n while not self.valid_bet(amount):\n print(f\"That is an invalid bet. Please input an amount within ${MINIMUM_BET()} and ${self.balance}\\n\")\n amount = self.get_bet()\n self.balance -= amount\n self.bet = am... | [
"0.70802295",
"0.6853024",
"0.6825054",
"0.6718689",
"0.671583",
"0.67043567",
"0.6674088",
"0.66712844",
"0.64814967",
"0.64650905",
"0.6464141",
"0.64590806",
"0.64511913",
"0.6350406",
"0.627941",
"0.6273458",
"0.62659526",
"0.61382014",
"0.6119612",
"0.6117631",
"0.610332... | 0.70504504 | 1 |
Deals cards to the user and house, returns None. Deals two cards to player and house each. House receives one open and one closed card. If cards have already been dealt this method just returns None. | def first_deal(self) -> None:
if len(self.house.hand.cards) == 0 and len(self.user.hand.cards) == 0: # Check if cards are already dealt.
print(self.deal_card(self.user))
print(self.deal_card(self.house))
print(self.deal_card(self.user))
print(self.deal_card(self.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def deal(self):\n\n if self.dealer: # Has cards in hand\n self.dealer.reset()\n\n if self.player: # Has cards in hand\n self.player.reset()\n\n dealer_first = self.deck.draw()\n dealer_second = self.deck.draw()\n dealer_second.flip()\n self.dealer.t... | [
"0.6993562",
"0.6883988",
"0.6612903",
"0.6499829",
"0.6383287",
"0.6368293",
"0.62500584",
"0.6218783",
"0.61778855",
"0.61760587",
"0.6155784",
"0.6136452",
"0.6116217",
"0.60801005",
"0.6064902",
"0.60176337",
"0.6009256",
"0.59821904",
"0.5931164",
"0.59221417",
"0.591003... | 0.68916774 | 1 |
Deals cards to house, returns None | def house_deal(self) -> None:
if not self.has_game_ending_hand:
while max(self.house.hand.value) < 17:
print(f"{self.deal_card(self.house)}") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def first_deal(self) -> None:\n if len(self.house.hand.cards) == 0 and len(self.user.hand.cards) == 0: # Check if cards are already dealt.\n print(self.deal_card(self.user))\n print(self.deal_card(self.house))\n print(self.deal_card(self.user))\n print(self.deal_... | [
"0.7425127",
"0.6940771",
"0.6936745",
"0.6591779",
"0.6573968",
"0.65444267",
"0.65152925",
"0.6493008",
"0.6459767",
"0.6452606",
"0.6400211",
"0.63715595",
"0.63715595",
"0.6359715",
"0.63436705",
"0.63021743",
"0.6300474",
"0.6289987",
"0.62397206",
"0.6235566",
"0.622235... | 0.7155595 | 1 |
Checks for the different kinds of hands the player and house has, returns bool. | def get_game_ending_hands(self) -> bool:
end = False
if 10 in self.house.hand.value: # Check if house's first card is a 10
if self.action_peek_cards() == 1: # Peek the card to check for and ace. CardValue.ACE has a value of 1
self.event_house_blackjack()
end... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_fullhouse(self):\n if self.has_pair() & self.has_three_of_a_kind():\n self.rank_per_hand['5'] = \"full house\"\n return True\n return False",
"def is_full_house(hand):\n\tis_a_full_house = False\n\tnum_three_kind = 0\n\tnum_pair = 0\n\ti = 0\n\twhile i < 13:\n\t\tif ha... | [
"0.6710579",
"0.664217",
"0.6553142",
"0.64558953",
"0.6409192",
"0.6303049",
"0.630163",
"0.61734915",
"0.614371",
"0.6137094",
"0.6111759",
"0.60144633",
"0.59642214",
"0.59610355",
"0.5945365",
"0.59393865",
"0.59295696",
"0.59169227",
"0.5908294",
"0.59029585",
"0.5900479... | 0.6740741 | 0 |
Asks user if the game should be ended or not, returns None. | def round_end(self) -> None:
input_ = self.validate_input("\nDo you want to play another round?[y/n]", ("y", "n"))
if input_ == "n":
self.has_ended = True
else:
self.user.bet = 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def end_of_game(self):\n end_game = pyip.inputYesNo(f'\\nDo you want to play again?: ')\n\n if end_game == 'no':\n print('\\n-- GAME OVER --')\n sys.exit()\n elif end_game == 'yes':\n self.game_counter += 1",
"def EndGame(self):\n check_endgame = not s... | [
"0.7820257",
"0.75849676",
"0.75164115",
"0.7323227",
"0.71045566",
"0.70531404",
"0.7052095",
"0.6873565",
"0.6841535",
"0.6786962",
"0.67742175",
"0.6761526",
"0.6748283",
"0.6743815",
"0.6704593",
"0.6692921",
"0.66365916",
"0.6626896",
"0.6626896",
"0.6623149",
"0.6581739... | 0.7586079 | 1 |
Event for when house has blackjack, returns None. | def event_house_blackjack(self) -> None:
if 21 in self.user.hand.value:
self.event_player_push()
else:
print("The house has blackjack")
self.event_house_wins() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_for_blackjack(self):\n if (self.dealer.hand.value + self.dealer.face_down.value) == 21:\n if self.player.hand.blackjack:\n return self.blackjack_push()\n else:\n return self.blackjack_dealer_win()\n\n if self.player.hand.blackjack():\n ... | [
"0.7102307",
"0.6858465",
"0.6709716",
"0.6596564",
"0.6382169",
"0.6296633",
"0.62518513",
"0.6159988",
"0.6137631",
"0.61218387",
"0.6086342",
"0.60474914",
"0.60283005",
"0.602187",
"0.59936106",
"0.5944831",
"0.59164226",
"0.5806925",
"0.57985395",
"0.5778431",
"0.5761524... | 0.85808146 | 0 |
Event for when user wins, returns None. | def event_player_wins(self) -> None:
win_amount = self.user.bet
print("Congratulations, you win:", win_amount)
self.user.win_balance(self.user.bet) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_winner(self) -> None:\n if not self.get_game_ending_hands():\n if max(self.user.hand.value) > max(self.house.hand.value): # Values above 21 are omitted\n self.event_player_wins()\n elif max(self.user.hand.value) == max(self.house.hand.value):\n se... | [
"0.68993604",
"0.68964064",
"0.6843061",
"0.6753403",
"0.6743779",
"0.6651324",
"0.65241176",
"0.65032357",
"0.64356375",
"0.6432726",
"0.63998324",
"0.6389373",
"0.6332981",
"0.62867635",
"0.62409985",
"0.6231352",
"0.62251234",
"0.6204182",
"0.62012535",
"0.6200097",
"0.618... | 0.7420098 | 0 |
Event for when house wins, returns None. | def event_house_wins(self) -> None:
print("You lose")
self.user.lose_balance(self.user.bet) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_winner(self) -> None:\n if not self.get_game_ending_hands():\n if max(self.user.hand.value) > max(self.house.hand.value): # Values above 21 are omitted\n self.event_player_wins()\n elif max(self.user.hand.value) == max(self.house.hand.value):\n se... | [
"0.7377803",
"0.7067633",
"0.7039978",
"0.6885437",
"0.6532778",
"0.64540684",
"0.6443208",
"0.63587207",
"0.6265723",
"0.6253461",
"0.625192",
"0.6251206",
"0.6244894",
"0.6225948",
"0.62121314",
"0.6206654",
"0.61854243",
"0.61658245",
"0.61578286",
"0.61563206",
"0.6133475... | 0.7271658 | 1 |
Event for when house goes bust, returns None. | def event_house_bust(self) -> None:
print(f"The house's hand contains {min(self.house.hand.value)}, they're bust")
self.event_player_wins() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def event_player_bust(self) -> None:\n print(f\"Your hand contains {min(self.user.hand.value)}, you're bust\")\n self.event_house_wins()",
"def event_house_blackjack(self) -> None:\n if 21 in self.user.hand.value:\n self.event_player_push()\n else:\n print(\"The ... | [
"0.692791",
"0.60571635",
"0.58967096",
"0.55677986",
"0.5558159",
"0.55171144",
"0.55069155",
"0.5488246",
"0.54822344",
"0.54730093",
"0.5447639",
"0.54356676",
"0.5406993",
"0.5402682",
"0.53844774",
"0.5326585",
"0.5324676",
"0.53170097",
"0.52970785",
"0.5275559",
"0.525... | 0.7827559 | 0 |
Event for when player goes bust, returns None. | def event_player_bust(self) -> None:
print(f"Your hand contains {min(self.user.hand.value)}, you're bust")
self.event_house_wins() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def event_house_bust(self) -> None:\n print(f\"The house's hand contains {min(self.house.hand.value)}, they're bust\")\n self.event_player_wins()",
"def update(self):\n if self.bunker_health == 0:\n self.kill()",
"def on_loop(self):\n\n if not Syringe.craftable:\n ... | [
"0.72710687",
"0.6107994",
"0.5895356",
"0.5872952",
"0.583328",
"0.582141",
"0.58022356",
"0.5797654",
"0.5782969",
"0.57784337",
"0.5760133",
"0.57263",
"0.56755555",
"0.5641476",
"0.56328326",
"0.5613689",
"0.5613351",
"0.55944276",
"0.55883646",
"0.55850583",
"0.55589384"... | 0.77857053 | 0 |
list of urls of a user's repos | def urls(gh, user):
return [repo.url for repo in getuserrepos(gh, user)] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def repositories(self, user_name=None):\n user_name = user_name if user_name else self._auth[0]\n data = self._request('GET', 'users', user_name)\n return data.repositories\n #ret_val = []\n #for repository in data.repositories:\n # ret_val.append(repository.name)\n ... | [
"0.7733041",
"0.77024794",
"0.7624664",
"0.7403024",
"0.73314524",
"0.7210593",
"0.7078684",
"0.70109814",
"0.6999416",
"0.69814646",
"0.6937563",
"0.6918695",
"0.6880146",
"0.6738339",
"0.67307055",
"0.6662354",
"0.65915906",
"0.65727204",
"0.65644765",
"0.65623707",
"0.6557... | 0.8964593 | 0 |
number of public repositories of a user | def n_public_repos(gh, user):
return getuser(gh, user).public_repos | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_count(username):\n return get_contributor(username)[\"count\"]",
"def get_public_narrative_count():\n client_workspace = MongoClient(mongoDB_metrics_connection+to_workspace)\n db_workspace = client_workspace.workspace\n public_narrative_count = db_workspace.workspaceACLs.find({\"user\" : \"*\... | [
"0.6931196",
"0.69251525",
"0.6906984",
"0.6766805",
"0.66190344",
"0.6315404",
"0.63035226",
"0.629744",
"0.6281933",
"0.62044704",
"0.6178291",
"0.61447835",
"0.6059186",
"0.6017082",
"0.59982175",
"0.5984747",
"0.59217376",
"0.5917715",
"0.5898999",
"0.5878044",
"0.5862865... | 0.8427448 | 0 |
Applying the same augmentation to image and its corresponding mask | def augment(image,masks):
# Random horizontal flipping
if random.random() > 0.5:
image = TF.hflip(image)
masks = TF.hflip(masks)
# Random vertical flipping
if random.random() > 0.5:
image = TF.vflip(image)
masks = TF.vflip(masks)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def img_and_mask_augmentation(augmentation, img, mask):\n\n # img_copy = img.copy()\n image_shape = img.shape\n\n # Convert the stochastic sequence of augmenters to a deterministic one.\n # The deterministic sequence will always apply the exactly same effects to the images.\n det = augmentation.to_d... | [
"0.7971662",
"0.6987494",
"0.6844219",
"0.6818389",
"0.6804014",
"0.67105186",
"0.6666665",
"0.6547314",
"0.65413684",
"0.65087134",
"0.64880174",
"0.645089",
"0.6445864",
"0.6416765",
"0.6411415",
"0.6388375",
"0.63562083",
"0.63396513",
"0.6335781",
"0.6261895",
"0.62515956... | 0.72530645 | 1 |
Function to read the image and mask and return a sample of dataset when neededself. | def __getitem__(self,image_id):
# read the image
image_path = (os.path.join(self.dataset_dir,self.list_dir[image_id],"images/{}.png".format(self.list_dir[image_id])))
image = io.imread(image_path)
# read the mask
mask_dir = os.path.join(self.dataset_dir,self.list_dir[image_id],'... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __getitem__(self, idx):\n img_path = self.img_labels.iloc[idx, 0]\n mask_path = self.img_labels.iloc[idx, 1]\n\n image = _load_img(img_path)\n image = np.array(image)\n image = torch.from_numpy(image)\n \n mask = _load_img(mask_path)\n mask = np.array(mas... | [
"0.67121446",
"0.66772234",
"0.6363293",
"0.6307143",
"0.62401533",
"0.6154699",
"0.6122595",
"0.60832435",
"0.60519624",
"0.60349685",
"0.60263544",
"0.6025657",
"0.6024643",
"0.6020571",
"0.6012803",
"0.60097057",
"0.5902136",
"0.5896047",
"0.58942544",
"0.587289",
"0.58579... | 0.7232249 | 0 |
finds columns in the dataframe with zero variance ie those with the same value in every observation. | def find_zero_var(df):
toKeep = []
toDelete = []
for col in df:
if len(df[col].value_counts()) > 1:
toKeep.append(col)
else:
toDelete.append(col)
##
return {'toKeep':toKeep, 'toDelete':toDelete} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_zero_var(df): \n toKeep = []\n toDelete = []\n for col in df:\n if len(df[col].value_counts()) > 1:\n toKeep.append(col)\n else:\n toDelete.append(col)\n ##\n return {'toKeep':toKeep, 'toDelete':toDelete}",
"def test_drop_zero_variance_on_subset_columns(da... | [
"0.74193525",
"0.6533197",
"0.62334067",
"0.62208056",
"0.61681634",
"0.6127774",
"0.60418195",
"0.59925526",
"0.597131",
"0.5882125",
"0.586426",
"0.57852906",
"0.57829046",
"0.57698643",
"0.57459974",
"0.57398176",
"0.56759185",
"0.55791897",
"0.55541277",
"0.55518734",
"0.... | 0.7350333 | 1 |
finds columns that are eother positively or negatively perfectly correlated (with correlations of +1 or 1), and creates a dict that includes which columns to drop so that each remaining column is independent | def find_perfect_corr(df):
corrMatrix = df.corr()
corrMatrix.loc[:,:] = numpy.tril(corrMatrix.values, k = -1)
already_in = set()
result = []
for col in corrMatrix:
perfect_corr = corrMatrix[col][abs(numpy.round(corrMatrix[col],10)) == 1.00].index.tolist()
if perfect_corr and col n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_perfect_corr(df): \n corrMatrix = df.corr()\n corrMatrix.loc[:,:] = numpy.tril(corrMatrix.values, k = -1)\n already_in = set()\n result = []\n for col in corrMatrix:\n perfect_corr = corrMatrix[col][abs(numpy.round(corrMatrix[col],10)) == 1.00].index.tolist()\n if perfect_corr and ... | [
"0.6928181",
"0.66915566",
"0.6476721",
"0.64294565",
"0.6361409",
"0.5917592",
"0.57251847",
"0.5655154",
"0.56510097",
"0.5580107",
"0.54400027",
"0.5428099",
"0.5409625",
"0.53756136",
"0.5341789",
"0.5323188",
"0.5310228",
"0.5274723",
"0.52521986",
"0.5248313",
"0.523950... | 0.69375426 | 0 |
get the text output | def get_text(self):
return self.output.getvalue() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_text(self):\n\n return self.output['text']",
"def getText():",
"def getText():",
"def getText():",
"def getText():",
"def getText():",
"def obtain_text():\n pass",
"def get_text(self):",
"def output_text(text):\n print(text)",
"def text(self) -> str:",
"def get_text(self):\... | [
"0.80502146",
"0.76949847",
"0.76949847",
"0.76949847",
"0.76949847",
"0.76949847",
"0.76014626",
"0.75969446",
"0.74793994",
"0.74737936",
"0.7280087",
"0.725396",
"0.7242547",
"0.7066192",
"0.7057842",
"0.69442976",
"0.6915638",
"0.6883678",
"0.6883098",
"0.685257",
"0.6839... | 0.8387408 | 0 |
Displays statistics on the most popular stations and trip. | def station_stats(data):
print('\nCalculating The Most Popular Stations and Trip...\n')
start_time = time.time()
# display most commonly used start station
popular_ss= data['Start Station'].mode()[0]
print('Most popular Start Station:', popular_ss)
# display most commonly used end station
po... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def station_stats(df):\n\n print('\\nCalculating The Most Popular Stations and Trip...\\n')\n start_time = time.time()\n\n # display most commonly used start station\n print(popular_start_station(df))\n\n # display most commonly used end station\n print(popular_end_station(df))\n\n # display m... | [
"0.7815675",
"0.7553417",
"0.74914914",
"0.74748665",
"0.7446617",
"0.7428588",
"0.74237514",
"0.74177027",
"0.7400495",
"0.7387161",
"0.7385634",
"0.73647535",
"0.735934",
"0.73566747",
"0.73548365",
"0.7351854",
"0.7351274",
"0.735057",
"0.73421645",
"0.7340198",
"0.7337384... | 0.7662213 | 1 |
Displays statistics on the total and average trip duration. | def trip_duration_stats(data):
print('\nCalculating Trip Duration...\n')
start_time = time.time()
# display total travel time
total_trip_time= data['Trip Duration'].sum()
print('The Total Travel Time is {} Hours'. format(total_trip_time/3600))
# display mean travel time
avg_trip= data['Trip ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def trip_duration_stats(df):\n\n print('\\nCalculating Trip Duration...\\n')\n start_time = time.time()\n\n # TO DO: display total travel time\n total_time = df['Trip Duration'].sum()\n print(\"The total travel time was:\",str(total_time))\n\n # TO DO: display mean travel time\n mean_time = df... | [
"0.802504",
"0.8003995",
"0.7949535",
"0.7937111",
"0.793114",
"0.7926624",
"0.79147255",
"0.7913882",
"0.7907699",
"0.79052943",
"0.7900545",
"0.78914416",
"0.7889074",
"0.7886493",
"0.7884836",
"0.7884105",
"0.78822976",
"0.78735834",
"0.7868467",
"0.7866015",
"0.786337",
... | 0.8142488 | 0 |
Returns a list containing the names of all installed FSLeyes plugins. | def listPlugins():
plugins = []
for dist in pkg_resources.working_set:
if dist.project_name.startswith('fsleyes-plugin-'):
plugins.append(dist.project_name)
return list(sorted(plugins)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def names() -> Tuple[str, ...]:\n return plugins.list_all(package_name=__name__)",
"def get_available_plugin_names():\n mgr = stevedore.EnabledExtensionManager(namespace=PLUGIN_NAMESPACE,\n check_func=_auth_plugin_available,\n ... | [
"0.77920425",
"0.7777894",
"0.76436985",
"0.7446259",
"0.735109",
"0.733451",
"0.7286112",
"0.7230579",
"0.71848685",
"0.70858264",
"0.7053823",
"0.70029324",
"0.68295395",
"0.6769856",
"0.6700735",
"0.6697945",
"0.66847473",
"0.6670819",
"0.6656807",
"0.6656699",
"0.6639548"... | 0.8093447 | 0 |
Loads the given Python file as a FSLeyes plugin. | def loadPlugin(filename):
name = op.splitext(op.basename(filename))[0]
modname = 'fsleyes_plugin_{}'.format(name)
distname = 'fsleyes-plugin-{}'.format(name)
if distname in listPlugins():
log.debug('Plugin %s is already in environment - skipping', distname)
return
log.debug('... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_plugin(self, name, path):\n\t\ttry:\n\t\t\t# Plugins are just python modules.\n\t\t\tloader = importlib.machinery.SourceFileLoader(name, path)\n\t\t\tmodule = loader.load_module()\n\t\t\treturn module\n\t\texcept:\n\t\t\t# Upon error, alert the user and return None.\n\t\t\tbot.error(\"Failure loading plug... | [
"0.6108969",
"0.6028346",
"0.5957791",
"0.5890156",
"0.5883845",
"0.5814956",
"0.581036",
"0.58080155",
"0.5806757",
"0.5711296",
"0.5694454",
"0.56307757",
"0.55246925",
"0.55135196",
"0.550469",
"0.54819465",
"0.5479231",
"0.5416481",
"0.53727555",
"0.5365991",
"0.5356906",... | 0.6279767 | 0 |
Copies the given Python file into the FSLeyes settings directory, within a subdirectory called ``plugins``. After the file has been | def installPlugin(filename):
basename = op.splitext(op.basename(filename))[0]
dest = 'plugins/{}.py'.format(basename)
log.debug('Installing plugin %s', filename)
with open(filename, 'rt') as inf, \
fslsettings.writeFile(dest) as outf:
outf.write(inf.read())
dest = fsl... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def python_plugin(path, name):\n require.directory(_uwsgi.UWSGI_PLUGINS_LOCATION, use_sudo=True)\n if not _uwsgi.plugin_exists(name):\n with cd(_uwsgi.UWSGI_INSTALLATION_DIR):\n cmd = \"PYTHON={path} ./uwsgi --build-plugin \\\"plugins/python {name}\\\"\"\n sudo(cmd.format(**local... | [
"0.60705787",
"0.5803295",
"0.5789761",
"0.5697095",
"0.56689143",
"0.55733675",
"0.5551937",
"0.5447961",
"0.54258406",
"0.53851646",
"0.53426594",
"0.53335357",
"0.5332662",
"0.53268933",
"0.53224117",
"0.5322032",
"0.52970606",
"0.52946967",
"0.5293114",
"0.52759516",
"0.5... | 0.6132073 | 0 |
Handles a filesystem delete based on UUID. | def handle_delete(uuid):
location = os.path.join(app.config['UPLOAD_DIRECTORY'], uuid)
print(uuid)
print(location)
shutil.rmtree(location) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete(self, uuid):\n try:\n handle_delete(uuid)\n return make_response(200, {\"success\": True})\n except Exception, e:\n return make_response(400, {\"success\": False, \"error\": e.message})",
"def delete(self, uuid):\n try:\n handle_delete(u... | [
"0.70867515",
"0.70867515",
"0.660941",
"0.6598334",
"0.65764475",
"0.6433648",
"0.6430364",
"0.63916093",
"0.6335144",
"0.6332568",
"0.6312674",
"0.6248714",
"0.623831",
"0.61949",
"0.6183798",
"0.6121713",
"0.61208045",
"0.6118135",
"0.6065186",
"0.6054746",
"0.6049135",
... | 0.80184585 | 1 |
Handle a chunked or nonchunked upload. | def handle_upload(f, attrs):
# chunked = False
dest_folder = os.path.join(app.config['UPLOAD_DIRECTORY'], attrs['qquuid'])
dest = os.path.join(dest_folder, attrs['qqfilename'])
save_upload(f, dest) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _upload_chunk(self, final=False):\n out = self.fs.session.post(\n self.location,\n data=self.buffer.getvalue(),\n headers={\"content-type\": \"application/octet-stream\"},\n )\n out.raise_for_status()\n return True",
"def upload_chunk(self, request... | [
"0.6564833",
"0.65228426",
"0.6468114",
"0.6433403",
"0.64023376",
"0.63730204",
"0.6338926",
"0.6337131",
"0.6185726",
"0.61249465",
"0.6094075",
"0.6055695",
"0.5978826",
"0.59438723",
"0.58829886",
"0.5869195",
"0.58663183",
"0.5866303",
"0.5789348",
"0.5735959",
"0.571598... | 0.6543689 | 1 |
Save an upload. Uploads are stored in media/uploads | def save_upload(f, path):
if not os.path.exists(os.path.dirname(path)):
os.makedirs(os.path.dirname(path))
with open(path, 'wb+') as destination:
destination.write(f.read()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _save(self, name, content):\n if not self.oauth_token:\n raise AuthenticationError(\"You must be authenticated with oAuth \"\n \"for upload files.\")\n params = {\n 'title': name,\n # 'description': description,\n # ... | [
"0.66148895",
"0.65704787",
"0.6502347",
"0.6467279",
"0.6402686",
"0.6367206",
"0.6337269",
"0.62911373",
"0.6290135",
"0.6253598",
"0.6241659",
"0.6228346",
"0.61645436",
"0.61511374",
"0.6148766",
"0.6096052",
"0.6096052",
"0.6096052",
"0.6071183",
"0.5982553",
"0.5977057"... | 0.7024745 | 1 |
A POST request. Validate the form and then handle the upload based ont the POSTed data. Does not handle extra parameters yet. | def post(self):
if validate(request.form):
handle_upload(request.files['qqfile'], request.form)
return make_response(200, {"success": True})
else:
return make_response(400, {"error": "Invalid request"}) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post(self, request, *args, **kwargs):\n form = self.get_form()\n if form.validate():\n return self.form_valid(form)\n else:\n return self.form_invalid(form)",
"def post(self, request, *args, **kwargs):\n form = self.get_form(self.form_class)\n if form.... | [
"0.6935135",
"0.6721188",
"0.67184585",
"0.67082894",
"0.6695506",
"0.66680175",
"0.665402",
"0.6633827",
"0.6602961",
"0.65494746",
"0.6471828",
"0.6467104",
"0.64652175",
"0.6428505",
"0.636845",
"0.63206375",
"0.62829965",
"0.62138766",
"0.6189452",
"0.61750424",
"0.615428... | 0.7618754 | 0 |
Handles a filesystem delete based on UUID. | def handle_delete(uuid):
location = os.path.join(app.config['UPLOAD_DIRECTORY'], uuid)
print(uuid)
print(location)
shutil.rmtree(location) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete(self, uuid):\n try:\n handle_delete(uuid)\n return make_response(200, {\"success\": True})\n except Exception, e:\n return make_response(400, {\"success\": False, \"error\": e.message})",
"def delete(self, uuid):\n try:\n handle_delete(u... | [
"0.70867515",
"0.70867515",
"0.660941",
"0.6598334",
"0.65764475",
"0.6433648",
"0.6430364",
"0.63916093",
"0.6335144",
"0.6332568",
"0.6312674",
"0.6248714",
"0.623831",
"0.61949",
"0.6183798",
"0.6121713",
"0.61208045",
"0.6118135",
"0.6065186",
"0.6054746",
"0.6049135",
... | 0.80184585 | 0 |
if we downscale the image, the intrinsic matrix also needs to be changed. | def rescale_intrinsic(self):
# scale focal length and principal points wrt image resizeing
if self.downscale > 1:
self.K = self.K_orig.copy()
self.K[0, 0] /= float(self.downscale)
self.K[1, 1] /= float(self.downscale)
self.K[0, 2] /= float(self.downscale)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rescale(self, img):\n\n if self.scale != 1:\n return imutils.resize(img, width=int(img.shape[1] * self.scale))\n else:\n return img",
"def _scale(self, image):\n\n if image.GetWidth() != self._width or image.GetHeight()!= self._height:\n image.Rescale(sel... | [
"0.6996561",
"0.68154985",
"0.67812395",
"0.66067845",
"0.65932626",
"0.657384",
"0.64108557",
"0.63874376",
"0.6248599",
"0.6233107",
"0.6231488",
"0.62114924",
"0.6186186",
"0.6160583",
"0.61534476",
"0.61527234",
"0.61435246",
"0.6095281",
"0.6093892",
"0.6093892",
"0.6087... | 0.78269804 | 0 |
Loads a set of images to self.imgs list | def load_images(self):
self.img_paths = sorted(glob(self.img_pattern))
self.imgs = []
for idx, this_path in enumerate(self.img_paths):
try:
this_img = cv2.imread(this_path)
if self.downscale > 1:
this_img = cv2.resize(this_img, (0, ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_images(self):\n for image in self.gltf.images:\n self.images.append(image.load(self.path.parent))",
"def load_images(self):\n images_list = [os.path.join(self.root, image['file_name'])\n for image in self.data['images']]\n\n if self.shuffle:\n ... | [
"0.8590295",
"0.77870566",
"0.7699553",
"0.76801467",
"0.7673592",
"0.7590096",
"0.75795263",
"0.74018186",
"0.72978824",
"0.7295722",
"0.725373",
"0.72240764",
"0.7198496",
"0.7194455",
"0.7186009",
"0.7184365",
"0.718259",
"0.71660835",
"0.71409017",
"0.7089566",
"0.7082811... | 0.7847628 | 1 |
This function visualizes the epipolar lines | def visualize_epipolar_lines(self, img1, img2, p1, p2, E, save_path):
# get fundamental matrix
F, mask_fdm = cv2.findFundamentalMat(p1, p2, cv2.RANSAC)
p1_selected = p1[mask_fdm.ravel() == 1]
p2_selected = p2[mask_fdm.ravel() == 1]
# draw lines
lines1 = cv2.computeCorres... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_lines(self):\n self.plot(3)",
"def plot(self): \n\t\txandy = sep_xy(self.start, self.end)\n\t\tplt.plot(xandy[0], xandy[1], 'k-', lw=1, color='red')",
"def plot(self): \n\t\txandy = sep_xy(self.start, self.end)\n\t\tplt.plot(xandy[0], xandy[1], 'k-', lw=1, color='green')",
"def plot(self): \n... | [
"0.65509456",
"0.65389705",
"0.65010214",
"0.64777714",
"0.6332598",
"0.63312864",
"0.6290788",
"0.6257814",
"0.61941946",
"0.61722386",
"0.61518055",
"0.6132958",
"0.6102459",
"0.6102354",
"0.6092172",
"0.60891706",
"0.6056098",
"0.60538334",
"0.6052147",
"0.6045826",
"0.601... | 0.6725889 | 0 |
Evaluates the baseline predictor. | def evalBaseline(self, df = None):
if (df is None):
self.r_b = self.df.merge(self.df_user[["user ind", "b_u"]], on = "user ind")
self.r_b = self.r_b.merge(self.df_item[["item ind", "b_i"]], on = "item ind")
self.r_b["baseline"] = self.r_mean + self.r_b["b_u"] + self.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def evaluate_prediction(self):\n\n # ratio_train = self.evaluate_data(self.train_x, self.train_y)\n ratio_test = self.evaluate_data(self.test_x, self.test_y)\n\n print(\"\\n*NAIVE BAYES:\")\n # print(\"Test1: {}%\".format(ratio_dev*100))\n print(\"Test: {} %\".format(ratio_test*1... | [
"0.6852386",
"0.6681168",
"0.66578424",
"0.6598341",
"0.6555525",
"0.65538764",
"0.65262705",
"0.65068984",
"0.65044415",
"0.64675784",
"0.6452903",
"0.63666344",
"0.6350837",
"0.6343575",
"0.6316385",
"0.630979",
"0.62960446",
"0.6286752",
"0.62639403",
"0.625002",
"0.624637... | 0.7059672 | 0 |
Estimates model coefficients from calculated shifts. | def initialize_model(self, positions, shifts_y, shifts_x):
shifts_y = list(map(lambda x: x*-1, shifts_y))
shifts_x = list(map(lambda x: x*-1, shifts_x))
def list_shift(pos, c):
return np.array([DeformationModel.calculate_shifts_from_coeffs(p[0],
p[1], p[2... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def coefficients(self) :\n raise NotImplementedError",
"def coef_(self):\n assert self.sess is not None, \"Model has not been fitted yet!\"\n return self.sess.run(self.W_lst)[0]",
"def coefficients(self):\r\n return self.coef_['x']",
"def apply_const_shift_operator(model, operator... | [
"0.5734117",
"0.5412557",
"0.536942",
"0.5354503",
"0.5295235",
"0.52839845",
"0.52596015",
"0.52424043",
"0.51920736",
"0.5175553",
"0.5158605",
"0.5158605",
"0.5134293",
"0.5107185",
"0.5097566",
"0.5093408",
"0.5078818",
"0.5078818",
"0.50681216",
"0.50326604",
"0.5027408"... | 0.693465 | 0 |
Randomly generates model with reasonable coefficients. | def initialize_model_randomly(self, shape=(2048, 2048), tn=50):
self.coeffs = self.generate_random_coeffs(shape, tn) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_model (d):\n return np.random.rand (d+1, 1)",
"def initializeWeights(mlModel):\n\n randInitRange = mlModel.randInitRange\n\n numFeatures = mlModel.features.shape[1]\n mlModel.weights = np.random.rand(numFeatures+1) * 2 * randInitRange - randInitRange\n\n return mlModel",
"def random... | [
"0.64208275",
"0.5918288",
"0.58846515",
"0.5881533",
"0.5875465",
"0.58405405",
"0.5833292",
"0.5814761",
"0.5787209",
"0.5702006",
"0.5701312",
"0.5696805",
"0.5688786",
"0.5681196",
"0.56801695",
"0.56607825",
"0.56421375",
"0.5633048",
"0.5573776",
"0.55682325",
"0.554259... | 0.68959796 | 0 |
Generates vector of reasonable random model coefficients a_i. shape is (height, width) tuple. Generated coefficients are in interval with c_0 in . | def generate_random_coeffs(shape, tn):
res = np.zeros((2, 9))
# reasonable space-dependent part
width = shape[1]
height = shape[0]
min_val = 1e-4
for i in range(2):
c = res[i]
# generate quadratic coefficients
c[2] = np.random.uniform... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def coef_random(an,bn,random_trun_start=0,random_start=1,random_end= 32, halfwidth0=1,pow=-1):\n\n an=np.asarray(an)\n bn=np.asarray(bn)\n half=halfcube(random_start,random_end,halfwidth0,pow)\n an_random=half*np.random.uniform(-1,1,(random_end-random_start,))\n bn_random=half*np.random.uniform(-1,1... | [
"0.6511364",
"0.6201331",
"0.6073942",
"0.6068727",
"0.5951372",
"0.5904999",
"0.5790906",
"0.5731309",
"0.5686012",
"0.5672112",
"0.5663319",
"0.5612603",
"0.56111264",
"0.55973434",
"0.5548478",
"0.5548478",
"0.5527172",
"0.55149466",
"0.5494699",
"0.548396",
"0.54814345",
... | 0.6319211 | 1 |
Defines the base unit of this sensor | def base_unit() -> ureg:
return ureg.meter | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_base_unit(self, obj: Dimension) -> Unit:\n return obj.base_unit",
"def unit_of_measurement(self):\n return self.sensor_type[\"unit\"]",
"def unit_of_measurement(self):\r\n return self._sensor_cfg[1]",
"def unit_of_measurement(self):\r\n return self._sensor_cfg[1]",
"def ... | [
"0.7427461",
"0.66860276",
"0.6682726",
"0.6682726",
"0.65782034",
"0.6503735",
"0.64724845",
"0.6439907",
"0.64389485",
"0.6436502",
"0.6423663",
"0.6423663",
"0.6419997",
"0.6406627",
"0.63824344",
"0.63757634",
"0.6370861",
"0.63593864",
"0.63399184",
"0.63399184",
"0.6335... | 0.7912085 | 0 |
Test that the byteps_push_pull correctly sums 1D, 2D, 3D tensors. | def test_byteps_push_pull(self):
dtypes = ['float16', 'float32', 'float64']
dims = [1, 2, 3]
count = 0
ctx = self._current_context()
shapes = [(), (17), (17, 17), (17, 17, 17)]
for dtype, dim in itertools.product(dtypes, dims):
# MXNet uses gpu_id as part of t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_byteps_push_pull_inplace(self):\n size = bps.size()\n dtypes = ['float16', 'float32', 'float64']\n dims = [1, 2, 3]\n count = 0\n ctx = self._current_context()\n shapes = [(), (17), (17, 17), (17, 17, 17)]\n for dtype, dim in itertools.product(dtypes, dims)... | [
"0.81022996",
"0.6435133",
"0.63489884",
"0.6338958",
"0.6273451",
"0.59371763",
"0.5863565",
"0.58035696",
"0.558139",
"0.54165804",
"0.5360265",
"0.5321667",
"0.52746713",
"0.52081335",
"0.5206156",
"0.5201949",
"0.5191096",
"0.51699805",
"0.5164772",
"0.5162587",
"0.514622... | 0.84918064 | 0 |
Test that the byteps_push_pull correctly sums 1D, 2D, 3D tensors. | def test_byteps_push_pull_inplace(self):
size = bps.size()
dtypes = ['float16', 'float32', 'float64']
dims = [1, 2, 3]
count = 0
ctx = self._current_context()
shapes = [(), (17), (17, 17), (17, 17, 17)]
for dtype, dim in itertools.product(dtypes, dims):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_byteps_push_pull(self):\n dtypes = ['float16', 'float32', 'float64']\n dims = [1, 2, 3]\n count = 0\n ctx = self._current_context()\n shapes = [(), (17), (17, 17), (17, 17, 17)]\n for dtype, dim in itertools.product(dtypes, dims):\n # MXNet uses gpu_id ... | [
"0.848981",
"0.6435212",
"0.63493204",
"0.63393897",
"0.627382",
"0.59382117",
"0.5861871",
"0.5806715",
"0.55826056",
"0.5418833",
"0.53611726",
"0.5323135",
"0.52746826",
"0.5208869",
"0.52074116",
"0.52009845",
"0.5188586",
"0.5170058",
"0.51654714",
"0.5162977",
"0.514367... | 0.80997765 | 1 |
scan the pzt_motor (e.g., pzt_dcm_th2), detectors can be any signal or motor (e.g., Andor, dcm.th2) | def pzt_scan(pzt_motor, start, stop, steps, detectors=[Vout2], sleep_time=1, md=None):
if Andor in detectors:
exposure_time = yield from bps.rd(Andor.cam.acquire_time)
yield from mv(Andor.cam.acquire, 0)
yield from mv(Andor.cam.image_mode, 0)
yield from mv(Andor.cam.num_images, 1)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pzt_scan_multiple(\n moving_pzt,\n start,\n stop,\n steps,\n detectors=[Vout2],\n repeat_num=2,\n sleep_time=1,\n fn=\"/home/xf18id/Documents/FXI_commision/DCM_scan/\",\n):\n\n det = [det.name for det in detectors]\n det_name = \"\"\n for i in range(len(det)):\n det_name... | [
"0.5739672",
"0.55752635",
"0.5421364",
"0.5333477",
"0.5325447",
"0.5255563",
"0.51745707",
"0.51531947",
"0.51229215",
"0.5022708",
"0.50104445",
"0.49869722",
"0.4959905",
"0.49559098",
"0.49386626",
"0.49105185",
"0.49098516",
"0.4906843",
"0.48975998",
"0.48923635",
"0.4... | 0.70551413 | 0 |
Repeat scanning the pzt (e.g. pzt_dcm_ch2, pzt_dcm_th2), and read the detector outputs. Images and .csv data file will be saved | def pzt_scan_multiple(
moving_pzt,
start,
stop,
steps,
detectors=[Vout2],
repeat_num=2,
sleep_time=1,
fn="/home/xf18id/Documents/FXI_commision/DCM_scan/",
):
det = [det.name for det in detectors]
det_name = ""
for i in range(len(det)):
det_name += det[i]
det_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run(self):\r\n self.create_output_dirs()\r\n data = self.read_input()\r\n while (data):\r\n # Initiate ORB detector\r\n orb = cv2.ORB_create()\r\n\r\n if (self.continu):\r\n current_frame_nr = data[\"frameNr\"]\r\n if(current_fr... | [
"0.6212296",
"0.58695394",
"0.5823236",
"0.57866335",
"0.5777293",
"0.5715863",
"0.5676956",
"0.5636035",
"0.5631047",
"0.55860215",
"0.5562953",
"0.55607384",
"0.554145",
"0.55249727",
"0.54934704",
"0.549295",
"0.54726213",
"0.5466943",
"0.54605633",
"0.5457797",
"0.5455398... | 0.6958013 | 0 |
With given energy list, scan the pzt multiple times and record the signal from various detectors, file will be saved to local folder. | def pzt_energy_scan(
moving_pzt,
start,
stop,
steps,
eng_list,
detectors=[dcm.th2, Vout2],
repeat_num=1,
sleep_time=1,
fn="/home/xf18id/Documents/FXI_commision/DCM_scan/",
):
det = [det.name for det in detectors]
det_name = ""
for i in range(len(det)):
det_name +=... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def readenergy(self, filelist):\r\n \r\n energy=[]\r\n tmpenergy=[]\r\n for filename in filelist:\r\n if not(os.path.exists(filename)):\r\n if self._resultfile: self._resultfile.write('Output file: \"'+filename+'\" does not exist. Restart your calculation. \\n')\r\n else: print 'Outp... | [
"0.6509747",
"0.57093614",
"0.5667372",
"0.5663888",
"0.56243795",
"0.56148547",
"0.55704665",
"0.5513959",
"0.54973865",
"0.5366151",
"0.5344379",
"0.53401536",
"0.5294211",
"0.5282262",
"0.52793986",
"0.5203054",
"0.51673126",
"0.5163976",
"0.5157231",
"0.51282185",
"0.5102... | 0.620671 | 1 |
Calculate which row to update, factoring in the header row placed every $hdr_span years. | def year_span(target_year:int, base_year:int, yr_span:int, hdr_span:int, logger:lg.Logger = None) -> int:
if logger:
logger.debug(F"target year = {target_year}; base year = {base_year}; year span = {yr_span}; header span = {hdr_span}")
year_diff = target_year - base_year
hdr_adjustment = 0 if hdr_sp... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def handle_irregular(rows):\n \n for data in rows:\n if len(data.findChildren([\"th\"])) < 1:\n row = Row(\"2006\", data, 6, 7)\n if any(r.year == \"2006\" and r.county == row.county for r in csv_rows) and row.county is not None:\n matching_row = next((match for match in csv_rows if match.yea... | [
"0.5644471",
"0.53534263",
"0.5230461",
"0.5187199",
"0.51704454",
"0.51178247",
"0.5092591",
"0.5007937",
"0.5000446",
"0.48899803",
"0.48895955",
"0.4858776",
"0.48426914",
"0.4825437",
"0.48032025",
"0.47941107",
"0.47811443",
"0.47728986",
"0.47709316",
"0.476204",
"0.476... | 0.6459912 | 0 |
Convert the string representation of a quarter to an int. | def get_int_quarter(p_qtr:str, logger:lg.Logger = None) -> int:
if logger:
logger.debug(F"quarter to convert = {p_qtr}")
msg = "Input MUST be a String of 0..4!"
if not p_qtr.isnumeric() or len(p_qtr) != 1:
if logger:
c_frame = inspect.currentframe().f_back
logger.err... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _quarter_number(self, dategiven):\n return RetailDate(dategiven).quarter",
"def dec2int(r: str) -> int:",
"def quarter(self) -> Index:\n warnings.warn(\n \"`quarter` will return int32 index instead of int 64 index in 4.0.0.\",\n FutureWarning,\n )\n return ... | [
"0.64421225",
"0.6198249",
"0.56812286",
"0.5672642",
"0.5546351",
"0.5473638",
"0.54137665",
"0.5393882",
"0.5266237",
"0.52620816",
"0.51355624",
"0.5131029",
"0.50740594",
"0.50709116",
"0.5026049",
"0.49898073",
"0.49762765",
"0.49730146",
"0.49620914",
"0.4958292",
"0.49... | 0.81801647 | 0 |
Get the year and month that start the FOLLOWING quarter. | def next_quarter_start(start_year:int, start_month:int, logger:lg.Logger = None) -> (int, int):
if logger:
logger.debug(F"start year = {start_year}; start month = {start_month}")
# add number of months for a Quarter
next_month = start_month + QTR_MONTHS
# use integer division to find out if the ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prev_quarter_boundaries(now):\n first_of_month = datetime.datetime(now.year, now.month, 1)\n\n # 75 days before the 1st is always in the previous quarter\n date_in_prev_q = first_of_month - datetime.timedelta(days=75)\n\n q_y = date_in_prev_q.year\n q_start_m = int((date_in_prev_q.month-1) / 3)*... | [
"0.7338803",
"0.7215223",
"0.7130429",
"0.7078758",
"0.6997591",
"0.690662",
"0.6612257",
"0.6464504",
"0.6396317",
"0.6276966",
"0.6186094",
"0.6084192",
"0.60228586",
"0.60228586",
"0.59833634",
"0.5969586",
"0.5969524",
"0.5858372",
"0.5796026",
"0.57202613",
"0.5689967",
... | 0.73292184 | 1 |
Get the date that ends the CURRENT quarter. | def current_quarter_end(start_year:int, start_month:int, logger:lg.Logger = None) -> date:
if logger:
logger.info(F"start year = {start_year}; start month = {start_month}")
end_year, end_month = next_quarter_start(start_year, start_month)
# end date is one day back from the start of the next period
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_quarter_end(x: Optional[Date] = None) -> Date:\n return get_quarter_start(x or get_today()) + relativedelta(months=+3, days=-1)",
"def last_quarter(today):\n quarter_date = today - relativedelta(months=1)\n while quarter_date.month % 3 != 0:\n quarter_date = quarter_date - relativedelta(m... | [
"0.8170659",
"0.7075324",
"0.6908958",
"0.6836984",
"0.66845727",
"0.6497959",
"0.64169747",
"0.62825865",
"0.62558955",
"0.6109868",
"0.6003702",
"0.60028976",
"0.60028976",
"0.5731196",
"0.5731196",
"0.57094854",
"0.57011384",
"0.5657141",
"0.5642791",
"0.5642791",
"0.55984... | 0.81834036 | 0 |
Generate the start and end dates for the quarters in the submitted range. | def generate_quarter_boundaries(start_year:int, start_month:int, num_qtrs:int, logger:lg.Logger = None) -> (date, date):
if logger:
logger.debug(F"start year = {start_year}; start month = {start_month}; num quarters = {num_qtrs}")
for i in range(num_qtrs):
yield date(start_year, start_month, 1),... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _recompute(self):\n current_date = self.start_date\n self.quarterly_date_list = []\n self.daily_date_list = []\n while current_date <= self.end_date:\n current_quarter = get_quarter(current_date)\n current_year = current_date.year\n next_year, next_q... | [
"0.6163751",
"0.61617553",
"0.6156018",
"0.6087009",
"0.59538853",
"0.5751105",
"0.5747524",
"0.56566805",
"0.56298023",
"0.5623435",
"0.56176776",
"0.56133264",
"0.5609766",
"0.55975634",
"0.55484426",
"0.5538029",
"0.5492789",
"0.5463719",
"0.54399437",
"0.541501",
"0.53804... | 0.73519164 | 0 |
Sum values over given axis | def sum(self, axis: int = 0):
self.values = self.values.sum(axis=axis)
self.layers = [None]
return self.copy() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sum(tensor, axis=None):\n raise NotImplementedError",
"def sum(self, axis=None, keepdims=False):\n return F.Sum.apply(self, axis, keepdims)",
"def val_sum(self, axis = None):\n f = self.to_Poly()\n return f.val_sum(axis).to_PolyMesh(self.params)",
"def val_sum(self, axis = Non... | [
"0.7622369",
"0.7435083",
"0.742321",
"0.73752266",
"0.73362845",
"0.71223015",
"0.69976205",
"0.69614166",
"0.6825869",
"0.6780794",
"0.67299175",
"0.66423965",
"0.6566993",
"0.6565615",
"0.6412074",
"0.63147205",
"0.6298999",
"0.6296889",
"0.6282736",
"0.61980706",
"0.61980... | 0.8020687 | 0 |
Config file for main trainer factory (Scheduler to train multiple models in a row i.e. for a specified set of horizons) To ensure that we store the model settings only in one place, the configs Trainer will take the default values given in the model configs file (that must be specified in file_name_model_configs argume... | def __init__(self, config_file_name: str):
configs_trainer = io.read_yaml(PATH_CONFIG, config_file_name)
configs_model = configs_trainer[configs_trainer['model']]
# Add trainer configs attributes
horizons = configs_trainer['forecasting_horizons_trainer']
self.forecasting_horizon... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, config_file_name: str=None, configs: dict=None, is_sell_in_model: bool=None):\n\n if config_file_name is not None:\n configs = io.read_yaml(PATH_CONFIG, config_file_name)\n\n if is_sell_in_model is None:\n self.is_sell_in_model = configs['model'] == 's... | [
"0.6581065",
"0.65535516",
"0.64014393",
"0.6348182",
"0.6270936",
"0.6252991",
"0.6247476",
"0.62378055",
"0.62012976",
"0.6048395",
"0.59550464",
"0.594158",
"0.59358466",
"0.5920022",
"0.5893728",
"0.5885183",
"0.58825177",
"0.58792585",
"0.58395",
"0.5823655",
"0.5821777"... | 0.7245064 | 0 |
Looks in build_dir for log_file in a folder that also includes the junit file. | def find_log_junit(build_dir, junit, log_file):
tmps = [f.filename for f in view_base.gcs_ls('%s/artifacts' % build_dir)
if '/tmp-node' in f.filename]
for folder in tmps:
filenames = [f.filename for f in view_base.gcs_ls(folder)]
if folder + junit in filenames:
path = fol... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pytest_logger_logsdir(self, config):",
"def test_log_dir(self):\n false_dir = '/tmp/any'\n self.test_config['LOG_DIR'] = false_dir\n self.write_config_to_file()\n self.log = nginx_log_generator()\n self.generate_report()\n # Check our log\n path_to_log = '{}/a... | [
"0.66856474",
"0.6602517",
"0.63428384",
"0.6296752",
"0.62367845",
"0.62194216",
"0.6125659",
"0.61027193",
"0.60568506",
"0.60384834",
"0.5944967",
"0.58859736",
"0.5884929",
"0.58814096",
"0.5857451",
"0.5755718",
"0.57389444",
"0.5735726",
"0.5714073",
"0.57060564",
"0.56... | 0.78429896 | 0 |
Returns list of files named log_file from values in all_logs | def find_log_files(all_logs, log_file):
log_files = []
for folder in all_logs.itervalues():
for log in folder:
if log_file in log:
log_files.append(log)
return log_files | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_log_files():\n for filename in os.listdir(\"/home/malyhass/log-parser\"):\n if filename.startswith(\"access.log\"):\n yield filename",
"def find_logs():\n\n file_list_targets = [r'/Program Files/IDEMIA/MFace Flex IA/first/log/*.log*',\n r'/Program Files/ID... | [
"0.7600446",
"0.7588688",
"0.7271703",
"0.7102535",
"0.6964148",
"0.6879073",
"0.6856349",
"0.6664205",
"0.6594064",
"0.6556262",
"0.6484734",
"0.6444405",
"0.63837224",
"0.63441855",
"0.6228864",
"0.6220997",
"0.62146014",
"0.61931854",
"0.61931854",
"0.6190094",
"0.61443925... | 0.8292149 | 0 |
returns dictionary given the artifacts folder with the keys being the folders, and the values being the log files within the corresponding folder | def get_all_logs(directory, artifacts):
log_files = {}
if artifacts:
dirs = [f.filename for f in view_base.gcs_ls('%s/artifacts' % directory)
if f.is_dir]
else:
dirs = [directory]
for d in dirs:
log_files[d] = []
for f in view_base.gcs_ls(d):
l... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def collect_logs(self):\n logs = glob.glob(f\"{self.production.rundir}/*.err\") #+ glob.glob(f\"{self.production.rundir}/*/logs/*\")\n logs += glob.glob(f\"{self.production.rundir}/*.out\")\n messages = {}\n for log in logs:\n with open(log, \"r\") as log_f:\n ... | [
"0.7088755",
"0.65402335",
"0.61850625",
"0.6157875",
"0.61373955",
"0.6120842",
"0.6115297",
"0.6083896",
"0.60730094",
"0.60391843",
"0.6012872",
"0.59854996",
"0.59497964",
"0.58434486",
"0.5785914",
"0.57677436",
"0.5703347",
"0.5692961",
"0.5668204",
"0.5629328",
"0.5591... | 0.74142367 | 0 |
Based on make_dict, either returns the objref_dict or the parsed log file | def parse_log_file(log_filename, pod, filters=None, make_dict=False, objref_dict=None):
log = gcs_async.read(log_filename).get_result()
if log is None:
return {}, False if make_dict else None
if pod:
bold_re = regex.wordRE(pod)
else:
bold_re = regex.error_re
if objref_dict is... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def object_decoder(obj):\n\t\tif 'logfile' in obj:\n\t\t\treturn logfile(obj['logfile']['name'], obj['logfile']['lines'], obj['logfile']['type'], obj['logfile']['content'], obj['logfile']['sources'])\n\t\tif 'logfile_entry' in obj:\n\t\t\tif len(obj['logfile_entry']['timestamp']['datetime']) >= 20 :\n\t\t\t\tdate ... | [
"0.6649974",
"0.59932905",
"0.58671886",
"0.5755533",
"0.5745892",
"0.55871373",
"0.55416346",
"0.5481624",
"0.5440245",
"0.5378912",
"0.5357203",
"0.5282771",
"0.52630085",
"0.5223232",
"0.5209461",
"0.51650983",
"0.5125105",
"0.51221484",
"0.5097486",
"0.50874823",
"0.50788... | 0.67737544 | 0 |
Load Disaster Declarations and County information into database, as two separate tables that are being created simultaneously. Database information being pulled from FEMA API Disasters Declaration Summaries Data set. Data populates both disastesr and counties tables. API returns 1k records max ($top set to variable res... | def load_disasters():
print "Disasters"
#deletes any data within the table before seeding
Disaster.query.delete()
result_count = 1000
iteration = 0
records_returned = 1000
# makes payload requests from FEMA API
while records_returned == 1000:
payload = {'$top': result_count,... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Collect_data(clo, cla, FD, LD, ZC, idx_time, cntry, TZ):\r\n #initiate the console response\r\n rep = \"\"\r\n global ddf\r\n \r\n #define the noaa server access\r\n server_noaa = \"https://www.ncei.noaa.gov/data/global-hourly/access/\"\r\n \r\n #Initate dateframe\r\n data = pd.DataF... | [
"0.6040113",
"0.5981123",
"0.59303576",
"0.58975035",
"0.5869871",
"0.57901585",
"0.576051",
"0.5668672",
"0.56307334",
"0.5579675",
"0.554138",
"0.55237526",
"0.55177534",
"0.5482741",
"0.544993",
"0.54196256",
"0.53621525",
"0.5353647",
"0.5353226",
"0.53431803",
"0.533402"... | 0.8253348 | 0 |
Load States into database from a text file. | def load_states():
print "States and Territories"
State.query.delete()
for row in open("data/states_and_territories.txt"):
row = row.rstrip()
# can't seem to get rid of "\r" character other than doing a .split
piped_rows = row.split("\r")
for i in piped_rows:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Load(self, filename):\n\n self.sm['state'] = self.AddState\n self.sm['condition'] = self.AddCondition\n exec(open(filename).read(), self.sm)\n self.name = self.sm['name']\n if not self.name.isalnum():\n raise Exception(\"State machine name must consist of only alphanumeric\"\n ... | [
"0.67029935",
"0.64187706",
"0.636451",
"0.6263663",
"0.617526",
"0.61659336",
"0.6165151",
"0.6137184",
"0.6128943",
"0.6117616",
"0.6106107",
"0.60338277",
"0.6024515",
"0.60234845",
"0.5983557",
"0.5983557",
"0.59706086",
"0.5956377",
"0.5955591",
"0.5950796",
"0.5930032",... | 0.81981784 | 0 |
Return a tupil represent the upper and lower values of the price range at the given index. If there is one dataseries then return the tupil (value, None) | def get_value_at_index(self, index, cc):
high = cc.dsget('high')
low = cc.dsget('low')
return (high[index], low[index]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_bounds(self, value = None, index = None):\n\n if self._data is None or 0 in self._data.shape:\n return (0.0, 0.0)\n\n if type(value) == types.IntType:\n if self.value_dimension == 0:\n maxi = nanmax(self._data[value, ::])\n mini = nanmin(sel... | [
"0.62020886",
"0.58060557",
"0.57509655",
"0.5696991",
"0.5630712",
"0.5555234",
"0.549801",
"0.5446549",
"0.54304546",
"0.5422337",
"0.54095584",
"0.5409541",
"0.5402449",
"0.53884476",
"0.5376142",
"0.5351813",
"0.5332987",
"0.53233963",
"0.5312718",
"0.53064764",
"0.529671... | 0.6731937 | 0 |
Trains one elastic logistic classifier per review group. Saves the trained classifiers within self.models. | def train(self, x_train, y_train):
# convert input to format for classifier
list_of_embeddings = list(x_train[self.embeddings_col])
x_train = np.array([[float(i) for i in embedding.strip('[]').split()] for embedding in list_of_embeddings])
# discard fold ID column from labels
r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def apply_classifier(self):\n for detected_object in self.detected_objects:\n detected_object.predict_class(self.original_image)",
"def retrain(self):\n thread = Thread(target=self.trainer.train_classifier)\n thread.start()",
"def trainModel( self, featureTrain, classTrain):",
... | [
"0.6353949",
"0.6166256",
"0.60605466",
"0.6053671",
"0.59588176",
"0.5941645",
"0.5833356",
"0.57968616",
"0.57968616",
"0.5778012",
"0.5771533",
"0.57486176",
"0.5737569",
"0.57228905",
"0.57154137",
"0.5713114",
"0.56817275",
"0.5633404",
"0.5621355",
"0.5607235",
"0.55679... | 0.6931635 | 0 |
Get the admin visual data for a specific assignment. Currently the data passed back feeds into the radial and passed time scatter graphs. | def public_visuals_assignment_id(assignment_id: str):
# Get the assignment object
assignment = Assignment.query.filter(
Assignment.id == assignment_id
).first()
# If the assignment does not exist, then stop
req_assert(assignment is not None, message='assignment does not exist')
# Asse... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getAdminData(self):\n return getAdminData(self)",
"def admin_dashboard(request):\n data = request.GET.copy()\n if \"assigned_to\" not in data:\n data[\"assigned_to\"] = request.user.id\n assignment_form = AssignmentForm(data)\n assigned_to: Optional[Person] = None\n if assignment... | [
"0.611185",
"0.56681174",
"0.5536008",
"0.54843163",
"0.5468018",
"0.54487526",
"0.5419295",
"0.5360861",
"0.5259989",
"0.5253528",
"0.5136372",
"0.51328814",
"0.5104171",
"0.50537735",
"0.50513554",
"0.5044633",
"0.5022114",
"0.4999167",
"0.4984658",
"0.4978159",
"0.49689788... | 0.6321538 | 0 |
Get the visual history for a specific student and assignment. lightly cached per assignment and user | def visual_history_assignment_netid(assignment_id: str, netid: str):
# Get the assignment object
assignment = Assignment.query.filter(
Assignment.id == assignment_id
).first()
# If the assignment does not exist, then stop
req_assert(assignment is not None, message='assignment does not exis... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_history(self):\r\n cursor = connection.cursor()\r\n cursor.execute(\"\"\"\r\n SELECT id, created, student_module_id FROM courseware_studentmodulehistory\r\n \"\"\")\r\n return cursor.fetchall()",
"def history():\n \n user_id = session[\"user_id\"]\n histor... | [
"0.6364211",
"0.6215497",
"0.61883956",
"0.6163177",
"0.61592215",
"0.6120353",
"0.60890216",
"0.60595787",
"0.59833455",
"0.5978124",
"0.5969229",
"0.5968126",
"0.59636605",
"0.5947022",
"0.5911437",
"0.5892776",
"0.5835226",
"0.58197695",
"0.5789049",
"0.57594925",
"0.57415... | 0.66048294 | 0 |
Get the summary sundial data for an assignment. This endpoint is ridiculously IO intensive. heavily cached | def visual_sundial_assignment(assignment_id: str):
# Get the assignment object
assignment = Assignment.query.filter(
Assignment.id == assignment_id
).first()
# If the assignment does not exist, then stop
req_assert(assignment is not None, message='assignment does not exist')
# Assert t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __get_evaluation_summary(self):\n self.logger.debug(\n f\"Getting summary for assignment {self.assignment_id}, eval_id {self.eval_id}\"\n )\n result = self.interactor.get_policy_eval_summary(self.assignment_id)\n\n if result.status_code != 200:\n self.logger.de... | [
"0.65082306",
"0.61989534",
"0.60656804",
"0.59108555",
"0.58665276",
"0.58484167",
"0.5837141",
"0.57975644",
"0.57505107",
"0.5686875",
"0.5664202",
"0.5660172",
"0.5644205",
"0.5644205",
"0.5644205",
"0.5629081",
"0.5628967",
"0.56143475",
"0.56098056",
"0.55950415",
"0.55... | 0.7021534 | 0 |
Reshapes an input variable without copy. | def reshape(x, shape):
if x.shape == shape:
return chainer.as_variable(x)
y, = Reshape(shape).apply((x,))
return y | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reshape(x, shape):\n return Reshape(shape)(x)",
"def reshape_var(var):\n dims = np.shape(var)\n nx = dims[0]\n ny = dims[1]\n nz = dims[2]\n\n var_2d = var.reshape(nx * ny, nz)\n return var_2d",
"def flatten_reshape(variable):\n dim = 1\n for d in variable.get_shape()[1:].as_list... | [
"0.7709701",
"0.73209643",
"0.709344",
"0.7088738",
"0.6896953",
"0.67383665",
"0.67162436",
"0.6679906",
"0.63716567",
"0.63189733",
"0.63096625",
"0.63083035",
"0.6296938",
"0.62918407",
"0.62788635",
"0.62673515",
"0.6232674",
"0.61841697",
"0.61799854",
"0.614986",
"0.612... | 0.78366554 | 0 |
Convolve image [img] with [kernel]. | def convolution(img, kernel, padding='fill'):
kernel = np.rot90(kernel, 2)
h,w = kernel.shape[:2]
t,b,l,r = (h-1)//2, h//2, (w-1)//2, w//2 # Use numpy padding because it works for >2d
padshape = [(t,b),(l,r)]+[(0,0)]*(len(img.shape[2:]))
padded_img = np.pad(img, padshape, mode={'fill':'constant',... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _convolve_2d(kernel, image):\n\n nx = image.shape[0]\n ny = image.shape[1]\n nkx = kernel.shape[0]\n nky = kernel.shape[1]\n wkx = nkx // 2\n wky = nky // 2\n\n result = np.zeros(image.shape, dtype=float32)\n\n for i in prange(0, nx, 1):\n iimin = max(i - wkx, 0)\n iimax =... | [
"0.79295087",
"0.7629679",
"0.75895846",
"0.753147",
"0.7514754",
"0.7478905",
"0.7469306",
"0.74531704",
"0.7446393",
"0.7420992",
"0.74199206",
"0.7359379",
"0.73560745",
"0.733671",
"0.7332733",
"0.73180735",
"0.72574836",
"0.72479475",
"0.71656466",
"0.7125642",
"0.712427... | 0.77688134 | 1 |
Given two list of keypoint locations and descriptions, compute the correspondences. | def find_correspondences(pts1, pts2, desc1, desc2, match_score_type='ratio'):
N = pts1.shape[0]
X = np.sum(desc1**2, axis=1, keepdims=True)
Y = np.sum(desc2**2, axis=1, keepdims=True).T
XY = np.dot(desc1,desc2.T)
L = X + Y - 2*XY
D = (np.maximum(L, 0))
scores = np.min(D, axis = 1)
indic... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def match(desc1,desc2):\n desc1 = array([d/linalg.norm(d) for d in desc1])\n desc2 = array([d/linalg.norm(d) for d in desc2])\n dist_ratio = 0.6\n desc1_size = desc1.shape\n matchscores = zeros((desc1_size[0],1),'int')\n desc2t = desc2.T # precompute matrix transpose\n for i in range(desc1_siz... | [
"0.63015306",
"0.62716055",
"0.626144",
"0.62531865",
"0.6191865",
"0.6147474",
"0.6070767",
"0.5903749",
"0.5840502",
"0.5816759",
"0.5778241",
"0.5762855",
"0.57483983",
"0.570337",
"0.5675253",
"0.56423503",
"0.563314",
"0.5577304",
"0.55716807",
"0.5569695",
"0.5564171",
... | 0.65722686 | 0 |
Compute the Symmetrical Epipolar Distance. | def sym_epipolar_dist(corr, F):
corrs_temp = np.zeros(4)
corrs_temp[1] = corr[0]
corrs_temp[0] = corr[1]
corrs_temp[2] = corr[3]
corrs_temp[3] = corr[2]
corr = corrs_temp
p1 = np.hstack([corr[:2],1])
p2 = np.hstack([corr[2:],1])
first_term = (F @ p1)[:-1]
second_term = (F.T @ p2)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sym_distance(p, q):\n p = np.asarray(p)\n q = np.asarray(q)\n return np.minimum(norm(p - q), norm(p + q))",
"def sym_adj(adj):\n adj = sp.coo_matrix(adj)\n rowsum = np.array(adj.sum(1))\n d_inv_sqrt = np.power(rowsum, -0.5).flatten()\n d_inv_sqrt[np.isinf(d_inv_sqrt)] = 0.\n d_mat_inv... | [
"0.58554745",
"0.58154327",
"0.5790009",
"0.578392",
"0.5774197",
"0.5734582",
"0.5672689",
"0.564891",
"0.5642469",
"0.56281424",
"0.562024",
"0.5614998",
"0.56049925",
"0.55514705",
"0.55148494",
"0.550842",
"0.5503222",
"0.5497139",
"0.5496303",
"0.545838",
"0.5450096",
... | 0.5896209 | 0 |
Main function with assistance of helper functions finds all variable declarations matching regex_string inside the file and returns them inside a list. | def parse_file(self, file_name):
with open(file_name, "r") as input_file:
file_contents = input_file.read()
"""
Regex is done on line by line basis - to ensure that irrespective
of the formatting all docstrings are identified and all variable
specifications are foun... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GetDefinitions(filename,obj):\n file=open(filename)\n content=file.read().replace(\"\\t\",\" \")\n file.close\n pat=re.compile(obj +' \\{([\\S\\s]*?)\\}',re.DOTALL)\n finds=pat.findall(content)\n return finds",
"def regex_findall_variables(raw_string: Text) -> List[Text]:\n try:\n ... | [
"0.646614",
"0.6357556",
"0.617826",
"0.60977983",
"0.60213876",
"0.5975594",
"0.59012467",
"0.58486295",
"0.5812768",
"0.58079183",
"0.5763601",
"0.5752095",
"0.57495373",
"0.574335",
"0.57063615",
"0.565007",
"0.5638748",
"0.56160724",
"0.55971515",
"0.5569792",
"0.5567144"... | 0.6841503 | 0 |
Attempts to find the specified regex_string in a docstring. Returns True if matched, False otherwise. | def docstring_contains_variable_declaration(self, docstring):
found = re.search(self.regex_string, docstring)
if found == None:
return False
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def search(self, string):\n fid = open(os.path.join(self.output_path, \"%s.html\" % TEST_FILE_STEM), \"r\")\n found = False\n for line in fid.readlines():\n if re.search(string, line):\n found = True\n break\n fid.close()\n return found",
... | [
"0.6317987",
"0.61371905",
"0.6057289",
"0.6057289",
"0.60314524",
"0.60288835",
"0.59919053",
"0.59886557",
"0.5945532",
"0.5905841",
"0.58453524",
"0.5827701",
"0.5811089",
"0.5714999",
"0.5651282",
"0.56070274",
"0.56042236",
"0.5587269",
"0.55047214",
"0.5490997",
"0.5484... | 0.64932317 | 0 |
ultraio = chrlength uniqueratio / chr_total_reads | def ultratio(chrlength, uniqueratio, chrtotalreads, frcount):
ultratio = chrlength * uniqueratio / (chrtotalreads - frcount)
return ultratio | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def overhead(readings):\n return 100.0 * (int(readings[0]) + int(readings[1])) / (int(readings[2]) + int(readings[3]))",
"def IOU(s1, e1, s2, e2):\r\n if (s2 > e1) or (s1 > e2):\r\n return 0\r\n Aor = max(e1, e2) - min(s1, s2)\r\n Aand = min(e1, e2) - max(s1, s2)\r\n return float(Aand) ... | [
"0.62412286",
"0.57697046",
"0.57169855",
"0.5621136",
"0.5599058",
"0.5457794",
"0.54397404",
"0.54225004",
"0.54191625",
"0.53480023",
"0.53407586",
"0.53328043",
"0.5329747",
"0.53244",
"0.5299296",
"0.5296787",
"0.52902675",
"0.5287149",
"0.52871114",
"0.52828074",
"0.527... | 0.80247974 | 0 |
For a single string, checks if it is one of the FlowFrame's channel names. For a collection, checks if all its items are a channel name. | def __contains__(self, item):
if isinstance(item, basestring):
return item in self._channels
elif hasattr(item, '__iter__'):
return all(ch in self._channels for ch in item)
else:
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_channel_name(name):\n return name.startswith('#') or name.startswith('&')",
"def is_valid_channel_name(channel):\n if not is_channel_name(channel):\n return False\n\n test_section = channel[1:]\n\n if not MIN_CHANNEL_NAME_LEN < len(channel) < MAX_CHANNEL_NAME_LEN:\n return False\... | [
"0.62983626",
"0.59590423",
"0.58351296",
"0.55657226",
"0.5565677",
"0.54451466",
"0.54303205",
"0.5344488",
"0.5261591",
"0.5208733",
"0.51922476",
"0.5166167",
"0.5158738",
"0.5141583",
"0.5093375",
"0.5037257",
"0.50335044",
"0.50283056",
"0.49992242",
"0.49898973",
"0.49... | 0.61462975 | 1 |
Creates a new FlowFrame with copy of this one's data. The copy will not be linked to the same FCS file. | def copy(self, ID=None):
if ID is None:
match = re.match(r'^(.*-copy)(\d*)$', self._ID)
if match is not None:
ID = match.group(1) + str(int(match.group(2) or 1) + 1)
else:
ID = self._ID + '-copy'
return FlowFrame(self.data.copy(), ID=ID) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __copy__(self):\n logger.debug(\"Copying Flow() object.\")\n c = Flow()\n c.workingDir = self.workingDir \n c.cleanupTemp = self.cleanupTemp\n c.default_inputpaths = self.default_inputpaths\n c.default_outputpath = self.default_outputpath\n c.startNode = self.st... | [
"0.6915684",
"0.6491118",
"0.6262288",
"0.6196588",
"0.6177096",
"0.60805684",
"0.6039008",
"0.6006622",
"0.59907234",
"0.5963644",
"0.59613174",
"0.5920683",
"0.5904271",
"0.5897508",
"0.5892225",
"0.588936",
"0.588936",
"0.588936",
"0.58768296",
"0.5876595",
"0.58375454",
... | 0.6979232 | 0 |
Creates a new FlowFrame from a subset of this one's events. The data is copied (changing the new data wont' affect the old) and the new FlowFrame won't be linked to the same FCS file. | def filter(self, which, **kwargs):
# Get data (if lazy loading, want to avoid accessing this attribute
# twice)
data = self.data
# Get filtered data frame
df = data.iloc[which]
# Some indexing methods return a *view* on the original data, meaning
# changes to one will affect the other. We don't want thi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _gather_events(self, newframe_event):\n if not self.closed:\n for pg_event in pg.event.get():\n event = self._pygame_event_to_event(pg_event)\n if event is not None:\n self.event_hub.raise_event(event)\n self._add_animation_events()"... | [
"0.52557224",
"0.5220436",
"0.5044389",
"0.49591452",
"0.49120632",
"0.48713523",
"0.4860083",
"0.48562306",
"0.48033205",
"0.47910637",
"0.47875854",
"0.47843662",
"0.4754704",
"0.47503555",
"0.47374755",
"0.47197166",
"0.47195277",
"0.47106525",
"0.4694523",
"0.4671501",
"0... | 0.5344701 | 0 |
cast to str instead of HttpUrl model instance | def url_to_string(cls, v, values, **kwargs):
return str(v) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __repr__(self):\n return '<Url %r' % self.url",
"def put(self, obj):\n\n if obj is None:\n return\n\n assert isinstance(obj, str), (\n f\"object is not of type string, \"\n f\"but {type(obj)} for link attribute\")\n\n obj = obj.strip()\n\n i... | [
"0.6546976",
"0.6429486",
"0.6398717",
"0.6329465",
"0.6277657",
"0.6267619",
"0.61520636",
"0.61243427",
"0.60166615",
"0.60107136",
"0.59760755",
"0.5960031",
"0.5904033",
"0.58582616",
"0.5780172",
"0.5760385",
"0.57133275",
"0.56834507",
"0.5584159",
"0.55777216",
"0.5569... | 0.6620633 | 0 |
Get the matrix of doc into the feature matrix of length | def get_features(docs, max_length):
docs = list(docs)
Xs = numpy.zeros((len(docs), max_length), dtype='int32')
for i, doc in enumerate(docs):
j = 0
for token in doc:
vector_id = token.vocab.vectors.find(key=token.orth)
if vector_id >= 0:
Xs[i, j] = vec... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def docExtract(self):\n\n self.fv = []\n for doc in self.documents:\n self.fv.append(self.featureSet.extract(doc))\n\n # Convert to a numpy matrix.\n return np.array(np.asmatrix(self.fv))\n # return self.fv",
"def generateMatrix(self):\n if self.tokenWeights a... | [
"0.73008066",
"0.6616102",
"0.65988714",
"0.65695107",
"0.6559335",
"0.6553229",
"0.63959837",
"0.63307846",
"0.6287775",
"0.62767667",
"0.6253159",
"0.62464654",
"0.6183584",
"0.6170977",
"0.6160313",
"0.61482793",
"0.61415446",
"0.61357987",
"0.61317766",
"0.60834575",
"0.6... | 0.673142 | 1 |
add two numbers of different bases and return the sum | def flexibase_add(str1, str2, base1, base2):
n1 = base_to_int(str1, base1)
n2 = base_to_int(str2, base2)
#result = int_to_base(tmp, base1)
return n1+n2 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def flexibase_add(str1, str2, base1, base2):\n result = int_to_base(tmp, base1)\n return result",
"def sum(self, a, b):\n return int(a) + int(b)",
"def sum_num(a, b):\n return a + b",
"def add(num1,num2):\n if(num2==0):\n return num1\n return add((num1^num2),(num1&num2)<<1)",
"def add_numb... | [
"0.7697689",
"0.72538656",
"0.7124233",
"0.70175815",
"0.7010839",
"0.6899279",
"0.68684566",
"0.6858524",
"0.6757252",
"0.6746462",
"0.6708959",
"0.6673802",
"0.66633177",
"0.66163915",
"0.66131914",
"0.66131914",
"0.66076356",
"0.66049117",
"0.66027284",
"0.6597941",
"0.657... | 0.7828891 | 0 |
Create a new drink. | def drinks_new():
return render_template('drinks_new.html', drink={}) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_new_drink(user_data):\n drink_res = requests.post(url = \"http://127.0.0.1:5000/add_drink\", json=user_data)\n return drink_res.text",
"def onDrinkCreated(self, event):",
"def add_drink(self, _drink):\n self.drinks.append(_drink)",
"def make_drink(beverage_type, water, milk, sugar):\n... | [
"0.6792728",
"0.63321716",
"0.62927145",
"0.61510134",
"0.6055335",
"0.5757426",
"0.57419044",
"0.57061833",
"0.57061833",
"0.56481385",
"0.5645407",
"0.5643587",
"0.56387925",
"0.55879545",
"0.5575625",
"0.5549776",
"0.55411875",
"0.55409163",
"0.55409163",
"0.55409163",
"0.... | 0.64342654 | 1 |
Submit a new drink. | def drinks_submit():
drink = {
'name': request.form.get('name'),
'price': request.form.get('price'),
'description': request.form.get('description'),
'images': request.form.get('images').split()
}
drink_id = drinks_collection.insert_one(drink).inserted_id
return redirect(u... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_new_drink(user_data):\n drink_res = requests.post(url = \"http://127.0.0.1:5000/add_drink\", json=user_data)\n return drink_res.text",
"def post(self):\n\n model = gbmodel.get_model()\n\n #-------- sentiment-text analysis on review----------------\n review = request.form['re... | [
"0.62971145",
"0.59484977",
"0.5801306",
"0.57446504",
"0.57028437",
"0.5566209",
"0.5552328",
"0.5551744",
"0.5535918",
"0.553399",
"0.540908",
"0.5380634",
"0.5339647",
"0.5332633",
"0.53210694",
"0.53188866",
"0.53188866",
"0.53188866",
"0.53188866",
"0.53188866",
"0.53188... | 0.74074155 | 0 |
Show a single drink. | def drinks_show(drink_id):
drink = drinks_collection.find_one({'_id': ObjectId(drink_id)})
return render_template('drinks_show.html', drink=drink) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def drink(self):\n print(self.name + ' is drinking.')",
"def drinks_edit(drink_id):\n drink = drinks_collection.find_one({'_id': ObjectId(drink_id)})\n return render_template('drinks_edit.html', drink=drink)",
"def print_drinks(self):\n for beverage in self.drinks:\n print(bevera... | [
"0.70895994",
"0.6359162",
"0.62630725",
"0.61819303",
"0.5997045",
"0.5997045",
"0.5997045",
"0.5957326",
"0.59298",
"0.5922641",
"0.5921987",
"0.5875874",
"0.5837164",
"0.58103615",
"0.5791792",
"0.5771903",
"0.5733305",
"0.56826496",
"0.5669358",
"0.56403744",
"0.5607102",... | 0.80978394 | 0 |
Show the edit form for a drink. | def drinks_edit(drink_id):
drink = drinks_collection.find_one({'_id': ObjectId(drink_id)})
return render_template('drinks_edit.html', drink=drink) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show_edit_form(self, obj_pk=None):\n obj = self.model.objects.get(pk=obj_pk)\n # if there is no edit permission then does not show the form\n if not self.has_view_permissions(obj): return\n\n\n # create the edit form a add it to the empty widget details\n # override the funct... | [
"0.64750195",
"0.6467963",
"0.63552886",
"0.63058394",
"0.6244319",
"0.6187853",
"0.6180922",
"0.6136211",
"0.6059131",
"0.60525787",
"0.60396665",
"0.59724575",
"0.596908",
"0.5960207",
"0.59366137",
"0.59290475",
"0.5920844",
"0.58841246",
"0.5826922",
"0.5805979",
"0.58049... | 0.7579091 | 0 |
Submit an edited drink. | def drinks_update(drink_id):
updated_drink = {
'name': request.form.get('name'),
'price': request.form.get('price'),
'description': request.form.get('description'),
'images': request.form.get('images').split()
}
drinks_collection.update_one(
{'_id': ObjectId(drink_id)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def drinks_submit():\n drink = {\n 'name': request.form.get('name'),\n 'price': request.form.get('price'),\n 'description': request.form.get('description'),\n 'images': request.form.get('images').split()\n }\n drink_id = drinks_collection.insert_one(drink).inserted_id\n retu... | [
"0.64912164",
"0.60468745",
"0.58157015",
"0.5634383",
"0.5631785",
"0.55172324",
"0.5454788",
"0.53785783",
"0.53721833",
"0.5315731",
"0.5288665",
"0.5285213",
"0.5263699",
"0.52583075",
"0.5245523",
"0.52326274",
"0.5188646",
"0.5173956",
"0.51724726",
"0.5169337",
"0.5122... | 0.6137021 | 1 |
Convert pydantic object to pandas dataframe with 1 row. | def to_df(self):
return pd.DataFrame([dict(self)]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_df(self):\n return pd.DataFrame([dict(self)])",
"def to_df(self):\n return pd.DataFrame([dict(self)])",
"def to_df(self):\n return pd.DataFrame([dict(self)])",
"def to_df(self):\n return pd.DataFrame([dict(self)])",
"def to_df(self):\n return pd.DataFrame([dict(sel... | [
"0.75369906",
"0.75369906",
"0.75369906",
"0.75369906",
"0.75369906",
"0.7209753",
"0.71949995",
"0.71874905",
"0.71487474",
"0.71033204",
"0.7100494",
"0.7046343",
"0.6982141",
"0.69812274",
"0.69812274",
"0.6949213",
"0.6906141",
"0.68650144",
"0.6826173",
"0.681689",
"0.67... | 0.7580992 | 0 |
Test the internal _parse_image_meta methode Feed it an 'orphan' image as we get it from from imgadm list j | def test_parse_image_meta_orphan(image_orphan):
ret = {"Error": "This looks like an orphaned image, image payload was invalid."}
assert _parse_image_meta(image_orphan, True) == ret | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_list_image_metadata(self):\n pass",
"def test_parse_image_meta_native(image_native):\n ret = {\n \"description\": (\"A SmartOS image pre-configured for building pkgsrc packages.\"),\n \"name\": \"pkgbuild\",\n \"os\": \"smartos\",\n \"published\": \"2018-04-09T08:25... | [
"0.7048962",
"0.6765278",
"0.66359967",
"0.6442332",
"0.6345524",
"0.62997514",
"0.6292283",
"0.6252548",
"0.62425846",
"0.6214532",
"0.62140304",
"0.61478466",
"0.6136727",
"0.6091698",
"0.60507995",
"0.6047498",
"0.6019373",
"0.59844077",
"0.5983927",
"0.5947135",
"0.593055... | 0.795044 | 0 |
Test the internal _parse_image_meta methode Feed it an 'native' image as we get it from from imgadm list j | def test_parse_image_meta_native(image_native):
ret = {
"description": ("A SmartOS image pre-configured for building pkgsrc packages."),
"name": "pkgbuild",
"os": "smartos",
"published": "2018-04-09T08:25:52Z",
"source": "https://images.joyent.com",
"version": "18.1.0... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_parse_image_meta_lx(image_lx):\n ret = {\n \"description\": (\n \"Container-native Ubuntu 16.04 64-bit image. Built to run on \"\n \"containers with bare metal speed, while offering all the \"\n \"services of a typical unix host.\"\n ),\n \"name\": ... | [
"0.72541213",
"0.71688217",
"0.6869826",
"0.68278027",
"0.6766955",
"0.6693063",
"0.6681533",
"0.66430104",
"0.6527833",
"0.65183055",
"0.6516116",
"0.6472335",
"0.63868135",
"0.63460547",
"0.6322751",
"0.6241381",
"0.6176103",
"0.6162279",
"0.6160161",
"0.6152018",
"0.606092... | 0.8063198 | 0 |
Test the internal _parse_image_meta methode Feed it an 'lx' image as we get it from from imgadm list j | def test_parse_image_meta_lx(image_lx):
ret = {
"description": (
"Container-native Ubuntu 16.04 64-bit image. Built to run on "
"containers with bare metal speed, while offering all the "
"services of a typical unix host."
),
"name": "ubuntu-16.04",
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_list_image_metadata(self):\n pass",
"def test_parse_image_meta_native(image_native):\n ret = {\n \"description\": (\"A SmartOS image pre-configured for building pkgsrc packages.\"),\n \"name\": \"pkgbuild\",\n \"os\": \"smartos\",\n \"published\": \"2018-04-09T08:25... | [
"0.693872",
"0.6648406",
"0.6415607",
"0.64070094",
"0.6382566",
"0.63602597",
"0.63075614",
"0.6132728",
"0.61233515",
"0.6116494",
"0.6083304",
"0.607617",
"0.6065453",
"0.5985813",
"0.59669995",
"0.5943033",
"0.5930517",
"0.59295875",
"0.58997864",
"0.586116",
"0.5860643",... | 0.79599434 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.