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 |
|---|---|---|---|---|---|---|
Solves the problem, calling propagate with the specified enqueue condition (a function). If enqueue_condition is None, uses DFS only. Same return type as solve_constraint_dfs. | def solve_constraint_generic(problem, enqueue_condition=None) :
agenda=[problem]
extension=0
current_prob=agenda.pop(0)
extension+=1
#check failure
if has_empty_domains(current_prob) or (not check_all_constraints(current_prob)):
return (None, extension)
#check success
all_assig... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def solve_constraint_generic(problem, enqueue_condition=None) :\n q = [problem]\n extCount = 0\n while len(q)!=0:\n removed = q[0]\n q = q[1:]\n extCount+=1\n if has_empty_domains(removed) or check_all_constraints(removed)==False:\n continue\n if len(removed.u... | [
"0.61874056",
"0.60269624",
"0.5883873",
"0.51578814",
"0.4879061",
"0.4873792",
"0.477097",
"0.47651502",
"0.4752687",
"0.4752687",
"0.4752687",
"0.47192731",
"0.47146028",
"0.46874568",
"0.4684144",
"0.46682274",
"0.46657217",
"0.46555704",
"0.46519887",
"0.46489877",
"0.45... | 0.62442416 | 0 |
Returns True if m and n are adjacent, otherwise False. Assume m and n are ints. | def constraint_adjacent(m, n) :
if abs(m-n)==1:
return True
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def constraint_adjacent(m, n) :\n return abs(m-n)==1",
"def constraint_not_adjacent(m, n) :\n if abs(m-n)==1:\n return False\n return True",
"def adjacent(this, a, b): \n if not a in this.m:\n return False\n return b in this.m[a]",
"def is_adjacent(self, startVertex: np.int_ , endV... | [
"0.7547039",
"0.7503946",
"0.70974624",
"0.68953985",
"0.6753899",
"0.6653684",
"0.647436",
"0.640286",
"0.6334084",
"0.61786604",
"0.61773735",
"0.61628187",
"0.61348087",
"0.60599524",
"0.59721714",
"0.5959482",
"0.5896552",
"0.5825548",
"0.57971036",
"0.577877",
"0.5772970... | 0.77604765 | 0 |
Returns True if m and n are NOT adjacent, otherwise False. Assume m and n are ints. | def constraint_not_adjacent(m, n) :
if abs(m-n)==1:
return False
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def constraint_adjacent(m, n) :\n if abs(m-n)==1:\n return True\n return False",
"def constraint_not_adjacent(m, n) :\n return not constraint_adjacent(m,n)",
"def constraint_adjacent(m, n) :\n return abs(m-n)==1",
"def adjacent(this, a, b): \n if not a in this.m:\n return False\n ... | [
"0.74675065",
"0.73821",
"0.7177577",
"0.6544249",
"0.6490578",
"0.62371016",
"0.61099494",
"0.6015043",
"0.5944263",
"0.5914063",
"0.59129345",
"0.591148",
"0.5877347",
"0.58626205",
"0.58133686",
"0.5789058",
"0.577291",
"0.57566386",
"0.57319075",
"0.5714232",
"0.5690308",... | 0.79256696 | 0 |
Returns a list of constraints, with one difference constraint between each pair of variables. | def all_different(variables) :
constraints=[]
for index,var in enumerate(variables):
for sub_index in range(index+1,len(variables)):
var1=var
var2=variables[sub_index]
new_constraint=Constraint(var1,var2,constraint_different)
constraints.append(new_constra... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def all_different(variables) :\n constraints = []\n for i in xrange(len(variables)):\n var1 = variables[i]\n for j in xrange(i+1,len(variables)):\n var2 = variables[j]\n if var1!=var2:\n constraints.append(Constraint(var1,var2,constraint_different))\n ret... | [
"0.8078552",
"0.66408414",
"0.6599955",
"0.6543464",
"0.6522471",
"0.6371158",
"0.63207775",
"0.6170104",
"0.60099673",
"0.59447783",
"0.58882403",
"0.5870612",
"0.58607954",
"0.58588654",
"0.58560526",
"0.5849704",
"0.5846953",
"0.5846564",
"0.5788351",
"0.5731529",
"0.57275... | 0.81947106 | 0 |
p should be captured. If increment > 0, it searches the lower limit. | def search_the_limit_outwards(p, increment, flow, factor, printIt):
if not(p.captured):
exception_msg = 'Sorry, the particle isn\'t captured. We cannot ' \
+ 'proceed to the computation :('
raise Exception(exception_msg)
x0, y0 = p.pos0
new_p = deepcopy(p)
while ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def expectancyPcnt(self, p):\n return (2 * p) - 1",
"def test_increment(self):\r\n self.p + 1\r\n self.assertEqual(str(self.p), '1% [....................]')\r\n self.p + 4\r\n self.assertEqual(str(self.p), '5% [#...................]')",
"def p (self):\n\n return self.e... | [
"0.55990255",
"0.547974",
"0.5450231",
"0.5354124",
"0.5265712",
"0.52521616",
"0.51816934",
"0.5170011",
"0.51631105",
"0.5152142",
"0.5121149",
"0.5005209",
"0.4997024",
"0.49962348",
"0.4992007",
"0.49883386",
"0.496278",
"0.49342293",
"0.4931124",
"0.49284306",
"0.4916736... | 0.7255944 | 0 |
Tests that the metadata_cache_uri config property can be set using the `metadataStoreUri` config dict key when created via the Ocean __init__ | def test_metadataStoreUri_config_key():
config_dict = {"metadataStoreUri": "http://ItWorked.com", "network": GANACHE_URL}
ocean_instance = Ocean(config=config_dict)
assert "http://ItWorked.com" == ocean_instance.config.metadata_cache_uri | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_metadataCacheUri_config_key():\n config_dict = {\"metadataCacheUri\": \"http://ItWorked.com\", \"network\": GANACHE_URL}\n ocean_instance = Ocean(config=config_dict)\n assert \"http://ItWorked.com\" == ocean_instance.config.metadata_cache_uri",
"def test_metadata_cache_uri_set_via_config_option... | [
"0.8110486",
"0.7053254",
"0.6634108",
"0.60604185",
"0.59018505",
"0.58722854",
"0.58257353",
"0.5745626",
"0.5580887",
"0.556977",
"0.55264753",
"0.5463191",
"0.5448207",
"0.5435685",
"0.5418303",
"0.5416029",
"0.5395532",
"0.53821427",
"0.53754985",
"0.53621805",
"0.534305... | 0.8404406 | 0 |
Tests that the metadata_cache_uri config property can be set using the `metadataCacheUri` config dict key when created via the Ocean __init__ | def test_metadataCacheUri_config_key():
config_dict = {"metadataCacheUri": "http://ItWorked.com", "network": GANACHE_URL}
ocean_instance = Ocean(config=config_dict)
assert "http://ItWorked.com" == ocean_instance.config.metadata_cache_uri | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_metadataStoreUri_config_key():\n config_dict = {\"metadataStoreUri\": \"http://ItWorked.com\", \"network\": GANACHE_URL}\n ocean_instance = Ocean(config=config_dict)\n assert \"http://ItWorked.com\" == ocean_instance.config.metadata_cache_uri",
"def test_metadata_cache_uri_set_via_config_option... | [
"0.82415736",
"0.71620923",
"0.673239",
"0.61580616",
"0.5955389",
"0.5830755",
"0.5771999",
"0.5746774",
"0.5608073",
"0.5573063",
"0.554539",
"0.55337864",
"0.54992145",
"0.5444206",
"0.54412127",
"0.5407504",
"0.53995097",
"0.53991115",
"0.53822494",
"0.5361781",
"0.535119... | 0.8330855 | 0 |
Tests the metadata_cache_uri property fallback logic when set via a config dict | def test_metadata_cache_uri_set_via_config_options(caplog):
config_dict = {"resources": {"metadata_cache_uri": "https://custom-aqua.uri"}}
config = Config(options_dict=config_dict)
assert config.metadata_cache_uri == "https://custom-aqua.uri"
config_dict = {
"resources": {
"metadata... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_metadataCacheUri_config_key():\n config_dict = {\"metadataCacheUri\": \"http://ItWorked.com\", \"network\": GANACHE_URL}\n ocean_instance = Ocean(config=config_dict)\n assert \"http://ItWorked.com\" == ocean_instance.config.metadata_cache_uri",
"def test_metadataStoreUri_config_key():\n conf... | [
"0.71034646",
"0.69538647",
"0.6808724",
"0.5715817",
"0.56938386",
"0.5574205",
"0.55370295",
"0.5491125",
"0.546552",
"0.5424707",
"0.5402989",
"0.5387406",
"0.5384599",
"0.53076893",
"0.5281907",
"0.5273696",
"0.5259691",
"0.5257338",
"0.52134955",
"0.5207986",
"0.5204145"... | 0.7036153 | 1 |
Tests the metadata_cache_uri property fallback logic when set via an environment variable | def test_metadata_cache_uri_set_via_env_vars(monkeypatch, caplog):
ENV_METADATA_CACHE_URI = environ_names_and_sections[NAME_METADATA_CACHE_URI][0]
ENV_AQUARIUS_URL = deprecated_environ_names[NAME_AQUARIUS_URL][0]
monkeypatch.delenv(ENV_METADATA_CACHE_URI, raising=False)
monkeypatch.delenv(ENV_AQUARIUS_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_metadataCacheUri_config_key():\n config_dict = {\"metadataCacheUri\": \"http://ItWorked.com\", \"network\": GANACHE_URL}\n ocean_instance = Ocean(config=config_dict)\n assert \"http://ItWorked.com\" == ocean_instance.config.metadata_cache_uri",
"def test_metadataStoreUri_config_key():\n conf... | [
"0.6750669",
"0.6601639",
"0.62690765",
"0.5765948",
"0.5729508",
"0.56425256",
"0.5582084",
"0.55793303",
"0.55531746",
"0.55071336",
"0.55014575",
"0.5422239",
"0.5411803",
"0.53838736",
"0.5370863",
"0.53391415",
"0.5327401",
"0.5322019",
"0.5303017",
"0.5279534",
"0.52629... | 0.75551796 | 0 |
Tests the Config.address_file property. | def test_address_file(monkeypatch):
# Test default value when ADDRESS_FILE envvar and address.file config option not set
ENV_ADDRESS_FILE = environ_names_and_sections[NAME_ADDRESS_FILE][0]
monkeypatch.delenv(ENV_ADDRESS_FILE)
config_text_empty = ""
config = Config(text=config_text_empty)
assert... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_client_address_retrieve(self):\n pass",
"def test_get_contracts_addresses_bad_path():\n addresses = ContractHandler.get_contracts_addresses(\n _NETWORK, address_file=\"/bin/foo/bar/tralala\"\n )\n assert addresses is None",
"def test_config_filename_given_file_exists_wellformed_... | [
"0.6594589",
"0.6571221",
"0.65227056",
"0.64881337",
"0.64320743",
"0.63444334",
"0.6320931",
"0.6190733",
"0.6179718",
"0.6176872",
"0.6176226",
"0.61537004",
"0.6114624",
"0.6070274",
"0.6062185",
"0.59841394",
"0.5969519",
"0.5968312",
"0.5950967",
"0.5945774",
"0.5908652... | 0.78484046 | 0 |
find lyric video for this music video | def get_lyrics_url(non_lyrics_url, driver=None):
if not driver:
driver = get_browser()
driver.get(non_lyrics_url)
song_name = get_current_song_name(driver)
search_url = "https://www.youtube.com/results?search_query=" + song_name + " lyrics lyrical words"
driver.get(search_url)
driver.fi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def search_youtube_music_video(self, artist, name, duration_ms):\n\t\t# return val : false until proven wrong\n\t\tsuccess = False # could not find matching youtube video\n\t\terror_des = \"none\"\n\n\t\tself.authorize()\n\n\n\n\t\t# build search params aka q\n\t\t#finders = ['vevo','lyrics']\t\t\t# words t... | [
"0.65562254",
"0.56529564",
"0.55698454",
"0.5532732",
"0.5516258",
"0.5506556",
"0.548867",
"0.5443242",
"0.5431478",
"0.537894",
"0.53784645",
"0.53702825",
"0.53577554",
"0.535115",
"0.53355014",
"0.5326204",
"0.5320543",
"0.5302675",
"0.5299086",
"0.52988505",
"0.52712786... | 0.5713761 | 1 |
Calculate the ionization fraction, in equilibrium, for all ions of the element. Calculate the population fractions for every ion of this element as a function of temperature, assuming ionization equilibrium. This returns a matrix with dimensions ``(n,Z+1)``, where ``n`` corresponds to the temperature dimension and ``Z+... | def equilibrium_ionization(self):
# Solve system of equations using singular value decomposition
_, _, V = np.linalg.svd(self._rate_matrix.value)
# Select columns of V with smallest eigenvalues (returned in descending order)
# NOTE: must take the absolute value as the SVD solution is onl... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate(self, temperature):\n self.Temperature = np.array(temperature, 'float64')\n if self.Temperature.size == 1:\n print(' temperature must be an array')\n return\n ionList = []\n chIons = []\n z = self.Z\n for stage in range(1, z+2):\n ... | [
"0.55999285",
"0.5488472",
"0.5296714",
"0.50601256",
"0.5011484",
"0.4979466",
"0.48647112",
"0.48613384",
"0.48146105",
"0.4788765",
"0.47775778",
"0.475389",
"0.47358677",
"0.47119826",
"0.47119826",
"0.4689794",
"0.46835712",
"0.46832117",
"0.4669735",
"0.4662512",
"0.465... | 0.67447615 | 0 |
Store ticket changes in the database. The ticket must already exist in the database. | def save_changes(self, author, comment, when=0, db=None):
assert self.exists, 'Cannot update a new ticket'
if not self._old and not comment:
return # Not modified
if not db:
db = self.env.get_db_cnx()
handle_ta = True
else:
hand... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def insert(self, when=0, db=None):\r\n assert not self.exists, 'Cannot insert an existing ticket'\r\n if not db:\r\n db = self.env.get_db_cnx()\r\n handle_ta = True\r\n else:\r\n handle_ta = False\r\n\r\n # Add a timestamp\r\n if not when:\r\n ... | [
"0.6484097",
"0.6389335",
"0.6271799",
"0.6208508",
"0.6112109",
"0.6047159",
"0.59962136",
"0.5971508",
"0.59205115",
"0.59174293",
"0.5913187",
"0.5912593",
"0.59083515",
"0.59043074",
"0.5895396",
"0.5886866",
"0.5876326",
"0.5876326",
"0.58542764",
"0.583746",
"0.583746",... | 0.65532994 | 0 |
Return the changelog as a list of tuples of the form (time, author, field, oldvalue, newvalue). | def get_changelog(self, when=0, db=None):
if not db:
db = self.env.get_db_cnx()
cursor = db.cursor()
if when:
cursor.execute("SELECT time,author,field,oldvalue,newvalue "
"FROM ticket_change WHERE ticket=%s AND time=%s "
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _generate_changelog_for_form(form: PostMetaForm) -> List[str]:\n changelog = []\n changed_fields = form.changed_data.copy()\n if \"wp_id\" in changed_fields:\n changed_fields.remove(\"wp_id\")\n\n __ = lambda form, field: (\n \", \".join([str(i) for i in form.initial.get(field)]),\n ... | [
"0.71079546",
"0.6842395",
"0.6762967",
"0.67303646",
"0.66394424",
"0.6490158",
"0.6356165",
"0.62818974",
"0.62749875",
"0.6228601",
"0.6159745",
"0.6059099",
"0.601899",
"0.5970619",
"0.59150064",
"0.58712554",
"0.5840818",
"0.5787482",
"0.5769513",
"0.57500184",
"0.571843... | 0.7495389 | 0 |
This method writes in assembler the push/pop command | def writePushPop(self, command_type, m_segment, index):
#This list contains the traduction of the vm command
assemblerTraduction = []
#We get the adress where we going to push/pop
self.getAdressaAndStore(m_segment,index)
#Then we do the push or pop
if co... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_pushpop(self, command):\n commands = command.split(',')\n command_type = commands[0]\n vir_mem = commands[1]\n offset = commands[2]\n file_name = commands[3]\n vm_assembly_map = {Parser.LOCAL: \"LCL\", Parser.ARGUMENT: \"ARG\", Parser.THIS: \"THIS\", Parser.THAT:... | [
"0.7460648",
"0.7323929",
"0.71854126",
"0.717622",
"0.7167681",
"0.7059947",
"0.69785726",
"0.6529001",
"0.64451784",
"0.63728553",
"0.62207353",
"0.6165739",
"0.6126337",
"0.61054844",
"0.60555166",
"0.6050421",
"0.60131115",
"0.59999245",
"0.5981033",
"0.58814174",
"0.5862... | 0.73306566 | 1 |
Writes the assembly code that is the translation of the given "goto" command | def writeGoto(self, label):
# Create a list to store all the assembly commands and write them later
translated_commands = []
# Unconditional jump to the VM command following the label.
translated_commands.append("@{}:{}".format(self.actualFile.upper(), label.upper()))
tr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_goto(output_file, command, label, curr_function):\n if command == \"if-goto\":\n output_file.write(\"@SP\" + \"\\n\" +\n \"AM = M - 1\" + \"\\n\" +\n \"D = M\" + \"\\n\" +\n \"@\" + curr_function[0] + \"$\" + label + \"\... | [
"0.74865085",
"0.7146766",
"0.70925075",
"0.7080336",
"0.69135183",
"0.65403426",
"0.64314485",
"0.62226814",
"0.6202363",
"0.6194855",
"0.61400443",
"0.5994738",
"0.57696927",
"0.55874974",
"0.5553518",
"0.5529717",
"0.5472796",
"0.53618944",
"0.5350445",
"0.5304652",
"0.526... | 0.763298 | 0 |
Writes the assembly code that is the translation of the given "ifgoto" command | def writeIf(self, label):
# Create a list to store all the assembly commands and write them later
translated_commands = []
# Pops the topmost stack element.
# If it's not zero, jumps to the VM command following the label
translated_commands.append("@SP")
transla... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_goto(output_file, command, label, curr_function):\n if command == \"if-goto\":\n output_file.write(\"@SP\" + \"\\n\" +\n \"AM = M - 1\" + \"\\n\" +\n \"D = M\" + \"\\n\" +\n \"@\" + curr_function[0] + \"$\" + label + \"\... | [
"0.7327259",
"0.7298874",
"0.7261228",
"0.71433204",
"0.6993302",
"0.69160974",
"0.6741935",
"0.6675058",
"0.64891434",
"0.6331565",
"0.63166815",
"0.62714833",
"0.61997396",
"0.61812055",
"0.61686164",
"0.60897166",
"0.6078357",
"0.5986526",
"0.574756",
"0.5717213",
"0.55624... | 0.7407259 | 0 |
Writes the assembly code that is the translation of the given "call" command | def writeCall(self, function_name, num_args):
# Update the current function.
self.setFunctionName(function_name)
# Create a list to store all the assembly commands and write them later
translated_commands = []
# Store the return address in a local variable to use later... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_call(output_file, function_name, n_args, curr_function):\n curr_function[1] += 1\n # create return address\n output_file.write(\"@\" + curr_function[0] + \"$RET\" + str(curr_function[1]) + \"\\n\" +\n \"D = A\" + \"\\n\" +\n STACK_UPDATE + \"\\n\")\n ... | [
"0.6509174",
"0.63719326",
"0.6225837",
"0.61726874",
"0.5805217",
"0.57133055",
"0.5586849",
"0.54166335",
"0.5413903",
"0.5411246",
"0.5394381",
"0.5384571",
"0.53643495",
"0.53637886",
"0.5346244",
"0.5333947",
"0.5325409",
"0.5312069",
"0.5307116",
"0.53046227",
"0.528553... | 0.69511724 | 0 |
Writes the assembly code that is the translation of the given "return" command | def writeReturn(self):
# Create a list to store all the assembly commands and write them later
translated_commands = []
# FRAME = LCL --> R14
translated_commands.append("@LCL")
translated_commands.append("D=M")
translated_commands.append("@R14") # FRAME
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_return(self) -> None:\n end_frame = 'R13'\n ret_address = 'R14'\n\n self._write(['@'+CodeWriter.memory_prefixes[\"local\"], \"D=M\", '@'+end_frame, \"M=D\"]) # end_frame = LCL\n self._write(['@5', 'D=D-A', 'A=D', 'D=M', '@'+ret_address, 'M=D']) # get the caller's return\n ... | [
"0.72317594",
"0.7167266",
"0.7134336",
"0.707611",
"0.6868178",
"0.6615357",
"0.66047245",
"0.65911734",
"0.654644",
"0.6376672",
"0.6225002",
"0.6126",
"0.59634966",
"0.5819481",
"0.5789722",
"0.55900294",
"0.55519253",
"0.5461209",
"0.54514873",
"0.54444456",
"0.54034525",... | 0.7763137 | 0 |
Writes the assembly code that is the translation of the given "Function" command. | def writeFunction(self, function_name, num_locals):
# Create a list to store all the assembly commands and write them later
translated_commands = []
# Declare label for function entry.
translated_commands.append("({})".format(function_name.upper()))
# Allocat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_function(self, function_name, num_locals):\n self.func_name = function_name # activate function name\n asm_code = [\"({})\".format(self.func_name or \"null\")]\n asm_code += FunctionReturn.setup_n_local(num_locals)\n for line in asm_code:\n self.write_line(line)",
... | [
"0.65448916",
"0.6434927",
"0.6164372",
"0.60923684",
"0.6050931",
"0.60455984",
"0.59523684",
"0.5916754",
"0.5898677",
"0.57178897",
"0.57139844",
"0.5702395",
"0.5587398",
"0.5510793",
"0.54992193",
"0.5498126",
"0.548677",
"0.5445557",
"0.54203606",
"0.53866917",
"0.53669... | 0.729696 | 0 |
Initializing name, color and age attributes | def __init__(self, name, color, age):
self.name = name
self.color = color
self.age = age
self.breed = "something" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, name, color):\n self.name = name\n self.color = color",
"def __init__(self, name, race, sex, age):\n self.Race = race\n self.Sex = sex\n self.Age = age\n self.Name = name",
"def __init__(self, name, age):\n\t\tself.name = name\n\t\tself.age = age",
"def __... | [
"0.7229465",
"0.714791",
"0.7094137",
"0.7094137",
"0.7094137",
"0.7010226",
"0.7001638",
"0.69976294",
"0.69976294",
"0.69976294",
"0.69976294",
"0.69844526",
"0.69432414",
"0.6920252",
"0.6920252",
"0.6920252",
"0.6920252",
"0.6920252",
"0.6920252",
"0.6920252",
"0.6920252"... | 0.76693255 | 0 |
Simulating cat to listen to our command sit | def sit(self):
print(f"{self.name.title()} is listening to our command and sitting") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testEchoCat(self):\n pl = Pipeline(loadInitFile=False)\n repl = REPL(pl)\n repl.runCommandLine('echo hi | cat')\n self.assertEqual(['hi'], pl.stdin)\n self.assertEqual(REPL.DEFAULT_PS1, repl.prompt)",
"def testEchoCatCat(self):\n pl = Pipeline(loadInitFile=False)\n ... | [
"0.5931977",
"0.57579905",
"0.5540352",
"0.5496048",
"0.5449486",
"0.5423973",
"0.54195666",
"0.5364432",
"0.53474706",
"0.53463966",
"0.53456104",
"0.5331952",
"0.5260313",
"0.52574015",
"0.52497023",
"0.5230225",
"0.52069676",
"0.52069676",
"0.520344",
"0.5171255",
"0.51704... | 0.6624588 | 0 |
Simulating cat to rollover | def roll_over(self):
print(f"{self.name.title()} is rolling over") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def doRollover(self):\n if self.stream:\n self.stream.close()\n # get the time that this sequence started at and make it a TimeTuple\n t = self.rolloverAt - self.interval\n if self.utc:\n timeTuple = time.gmtime(t)\n else:\n timeTuple = time.local... | [
"0.6854691",
"0.58657295",
"0.57992905",
"0.57992905",
"0.57992905",
"0.5767629",
"0.5747008",
"0.563194",
"0.5625677",
"0.5621327",
"0.5595206",
"0.5483027",
"0.5443006",
"0.5398772",
"0.52660096",
"0.52587605",
"0.5206393",
"0.5191455",
"0.51152587",
"0.5071899",
"0.5060584... | 0.5929275 | 1 |
matches(self, accession) Returns true of accession matches this rule. | def matches(self, accession):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def match_accession(accession, rules_by_prefix_len):\n\n letter_match = LETTER_RE.match(accession)\n if letter_match is None:\n raise ValueError('an accession number must start with at least one capital letter, this does not: ' + accession)\n letter_prefix = letter_match.group(0)\n letter_match_... | [
"0.60738957",
"0.5563292",
"0.5425325",
"0.53730464",
"0.536121",
"0.535959",
"0.53519124",
"0.5302203",
"0.52693087",
"0.51938516",
"0.5173732",
"0.5142927",
"0.5121875",
"0.50970745",
"0.50970715",
"0.508755",
"0.508651",
"0.5061934",
"0.5061661",
"0.5059352",
"0.50521743",... | 0.7918863 | 0 |
make_range_matcher(spec) spec string (e.g. 'BAAABZZZ') Turns a range specification into a object that can match an accession that falls within that range. Returns a RangeMatcher() object | def make_range_matcher(spec):
if '-' in spec:
(start, end) = spec.split('-')
elif '_' in spec:
(start, end) = spec.split('_')
else:
raise ValueError('require specification with - or _ in it, got: ' + spec)
assert end.endswith('Z'), f'Range specifier has unknown format: {spec}'
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_range(spec):\n colons = spec.count(':')\n if colons == 2:\n low, high, step = spec.split(':')\n elif colons == 1:\n low, high = spec.split(':')\n step = '1' # parsed to int or float later on\n elif colons == 0:\n low = high = spec\n step = '1' # parsed to ... | [
"0.5896803",
"0.5682393",
"0.55807346",
"0.5524834",
"0.5447326",
"0.54415905",
"0.5430622",
"0.53848416",
"0.5376812",
"0.53439087",
"0.5319343",
"0.5316841",
"0.53064835",
"0.5224627",
"0.52209115",
"0.52198464",
"0.5207278",
"0.51443833",
"0.51329225",
"0.5128223",
"0.5110... | 0.83731127 | 0 |
build_accession_parser(rules_file) rules_file file object open for reading Builds a rule parse usable by match_accession() in this module from the accession rules described in rules_file. These rules can be downloaded by the scrape_accession_rules script. | def build_accession_parser(rules_file):
rules_data = json.load(rules_file)
rules_by_prefix_len = {}
for prefix_list, database, molecule_type, type_description in rules_data:
for prefix in prefix_list:
prefix_length = len(prefix)
if REFSEQ_PREFIX_RE.match(prefix) is not None:... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parseFile(file,rules = None):\n if not rules: rules = RuleCollection()\n buf = \"\"\n for line in open(file,'r'):\n if not line[0]=='#':\n buf += line\n try:\n for (ptree,lo,hi) in ruleNT.scanString(buf):\n rules.add(Parser._conver... | [
"0.6951147",
"0.636038",
"0.6193701",
"0.59042895",
"0.56647414",
"0.565295",
"0.56458706",
"0.5622873",
"0.55538076",
"0.5532373",
"0.5502544",
"0.5485067",
"0.544098",
"0.5404994",
"0.5376612",
"0.5286474",
"0.52077425",
"0.51797926",
"0.5108345",
"0.51012427",
"0.5075621",... | 0.8141396 | 0 |
match_accession(accession, rules_by_prefix_len) Returns the tuple (database, accession_type, type_description) for accession using the rules specified by rules_by_prefix_len. The database is one of 'GenBank', 'NCBI', 'GenBank and DDBJ' , 'DDBJ', and 'EMBL', accession_type is one of 'nucleotide', 'protein', 'WGS' and 'M... | def match_accession(accession, rules_by_prefix_len):
letter_match = LETTER_RE.match(accession)
if letter_match is None:
raise ValueError('an accession number must start with at least one capital letter, this does not: ' + accession)
letter_prefix = letter_match.group(0)
letter_match_length = le... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_accession_parser(rules_file):\n\n rules_data = json.load(rules_file)\n rules_by_prefix_len = {}\n for prefix_list, database, molecule_type, type_description in rules_data:\n for prefix in prefix_list:\n prefix_length = len(prefix)\n if REFSEQ_PREFIX_RE.match(prefix) ... | [
"0.6924238",
"0.50681436",
"0.49450368",
"0.47693393",
"0.46851796",
"0.46374428",
"0.45586807",
"0.4497541",
"0.44784194",
"0.44575775",
"0.44389337",
"0.44386113",
"0.43708226",
"0.43314365",
"0.42987517",
"0.42748004",
"0.42715642",
"0.42653817",
"0.4237109",
"0.42222515",
... | 0.8658083 | 0 |
sort dataframe columns by name | def _sort_dataframe(self, dataframe):
columns = list(dataframe.columns)
columns.sort()
dataframe = dataframe[columns]
return dataframe | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sort_data(df, col_order=[\"id\", 'event_name', 'specialty', 'plan_type']):\n df.sort_values(col_order, inplace = True)\n df.reset_index(drop=1, inplace=True)\n return df",
"def sort(df, cols):\n if not df:\n return []\n\n return sorted(df, key=lambda row: [row[col] for col in cols])",
... | [
"0.7239125",
"0.7190629",
"0.71153975",
"0.7062742",
"0.7044463",
"0.6999643",
"0.6853433",
"0.6828894",
"0.6581531",
"0.65472764",
"0.65136045",
"0.6483043",
"0.64684665",
"0.6465427",
"0.6447794",
"0.6442106",
"0.63748425",
"0.6305932",
"0.6299987",
"0.62696373",
"0.6225740... | 0.8045466 | 0 |
computes and returns weighted kappa score from 2 lists or pandas series of scorings. | def compute_kappa_score(self, scorer1, scorer2, items, matrix_weights):
#matrice nb items
df_n_items = pd.DataFrame(data=0, index=items, columns=items)
for score1, score2 in zip(scorer1, scorer2):
df_n_items[score1][score2] = df_n_items[score1][score2] + 1
#nb items * to... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_kappa(self):\r\n kappa_res_linear = []\r\n kappa_res_inv_linear = []\r\n kappa_res_quadratic = []\r\n kappa_res_inv_quadratic = []\r\n kappa_idx = []\r\n for score1 in self.scorer1_scoring.columns:\r\n for score2 in self.scorer2_scoring.columns:\r\n... | [
"0.6992644",
"0.65585124",
"0.650852",
"0.63415307",
"0.633713",
"0.633713",
"0.63092893",
"0.61077636",
"0.6023619",
"0.59239835",
"0.5740066",
"0.57364726",
"0.5706161",
"0.56984407",
"0.5692471",
"0.56705785",
"0.5668468",
"0.5650329",
"0.5636821",
"0.5620831",
"0.5601591"... | 0.7216733 | 0 |
Prepares data for Cohen's kappa score computation, score results and corresponding indexes | def compute_kappa(self):
kappa_res_linear = []
kappa_res_inv_linear = []
kappa_res_quadratic = []
kappa_res_inv_quadratic = []
kappa_idx = []
for score1 in self.scorer1_scoring.columns:
for score2 in self.scorer2_scoring.columns:
if sc... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_kappa(self):\n # recode data group 1, 2\n \n #self.data.iloc[:, [4]] = self.data.iloc[:, [4]].replace(1, 2)\n #self.data.iloc[:, [7]] = self.data.iloc[:, [7]].replace(1, 2)\n \n new_data = self.data[self.data.iloc[:, 4].notna()]\n new_data = self.data[sel... | [
"0.64328563",
"0.6239253",
"0.5851353",
"0.57640475",
"0.5761199",
"0.57593226",
"0.5727768",
"0.5669938",
"0.56463003",
"0.561262",
"0.5597555",
"0.55782264",
"0.5560468",
"0.555714",
"0.5535074",
"0.55244917",
"0.55013597",
"0.5499248",
"0.5495657",
"0.5483102",
"0.5468136"... | 0.6558322 | 0 |
Uses helper functions to get the leaves of a jet, recluster them following some algorithm, create the new tree for the algorithm, make a jet dictionary and save it. | def recluster(input_jet, alpha=None):
def _rec(jet, parent, node_id, outers_list):
"""
Recursive function to get a list of the leaves
"""
if jet["tree"][node_id, 0] == -1:
outers_list.append(jet["content"][node_id])
else:
_rec(jet, node_id, jet["tree"][node_id, 0], outers_list)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reCreatePseudoJets(jetalg, rsize, inputtype, variableRMassScale=-1.0, variableRMinRadius=-1.0):\n \n from JetRec.JetRecStandard import jtm\n from JetRec.JetRecUtils import buildJetContName\n jetContName = buildJetContName(jetalg, rsize, inputtype, variableRMassScale, variableRMinRadius)\n\n # Se... | [
"0.60989094",
"0.57564455",
"0.5737473",
"0.5692481",
"0.55827576",
"0.55827576",
"0.55561423",
"0.54220843",
"0.54043645",
"0.5390007",
"0.5388241",
"0.5383199",
"0.5362474",
"0.53002995",
"0.52984416",
"0.5276571",
"0.5245727",
"0.5230379",
"0.5229366",
"0.52263314",
"0.522... | 0.7371228 | 0 |
Calculate all d_ij and get the minimum. Update the constituents list by deleting the constituents that are merged and adding the new pseudojet | def dijMinPair(
const_list,
var_dij_history,
tree_dic,
jet_content,
idx,
alpha=None,
Nconst=None,
Nparent=None,
N_leaves_list=None,
linkage_list=None,
):
# Get all possible pairings
pairs = np.asarray(list(itertools.combinations(np.arange(len(const_list)), 2)))
# ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _partial_min_solution(self, j):\n beta_without_j = np.delete(self.betas, j, axis=0)\n X_without_j = np.delete(self.X, j, axis=0)\n X_j = self.X[j] # these are the X values for the jth feature in the model\n # Make predictions and obtain residuals on the full set of Ys, without the ... | [
"0.60378766",
"0.58585113",
"0.57932085",
"0.56271297",
"0.56104577",
"0.55938536",
"0.556066",
"0.5476421",
"0.54525477",
"0.54401803",
"0.5403905",
"0.54004693",
"0.5364363",
"0.5342022",
"0.53197366",
"0.5307228",
"0.5295947",
"0.52884704",
"0.5277132",
"0.52726316",
"0.52... | 0.6545502 | 0 |
Using 2way BFS, finds the shortest path from start_position to end_position. Returns a list of moves. You can use the rubik.quarter_twists move set. Each move can be applied using rubik.perm_apply | def shortest_path(start, end):
moves = rubik.quarter_twists
# Parent nodes: (Parent_State, move)
startParents = {}
startParents[start] = None # Start state has no parent
# Parent nodes: (Parent_State, move)
endParents = {}
endParents[end] = None # End state has no parent
startFrontier = [] #... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shortest_path(start, end):\n if start == end:\n return []\n \n start_frontier = Queue.Queue()\n start_parent = {}\n start_level = {}\n start_parent_move = {}\n start_frontier.put(start)\n start_level[start] = 0\n start_parent[start] = None\n start_parent_move[start] = None\... | [
"0.6811166",
"0.66258186",
"0.65891784",
"0.6562746",
"0.6408929",
"0.63918614",
"0.6378751",
"0.6358538",
"0.63519335",
"0.6339203",
"0.6333717",
"0.62664956",
"0.62529665",
"0.62339973",
"0.6215311",
"0.61844957",
"0.61844707",
"0.61737674",
"0.6125989",
"0.6118427",
"0.607... | 0.7770264 | 0 |
Gets x over y as a percentage. | def percentage(x, y):
try:
return 100 * (float(x) / y)
except ZeroDivisionError:
return "undefined" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prop(x,y):\n return 1 / (1/x + 1/y - 1)",
"def percentage(a, b):\n return (a * 100.0) / b",
"def metric_value(x, y):\n return (sum(np.all(x == y, axis=1) * 1) / len(x)) * 100",
"def percent_bias(x_arr, y_arr):\n delta = np.mean(x_arr) - np.mean(y_arr)\n denom = np.sqrt((np.var(x_arr) +... | [
"0.71006477",
"0.6950458",
"0.6932322",
"0.6346976",
"0.62966406",
"0.6291332",
"0.6265276",
"0.62534636",
"0.6222578",
"0.62091213",
"0.62091213",
"0.61994904",
"0.61975145",
"0.61975145",
"0.61975145",
"0.61852396",
"0.6153183",
"0.61317194",
"0.6122549",
"0.61025006",
"0.6... | 0.7717135 | 0 |
Find pairs of corresponding files. Gold files are of the form '0001GE.xml'. Corresponding sys files must start with '0001'. | def match_files(gold_folder, sys_folder):
print "Compiling files..."
# Get a list of files in the folders supplied.
gold_files = compile_files(gold_folder) # nnnnG.xml
sys_files = compile_files(sys_folder) # nnnnXXN.xml
print "%d gold files found in %s" % (len(gold_files), base_name(gold_folder)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_ntuples_from_xml_files(top_directory):\n for (dirpath, dirnames, filenames) in os.walk(top_directory):\n print(\"Looking in\", dirpath)\n for filename in filenames:\n full_filename = os.path.join(dirpath, filename)\n rel_path = os.path.relpath(full_filename, top_direc... | [
"0.631625",
"0.6021419",
"0.5848941",
"0.5605129",
"0.5570523",
"0.5570407",
"0.55495673",
"0.5540659",
"0.5538794",
"0.551618",
"0.5511254",
"0.550266",
"0.55013615",
"0.5497798",
"0.549736",
"0.54700136",
"0.5468638",
"0.5422212",
"0.5412847",
"0.5412159",
"0.5411767",
"0... | 0.7061894 | 0 |
Score pairs of files and write result to CSV. | def output_scores(pairs, out_file, bonus=True):
print "\nEvaluating system output..."
# Retrieve the scores for each pair, maintaining file name.
scores = [(file_name(p2), evaluate.process(p1, p2, bonus)) for (p1, p2) in pairs]
# Flatten the scores into a single list, keeping file name.
flat_score... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_scores(path, lines):\n\n headers = [\"File\"] + [\"%s%s\" % (t,v) for t in TYPES for v in VALUES]\n write_csv(path, lines, headers)",
"def write_scores(self, result):\n\n df = pd.read_csv('RPSscores.csv')\n for i in range(2):\n if not str(self.rps_data[i][0]) in df['Name'... | [
"0.67558867",
"0.61827487",
"0.6165984",
"0.61311907",
"0.6073014",
"0.5973442",
"0.59073937",
"0.58873034",
"0.5879521",
"0.58586526",
"0.5830975",
"0.5795374",
"0.5794796",
"0.57791287",
"0.57695943",
"0.5736669",
"0.57322085",
"0.57270706",
"0.57269216",
"0.57099265",
"0.5... | 0.7111616 | 0 |
Score pairs of files and write result to CSV. Outputs by type, the number and proportions of correct detections, recognitions and corrections. | def output_type_scores(pairs, out_file, mode="total"):
print "\nEvaluating system output by type..."
# Retrieve the scores for each pair, maintaining file name.
# score[k] = (total, detections, recogntions, corrections)
scores = [evaluate.process_type(p1, p2, mode) for (p1, p2) in pairs]
count = d... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_type_scores(path, lines):\n\n print \"Opening %s for score output\" % base_name(path)\n headers = [\"Type\", \"Total\", \"Detection\", \"Detection (%)\",\n \"Recognition\", \"Recognition (%)\",\n \"Correction\", \"Correction (%)\"]\n\n write_csv(path, lines, headers)"... | [
"0.6517771",
"0.64634323",
"0.64468825",
"0.6442818",
"0.62795043",
"0.5977089",
"0.59395987",
"0.5928222",
"0.59105945",
"0.5891227",
"0.5879979",
"0.5851659",
"0.58446866",
"0.57528603",
"0.57483405",
"0.56937736",
"0.5690374",
"0.56430155",
"0.5603435",
"0.5585392",
"0.557... | 0.70265925 | 0 |
Create a log() function that assumes the given context parameters by default | def logWithContext(**context):
destination = get_destination(context)
def _log(message="", **kwargs):
myContext = {}
myContext.update(context)
myContext.update(kwargs)
log(message, **myContext)
return _log | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _log(fn):\n @wraps(fn)\n def wrapper(self, *args, **kwargs):\n self.log.append(fn.__name__ + ' :: args={} kwargs={}'.format(args, kwargs))\n return fn(self, *args, **kwargs)\n return wrapper",
"def _log(fn):\n @wraps(fn)\n def wrapper(self, *args, **kw... | [
"0.6926635",
"0.6761614",
"0.67385125",
"0.66914254",
"0.6650855",
"0.6591471",
"0.65552855",
"0.6512889",
"0.6496456",
"0.6450647",
"0.64321446",
"0.6390331",
"0.63690305",
"0.63441205",
"0.6338015",
"0.6294673",
"0.6292847",
"0.62672466",
"0.62502795",
"0.6226921",
"0.62264... | 0.80761075 | 0 |
'Update' a null primary HDU This actually just checks hdu exists and creates it from hdu_in if it does not. | def update_null_primary(hdu_in, hdu=None):
if hdu is None:
hdu = fits.PrimaryHDU(header=hdu_in.header)
else:
hdu = hdu_in
hdu.header.remove('FILENAME')
return hdu | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_primary(hdu_in, hdu=None):\n if hdu is None:\n hdu = fits.PrimaryHDU(data=hdu_in.data, header=hdu_in.header)\n else:\n hdu.data += hdu_in.data\n return hdu",
"def create_primary_hdu(self, config=None):\n if not config: config = self.config\n t0 = time.time()\n ... | [
"0.7399129",
"0.6029987",
"0.5787915",
"0.5377",
"0.53164375",
"0.5116461",
"0.50992686",
"0.5097648",
"0.50974584",
"0.5085888",
"0.5077842",
"0.5054645",
"0.49968508",
"0.49845633",
"0.49787116",
"0.49667832",
"0.49317184",
"0.49300647",
"0.49021566",
"0.48998204",
"0.48982... | 0.7858423 | 0 |
'Update' a primary HDU This checks hdu exists and creates it from hdu_in if it does not. If hdu does exist, this adds the data in hdu_in to hdu | def update_primary(hdu_in, hdu=None):
if hdu is None:
hdu = fits.PrimaryHDU(data=hdu_in.data, header=hdu_in.header)
else:
hdu.data += hdu_in.data
return hdu | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_null_primary(hdu_in, hdu=None):\n if hdu is None:\n hdu = fits.PrimaryHDU(header=hdu_in.header)\n else:\n hdu = hdu_in\n hdu.header.remove('FILENAME')\n return hdu",
"def create_primary_hdu(self, config=None):\n if not config: config = self.config\n t0 = tim... | [
"0.7409614",
"0.6710726",
"0.6506826",
"0.57586634",
"0.5515132",
"0.5467803",
"0.53022814",
"0.5294916",
"0.52714276",
"0.5101926",
"0.49710563",
"0.49618804",
"0.49406534",
"0.49270725",
"0.4921398",
"0.48704994",
"0.4848736",
"0.48390216",
"0.4833807",
"0.47723728",
"0.475... | 0.81148696 | 0 |
'Update' an image HDU This checks hdu exists and creates it from hdu_in if it does not. If hdu does exist, this adds the data in hdu_in to hdu | def update_image(hdu_in, hdu=None):
if hdu is None:
hdu = fits.ImageHDU(
data=hdu_in.data, header=hdu_in.header, name=hdu_in.name)
else:
hdu.data += hdu_in.data
return hdu | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_primary(hdu_in, hdu=None):\n if hdu is None:\n hdu = fits.PrimaryHDU(data=hdu_in.data, header=hdu_in.header)\n else:\n hdu.data += hdu_in.data\n return hdu",
"def update_null_primary(hdu_in, hdu=None):\n if hdu is None:\n hdu = fits.PrimaryHDU(header=hdu_in.header)\n ... | [
"0.6926982",
"0.6569879",
"0.6121823",
"0.59545916",
"0.55643976",
"0.5550185",
"0.5482417",
"0.5419152",
"0.53597647",
"0.5301179",
"0.5215821",
"0.5160182",
"0.5106543",
"0.5102018",
"0.5078932",
"0.50642824",
"0.5056088",
"0.50277156",
"0.49389866",
"0.49303174",
"0.491130... | 0.83848846 | 0 |
'Update' the EBOUNDS HDU This checks hdu exists and creates it from hdu_in if it does not. If hdu does exist, this raises an exception if it doesn not match hdu_in | def update_ebounds(hdu_in, hdu=None):
if hdu is None:
hdu = fits.BinTableHDU(
data=hdu_in.data, header=hdu_in.header, name=hdu_in.name)
else:
for col in ['CHANNEL', 'E_MIN', 'E_MAX']:
if (hdu.data[col] != hdu_in.data[col]).any():
raise ValueError("Energy b... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_energies(hdu_in, hdu=None):\n if hdu is None:\n hdu = fits.BinTableHDU(\n data=hdu_in.data, header=hdu_in.header, name=hdu_in.name)\n else:\n for col in ['Energy']:\n if (hdu.data[col] != hdu_in.data[col]).any():\n raise ValueError(\"Energy values... | [
"0.6623036",
"0.6070509",
"0.6026206",
"0.5797366",
"0.49681273",
"0.47362316",
"0.470581",
"0.4664234",
"0.46528414",
"0.4650419",
"0.46447778",
"0.46102035",
"0.4597493",
"0.45665586",
"0.45542082",
"0.45516452",
"0.4536333",
"0.4528188",
"0.45268372",
"0.4526401",
"0.45060... | 0.6785469 | 0 |
'Update' the ENERGIES HDU This checks hdu exists and creates it from hdu_in if it does not. If hdu does exist, this raises an exception if it doesn not match hdu_in | def update_energies(hdu_in, hdu=None):
if hdu is None:
hdu = fits.BinTableHDU(
data=hdu_in.data, header=hdu_in.header, name=hdu_in.name)
else:
for col in ['Energy']:
if (hdu.data[col] != hdu_in.data[col]).any():
raise ValueError("Energy values do not match... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_primary(hdu_in, hdu=None):\n if hdu is None:\n hdu = fits.PrimaryHDU(data=hdu_in.data, header=hdu_in.header)\n else:\n hdu.data += hdu_in.data\n return hdu",
"def update_ebounds(hdu_in, hdu=None):\n if hdu is None:\n hdu = fits.BinTableHDU(\n data=hdu_in.dat... | [
"0.61940956",
"0.6072436",
"0.6020343",
"0.6019056",
"0.52538246",
"0.5197413",
"0.5152473",
"0.5001415",
"0.49822515",
"0.49789426",
"0.48927096",
"0.48741162",
"0.47840035",
"0.4775773",
"0.47685903",
"0.47683242",
"0.47139326",
"0.47082767",
"0.46813595",
"0.4679046",
"0.4... | 0.6803459 | 0 |
Extract some GTI related data | def extract_gti_data(hdu_in):
data = hdu_in.data
exposure = hdu_in.header['EXPOSURE']
tstop = hdu_in.header['TSTOP']
return (data, exposure, tstop) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extract(self, data):",
"def load_gtf_data(fil):\n ofunc = get_open_function(fil)\n\n gene_data = {}\n exon_data = {}\n with ofunc(fil, 'rt') as fh:\n for line in fh:\n if line.startswith('#'):\n continue\n cols = line.rstrip('\\r\\n').split('\\t')\n ... | [
"0.6465878",
"0.6260336",
"0.6158186",
"0.61349916",
"0.5999402",
"0.591599",
"0.59000826",
"0.58935034",
"0.5877949",
"0.57821643",
"0.5730033",
"0.5727758",
"0.5725765",
"0.56917304",
"0.56603914",
"0.5654494",
"0.56482",
"0.5645246",
"0.563089",
"0.5622953",
"0.5614257",
... | 0.6601886 | 0 |
'Update' a HEALPix skymap This checks map_out exists and creates it from map_in if it does not. If map_out does exist, this adds the data in map_in to map_out | def update_hpx_skymap_allsky(map_in, map_out):
if map_out is None:
in_hpx = map_in.hpx
out_hpx = HPX.create_hpx(in_hpx.nside, in_hpx.nest, in_hpx.coordsys,
None, in_hpx.ebins, None, in_hpx.conv, None)
data_out = map_in.expanded_counts_map()
print(data... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_map(self, boundaries):\n image = Image.open(self.image_file)\n update_pixels = ImageDraw.Draw(image)\n for i in range(len(boundaries) - 1):\n update_pixels.point(boundaries[i], fill=self.path_color)\n if self.season ==\"winter\":\n image.save(\"temp_wint... | [
"0.5519986",
"0.5442437",
"0.543888",
"0.54354",
"0.5379437",
"0.53515047",
"0.5325392",
"0.528644",
"0.52640593",
"0.5235342",
"0.52271897",
"0.5205729",
"0.5191248",
"0.517758",
"0.51566374",
"0.5133676",
"0.512622",
"0.51071656",
"0.50912577",
"0.5090438",
"0.50790477",
... | 0.745993 | 0 |
Merge all the files in filelist, assuming that they WCS counts cubes | def merge_wcs_counts_cubes(filelist):
out_prim = None
out_ebounds = None
datalist_gti = []
exposure_sum = 0.
nfiles = len(filelist)
ngti = np.zeros(nfiles, int)
for i, filename in enumerate(filelist):
fin = fits.open(filename)
sys.stdout.write('.')
sys.stdout.flush(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def merge_hpx_counts_cubes(filelist):\n out_prim = None\n out_skymap = None\n out_ebounds = None\n\n datalist_gti = []\n exposure_sum = 0.\n nfiles = len(filelist)\n ngti = np.zeros(nfiles, int)\n\n out_name = None\n\n for i, filename in enumerate(filelist):\n fin = fits.open(file... | [
"0.72943324",
"0.6355533",
"0.6309095",
"0.6259842",
"0.6159063",
"0.6089688",
"0.60719115",
"0.6045705",
"0.6029148",
"0.60253906",
"0.60001475",
"0.59901303",
"0.5943512",
"0.59293956",
"0.589633",
"0.58830863",
"0.58234817",
"0.5818004",
"0.58024824",
"0.5793821",
"0.57714... | 0.77227306 | 0 |
Merge all the files in filelist, assuming that they HEALPix counts cubes | def merge_hpx_counts_cubes(filelist):
out_prim = None
out_skymap = None
out_ebounds = None
datalist_gti = []
exposure_sum = 0.
nfiles = len(filelist)
ngti = np.zeros(nfiles, int)
out_name = None
for i, filename in enumerate(filelist):
fin = fits.open(filename)
sys.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def merge_wcs_counts_cubes(filelist):\n out_prim = None\n out_ebounds = None\n\n datalist_gti = []\n exposure_sum = 0.\n nfiles = len(filelist)\n ngti = np.zeros(nfiles, int)\n\n for i, filename in enumerate(filelist):\n fin = fits.open(filename)\n sys.stdout.write('.')\n ... | [
"0.7299076",
"0.66689265",
"0.63950956",
"0.6213643",
"0.6205799",
"0.6028902",
"0.59926766",
"0.5962839",
"0.5870728",
"0.585464",
"0.5813097",
"0.5810651",
"0.57805055",
"0.57656467",
"0.5754123",
"0.57460696",
"0.5734097",
"0.5733223",
"0.57271546",
"0.5724709",
"0.5708917... | 0.76345664 | 0 |
Deregister an event handler from this event. Throws EventError | def unhandle(self, handler):
try:
self.handlers.remove(handler)
except:
raise EventError("Can't unhandle handler %s: \
handler %s does not hook into this event!" % (handler, handler)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unsubscribe(self, event_handler):\n pass # pragma: no cover",
"def deregister_handler(cls):\n with cls._lock:\n try:\n cls._handlers.pop(cls)\n except KeyError:\n # no handler is registered so do nothing.\n pass",
"def unregi... | [
"0.761891",
"0.7457997",
"0.70799786",
"0.7071086",
"0.6935457",
"0.6867691",
"0.6856789",
"0.68473303",
"0.6838162",
"0.6821567",
"0.6818326",
"0.67305166",
"0.6524358",
"0.64668745",
"0.64484674",
"0.6428129",
"0.642803",
"0.6416318",
"0.6398188",
"0.6374036",
"0.6346724",
... | 0.7580798 | 1 |
Check that the correct padding is applied to unpadded b64 strings | def test_pad_b64(self):
test1 = {"value": b"any carnal pleasure.",
"unpadded": "YW55IGNhcm5hbCBwbGVhc3VyZS4",
"padded": "YW55IGNhcm5hbCBwbGVhc3VyZS4="}
test2 = {"value": b"any carnal pleasure",
"unpadded": "YW55IGNhcm5hbCBwbGVhc3VyZQ",
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pad_base64_str(str):\n missing_padding = len(str) % 4\n if missing_padding != 0:\n str += '=' * (4 - missing_padding)\n return str",
"def _validate_padding(padding):\n padding_ = str(padding).upper()\n if padding_ in {'SAME', 'VALID'}:\n return padding_\n raise ValueError(\n 'Argum... | [
"0.6917581",
"0.6822232",
"0.67514753",
"0.66963917",
"0.6687315",
"0.6626159",
"0.66185296",
"0.6437038",
"0.64260167",
"0.6413114",
"0.6400017",
"0.6221792",
"0.61559284",
"0.6155166",
"0.61504793",
"0.6127468",
"0.61092037",
"0.6101705",
"0.60503066",
"0.60450894",
"0.5998... | 0.79828584 | 0 |
Get an overview of the system state | def get_system_state(self, path, params):
system_summary = self._get_system_summary(path)
overview = {
'peer_controller_url': self._get_peer_controller_url(),
'summary_sources': system_summary,
'site_name': self._config.get('site', {}).get('name', 'unknown'),
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def state_info():\n info_list = []\n #info_list += AppGlobal.__dir__()\n info_list += dir( AppGlobal )\n\n return info_list\n #AppGlobal.state_info( )",
"def show_states():\n return render_template('7-states_list.html',\n storage=storage.all(\... | [
"0.7148844",
"0.68467396",
"0.6846482",
"0.6838712",
"0.68220145",
"0.6768029",
"0.6753322",
"0.6707728",
"0.6694008",
"0.66359985",
"0.66118914",
"0.6586082",
"0.65261465",
"0.6504606",
"0.6500215",
"0.64514995",
"0.64443666",
"0.6436063",
"0.64027727",
"0.6401785",
"0.63997... | 0.7532605 | 0 |
Clean up relevant internal data in all collectors | def cleanup(self):
self._faucet_collector.cleanup() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clean_up_data(self):\n pass",
"def clean_up(self):\n pass",
"def clean_up(self):\n pass",
"def cleanup(self):\n\n pass",
"def cleanUp(self):\r\n pass",
"def cleanup():",
"def _clean_up(self):",
"def cleanup(self):\n pass",
"def cleanup(self):\n p... | [
"0.7328266",
"0.71655595",
"0.71655595",
"0.7138663",
"0.7115787",
"0.7096337",
"0.70885485",
"0.70799506",
"0.70799506",
"0.70799506",
"0.70799506",
"0.70799506",
"0.70799506",
"0.70799506",
"0.70799506",
"0.70799506",
"0.70799506",
"0.70799506",
"0.7076115",
"0.7075666",
"0... | 0.73967594 | 0 |
Get the dataplane state overview | def get_dataplane_state(self, path, params):
reply = self._faucet_collector.get_dataplane_state()
self._augment_state_reply(reply, path)
return reply | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def state_info(self):\n raise NotImplementedError()",
"def state_info(self) -> pulumi.Output[Mapping[str, Any]]:\n return pulumi.get(self, \"state_info\")",
"def getState():\n # TODO: this isn't nearly as meaningful as it used to be",
"def get_state(self):\n return PLANET_STATES[s... | [
"0.6223954",
"0.6203313",
"0.6184042",
"0.6181515",
"0.6181515",
"0.6176792",
"0.6144386",
"0.61407816",
"0.6109651",
"0.60904914",
"0.6044486",
"0.6032304",
"0.60304093",
"0.6008729",
"0.5979441",
"0.5974553",
"0.5950835",
"0.5950606",
"0.59460306",
"0.5945699",
"0.59330606"... | 0.67006445 | 0 |
Get certain processes state on the controller machine | def get_process_state(self, path, params):
reply = self._local_collector.get_process_state()
self._augment_state_reply(reply, path)
return reply | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_state(self):\n process = self._get_process()\n if not self.is_on:\n process = StateOptions.NONE\n return self._update_feature(WashDeviceFeatures.PROCESS_STATE, process)",
"def get_state(self):\n\t\treturn Job(SDK.PrlVm_GetState(self.handle)[0])",
"def get_processes_r... | [
"0.6806903",
"0.6589053",
"0.6502321",
"0.64803624",
"0.643483",
"0.6385179",
"0.63660675",
"0.6299637",
"0.62829083",
"0.62457174",
"0.62420523",
"0.6184517",
"0.6145675",
"0.61289465",
"0.6115769",
"0.6112143",
"0.6021578",
"0.6015842",
"0.5992163",
"0.5968771",
"0.5961847"... | 0.674206 | 1 |
Get faucet config from facuet config file | def get_faucet_config(self, path, params):
try:
reply = self._get_faucet_config()
self._augment_state_reply(reply, path)
return reply
except Exception as e:
return f"Cannot read faucet config: {e}" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_config(self):\n if self.faucet is not None:\n return self.faucet.get_config()\n return None",
"def get_config():\n\n return json.loads(CONFIG_FILE.read_text())",
"def load_config(f):\n config = ConfigParser.RawConfigParser()\n config.readfp(f)\n # Mininum required d... | [
"0.7273333",
"0.7001213",
"0.6966111",
"0.692024",
"0.6876539",
"0.687354",
"0.6861744",
"0.6813058",
"0.67687595",
"0.6748989",
"0.6748989",
"0.67323655",
"0.67095643",
"0.669604",
"0.6686551",
"0.66834366",
"0.6682675",
"0.66814196",
"0.66809446",
"0.66713715",
"0.6668667",... | 0.7221663 | 1 |
Create a sorted order book with offers | def __init__(self, pair, offers=None):
self.book = {}
self.book[Trade.WAY_BUY] = []
self.book[Trade.WAY_SELL] = []
self.pair = pair
self.timestamp = 0
if offers:
for offer in offers:
self.add(offer)
self.sum_up() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_order():",
"def add(self, offer):\n other_offer = self.get(offer.get_price(), offer.get_way())\n if other_offer:\n other_offer.add_quote_amount(offer.get_quote_amount())\n other_offer.add_base_amount(offer.get_base_amount())\n return\n self.book[of... | [
"0.6681969",
"0.6315864",
"0.63098323",
"0.62559164",
"0.6064823",
"0.602484",
"0.60136616",
"0.5968839",
"0.5957956",
"0.5731327",
"0.5716378",
"0.5664231",
"0.56337076",
"0.56320804",
"0.56318533",
"0.56102186",
"0.55887127",
"0.55881983",
"0.55860436",
"0.5585022",
"0.5566... | 0.668072 | 1 |
Get offer at price in trading way. Offers with same price and way are combined to one. | def get(self, price, way):
for offer in self.book[way]:
if offer.get_price() == price:
return offer
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_best_offer(self,way):\n if way==\"BUY\":\n return self.book[Trade.WAY_BUY][0].get_price()\n elif way==\"SELL\":\n return self.book[Trade.WAY_SELL][len(self.book[Trade.WAY_SELL])-1].get_price()",
"def spread(self):\n if self.bid and self.offer:\n retur... | [
"0.7145987",
"0.64783365",
"0.63731086",
"0.63348854",
"0.6298139",
"0.62319213",
"0.61893195",
"0.61327106",
"0.6122905",
"0.6111128",
"0.6107752",
"0.61044466",
"0.6087829",
"0.60807866",
"0.6076605",
"0.60750973",
"0.60659534",
"0.60129094",
"0.6008401",
"0.6004976",
"0.59... | 0.77781796 | 0 |
Add offer to offer book. If other offer with same price and way exists, add the amounts to the existing. | def add(self, offer):
other_offer = self.get(offer.get_price(), offer.get_way())
if other_offer:
other_offer.add_quote_amount(offer.get_quote_amount())
other_offer.add_base_amount(offer.get_base_amount())
return
self.book[offer.get_way()].append(offer)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_offer(self,*args):\n to_read = str(self.exchanged_offers_filepath.get())\n if not os.path.isfile(to_read):\n if tkMessageBox.askyesno(title=\"File doesn't exist yet\",message=\"The filename or the location you entered does not exist yet. Do you want to create it?\"):\n ... | [
"0.62572896",
"0.62079287",
"0.61079454",
"0.59811974",
"0.5913609",
"0.58060807",
"0.5785621",
"0.5758943",
"0.56326485",
"0.5549845",
"0.5521655",
"0.5482868",
"0.54827327",
"0.5474815",
"0.54255426",
"0.5414618",
"0.53632414",
"0.5351649",
"0.534726",
"0.52987933",
"0.5280... | 0.86288035 | 0 |
Reset the offer book | def reset(self):
self.book = {}
self.book[Trade.WAY_BUY] = []
self.book[Trade.WAY_SELL] = [] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clear(self):\n Library.functions.clear(self._book)",
"def reset(self):\n \n pass",
"def reset(self) -> None:",
"def reset(self) -> None:",
"def reset(self) -> None:",
"def reset(self):",
"def reset(self):",
"def reset(self):",
"def reset(self):",
"def reset(self) -> None:\n ... | [
"0.657879",
"0.6566355",
"0.6537447",
"0.6537447",
"0.6537447",
"0.6477754",
"0.6477754",
"0.6477754",
"0.6477754",
"0.6472824",
"0.6472824",
"0.6472824",
"0.6472824",
"0.6472824",
"0.6472824",
"0.6472824",
"0.6472824",
"0.6440966",
"0.6440966",
"0.6422879",
"0.6422879",
"0... | 0.77113014 | 0 |
Return best offer BUY or SELL | def get_best_offer(self,way):
if way=="BUY":
return self.book[Trade.WAY_BUY][0].get_price()
elif way=="SELL":
return self.book[Trade.WAY_SELL][len(self.book[Trade.WAY_SELL])-1].get_price() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def best_buy(self):\n return Library.functions.best_buy(self._book)",
"def best_sell(self):\n return Library.functions.best_sell(self._book)",
"def best_price(self):\n # TODO rename this to \"display_lowest_price\" or something...\n price = self.lowest_price\n if price:\n r... | [
"0.7712135",
"0.7330952",
"0.69255537",
"0.67585963",
"0.6737412",
"0.6665721",
"0.65850675",
"0.65164346",
"0.65105176",
"0.6461021",
"0.64442986",
"0.63651025",
"0.628246",
"0.6246417",
"0.6240107",
"0.6227675",
"0.6206025",
"0.61554676",
"0.6143865",
"0.612969",
"0.612424"... | 0.829031 | 0 |
Sums each offer up | def sum_up(self):
sum_base = 0
sum_quote = 0
for i in range(len(self.book[Trade.WAY_BUY])):
offer = self.book[Trade.WAY_BUY][i]
sum_base = sum_base + offer.get_base_amount()
sum_quote = sum_quote + offer.get_quote_amount()
offer.set_sum_base(sum_ba... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def aggregate_offer_qty(self, trade_price):\n qty = 0\n for i in range(len(self.offer)):\n # print(\"trade_price = {} offer[{}] = {}\".format(trade_price, i, self.offer[i].price))\n if self.offer[i].price <= trade_price:\n qty += self.offer[i].qty\n ... | [
"0.65416944",
"0.6175351",
"0.61469644",
"0.61271346",
"0.6100096",
"0.60566324",
"0.5998801",
"0.5961973",
"0.59265363",
"0.5849682",
"0.5840781",
"0.58218294",
"0.57842696",
"0.578392",
"0.57434887",
"0.5735594",
"0.57143587",
"0.57143587",
"0.57130975",
"0.57087255",
"0.56... | 0.70203775 | 0 |
Simulates a taker trade with amount of token | def taker(self, amount, token):
if self.pair.get_base_token() == token:
return self.buy(amount)
if self.pair.get_quote_token() == token:
return self.sell(amount) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_trade(self):\n pass",
"def simulate_share_price_change(share_prices, t):\n time = 1\n for name in share_prices:\n Wt = share_prices[name]\n vola = VOLATILITY[name]\n exp_f = exp( (MARKET_INTEREST_RATE - vola**2/2)*time + vola * random_std(0,1) * time**(1/2) )\n ... | [
"0.5989451",
"0.5960052",
"0.59351724",
"0.58822274",
"0.585123",
"0.5812633",
"0.5802748",
"0.5732785",
"0.5724318",
"0.57217765",
"0.57074517",
"0.57074106",
"0.564287",
"0.5613687",
"0.56032723",
"0.5599949",
"0.55943924",
"0.55777675",
"0.5577078",
"0.55687726",
"0.556204... | 0.7571269 | 0 |
Simulates reversed taker buy trade | def reverse_buy(self, amount):
trade_amount = 0
precision = pow(10, self.pair.get_base_token().get_decimals() - self.pair.get_quote_token().get_decimals())
for i in range(len(self.book[Trade.WAY_SELL])):
offer = self.book[Trade.WAY_SELL][i]
amount_quote = offer.get_quote_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def trade_action(self, BUY_QTY):\n BUY_QTY = 4500\n self.trade(BUY_QTY)\n #self.show()",
"def Trading(Seller,Buyer):\n if Seller.has_sold == False:\n if Buyer.like_buy >= Seller.like_sell:\n Seller.has_sold = True\n Buyer.has_bought = True\n Selle... | [
"0.65092653",
"0.6503205",
"0.64490014",
"0.6267023",
"0.6184435",
"0.6127869",
"0.60579985",
"0.60374075",
"0.60211396",
"0.6020474",
"0.60166454",
"0.60085243",
"0.59992254",
"0.5979221",
"0.5917885",
"0.59104383",
"0.59099925",
"0.58990085",
"0.58956724",
"0.58821005",
"0.... | 0.6519859 | 0 |
Simulates reversed taker sell trade | def reverse_sell(self, amount):
trade_amount = 0
precision = pow(10, self.pair.get_quote_token().get_decimals() - self.pair.get_base_token().get_decimals())
for i in range(len(self.book[Trade.WAY_BUY])):
offer = self.book[Trade.WAY_BUY][i]
amount_quote = offer.get_quote_a... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def on_trade_decline(self, trade: \"steam.TradeOffer\") -> None:",
"def Trading(Seller,Buyer):\n if Seller.has_sold == False:\n if Buyer.like_buy >= Seller.like_sell:\n Seller.has_sold = True\n Buyer.has_bought = True\n Seller.sold_objects += 1\n Buye... | [
"0.66076905",
"0.65886",
"0.6561604",
"0.65361863",
"0.64315206",
"0.64205027",
"0.63910764",
"0.63028413",
"0.62971693",
"0.62870055",
"0.6254924",
"0.6253903",
"0.6214308",
"0.61548436",
"0.6127906",
"0.61069655",
"0.6096218",
"0.6076537",
"0.6043103",
"0.5996597",
"0.59896... | 0.66225725 | 0 |
Returns the trade way of taker buy offering token | def get_taker_trade_way(self, token):
if self.pair.get_base_token() == token:
return Trade.WAY_BUY
if self.pair.get_quote_token() == token:
return Trade.WAY_SELL | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def taker(self, amount, token):\n if self.pair.get_base_token() == token:\n return self.buy(amount)\n\n if self.pair.get_quote_token() == token:\n return self.sell(amount)",
"def get_maker_trade_way(self, token):\n if self.pair.get_base_token() == token:\n re... | [
"0.68150806",
"0.6329966",
"0.55800635",
"0.55156446",
"0.5513547",
"0.5513327",
"0.54976207",
"0.54774016",
"0.5402499",
"0.5402499",
"0.5402499",
"0.537787",
"0.5377004",
"0.5374751",
"0.53487736",
"0.5339768",
"0.53348345",
"0.5331372",
"0.5311707",
"0.5268392",
"0.5259822... | 0.70068544 | 0 |
Returns the trade way of maker buy offering token | def get_maker_trade_way(self, token):
if self.pair.get_base_token() == token:
return Trade.WAY_SELL
if self.pair.get_quote_token() == token:
return Trade.WAY_BUY | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_taker_trade_way(self, token):\n if self.pair.get_base_token() == token:\n return Trade.WAY_BUY\n\n if self.pair.get_quote_token() == token:\n return Trade.WAY_SELL",
"def taker(self, amount, token):\n if self.pair.get_base_token() == token:\n return s... | [
"0.6859137",
"0.6733909",
"0.58700055",
"0.5637433",
"0.56087637",
"0.5492912",
"0.5490883",
"0.5437437",
"0.5369206",
"0.5362286",
"0.535787",
"0.5356728",
"0.53365165",
"0.5332183",
"0.53190184",
"0.53147775",
"0.53147775",
"0.53147775",
"0.5276225",
"0.52603674",
"0.524516... | 0.67505014 | 1 |
Return the sum of all offers til index in trade way of token. | def get_sum(self, index, way, token):
if len(self.book[way]) <= index:
return None
if token == self.pair.get_quote_token():
return self.book[way][index].get_sum_quote()
else:
return self.book[way][index].get_sum_base() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_sum_after_fees(self, index, way, token):\n sum = self.get_sum(index, way, token)\n if not sum:\n return None\n if self.pair.get_exchange().get_fee_token():\n return sum\n else:\n return int(sum * (1-self.pair.get_exchange().get_fees()))",
"def ... | [
"0.5883118",
"0.5613956",
"0.5512578",
"0.55058557",
"0.53068936",
"0.5305391",
"0.5219744",
"0.52070534",
"0.5185397",
"0.51835227",
"0.5149148",
"0.51137346",
"0.51100624",
"0.5095748",
"0.50797516",
"0.5036669",
"0.5026849",
"0.50081944",
"0.49941635",
"0.49902272",
"0.498... | 0.5975722 | 0 |
Return the sum after fees of all offers til index in trade way of token. | def get_sum_after_fees(self, index, way, token):
sum = self.get_sum(index, way, token)
if not sum:
return None
if self.pair.get_exchange().get_fee_token():
return sum
else:
return int(sum * (1-self.pair.get_exchange().get_fees())) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fee(self, prices, fee):\n return self.volume(prices) * fee.value / Config.FEE_TOKEN_PRICE",
"async def fetch_trading_fees(self, params={}):\n await self.load_markets()\n response = await self.privatePostAuthRSummary(params)\n #\n # Response Spec:\n # [\n ... | [
"0.6136639",
"0.5811248",
"0.55952656",
"0.55918145",
"0.5559933",
"0.5494928",
"0.54587615",
"0.5445411",
"0.5401543",
"0.53633136",
"0.53548187",
"0.5306838",
"0.5306567",
"0.53050745",
"0.5283772",
"0.5260893",
"0.5246214",
"0.5231818",
"0.5224956",
"0.5220378",
"0.5214280... | 0.75667626 | 0 |
Return "{city}, {state code} {ZIP code}". | def city_state_zip(**kwargs):
result = "{city_name}, {state_code}".format(**kwargs)
if kwargs["five_digit_zip_code"]:
# RLID for some reason has two spaces between state & ZIP.
result += " {five_digit_zip_code}".format(**kwargs)
return result | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ad_rep_city_state(obj):\n return '%s, %s' % (obj.ad_rep.geolocation_object.us_city.name,\n obj.ad_rep.geolocation_object.us_state.abbreviation)",
"def city_country(city, country):\n return f\"{city.title()}, {country.title()}\"",
"def city_country(city, country):\n return f\"{city.title()},... | [
"0.69893783",
"0.69827586",
"0.69827586",
"0.6969536",
"0.69179726",
"0.6855643",
"0.68439883",
"0.6841213",
"0.6819089",
"0.6816567",
"0.67470276",
"0.67214346",
"0.67134976",
"0.6691764",
"0.668276",
"0.6682679",
"0.6677165",
"0.66764975",
"0.6629258",
"0.6621922",
"0.65830... | 0.80201566 | 0 |
Send message for any recentlyadded address in the Lincoln PSAP area. | def send_new_lincom_address_message():
keys = ["city_name", "concat_address", "geofeat_id", "initial_create_date"]
addresses = sorted(
addr
for addr in arcetl.attributes.as_iters(
dataset.SITE_ADDRESS.path("pub"),
field_names=keys,
dataset_where_sql="ps... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_message_to_out_buff(self, address, message):\n\t\ttry:\n\t\t\tself.nodes[address].add_message_to_out_buff(message)\n\t\t\tprint(\n\t\t\t\tf'Add message with type = {message.type} from {message.get_source_server_address()} to {address} out buffer.')\n\t\texcept Exception as e:\n\t\t\t# desired_trace = tr... | [
"0.56090575",
"0.5524899",
"0.5508821",
"0.53976107",
"0.5377961",
"0.5349766",
"0.5327298",
"0.5213806",
"0.5163616",
"0.5137086",
"0.513573",
"0.51152474",
"0.50923866",
"0.507804",
"0.50619996",
"0.50476956",
"0.50184095",
"0.49710304",
"0.4962221",
"0.49404788",
"0.492523... | 0.6667451 | 0 |
Send message of issues that affect address publication. | def send_publication_issues_message():
keys = ["description", "city_name", "concat_address", "geofeat_id"]
issues = sorted(
arcetl.attributes.as_iters(
dataset.ADDRESS_ISSUES.path(),
field_names=keys,
dataset_where_sql="update_publication = 0",
)
)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def issues(self, ctx):\n await ctx.message.delete()\n await ctx.send(\"Issue tracker: https://github.com/TheSuperGamer20578/Sudan-bot/issues\")",
"def issue(msg: telebot.types.Message) -> None:\n data = msg.text.split()\n if len(data) == 1:\n bot.send_message(\n msg.fr... | [
"0.58342916",
"0.57691723",
"0.559316",
"0.55438274",
"0.5429443",
"0.53226775",
"0.524465",
"0.5244591",
"0.52024007",
"0.5160951",
"0.5148793",
"0.5118599",
"0.50984514",
"0.5091462",
"0.5090361",
"0.50735873",
"0.50727224",
"0.5069178",
"0.50484574",
"0.5043041",
"0.504048... | 0.74025977 | 0 |
Run ETL for site addresses. | def site_address_etl():
with arcetl.ArcETL("Site Addresses") as etl:
etl.extract(dataset.SITE_ADDRESS.path("maint"))
# Clean maintenance values.
transform.clear_nonpositive(etl, field_names=["house_nbr"])
transform.clean_whitespace(
etl,
field_names=[
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main():\n sites = []\n parser = Parser('IP, URL, and Hash Passive Analysis tool')\n\n # if no target run and print help\n if parser.hasNoTarget():\n print '[!] No argument given.'\n parser.print_help() # need to fix this. Will later\n sys.exit()\n\n # user may only want to ... | [
"0.54403937",
"0.52629",
"0.51500326",
"0.5148145",
"0.5098838",
"0.49752128",
"0.4916554",
"0.49031782",
"0.48899403",
"0.4877138",
"0.47783902",
"0.47514454",
"0.47422868",
"0.47114214",
"0.47052565",
"0.4682272",
"0.46499026",
"0.46451038",
"0.4619294",
"0.46003208",
"0.46... | 0.62391794 | 0 |
Raises error if sheet name is not present in file. | def check_sheet(path, sheet):
xl = pd.ExcelFile(path)
if sheet not in xl.sheet_names:
raise ValueError("Invalid sheet name \'" + sheet +"\'") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_non_existent_sheet(suffix: str) -> None:\n path = rsc / header_file\n sheet_name = \"No_Sheet\"\n\n with pytest.raises(KeyError) as e_info:\n read_ods(path.with_suffix(suffix), sheet_name)\n assert e_info.match(f\"There is no sheet named {sheet_name}\")",
"def test_load_google_spr... | [
"0.68252397",
"0.65307903",
"0.64688885",
"0.62882745",
"0.6172317",
"0.6148374",
"0.6123559",
"0.60812616",
"0.59533036",
"0.5938308",
"0.5923492",
"0.5895471",
"0.5884579",
"0.58706343",
"0.58625674",
"0.5859781",
"0.5805962",
"0.5696485",
"0.5690528",
"0.56885326",
"0.5663... | 0.8132789 | 0 |
Changes index column to intergers 0, 1, 2... if first index is NaN | def filter_index_column(df, verbose = False):
index_starts_with_nan = pd.isnull(df.index)[0]
if index_starts_with_nan:
full_row_count = df.shape[0]
df.index = list(range(full_row_count))
if verbose is True:
print("")
print("Index changed. New dataframe index: ", d... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _idxs_postformat_null(self):\n pass",
"def _index_to_nan(data, existing_nans, to_nan):\n index_nan = np.random.choice([i for i in range(len(data)) if i not in existing_nans],\n size=to_nan, replace=False)\n data_imp = data.copy()\n data_imp[index_nan] = np.nan\n return d... | [
"0.6478332",
"0.584602",
"0.56894016",
"0.5651661",
"0.56314236",
"0.5618266",
"0.5578476",
"0.5521336",
"0.55025977",
"0.5412113",
"0.5373306",
"0.53429204",
"0.5328465",
"0.5287336",
"0.52435946",
"0.52248645",
"0.5213634",
"0.5180687",
"0.5155886",
"0.509588",
"0.5084493",... | 0.63214374 | 1 |
Prints head and tail for sort long dataframe, all dataframe for short one. | def print_dataframe(df):
print ("")
if df.shape[0] > 20:
print (df.head())
print (df.tail())
else:
print (df) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_full(df):\n pandas.set_option('display.max_rows', len(df))\n print df\n pandas.reset_option('display.max_rows')",
"def show_dataframe(self, df, **kwargs):\n show_index = False\n if 'show_index' in kwargs:\n show_index = kwargs['show_index']\n\n exceed_limit = len(df) ... | [
"0.68345803",
"0.6443878",
"0.63926333",
"0.6306814",
"0.6294796",
"0.62146837",
"0.62128216",
"0.61718494",
"0.6122782",
"0.605948",
"0.59988505",
"0.5980462",
"0.5920827",
"0.59166116",
"0.59086597",
"0.58704686",
"0.5808789",
"0.58024585",
"0.5765217",
"0.574971",
"0.57289... | 0.68289214 | 1 |
Modify file path using postfix to basename and new file extension. | def make_new_path(path, postfix = "", ext = ""):
dir = os.path.split(path)[0]
old_basename, old_ext = os.path.splitext(path)
new_basename = old_basename + "_" + postfix
new_path = os.path.join(dir, new_basename + "." + ext)
return new_path | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def change_filepath_ext(filepath: str, new_ext: str) -> str:\n return str(pathlib.Path(filepath).with_suffix(new_ext))",
"def add_filename_suffix(filepath, suffix):\r\n root, extension = splitext(basename(filepath))\r\n return root + suffix + extension",
"def changeFilenameExtension(path, extension):\... | [
"0.7294694",
"0.71958923",
"0.6968317",
"0.68717796",
"0.68331337",
"0.6766859",
"0.67356116",
"0.67146754",
"0.66778815",
"0.66768867",
"0.6563989",
"0.6483556",
"0.64791",
"0.6463151",
"0.6446963",
"0.6369973",
"0.6356547",
"0.63207704",
"0.62991595",
"0.6294914",
"0.627065... | 0.7425919 | 0 |
Switch focus to a card under given index. | def focus_on(self, card_idx: int) -> None: | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_current_index(self, index):\r\n self.contents_widget.setCurrentRow(index)",
"def click_on_card(num_in_hand, card_idx):\n card_idx -= 1\n logger.debug(\"Clicking on hand card index {} with {} cards in hand\".\\\n format(card_idx, num_in_hand))\n coords = card_coords[num_in_... | [
"0.6644266",
"0.6164258",
"0.6145358",
"0.5976609",
"0.59723157",
"0.5953028",
"0.5934058",
"0.59067446",
"0.5884343",
"0.58390933",
"0.58095294",
"0.5761498",
"0.57291913",
"0.5716547",
"0.57132137",
"0.5672907",
"0.5667205",
"0.56568944",
"0.5606812",
"0.55926514",
"0.55065... | 0.85468566 | 0 |
Create a TensorRT Model. config_path (string) The path to the model config file. checkpoint_path (string) The path to the model checkpoint file(s). graph_path (string) The path to the model graph. returns (Model) The TRT model built or loaded from the input files. | def createModel(config_path, checkpoint_path, graph_path):
global build_graph, prev_classes
trt_graph = None
input_names = None
if build_graph:
frozen_graph, input_names, output_names = build_detection_graph(
config=config_path,
checkpoint=checkpoint_path
)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_model(path='./model_checkpoint', name='tf_model'):\n with open(os.path.join(path, name + '.json')) as json_file:\n json_config = json_file.read()\n model = TensorModel(tf.keras.models.model_from_json(json_config))\n model._model.load_weights(os.path.join(path, name + '_weig... | [
"0.69247645",
"0.66378367",
"0.650394",
"0.643654",
"0.6435618",
"0.6396238",
"0.63284785",
"0.63075274",
"0.62111956",
"0.61979026",
"0.6182194",
"0.6162426",
"0.61578256",
"0.6139783",
"0.61190164",
"0.6109947",
"0.6109201",
"0.60900235",
"0.6086496",
"0.60713947",
"0.60698... | 0.8482573 | 0 |
Finds a nested value in `root` by splitting `path` by a `.`. | def find(root, path, default_value=None):
if root is None or path is None:
return default_value
assert isinstance(path, str)
tokens = path.split('.')
for token in tokens:
root = root.get(token)
if root is None:
return default_value
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_by_path(root, path):\n \n sub_data = root\n for key in path:\n sub_data = sub_data[key]\n \n return sub_data",
"def getpath(data, path):\n\n for p in path.split('.'):\n data = data[p]\n\n return data",
"def _safe_get_element(path, root):\n elements = path.split('.'... | [
"0.68399495",
"0.6797997",
"0.6620876",
"0.6504519",
"0.61498713",
"0.61055905",
"0.60620886",
"0.6012882",
"0.6004146",
"0.59793323",
"0.5957981",
"0.59493357",
"0.5936445",
"0.5898633",
"0.58313113",
"0.5759231",
"0.57245004",
"0.5708681",
"0.5706887",
"0.5701254",
"0.56859... | 0.75070685 | 0 |
This class is always instantiated with a DataHandler class instance. This instance should have the pipeline run, with extra columns included that identify the candidate sensors. | def __init__(self, data_handler_obj):
self.data_handler = data_handler_obj
self.sensor_keys = np.array(list(self.data_handler.extra_matrices.keys()))
if len(self.sensor_keys) == 0:
print("Please add sensor columns to DataHandler pipeline.")
return
self.coverage_sc... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_pipeline(self):\n pipe_distance = make_pipeline(DistanceTransformer(), RobustScaler())\n pipe_time = make_pipeline(TimeFeaturesEncoder(time_column='pickup_datetime'), OneHotEncoder(handle_unknown='ignore'))\n dist_cols = ['pickup_latitude', 'pickup_longitude', 'dropoff_latitude', 'drop... | [
"0.5981283",
"0.5748262",
"0.5745058",
"0.5740179",
"0.573706",
"0.5722975",
"0.56946933",
"0.5666524",
"0.56656593",
"0.5637534",
"0.56011313",
"0.5574644",
"0.5571768",
"0.55624294",
"0.55260295",
"0.5505294",
"0.5492911",
"0.54925513",
"0.5490077",
"0.5489706",
"0.54857033... | 0.7206935 | 0 |
Sets the favourite of this UpdateInboxOptions. | def favourite(self, favourite):
self._favourite = favourite | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def favorite(self, favorite: bool):\n if favorite is None:\n raise ValueError(\"Invalid value for `favorite`, must not be `None`\")\n\n self._favorite = favorite",
"def set_favorite(self, favorite):\n\n\t\tif favorite is not None and not isinstance(favorite, int):\n\t\t\traise SDKExcepti... | [
"0.72608376",
"0.72350186",
"0.6514002",
"0.6215668",
"0.6077232",
"0.56381255",
"0.5513775",
"0.55048925",
"0.5418328",
"0.5400707",
"0.52854884",
"0.5237168",
"0.51928574",
"0.5185944",
"0.51786065",
"0.51267153",
"0.5121262",
"0.50673515",
"0.50433147",
"0.5001181",
"0.497... | 0.7852814 | 0 |
The constructor sets bare essentials for a Task object. See the initialize() and start() methods. | def __init__(self):
self.ev_done = threading.Event()
self.tag = None
self.logger = None
self.threadPool = None
# Lock for task state critical sections
self.tlock = threading.RLock()
# Parent task can set this (or add to it) explicitly to determine
# which ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self):\n Task.__init__(self)",
"def __init__(self, task_type, task):\n self.task = task\n self.task_type = task_type",
"def SetUp(self):\n parser = argparse.ArgumentParser()\n parser.add_argument('--task-hash')\n args, _ = parser.parse_known_args()\n\n self.task = ... | [
"0.78874654",
"0.7790852",
"0.76478934",
"0.75159717",
"0.72075695",
"0.718874",
"0.7125532",
"0.70574737",
"0.7047362",
"0.70349383",
"0.70349383",
"0.70252115",
"0.6991528",
"0.6957877",
"0.6957645",
"0.69319767",
"0.68996876",
"0.6898044",
"0.6898044",
"0.689732",
"0.68906... | 0.7992555 | 0 |
This method initializes a task for (re)use. taskParent is the object instance of the parent task, or a 'task environment' (something that runs tasks). If subclass overrides this method, it should call the superclass method at some point. Copy shared data from taskParent, overriding items from _override_ if they are pre... | def initialize(self, taskParent, override=None):
# For now, punt if we have no apparent parent
if taskParent and hasattr(taskParent, 'shares'):
# Copy some variables from our parent task, unless they are being
# overridden explicitly. Using this general "contagion" mechanism,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_and_start(self, taskParent, override={}):\n tag = self.initialize(taskParent, override=override)\n self.start()\n\n return tag",
"def __init__(self):\n self.ev_done = threading.Event()\n self.tag = None\n self.logger = None\n self.threadPool = None\n ... | [
"0.7792664",
"0.73514235",
"0.6626714",
"0.64667386",
"0.6450714",
"0.6421855",
"0.6395594",
"0.63193023",
"0.62947965",
"0.623407",
"0.6219985",
"0.61928684",
"0.6066744",
"0.6062704",
"0.6042495",
"0.60193473",
"0.595547",
"0.59406453",
"0.5917704",
"0.5917704",
"0.590175",... | 0.84407574 | 0 |
This method resumes an executing task (if possible). Subclass should override this method, should not call super.resume(). Return True if task could be resumed, False if not? | def resume(self):
raise TaskError("Task %s: subclass should override resume() method!" % (
self)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ex_resume_node(self, node):\n domain = self._get_domain_for_node(node=node)\n return domain.resume() == 0",
"def _is_resume(self, message):\n\t\treturn message.lower() in (\"r\", \"resume\")",
"def should_resume(self, data_inputs) -> bool:\n for index, (step_name, step) in enumerate(re... | [
"0.661189",
"0.6533991",
"0.6450669",
"0.6358194",
"0.62071115",
"0.6176505",
"0.6172365",
"0.61308116",
"0.61308116",
"0.6111958",
"0.6064924",
"0.5991726",
"0.5991171",
"0.5991171",
"0.5991171",
"0.58760476",
"0.58657",
"0.58308566",
"0.58245856",
"0.5804862",
"0.5781874",
... | 0.67685986 | 0 |
If a task has a way of stepping through an operation. It can implement this method. Subclass should not call super.step(). | def step(self):
raise TaskError("Task %s: subclass should override step() method!" %
self) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def step(self):\n raise NotImplementedError()",
"def step(self):\n raise NotImplementedError()",
"def step(self):\n raise NotImplementedError()",
"def step(self):\r\n raise NotImplementedError",
"def step(self):\n raise NotImplementedError",
"def step(self):\n ra... | [
"0.7439212",
"0.7439212",
"0.7439212",
"0.74252063",
"0.7342782",
"0.73412836",
"0.732844",
"0.7307802",
"0.724046",
"0.7116015",
"0.70831084",
"0.6796387",
"0.6742982",
"0.67349994",
"0.6703522",
"0.6632001",
"0.6586868",
"0.65719897",
"0.65517116",
"0.6479811",
"0.64297694"... | 0.83859587 | 0 |
make_tasker takes a callable (function, method, etc.) and returns a new factory function for generating tasks. Each factory function is designed to consume its arguments and return a task that, when executed, will call the function upon the arguments. | def make_tasker(func):
def anonFunc(*args, **kwdargs):
class anonTask(Task):
def execute(self):
self.logger.debug("Executing fn %s" % func)
try:
val = func(*args, **kwdargs)
self.logger.debug("Done executing fn %s" % func)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def task(self, *args, **options):\n\n def inner_create_task_cls(**options):\n\n def _create_task_cls(fun):\n options[\"app\"] = self\n options.setdefault(\"accept_magic_kwargs\", False)\n base = options.pop(\"base\", None) or self.Task\n\n ... | [
"0.7129282",
"0.6644696",
"0.66127086",
"0.64700747",
"0.63587636",
"0.63433164",
"0.6271414",
"0.6251388",
"0.6177328",
"0.60954773",
"0.60446423",
"0.59781486",
"0.5938489",
"0.59201837",
"0.58971405",
"0.58387667",
"0.5808269",
"0.57529",
"0.5729523",
"0.56994873",
"0.5692... | 0.67076015 | 1 |
Interrupt/cancel execution, but will allow current child task to complete. | def stop(self):
#self.ev_intr.set()
try:
self.task.stop()
except TaskError as e:
self.logger.error("Error cancelling child task: %s" % (str(e))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hard_cancel(self, exec_info: ExecutionInfo) -> None:\n for task in exec_info.tasks.values():\n if not task.done():\n task.cancel()",
"async def __aexit__(self, *args) -> None:\n assert self._task\n await cancel(self._task)\n self._task = None",
"def int... | [
"0.67397135",
"0.6738263",
"0.6520559",
"0.6486777",
"0.64004767",
"0.63515025",
"0.6327308",
"0.63229436",
"0.61995256",
"0.61196995",
"0.6106748",
"0.60995656",
"0.60775506",
"0.6070717",
"0.6020986",
"0.5996094",
"0.5988845",
"0.59723526",
"0.5965248",
"0.59603995",
"0.595... | 0.7678175 | 0 |
Run all child tasks concurrently in separate threads. Return last result after all child tasks have completed execution. | def execute(self):
with self._lock_c:
self.count = 0
self.numtasks = 0
self.taskset = []
self.results = {}
self.totaltime = time.time()
# Start all tasks
for task in self.taskseq:
self.taskset.append(task)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run_all(self):\n results = []\n # Keep a loop going until all the tasks are gone:\n i = 0\n while self.tasks:\n i += 1\n time.sleep(0.0)\n print(f\"\\nOuter loop count: {i}\")\n # pop a task off the end\n task = self.tasks.pop()... | [
"0.7118713",
"0.67689633",
"0.6757617",
"0.6639924",
"0.65095407",
"0.61557037",
"0.60802907",
"0.6077791",
"0.60773194",
"0.606234",
"0.58803153",
"0.5876779",
"0.58640075",
"0.5861931",
"0.5857762",
"0.58499646",
"0.58399856",
"0.5830844",
"0.5811519",
"0.5805945",
"0.58044... | 0.7624203 | 0 |
Call stop() on all child tasks, and ignore TaskError exceptions. Behavior depends on what the child tasks' stop() method does. | def stop(self):
with self._lock_c:
for task in self.taskset:
try:
task.stop()
except TaskError as e:
# Task does not have a way to stop it.
# TODO: notify who?
pass
# stop oursel... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stop(self):\n for task in self._tasks:\n task.stop()",
"def stop(self):\n #self.ev_intr.set()\n\n try:\n self.task.stop()\n\n except TaskError as e:\n self.logger.error(\"Error cancelling child task: %s\" % (str(e)))",
"def stop(self):\n r... | [
"0.7083412",
"0.69144845",
"0.6872258",
"0.6691367",
"0.65108734",
"0.650881",
"0.63249207",
"0.6224278",
"0.6118037",
"0.6117924",
"0.61134964",
"0.6084416",
"0.60630214",
"0.6011201",
"0.59539086",
"0.59420437",
"0.5933003",
"0.5927026",
"0.59114164",
"0.5899331",
"0.588867... | 0.6986386 | 1 |
Start all of the threads in the thread pool. If _wait_ is True then don't return until all threads are up and running. Any extra keyword arguments are passed to the worker thread constructor. | def startall(self, wait=False, **kwdargs):
self.logger.debug("startall called")
with self.regcond:
while self.status != 'down':
if self.status in ('start', 'up') or self.ev_quit.is_set():
# For now, abandon additional request to start
s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def invoke_all_and_wait(self):\n list_promise = []\n for thread in self.__list_thread:\n thread.start()\n list_promise.append(thread)\n for process in list_promise: process.join()",
"def start_workers(self):\n\n for thread in self.threads:\n thread.sta... | [
"0.69613624",
"0.6886227",
"0.6605695",
"0.64993364",
"0.6497804",
"0.6468168",
"0.6294604",
"0.6250667",
"0.6239306",
"0.6113188",
"0.6049631",
"0.59441143",
"0.5940667",
"0.5934179",
"0.59080654",
"0.5871962",
"0.58526856",
"0.58526856",
"0.5841138",
"0.57503253",
"0.571583... | 0.8479139 | 0 |
Stop all threads in the worker pool. If _wait_ is True then don't return until all threads are down. | def stopall(self, wait=False):
self.logger.debug("stopall called")
with self.regcond:
while self.status != 'up':
if self.status in ('stop', 'down') or self.ev_quit.is_set():
# For now, silently abandon additional request to stop
self.lo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _stopAllWorkers():\n if _workerConfig.get('waitThread'):\n return\n delay = 0\n try:\n delay = float(_workerConfig['idle-time']['all'])\n except Exception:\n delay = 300\n delay -= time.time() - _workerConfig['lastChange']\n if delay > 0:\n _workerConfig['waitThrea... | [
"0.718188",
"0.69673514",
"0.6908031",
"0.68881804",
"0.68620485",
"0.6774259",
"0.6692037",
"0.66643304",
"0.6629136",
"0.6609075",
"0.659649",
"0.65886146",
"0.6468341",
"0.6441678",
"0.6406224",
"0.6363945",
"0.61721545",
"0.61622065",
"0.6160123",
"0.6158942",
"0.61549705... | 0.876886 | 0 |
Called by WorkerThread objects to register themselves. Acquire the condition variable for the WorkerThread objects. Increment the runningthread count. If we are the last thread to start, set status to 'up'. This allows startall() to complete if it was called with wait=True. | def register_up(self):
with self.regcond:
self.runningcount += 1
tid = threading.get_ident()
self.tids.append(tid)
self.logger.debug("register_up: (%d) count is %d" %
(tid, self.runningcount))
if self.runningcount == self.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def startall(self, wait=False, **kwdargs):\n self.logger.debug(\"startall called\")\n with self.regcond:\n while self.status != 'down':\n if self.status in ('start', 'up') or self.ev_quit.is_set():\n # For now, abandon additional request to start\n ... | [
"0.7070651",
"0.630651",
"0.6123082",
"0.5980859",
"0.5978249",
"0.59487885",
"0.59457076",
"0.5763278",
"0.57251996",
"0.5709683",
"0.56876063",
"0.5604419",
"0.5500896",
"0.54932725",
"0.5491303",
"0.5483827",
"0.5452877",
"0.54497087",
"0.54494697",
"0.5441708",
"0.5431394... | 0.7592536 | 0 |
Da la posicion en cartesianas | def getpos(self):
return self.pos.cartesianas() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getPosicion(self):\r\n\t\treturn [self._x, self._y]",
"def cartesian_coordinates(self, *axes):",
"def positions(self):\n return self.inorder() # make inorder the default",
"def positions(self):\n return self.preorder()",
"def cartesian(position):\n return [position[0] *... | [
"0.6881865",
"0.6482955",
"0.6421982",
"0.63671225",
"0.6356395",
"0.63118434",
"0.6168128",
"0.6105387",
"0.6069279",
"0.6061091",
"0.6059594",
"0.604117",
"0.5994154",
"0.5994154",
"0.598406",
"0.5981543",
"0.59720284",
"0.5967554",
"0.5953677",
"0.58919364",
"0.58807313",
... | 0.6915383 | 0 |
returns all assigned tasks that are stale | def get_stale_assigned_tasks():
# select t.id from tasks t, actions a where
# a.task_id = t.id and t.currentaction = 'assigned'
# group by t.id having now() - max(a.timestamp) < interval '1 day';
return db.session.query(Task).filter_by(
currentaction='assigned').join(Task.actions).group_by(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_pending(tasks):\n results = [task for task in tasks if task != main_poller_task and task.done() == False]\n return results",
"def list_pending_tasks():\n inspector = current_app.control.inspect()\n\n return inspector.reserved()",
"def Wait(self):\n sleep_time = min(self._time_remaining.v... | [
"0.6470993",
"0.64056075",
"0.60761416",
"0.6043872",
"0.59645206",
"0.57820654",
"0.57209444",
"0.5690144",
"0.5623507",
"0.55904436",
"0.558203",
"0.5554141",
"0.55465615",
"0.5508562",
"0.54976636",
"0.5480646",
"0.5476197",
"0.54631305",
"0.54573554",
"0.54564995",
"0.544... | 0.85103685 | 0 |
Returns the character attributes (colors) of the console screen buffer. | def get_text_attr():
csbi = CONSOLE_SCREEN_BUFFER_INFO()
GetConsoleScreenBufferInfo(stdout_handle, byref(csbi))
return csbi.wAttributes | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_colors(cls, font) -> tuple:\n\n return font[BFC]",
"def colors(self):\n return self[\"colors\"]",
"def colors(self):\n return self[\"colors\"]",
"def colors(self):\r\n\t\treturn self._colors",
"def read_global_attributes(self):\n return self._attrs.keys()",
"def colors... | [
"0.618928",
"0.61449754",
"0.61449754",
"0.60777587",
"0.5841053",
"0.5839246",
"0.5747193",
"0.5702105",
"0.5695992",
"0.56194615",
"0.5618548",
"0.5612629",
"0.5612537",
"0.5579472",
"0.55674505",
"0.556737",
"0.55371135",
"0.5450904",
"0.5437259",
"0.54313546",
"0.5431309"... | 0.79341596 | 0 |
Sets the character attributes (colors) of the console screen buffer. Color is a combination of foreground and background color, foreground and background intensity. | def set_text_attr(color):
SetConsoleTextAttribute(stdout_handle, color) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init():\n global _default_foreground, _default_background, _default_style\n try:\n attrs = GetConsoleScreenBufferInfo().wAttributes\n except (ArgumentError, WindowsError):\n _default_foreground = GREY\n _default_background = BLACK\n _default_style = NORMAL\n else:\n ... | [
"0.65293914",
"0.59243166",
"0.5920152",
"0.58186567",
"0.5738975",
"0.57069314",
"0.56998813",
"0.5632887",
"0.5621744",
"0.56068224",
"0.55855024",
"0.5512038",
"0.5498875",
"0.54817593",
"0.54728025",
"0.5425896",
"0.5384956",
"0.5370457",
"0.53538483",
"0.53400093",
"0.52... | 0.6634589 | 0 |
Add add two values as unsigned 8bit values. | def _uint8_add(self, a, b):
return ((a & 0xFF) + (b & 0xFF)) & 0xFF | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _add(a, b):\n\n # Todo: What if numbers have bigger length than 8\n a = _I2B(a, fixed_length=8)\n b = _I2B(b, fixed_length=8)\n return _B2I([i ^ j for i, j in zip(a, b)])",
"def add_binary(a, b):\n return bin(a + b)[2:]",
"def add64(a,b):\n return(np.add(a, b, dtype=np.uint64))",
"def a... | [
"0.7118355",
"0.6863869",
"0.6765149",
"0.665138",
"0.66207707",
"0.64209676",
"0.63915664",
"0.63376117",
"0.62058306",
"0.6175232",
"0.60576916",
"0.603546",
"0.6032429",
"0.59999746",
"0.5897095",
"0.5881542",
"0.5862601",
"0.5828295",
"0.58184725",
"0.5767223",
"0.5704461... | 0.8304557 | 0 |
Busy wait for the specified number of milliseconds. | def _busy_wait_ms(self, ms):
start = time.time()
delta = ms/1000.0
while (time.time() - start) <= delta:
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wait(self, ms=None):\r\n util.raiseNotDefined()",
"def busy_wait(self, seconds):\n end_time = time.perf_counter() + seconds\n while(time.perf_counter() < end_time):\n pass",
"def busyWait(self):\n time.sleep(0.0)",
"def wait(wait_time=WAIT_TIME):\n # time.sleep(w... | [
"0.7914963",
"0.77291715",
"0.7504995",
"0.72830254",
"0.72355634",
"0.7144105",
"0.70819026",
"0.69723344",
"0.6963981",
"0.6943757",
"0.69373953",
"0.68748826",
"0.68748826",
"0.68748826",
"0.68650585",
"0.68419313",
"0.68388855",
"0.6823371",
"0.68209547",
"0.68125963",
"0... | 0.8330288 | 0 |
Read a response frame from the PN532 of at most length bytes in size. Returns the data inside the frame if found, otherwise raises an exception if there is an error parsing the frame. Note that less than length bytes might be returned! | def _read_frame(self, length):
# Read frame with expected length of data.
response = self._read_data(length+8)
# Check frame starts with 0x01 and then has 0x00FF (preceeded by optional
# zeros).
if not (PN532_ACK_FRAME == response.tostring()):
if response[0] != 0x00:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def _read_frame(self):\n # Read the Frame start and header\n response = await self.sreader.read(len(_FRAME_START)+2)\n if self.debug:\n print('_read_frame: frame_start + header:', [hex(i) for i in response])\n\n if len(response) < (len(_FRAME_START) + 2) or response[:-2... | [
"0.704474",
"0.6765647",
"0.67006445",
"0.65825397",
"0.64653546",
"0.6378786",
"0.624671",
"0.6166918",
"0.61652833",
"0.60626686",
"0.6041952",
"0.59867275",
"0.598034",
"0.5949618",
"0.5946916",
"0.5946916",
"0.5918345",
"0.5908369",
"0.5856201",
"0.5810847",
"0.5809149",
... | 0.8287509 | 0 |
Send specified command to the PN532 and expect up to response_length bytes back in a response. Note that less than the expected bytes might be returned! Params can optionally specify an array of bytes to send as parameters to the function call. Will wait up to timeout_secs seconds for a response and return a bytearray ... | def call_function(self, command, response_length=0, params=[], timeout_sec=1):
# Build frame data with command and parameters.
data = bytearray(2+len(params))
data[0] = PN532_HOSTTOPN532
data[1] = command & 0xFF
data[2:] = params
# Send frame and wait for response.
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def call_function(self, command, params=[]):\n data = bytearray(2 + len(params))\n data[0] = _HOSTTOPN532\n data[1] = command & 0xFF\n for i, val in enumerate(params):\n data[2+i] = val\n \n # Send the frame and read the response\n await self._write... | [
"0.6998719",
"0.62475526",
"0.61771166",
"0.6033646",
"0.6013181",
"0.5989991",
"0.5949725",
"0.58775395",
"0.5869759",
"0.58432835",
"0.5774818",
"0.5764293",
"0.57640105",
"0.57458293",
"0.57424915",
"0.5739679",
"0.57226133",
"0.57144946",
"0.5690163",
"0.5660772",
"0.5655... | 0.74638414 | 0 |
Call PN532 GetFirmwareVersion function and return a tuple with the IC, Ver, Rev, and Support values. | def get_firmware_version(self):
response = self.call_function(PN532_COMMAND_GETFIRMWAREVERSION, 4)
if response is None:
raise RuntimeError('Failed to detect the PN532! Make sure there is sufficient power (use a 1 amp or greater power supply), the PN532 is wired correctly to the device, and ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def get_firmware_version(self):\n if self.debug:\n print(\"Sending GET_FIRMWARE_VERSION\")\n\n response = await self.call_function(_COMMAND_GETFIRMWAREVERSION)\n if response is None:\n raise RuntimeError('Failed to detect the PN532')\n return tuple(response)"... | [
"0.8340191",
"0.70127285",
"0.6902346",
"0.68323416",
"0.6800303",
"0.67767984",
"0.67619514",
"0.6689992",
"0.668426",
"0.66747904",
"0.66712964",
"0.66259307",
"0.65817636",
"0.65780747",
"0.65738904",
"0.65549785",
"0.6549143",
"0.6520437",
"0.6484987",
"0.6469028",
"0.640... | 0.8383756 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.