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 |
|---|---|---|---|---|---|---|
Run pip with docker. | def dockerized_pip(
work_dir: str,
client: Optional[docker.DockerClient] = None,
runtime: Optional[str] = None,
docker_file: Optional[str] = None,
docker_image: Optional[str] = None,
python_dontwritebytecode: bool = False,
**_: Any,
) -> None:
# TODO use kwargs to pass args to docker for... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def full_pip_freeze(docker_image, pip):\n\n match = None\n pip_vers = None\n\n try:\n\n cmd = ['sudo', 'docker', 'run', '--env', \"LD_LIBRARY_PATH=''\", '--rm', '-ti',\n '--entrypoint={}'.format(pip), docker_image, 'freeze']\n\n print(' '.join(cmd))\n r = sp.Popen(cmd, s... | [
"0.6504361",
"0.63231766",
"0.615957",
"0.61558837",
"0.60848695",
"0.60628784",
"0.59793115",
"0.5911659",
"0.58846164",
"0.58580613",
"0.58296275",
"0.5822538",
"0.58122975",
"0.57188886",
"0.5698203",
"0.56575954",
"0.5615017",
"0.5600989",
"0.5595091",
"0.55341893",
"0.54... | 0.6530509 | 0 |
Return boolean on whether pip is new enough to have nocolor option. pip v10 introduced this option, and it's used to minimize the effect of | def _pip_has_no_color_option(python_path: str) -> bool:
try:
pip_version_string = subprocess.check_output(
[
python_path,
"-c",
"from __future__ import print_function;"
"import pip;"
"print(pip.__version__)",
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def no_color():\n return (bool(_environ.get(\"ACCELPY_NO_COLOR\", False)) and\n _system() != 'Windows')",
"def _default_color_enabled() -> bool:\n import platform\n\n # If we're not attached to a terminal, go with no-color.\n if not sys.__stdout__.isatty():\n return False\n\n # O... | [
"0.73090255",
"0.69218844",
"0.6608089",
"0.65810806",
"0.6552736",
"0.65195435",
"0.6429177",
"0.64068675",
"0.6352326",
"0.6281814",
"0.6131098",
"0.5832753",
"0.5820403",
"0.581131",
"0.5655444",
"0.555243",
"0.55007124",
"0.54842734",
"0.54663014",
"0.54660404",
"0.545164... | 0.75785536 | 0 |
Validate file search patterns from user configuration. Acceptable input is a string (which will be converted to a singleton list), a list of strings, or anything falsy (such as None or an empty dictionary). Empty or unset input will be converted to a default. | def _check_pattern_list(
patterns: Optional[Union[List[str], str]],
key: str,
default: Optional[List[str]] = None,
) -> Optional[List[str]]:
if not patterns:
return default
if isinstance(patterns, str):
return [patterns]
if isinstance(patterns, list) and all(isinstance(p, str) ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _resolve_arguments(patterns, packages_path, search_packages_path):\n\n def _read_patterns(path):\n try:\n with open(path, \"r\") as handler:\n return set(handler.read().splitlines())\n except IOError:\n return set()\n\n ignore_patterns = set()\n\n for... | [
"0.5847642",
"0.571779",
"0.56237805",
"0.5558958",
"0.5545299",
"0.54854465",
"0.54795384",
"0.53806275",
"0.53201216",
"0.5245875",
"0.52377",
"0.5226893",
"0.52046716",
"0.51762396",
"0.5132988",
"0.5130737",
"0.50783855",
"0.50730044",
"0.5066616",
"0.5059243",
"0.5021123... | 0.6681264 | 0 |
Return the appropriate region to use when uploading functions. Select the appropriate region for the bucket where lambdas are uploaded in. | def select_bucket_region(
custom_bucket: Optional[str],
hook_region: Optional[str],
cfngin_bucket_region: Optional[str],
provider_region: str,
) -> str:
region = None
region = hook_region if custom_bucket else cfngin_bucket_region
return region or provider_region | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def function_region(self) -> str:\n return pulumi.get(self, \"function_region\")",
"def load_aws_region_name() -> str:\n session = boto3.session.Session()\n region_name = (\n click.get_current_context().params.get(\"region\") or session.region_name\n )\n return region_name",
"def regi... | [
"0.7334205",
"0.6579131",
"0.6273241",
"0.6175507",
"0.6165684",
"0.6162876",
"0.6162876",
"0.6162876",
"0.6162876",
"0.6162876",
"0.6162876",
"0.6162876",
"0.6162876",
"0.6162876",
"0.6162876",
"0.6162876",
"0.6162876",
"0.6162876",
"0.61409694",
"0.6136126",
"0.6130676",
... | 0.71261233 | 1 |
calls the 'build()' method of the current (user folder) conanfile.py | def build(self, conanfile):
app = ConanApp(self._conan_api.cache_folder)
conanfile.folders.set_base_package(conanfile.folders.base_build)
conanfile.folders.set_base_pkg_metadata(os.path.join(conanfile.build_folder, "metadata"))
run_build_method(conanfile, app.hook_manager) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build():",
"def build(config):",
"def build(_):",
"def build(build_ctx: str, bentofile: str, version: str) -> None: # type: ignore (not accessed)\n if sys.path[0] != build_ctx:\n sys.path.insert(0, build_ctx)\n\n build_bentofile(bentofile, build_ctx=build_ctx, version=version)",... | [
"0.7333871",
"0.71412677",
"0.6977461",
"0.6936356",
"0.68916893",
"0.68744874",
"0.68205845",
"0.6769663",
"0.6651863",
"0.6582709",
"0.6576951",
"0.6561471",
"0.65468836",
"0.6516524",
"0.65142125",
"0.6505344",
"0.64734596",
"0.6464042",
"0.645478",
"0.63959265",
"0.639177... | 0.8105695 | 0 |
calls the 'test()' method of the current (user folder) test_package/conanfile.py | def test(conanfile):
with conanfile_exception_formatter(conanfile, "test"):
with chdir(conanfile.build_folder):
conanfile.test() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test():\n current_directory = os.getcwd()\n os.chdir(PACKAGE_DIR)\n pytest.main()\n os.chdir(current_directory)",
"def test():\n tests = unittest.TestLoader().discover('project/tests', pattern='test*.py')\n result = unittest.TextTestRunner(verbosity=2).run(tests)\n if result.wasSuccessfu... | [
"0.71587485",
"0.6982787",
"0.69825524",
"0.69750357",
"0.6971307",
"0.69660246",
"0.6936495",
"0.6896736",
"0.6883618",
"0.6883618",
"0.6883618",
"0.6883618",
"0.68168396",
"0.6809316",
"0.68035895",
"0.6797254",
"0.67825884",
"0.67797387",
"0.67692393",
"0.6762063",
"0.6757... | 0.82097435 | 0 |
Use matplotlib figure as component (by converting into plotly format first.) | def MatplotlibFigure(id, fig, size_in_pixels):
width_height_tuple_in_inches = (size_in_pixels[0]/fig.dpi, size_in_pixels[1]/fig.dpi)
fig.set_size_inches(width_height_tuple_in_inches)
plotly_fig = mpl_to_plotly(fig, strip_style=True)
return dcc.Graph(id, figure=plotly_fig) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_figure(self, traces):\n pass",
"def get_div_from_data(mpl_fig):\n res = plotly.offline.plot_mpl(\n mpl_fig,\n include_plotlyjs=False,\n output_type='div',\n resize=True,\n image_height=\"100%\", image_width=\"100%\"\n )\n return res",
"def embed_matpl... | [
"0.6617626",
"0.6531744",
"0.6453837",
"0.6431585",
"0.6351513",
"0.6198196",
"0.6140918",
"0.6118211",
"0.60988694",
"0.6052095",
"0.60091686",
"0.5962658",
"0.59478086",
"0.59292096",
"0.5902695",
"0.5902364",
"0.5892394",
"0.58689743",
"0.58653957",
"0.58606535",
"0.586036... | 0.67803866 | 0 |
Calculate the Lorenz curve graph based on the weight of the nodes. | def calculate_lorenz_curve(graph, type, steps=100):
vertices = {}
total_weight = 0.0
for node in graph.nodes():
if graph.node[node]['type'] is type:
vertices[node] = graph.node[node]['weight']
total_weight += graph.node[node]['weight']
print 'Total Weight:', total_weight
step_size = len(vertices.keys()... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def laplacian(G,nodelist=None,weight='weight'):\n try:\n import numpy as np\n except ImportError:\n raise ImportError(\n \"laplacian() requires numpy: http://scipy.org/ \")\n # this isn't the most efficient way to do this...\n if G.is_multigraph():\n A=np.asarray(nx.to_num... | [
"0.61697334",
"0.5985262",
"0.57928765",
"0.5774828",
"0.5718139",
"0.57098746",
"0.56282556",
"0.56156987",
"0.561296",
"0.5546312",
"0.55331117",
"0.5505912",
"0.55016",
"0.54956394",
"0.54727376",
"0.54492074",
"0.54362154",
"0.5434964",
"0.54281646",
"0.54253894",
"0.5422... | 0.6974506 | 0 |
Create and insert a salesman in DB. Return this salesman. | def create(self, **kwargs):
self.Salesman.SalesmanSchema(kwargs)
salesman = self.Salesman.Salesman(**kwargs)
self._dbsession.add(salesman)
return salesman | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create(self):\n db.session.add(self)\n db.session.commit()",
"def insert(self):\n db.session.add(self)\n db.session.commit()",
"def insert(self):\n db.session.add(self)\n db.session.commit()",
"def insert(self):\n db.session.add(self)\n db.session.c... | [
"0.61802167",
"0.6086429",
"0.6086429",
"0.6086429",
"0.60064095",
"0.5817878",
"0.5795104",
"0.5790183",
"0.5750525",
"0.5674662",
"0.5659894",
"0.55962473",
"0.55460125",
"0.5523515",
"0.5506935",
"0.5506935",
"0.5506935",
"0.5506935",
"0.5506935",
"0.5506935",
"0.5506935",... | 0.83125734 | 0 |
Update a salesman. Return False if there is no update or the updated salesman. | def update(self, salesman_id=None, salesman=None, **kwargs):
salesman = self._get(salesman_id, salesman)
salesman_dict = {k: getattr(salesman, k) for k in salesman.create_dict
if getattr(salesman, k) is not None}
new_salesman_dict = salesman_dict.copy()
item_to... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update(self, **validated_data):\n updated = self._provision(validated_data)\n if updated:\n try:\n db.session.commit()\n return True\n except Exception as error:\n db.session.rollback()\n print(error.args)\n ... | [
"0.54279137",
"0.5248786",
"0.5225192",
"0.5171629",
"0.5153626",
"0.5130111",
"0.5093068",
"0.50651497",
"0.5039609",
"0.5020056",
"0.49453017",
"0.4910194",
"0.48789948",
"0.48310226",
"0.48208135",
"0.48175666",
"0.48078495",
"0.47769818",
"0.4775985",
"0.4775985",
"0.4768... | 0.7559009 | 0 |
Set the commission formulae of a salesman. Return False if there is no update or the updated salesman. | def set_commissions_formulae(self, salesman_id=None, salesman=None,
commissions_formulae=None):
if commissions_formulae is None:
raise TypeError('commissions_formulae missing')
salesman = self._get(salesman_id, salesman)
if commissions_formulae == salesman.commissions_f... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setFormula(self, *args):\n return _libsbml.KineticLaw_setFormula(self, *args)",
"def setFormula(self, *args):\n return _libsbml.Rule_setFormula(self, *args)",
"def isSetFormula(self):\n return _libsbml.KineticLaw_isSetFormula(self)",
"def isSetFormula(self):\n return _libsbml.... | [
"0.5631036",
"0.5510063",
"0.54576015",
"0.5227687",
"0.5168512",
"0.51609457",
"0.5027287",
"0.49783978",
"0.4966199",
"0.49557495",
"0.4914359",
"0.48699042",
"0.48342544",
"0.48213744",
"0.4819287",
"0.4814658",
"0.48145792",
"0.47860384",
"0.47783843",
"0.47650018",
"0.47... | 0.798566 | 0 |
NYT most recent case count only merged with census density data | def merge_recent(nyt, census):
nyt['name'] = [county + ', ' + state for county, state in zip(nyt['county'].values, nyt['state'].values)]
del nyt['county']
del nyt['state']
sorted_cases = nyt[:len(nyt)].sort_values(by=['name', 'date'], inplace=False)
recent_cases = sorted_cases.drop_duplicates(subset... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_county_case_info(date=None):\n def get_latest_case_info(url, column_name):\n df = fetch_df(url)\n col = df.columns[-1]\n if date is not None:\n if not date in df.columns:\n raise Exception('Date {} not in dataset or not in proper format'.format(date))\n ... | [
"0.66494733",
"0.57787514",
"0.5734458",
"0.5731972",
"0.5592073",
"0.5574256",
"0.5548086",
"0.55144674",
"0.5508588",
"0.54565537",
"0.5449514",
"0.5423221",
"0.54035956",
"0.53978556",
"0.53924435",
"0.53587765",
"0.5358537",
"0.53479904",
"0.5324095",
"0.5274466",
"0.5264... | 0.6022568 | 1 |
Calculates position of an object around a circle after some time with interval dt. | def CalculatePosition(radius,velocity,time,dt):
# Initial conditions
theta = 0
xini = radius * np.cos(theta)
yini = radius * np.sin(theta)
t = 0
# Store positions and time
xposition = [xini]
yposition = [yini]
storedtime = [t]
# Calculate positions
while t < ti... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_position(self, dt):\n self._x += self._vx * dt\n self._y += self._vy * dt\n\n # TODO: Add timer countdown if infected and logic for dying/recovering.",
"def move(self, dt):\n w_px = self.meter_to_cart(self.vw)\n # delta_theta = delta_s/r\n self.theta += self.v... | [
"0.68143946",
"0.6695585",
"0.6501338",
"0.6077402",
"0.6071127",
"0.5974124",
"0.59736204",
"0.59488606",
"0.5938238",
"0.58743864",
"0.58348894",
"0.583335",
"0.58260334",
"0.5783727",
"0.57738256",
"0.57213885",
"0.5694227",
"0.5692534",
"0.5640608",
"0.56402296",
"0.56323... | 0.68198085 | 0 |
Calculate positions of multiple objects around a circle. | def MultiplePositions(radius,velocity,time,dt):
# Stop the calculation when the outermost point takes a whole revolution
# Outermost point position
outerposition = radius[len(radius)-1]
# Calculate the positions of outermost point:
xouter = CalculatePosition(radius[len(radius)-1],velocity[... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def objects_radius(self, centre, radius):",
"def get_circle_coords(self, radius, divider, count,center_x, center_y):\n\n angle_deg = (360/divider)*count\n angle = radians(angle_deg-(90 + (360/divider)))\n x = radius*cos(angle) + center_x;\n y = radius*sin(angle) + center_y;\n r... | [
"0.6573711",
"0.6500878",
"0.6470239",
"0.64024395",
"0.6312665",
"0.6311622",
"0.62207884",
"0.6218778",
"0.62045026",
"0.6172052",
"0.6139447",
"0.6115408",
"0.60919094",
"0.60410416",
"0.60351837",
"0.6013027",
"0.60069835",
"0.5990119",
"0.5984226",
"0.59842",
"0.5969877"... | 0.65115094 | 1 |
Creates a new datacenter | def create_datacenter(self, name, location, rs_address):
log.info("Creating datacenter %s at %s..." % (name, location))
datacenter = Datacenter.builder(self.__context) \
.name(name) \
.location(location) \
.remoteServices(rs_address, AbiquoE... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_data_center(\n dc_name, cluster_name, host_name, comp_version=config.COMPATIBILITY_VERSION\n):\n testflow.step(\"Add data-center %s\", dc_name)\n assert ll_dc.addDataCenter(\n True, name=dc_name, local=False, version=comp_version\n ), \"Failed to create dc %s\" % dc_name\n\n testfl... | [
"0.71436054",
"0.6854401",
"0.68000853",
"0.66635144",
"0.6579462",
"0.645192",
"0.62347233",
"0.6209931",
"0.60344267",
"0.59921485",
"0.58602756",
"0.5857226",
"0.5770692",
"0.57693875",
"0.57291585",
"0.5673177",
"0.564252",
"0.564252",
"0.56083393",
"0.560283",
"0.5579511... | 0.7115503 | 1 |
Creates a new rack | def create_rack(self, datacenter, name, vlan_id_min, vlan_id_max, nrsq):
log.info("Adding rack %s..." % name)
rack = Rack.builder(self.__context, datacenter) \
.name(name) \
.vlanIdMin(vlan_id_min) \
.vlanIdMax(vlan_id_max) \
.nrsq(nrsq) \
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fusion_api_add_rack(self, body, api=None, headers=None):\n return self.rack.create(body, api, headers)",
"def create_stack(Name=None, Region=None, VpcId=None, Attributes=None, ServiceRoleArn=None, DefaultInstanceProfileArn=None, DefaultOs=None, HostnameTheme=None, DefaultAvailabilityZone=None, Def... | [
"0.5731745",
"0.5350707",
"0.53393763",
"0.53384423",
"0.5296091",
"0.5239721",
"0.52332866",
"0.52140033",
"0.5193469",
"0.5193469",
"0.5127653",
"0.5095804",
"0.5093371",
"0.50695837",
"0.50252014",
"0.5025094",
"0.5003722",
"0.50027835",
"0.49996632",
"0.49757338",
"0.4974... | 0.6487994 | 0 |
Creates the default infrastructure compute entities. | def create_infrastructure_compute(config, context):
log.info("### Configuring infrastructure ###")
comp = InfrastructureCompute(context)
rs_address = config.get("datacenter", "rs") \
if config.has_option("datacenter", "rs") \
else context.getApiContext().getEndpoint().getHost()
d... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_infrastructure_storage(config, context, dc):\n print \"### Configuring storage ###\"\n storage = InfrastructureStorage(context)\n tier = storage.configure_tiers(dc, config.get(\"tier\", \"name\"))\n try: \n user = config.get(\"device\", \"user\")\n password= config.get(\"device... | [
"0.6158783",
"0.60312074",
"0.5879258",
"0.5680778",
"0.5614755",
"0.5404508",
"0.5369365",
"0.5341656",
"0.52965254",
"0.52809167",
"0.52513313",
"0.5248991",
"0.52394885",
"0.52330923",
"0.520033",
"0.51824903",
"0.51824903",
"0.51648235",
"0.5156057",
"0.51496494",
"0.5147... | 0.69378626 | 0 |
Cleans up previously created infrastructure compute resources | def cleanup_infrastructure_compute(config, context):
log.info("### Cleaning up infrastructure ###")
admin = context.getAdministrationService()
for datacenter in admin.listDatacenters():
cleanup_infrastructure_storage(config, datacenter)
cleanup_infrastructure_network(config, datacenter)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cleanupResources():\n None",
"def finalizer():\n for resource_type in pods, pvcs, storageclasses, secrets:\n for resource in resource_type:\n resource.delete()\n resource.ocp.wait_for_delete(resource.name)\n if pools:\n # Delete only the RBD ... | [
"0.7537821",
"0.7452589",
"0.7419435",
"0.7336632",
"0.7252372",
"0.7234718",
"0.7166905",
"0.7032153",
"0.69838613",
"0.6968813",
"0.68726987",
"0.6845922",
"0.683998",
"0.6813877",
"0.680531",
"0.6766662",
"0.67335284",
"0.67247486",
"0.6697108",
"0.6697108",
"0.6697108",
... | 0.7529746 | 1 |
Create a chessboard with of the size passed in. Don't return anything, print the output to stdout | def create_chessboard(size=8):
r1 = (WHITE + BLACK) * int((size / 2)) + "\n"
r2 = (BLACK + WHITE) * int((size / 2)) + "\n"
print((r1 + r2) * int((size / 2))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_chessboard(size=8):\r\n\r\n def _create_even_line(size):\r\n return ''.join([WHITE if i % 2 else BLACK for i in range(size)])\r\n \r\n even_line = _create_even_line(size)\r\n odd_line = even_line[::-1]\r\n \r\n print('\\n'.join(even_line if line % 2 else odd_line for line in range(size)... | [
"0.79357535",
"0.6987011",
"0.68661624",
"0.68543833",
"0.68187064",
"0.68181366",
"0.6788091",
"0.6741951",
"0.6613889",
"0.6524536",
"0.6518203",
"0.64458066",
"0.63901216",
"0.63888204",
"0.63836443",
"0.6348464",
"0.6335169",
"0.630147",
"0.62831014",
"0.62610894",
"0.625... | 0.8453823 | 0 |
Prints profile parameters from credentials file (~/.aws/credentials) as evalable environment variables | def profile_to_env():
parser = argparse.ArgumentParser(description=profile_to_env.__doc__)
parser.add_argument("-t", "--target-role", action="store_true", help="Output also azure_default_role_arn")
parser.add_argument("-r", "--role-arn", help="Output also the role given here as the target role for the profi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def aws_credentials():\n os.environ['AWS_ACCESS_KEY_ID'] = 'testing'\n os.environ['AWS_SECRET_ACCESS_KEY'] = 'testing'\n os.environ['AWS_SECURITY_TOKEN'] = 'testing'\n os.environ['REGION'] = 'region'",
"def aws_credentials():\n os.environ['AWS_ACCESS_KEY_ID'] = 'testing'\n os.environ['AWS_SECRET_AC... | [
"0.63308054",
"0.6250225",
"0.62485486",
"0.6236004",
"0.62349755",
"0.6216572",
"0.6216572",
"0.6216572",
"0.61766446",
"0.61766446",
"0.6161644",
"0.6127176",
"0.61246246",
"0.58668566",
"0.5831417",
"0.5773495",
"0.5698812",
"0.5667367",
"0.5665289",
"0.5597459",
"0.553797... | 0.6741683 | 0 |
Prints profile expiry from credentials file (~/.aws/credentials) as evalable environment variables | def profile_expiry_to_env():
parser = argparse.ArgumentParser(description=profile_expiry_to_env.__doc__)
if "_ARGCOMPLETE" in os.environ:
parser.add_argument("profile", help="The profile to read expiry info from").completer = \
ChoicesCompleter(read_expiring_profiles())
argcomplete.a... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cli_read_profile_expiry():\n parser = argparse.ArgumentParser(description=cli_read_profile_expiry.__doc__)\n parser.add_argument(\"profile\", help=\"The profile to read expiry info from\").completer = \\\n ChoicesCompleter(read_expiring_profiles())\n argcomplete.autocomplete(parser)\n args =... | [
"0.6548482",
"0.5855601",
"0.58411586",
"0.5837414",
"0.5820175",
"0.5790486",
"0.5790486",
"0.5790486",
"0.5755642",
"0.5755642",
"0.5731502",
"0.5716918",
"0.57167935",
"0.5633017",
"0.5630155",
"0.5487631",
"0.5353106",
"0.52786773",
"0.5207291",
"0.5152932",
"0.5141173",
... | 0.6968569 | 0 |
Enable a configured profile. Simple IAM user, AzureAD and ndt assumerole profiles are supported | def cli_enable_profile():
parser = argparse.ArgumentParser(description=cli_enable_profile.__doc__)
type_select = parser.add_mutually_exclusive_group(required=False)
type_select.add_argument("-i", "--iam", action="store_true", help="IAM user type profile")
type_select.add_argument("-a", "--azure", action... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def enable(self,\n profile_id=None):\n if profile_id is None:\n self._enabled = True\n else:\n self._profiles[profile_id] = True",
"def set_authentication_profile(profile=None, deploy=False):\n\n if not profile:\n raise CommandExecutionError(\"Profile n... | [
"0.71673536",
"0.64258325",
"0.63383347",
"0.60237646",
"0.5901494",
"0.5857726",
"0.579151",
"0.57829446",
"0.5696671",
"0.56693006",
"0.56515276",
"0.55771184",
"0.55110115",
"0.5508152",
"0.5491759",
"0.54747105",
"0.5444639",
"0.5444156",
"0.5412009",
"0.54075176",
"0.540... | 0.79776365 | 0 |
Print something in red | def printRed(text):
print(Fore.RED + text + Fore.WHITE) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_red(msg: str = None) -> None:\n if msg is None:\n raise Exception(\"msg was not defined\")\n\n print(Fore.RED + msg)\n print(Style.RESET_ALL + \"\", end=\"\")",
"def print_green(msg: str = None) -> None:\n if msg is None:\n raise Exception(\"msg was not defined\")\n\n print... | [
"0.7844057",
"0.76571864",
"0.72239184",
"0.7149927",
"0.70288014",
"0.70163584",
"0.69991595",
"0.6988605",
"0.6988605",
"0.6988605",
"0.6988605",
"0.698294",
"0.6976125",
"0.69745344",
"0.6963944",
"0.6963944",
"0.6963944",
"0.6963944",
"0.69105566",
"0.6903078",
"0.6901880... | 0.80345446 | 0 |
Run a subprocess call with some printing and stuff | def callSubprocess(args, test=False):
print(Fore.MAGENTA),
for arg in args:
print arg,
print(Fore.WHITE)
if not test:
subprocess.call(args) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def system_call(command):\n print(\"\\n### {}\".format(command))\n stderr = subprocess.STDOUT\n pipe = subprocess.Popen(\n command,\n stdout=subprocess.PIPE,\n stderr=subprocess.STDOUT,\n shell=True,\n )\n stdout, stderr = pipe.communicate()\n print(stdout)",
"def ru... | [
"0.74172086",
"0.72924894",
"0.70098263",
"0.6968202",
"0.68901086",
"0.68606615",
"0.6839701",
"0.6801746",
"0.67945224",
"0.676581",
"0.6753861",
"0.6706629",
"0.67058957",
"0.66742986",
"0.66731685",
"0.6653105",
"0.6648998",
"0.6636191",
"0.662624",
"0.6626091",
"0.662071... | 0.73385876 | 1 |
Print the sidereal times of a dada file. Now reads DADA header | def computeLstFromDada(filename):
d = dada.DadaReader(filename, n_int=0)
telescope = d.header["TELESCOPE"]
if telescope in ('LEDA', 'LWAOVRO', 'LWA-OVRO', 'LEDAOVRO', 'LEDA512', 'LEDA-OVRO'):
h3("Data appears to be from LWAOVRO")
site = ledafits_config.ovro
elif tele... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _read_snc(snc_file):\r\n with open(snc_file, 'rb') as f:\r\n filebytes = f.read()\r\n i = 352 # end of header\r\n\r\n sampleStamp = []\r\n sampleTime = []\r\n while i < len(filebytes):\r\n sampleStamp.append(unpack('<i', filebytes[i:(i + 4)])[0])\r\n i += 4\r\n sampl... | [
"0.5786813",
"0.5596807",
"0.55537003",
"0.5467872",
"0.5450625",
"0.54284793",
"0.5415443",
"0.53824365",
"0.53529125",
"0.53363365",
"0.5327654",
"0.529744",
"0.52864784",
"0.52804893",
"0.524197",
"0.5240428",
"0.52306235",
"0.51868236",
"0.51856166",
"0.5177022",
"0.51532... | 0.5660324 | 1 |
Generate header for corr2uvfits | def generateHeader(param_dict, filename_out, test_mode=False, template="uvfits_headers/header.tpl"):
findAndReplace(param_dict, template,filename_out, test_mode) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_roi_header(**param):\n hdr_list = ['== Integration ROI ==']\n method = [i for i in list(param.keys()) if \"pos\" in i][0].split('_pos')[0]\n hdr_list.append('Integration method: {}'.format(method))\n\n for k, v in list(param.items()):\n hdr_list.append('{}: {}'.format(k, v))\n\n head... | [
"0.706126",
"0.6851616",
"0.68311733",
"0.6776908",
"0.6771392",
"0.67515165",
"0.6741585",
"0.6740746",
"0.6712894",
"0.6668977",
"0.66587687",
"0.6636849",
"0.6636847",
"0.65992546",
"0.657819",
"0.6571183",
"0.6547306",
"0.65389186",
"0.6521988",
"0.65072596",
"0.65061957"... | 0.7028798 | 1 |
interactive of ip reverse | def interactive_ip_reverse():
while True:
ip=input("Input IP: ").strip()
if not re.match(r"^(\d{1,3}\.){3}\d{1,3}$",ip):
print("\"%s\" is not a valid IP!"%ip)
print("-"*100)
continue
jobs=[
# gevent.spawn(ip_location, ip),
g... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reverse_ip(self, domain_or_ip, limit=None):\n params = {}\n if limit:\n params = {'limit':limit}\n if re.search('^(\\d{1,3}\\.){3}(\\d{1,3})$',domain_or_ip):\n uri = '/v1/{}/host-domains/'\n else:\n uri = '/v1/{}/reverse-ip/'\n return self.api... | [
"0.66558707",
"0.6445157",
"0.6230643",
"0.59917784",
"0.5846518",
"0.58067155",
"0.57389295",
"0.5678243",
"0.56706375",
"0.55527616",
"0.55294704",
"0.54846996",
"0.5458878",
"0.53976476",
"0.53787875",
"0.5371206",
"0.5370891",
"0.5307846",
"0.5247299",
"0.52192914",
"0.51... | 0.76797676 | 0 |
Construct a ``FlagSet`` from this ``EnumSet`` instance. | def flagset(self, flags=None):
return FlagSet(self, flags) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, eset, flags=None):\n\n # Store the EnumSet\n self.eset = eset\n\n # Initialize the flags\n self.bitflags = 0\n self.flags = set()\n\n # Routine to call if we're modified\n self._notify = None\n\n # Process the flags that were set\n i... | [
"0.684265",
"0.6717586",
"0.64065474",
"0.61438274",
"0.60595673",
"0.59785277",
"0.5597284",
"0.52705204",
"0.5201559",
"0.51301944",
"0.50747067",
"0.5051974",
"0.50294566",
"0.49907878",
"0.49886325",
"0.4908961",
"0.48859864",
"0.48733738",
"0.4863849",
"0.4858615",
"0.48... | 0.6772877 | 1 |
Construct an ``EnumAttr`` from this ``EnumSet`` instance. | def attr(self):
return EnumAttr(self) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, eset, invalidator='invalidate'):\n\n # Initialize the superclass\n super(EnumAttr, self).__init__(invalidator)\n\n # Save the EnumSet\n self.eset = eset",
"def __init__(self, eset, invalidator='invalidate'):\n\n # Initialize the superclass\n super(Flag... | [
"0.6876052",
"0.60064405",
"0.5596352",
"0.55440545",
"0.54308647",
"0.5390676",
"0.5377266",
"0.53603077",
"0.5320629",
"0.530252",
"0.5269718",
"0.5245316",
"0.5220791",
"0.5206996",
"0.5182474",
"0.51805717",
"0.5168795",
"0.5149678",
"0.5147749",
"0.51453966",
"0.51028717... | 0.7049603 | 0 |
Construct a ``FlagSetAttr`` from this ``EnumSet`` instance. | def flags(self):
return FlagSetAttr(self) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, eset, invalidator='invalidate'):\n\n # Initialize the superclass\n super(FlagSetAttr, self).__init__(invalidator)\n\n # Save the EnumSet\n self.eset = eset",
"def __init__(self, eset, invalidator='invalidate'):\n\n # Initialize the superclass\n super(E... | [
"0.68628246",
"0.64354247",
"0.60697484",
"0.5878465",
"0.58728904",
"0.5784921",
"0.5717447",
"0.5555458",
"0.5312354",
"0.51613283",
"0.50998247",
"0.5003668",
"0.49232012",
"0.48911116",
"0.4842956",
"0.4807952",
"0.48032108",
"0.47879228",
"0.47613692",
"0.47541246",
"0.4... | 0.66749763 | 1 |
Initialize a ``FlagSet`` instance. | def __init__(self, eset, flags=None):
# Store the EnumSet
self.eset = eset
# Initialize the flags
self.bitflags = 0
self.flags = set()
# Routine to call if we're modified
self._notify = None
# Process the flags that were set
if isinstance(flags... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, eset, invalidator='invalidate'):\n\n # Initialize the superclass\n super(FlagSetAttr, self).__init__(invalidator)\n\n # Save the EnumSet\n self.eset = eset",
"def flagset(self, flags=None):\n\n return FlagSet(self, flags)",
"def __init__(self, *args):\n ... | [
"0.64819515",
"0.63964987",
"0.56189543",
"0.5566477",
"0.5560987",
"0.5417575",
"0.52496475",
"0.5185117",
"0.5179554",
"0.5157495",
"0.5156784",
"0.5125656",
"0.5108871",
"0.5105964",
"0.5104121",
"0.5084199",
"0.50583917",
"0.5032526",
"0.49541607",
"0.49460858",
"0.494453... | 0.6524963 | 0 |
Determine if the ``FlagSet`` instance contains the specified flags. | def __contains__(self, flag):
if isinstance(flag, six.integer_types):
# Pretty easy
return (self.bitflags & flag) == flag
elif isinstance(flag, six.string_types):
# Simple string
return flag in self.flags
else:
try:
# M... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def flagSet():\r\n for flag in flags:\r\n if flags[flag]:\r\n return True\r\n return False",
"def has(self, *options: str) -> bool:\n return bool(self.flags & self.mask(*options))",
"def supports_feature(flags: Set[str], feature: str) -> bool:\n\n if not isinstance(feature, st... | [
"0.7395332",
"0.70454514",
"0.6428682",
"0.6359156",
"0.63465047",
"0.62633365",
"0.5987054",
"0.5924127",
"0.590645",
"0.5763223",
"0.571385",
"0.5619686",
"0.54595345",
"0.5436726",
"0.5432826",
"0.54285216",
"0.5423442",
"0.54006237",
"0.53594786",
"0.5264322",
"0.52434474... | 0.7988177 | 0 |
Iterate over the flags contained within the ``FlagSet`` instance. | def __iter__(self):
for opt in self.eset:
if self.bitflags & int(opt):
yield opt | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_all():\n for i in flags:\n print(i)",
"def flagSet():\r\n for flag in flags:\r\n if flags[flag]:\r\n return True\r\n return False",
"def flags(self):\n return list(self._flags_generator())",
"def flags(self):\n return self.__flag_set",
"def process_... | [
"0.6518555",
"0.6327646",
"0.62502426",
"0.61422515",
"0.60469395",
"0.59845054",
"0.5980491",
"0.5960565",
"0.5954546",
"0.58856064",
"0.585419",
"0.58485126",
"0.57815963",
"0.57815963",
"0.57815963",
"0.57815963",
"0.57522607",
"0.5748207",
"0.5748207",
"0.5748207",
"0.574... | 0.718754 | 0 |
Determine the number of flags set. | def __len__(self):
return len(self.flags) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_flag_count(self):\n done = self.cur.execute(\"SELECT video_ID FROM flags\")\n return done",
"def countCmdLineFlags(options, flag):\n counter = 0\n # make sure only flag was supplied\n for key, value in options.__dict__.items():\n if key == flag:\n next\n #... | [
"0.7078012",
"0.6832917",
"0.66732156",
"0.6644083",
"0.64806825",
"0.6419411",
"0.6406578",
"0.64009017",
"0.6394799",
"0.6365754",
"0.62850374",
"0.6284501",
"0.62693596",
"0.6268682",
"0.6248366",
"0.6245902",
"0.6245397",
"0.6241673",
"0.62223226",
"0.62160933",
"0.621576... | 0.723476 | 0 |
Discard a flag on the ``FlagSet`` instance. | def discard(self, flag):
try:
# Resolve the flag
flag = self.eset[flag]
except KeyError:
return
# Save the current bitflags
previous = self.bitflags
self.bitflags &= ~int(flag)
self.flags.discard(str(flag))
# Call the notifi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setDiscardFlag(self, flag, on=True):\r\n if on:\r\n self.__data.discardFlags |= flag\r\n else:\r\n self.__data.discardFlags &= ~flag",
"def setDiscardFlags(self, flags):\r\n self.__data.discardFlags = flags",
"def discard(self, item):\n try:\n se... | [
"0.7705357",
"0.7167262",
"0.65679157",
"0.61577463",
"0.61577463",
"0.6107064",
"0.6039238",
"0.59883547",
"0.59009844",
"0.5894775",
"0.56465137",
"0.55505514",
"0.54692906",
"0.5387131",
"0.5349529",
"0.53450084",
"0.5329477",
"0.53255093",
"0.5220295",
"0.5217501",
"0.518... | 0.7911526 | 0 |
Initialize an ``EnumAttr`` instance. | def __init__(self, eset, invalidator='invalidate'):
# Initialize the superclass
super(EnumAttr, self).__init__(invalidator)
# Save the EnumSet
self.eset = eset | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def attr(self):\n\n return EnumAttr(self)",
"def __init__(self, node, declare):\n symbol.__init__(self, node, declare, \"enum\", \"Enumeration\")\n # check if values are required, must be true or false\n val_req = getOptionalTag(node, \"valuesRequired\", \"false\")\n if val_req... | [
"0.6581085",
"0.63450205",
"0.6230454",
"0.60921705",
"0.59040815",
"0.5869061",
"0.5846382",
"0.5828544",
"0.580048",
"0.57501423",
"0.5714125",
"0.5693442",
"0.5684198",
"0.5657441",
"0.5615489",
"0.5602678",
"0.55878705",
"0.55800617",
"0.5535318",
"0.544706",
"0.5345185",... | 0.6413726 | 1 |
Initialize a ``FlagSetAttr`` instance. | def __init__(self, eset, invalidator='invalidate'):
# Initialize the superclass
super(FlagSetAttr, self).__init__(invalidator)
# Save the EnumSet
self.eset = eset | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, eset, flags=None):\n\n # Store the EnumSet\n self.eset = eset\n\n # Initialize the flags\n self.bitflags = 0\n self.flags = set()\n\n # Routine to call if we're modified\n self._notify = None\n\n # Process the flags that were set\n i... | [
"0.6014541",
"0.5964356",
"0.5957173",
"0.5914509",
"0.58628297",
"0.58485585",
"0.5797345",
"0.5684662",
"0.5607551",
"0.55607164",
"0.5557966",
"0.53762037",
"0.53533566",
"0.5348422",
"0.5291797",
"0.52211326",
"0.52210116",
"0.52180463",
"0.5195433",
"0.5183904",
"0.51824... | 0.6945288 | 0 |
Moves a city from the list of unvisited cities to the list of visited ones. | def visit_city(city):
visited_cities.append(city)
unvisited_cities.remove(city) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def travel_next(city, city_list, tour, all_tours):\n city.traversed = 1\n tour.append(city)\n is_end = True\n \n for next_city in city_list:\n if(next_city.traversed is not 1):\n travel_next(next_city, city_list, tour, all_tours)\n next_city.traversed = 0\n is... | [
"0.65666753",
"0.6503452",
"0.6051666",
"0.59114844",
"0.5849416",
"0.58344364",
"0.5657373",
"0.5644101",
"0.56237173",
"0.5520811",
"0.5504626",
"0.54924834",
"0.5433857",
"0.541804",
"0.53408176",
"0.5340503",
"0.5338157",
"0.53203654",
"0.5307929",
"0.5307929",
"0.5307929... | 0.78725225 | 0 |
We convert Data from the format PosScfBC.schema.json to Scf_Pos_ZScr_vals | def PosScfBCDataToZScrPointsForValues(PosScfBC_fp, op_fp, analysis_type):
with open(PosScfBC_fp, "r") as f:
PosScfBC_d = json.loads(f.read())
if analysis_type == "0":
Scf_Pos_ZScr_vals = GetZScrInfoForAllScaffolds(PosScfBC_d)
elif analysis_type == "1":
Scf_Pos_ZScr_vals = GetZScr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GetZScrInfoForAllScaffolds(PosScfBC_d):\n total_pos_and_nIns_l = []\n\n # We initially run through the scaffolds to get SD, mean\n for scf in PosScfBC_d[\"scaffolds\"].keys():\n scf_info = PosScfBC_d[\"scaffolds\"][scf]\n pos_and_nIns_l = [[int(x), scf_info[\"positions\"][x][\"nIns\"]] f... | [
"0.56657326",
"0.5521152",
"0.53005815",
"0.5252095",
"0.50889254",
"0.5049737",
"0.50323945",
"0.49730736",
"0.49445271",
"0.49313352",
"0.491731",
"0.49049857",
"0.488291",
"0.4882402",
"0.48749822",
"0.4852411",
"0.4832353",
"0.48288804",
"0.4810229",
"0.4808238",
"0.47967... | 0.65343136 | 0 |
We calculate the ZScr over the individual scaffolds in the genome Input is the same as to the function PosScfBCDataToZScrPointsForValues above. | def GetZScrInfoForIndividualScaffolds(PosScfBC_d):
Scf_Pos_ZScr_vals = {"scaffolds": {}}
for scf_name in PosScfBC_d["scaffolds"].keys():
scf_info = PosScfBC_d["scaffolds"][scf_name]
pos_and_nIns_l = [[int(x), scf_info["positions"][x]["nIns"]] for x in \
scf_info["positions"].ke... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GetZScrInfoForAllScaffolds(PosScfBC_d):\n total_pos_and_nIns_l = []\n\n # We initially run through the scaffolds to get SD, mean\n for scf in PosScfBC_d[\"scaffolds\"].keys():\n scf_info = PosScfBC_d[\"scaffolds\"][scf]\n pos_and_nIns_l = [[int(x), scf_info[\"positions\"][x][\"nIns\"]] f... | [
"0.7223206",
"0.6110108",
"0.57937723",
"0.56277347",
"0.55523914",
"0.541697",
"0.5352479",
"0.5330102",
"0.5263481",
"0.51990825",
"0.51827395",
"0.5105967",
"0.50682276",
"0.5040792",
"0.50048345",
"0.4997109",
"0.4978912",
"0.4974794",
"0.49712288",
"0.4946973",
"0.494254... | 0.6503895 | 1 |
We calculate the ZScr over all the insertions for the genome Instead of calculating SD and mean for each scaffold, we calculate these stats over the entire genome. We return information without the values with Standard Deviations below 0 to minimize size of JSON file. Input is the same as to the function PosScfBCDataTo... | def GetZScrInfoForAllScaffolds(PosScfBC_d):
total_pos_and_nIns_l = []
# We initially run through the scaffolds to get SD, mean
for scf in PosScfBC_d["scaffolds"].keys():
scf_info = PosScfBC_d["scaffolds"][scf]
pos_and_nIns_l = [[int(x), scf_info["positions"][x]["nIns"]] for x in \
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GetZScrInfoForIndividualScaffolds(PosScfBC_d):\n Scf_Pos_ZScr_vals = {\"scaffolds\": {}}\n\n for scf_name in PosScfBC_d[\"scaffolds\"].keys():\n scf_info = PosScfBC_d[\"scaffolds\"][scf_name]\n\n pos_and_nIns_l = [[int(x), scf_info[\"positions\"][x][\"nIns\"]] for x in \\\n s... | [
"0.7047891",
"0.6128534",
"0.56608206",
"0.5634555",
"0.5603958",
"0.5495317",
"0.5444786",
"0.5407131",
"0.53483766",
"0.5233515",
"0.5173635",
"0.51629716",
"0.51305306",
"0.51079404",
"0.5100728",
"0.5080563",
"0.5062883",
"0.50543565",
"0.50170743",
"0.5014622",
"0.500641... | 0.8187482 | 0 |
We take position and num insertion values and get ZScrs for each | def GetZScrValuesForPoints(pos_and_nIns_l, mean, SD):
if SD == 0.0:
return [0,[]]
pos_to_ZScrs_list = []
max_z_scr = 0
for tup in pos_and_nIns_l:
Zscr = float(tup[1] - mean)/float(SD)
pos_to_ZScrs_list.append([tup[0], Zscr])
if Zscr > max_z_scr:
max_z_scr ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GetZScrInfoForAllScaffolds(PosScfBC_d):\n total_pos_and_nIns_l = []\n\n # We initially run through the scaffolds to get SD, mean\n for scf in PosScfBC_d[\"scaffolds\"].keys():\n scf_info = PosScfBC_d[\"scaffolds\"][scf]\n pos_and_nIns_l = [[int(x), scf_info[\"positions\"][x][\"nIns\"]] f... | [
"0.64086527",
"0.6003098",
"0.5867654",
"0.58437455",
"0.5629926",
"0.5586101",
"0.5543061",
"0.55379725",
"0.5523238",
"0.54702884",
"0.54187083",
"0.5392553",
"0.53826857",
"0.53677815",
"0.5359348",
"0.53465724",
"0.5340052",
"0.53313917",
"0.53248686",
"0.53190124",
"0.53... | 0.6023835 | 1 |
Combine Labeller classes dynamically. The Labeller class aims to split plot labeling in ArviZ into atomic tasks to maximize extensibility, and the few classes provided are designed with small deviations from the base class, in many cases only one method is modified by the child class. It is to be expected then to want ... | def mix_labellers(labellers, class_name="MixtureLabeller"):
return type(class_name, labellers, {}) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_labels(self):\n raise NotImplementedError()",
"def get_labels(self):\n raise NotImplementedError()",
"def get_labels(self):\n raise NotImplementedError()",
"def get_labels(self):\r\n raise NotImplementedError()",
"def getLabel2(*args):",
"def getLabel2(*args):",
"def __init__(self, ... | [
"0.56585646",
"0.56585646",
"0.56585646",
"0.5630137",
"0.56291884",
"0.56291884",
"0.55772626",
"0.5538508",
"0.5498137",
"0.54862446",
"0.5434813",
"0.54181445",
"0.5408373",
"0.5408373",
"0.5408373",
"0.5404845",
"0.5381343",
"0.5381343",
"0.5381343",
"0.5381343",
"0.53813... | 0.6857345 | 0 |
generates the python script that will daemonize the call to run script | def generateDaemonizer(working_dir="."):
py_template = """#!/usr/bin/python
import daemon
import subprocess
with daemon.DaemonContext(working_directory="."):
proc = subprocess.Popen(["nohup", "bash", "run.sh"])
"""
py_sh = open(os.path.join(working_dir, "daemonize.py"), "w")
py_sh.write(py_template)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def script_generator(self):\n analyze_tool = \"/home/haihuam/Projects/RepPoints/mmdetection/tools/analyze_logs.py\"\n ex_options = self.global_setting.get('analyze_options', str())\n py = self.global_setting.get('python', sys.executable)\n if os.access(py, os.X_OK):\n content... | [
"0.66752326",
"0.645501",
"0.6352275",
"0.6271266",
"0.62107617",
"0.6055067",
"0.60431343",
"0.6040542",
"0.597326",
"0.5939872",
"0.5934565",
"0.585356",
"0.58412933",
"0.58219093",
"0.5772267",
"0.57570595",
"0.5752123",
"0.5752123",
"0.5752123",
"0.5752123",
"0.5752123",
... | 0.7831942 | 0 |
Reduce ndarray data via binaveraging for specified peraxis bin sizes. For a 3D input data with shape (D, H, W) and axes_s of [s1, s2, s3], the output value result[0, 0, 0] will contain the average | def bin_reduce(data, axes_s):
d1 = data
# sort axes by stride distance to optimize for locality
# doesn't seem to make much difference on modern systems...
axes = [ (axis, d1.strides[axis]) for axis in range(d1.ndim) ]
axes.sort(key=lambda p: p[1])
assert len(axes_s) == data.ndim
#... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rebin(a, *args):\n shape = a.shape\n lenShape = len(shape)\n #factor = np.asarray(shape) / np.asarray(args)\n #print factor\n evList = ['a.reshape('] + ['args[%d],factor[%d],' % (i, i) for i in range(lenShape)] + [')'] + ['.mean(%d)' % (i + 1) for i in range(lenShape)]\n return eval(''.join(e... | [
"0.6197544",
"0.6139096",
"0.6051382",
"0.5896235",
"0.5862351",
"0.57766837",
"0.5664513",
"0.56489617",
"0.5627115",
"0.5602402",
"0.5573364",
"0.55187595",
"0.551417",
"0.5482396",
"0.5384104",
"0.5372279",
"0.53614336",
"0.5357239",
"0.53565305",
"0.53510183",
"0.53490233... | 0.71066993 | 0 |
Load named file using TIFF reader, returning (data, metadata). Keep temporarily for backwardcompatibility... | def load_tiff(fname):
data = TiffLazyNDArray(fname)
try:
data = canonicalize(data)
except Exception as e:
print(e)
# special case for raw TIFF (not LSM, not OME)
if data.ndim == 3:
data = data[(None,slice(None),slice(None),slice(None))] # add fake color dimension
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_image(fname):\n return load_tiff(fname)",
"def load_tiff(self):\n\n try:\n # Byte order\n h = bytes(self.tif_file.read(2))\n self.byteOrder = {b'II': 'little', b'MM': 'big'}[h]\n assert (self.byteOrder == 'little' or self.byteOrder == 'big')\n ... | [
"0.7372688",
"0.72276574",
"0.6451952",
"0.63730574",
"0.63536483",
"0.6299473",
"0.6247352",
"0.6202761",
"0.61148506",
"0.6113087",
"0.6061809",
"0.60330236",
"0.602107",
"0.6011453",
"0.5996214",
"0.5994353",
"0.5974746",
"0.59672064",
"0.5890447",
"0.589004",
"0.58861125"... | 0.7757786 | 0 |
Imports the given nmap result. | def import_nmap(result, tag, check_function=all_hosts, import_services=False):
host_search = HostSearch(arguments=False)
service_search = ServiceSearch()
parser = NmapParser()
report = parser.parse_fromstring(result)
imported_hosts = 0
imported_services = 0
for nmap_host in report.hosts:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_nmap_results(cls, info, output_filename):\n\n # Parse the scan results.\n # On error log the exception and continue.\n results = []\n hostmap = {}\n if info:\n hostmap[info.address] = info\n try:\n tree = ET.parse(output_filename)\n ... | [
"0.5647757",
"0.56106627",
"0.5591286",
"0.549616",
"0.4903906",
"0.4893976",
"0.48800737",
"0.48766825",
"0.48130697",
"0.47719243",
"0.4759616",
"0.47524032",
"0.47438028",
"0.47294953",
"0.47147262",
"0.47070262",
"0.46990514",
"0.46663794",
"0.46645853",
"0.46533662",
"0.... | 0.7243553 | 0 |
Includes only hosts that have the status 'up' | def include_up_hosts(nmap_host):
if nmap_host.status == 'up':
return True
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_reports_enabled_hosts_as_up(self):\n compute1 = self.start_service('compute', host='host1')\n compute2 = self.start_service('compute', host='host2')\n hosts = self.scheduler.driver.hosts_up(self.context, 'compute')\n self.assertEqual(2, len(hosts))\n compute1.kill()\n ... | [
"0.6929452",
"0.6754496",
"0.6679417",
"0.64882976",
"0.6351302",
"0.6138063",
"0.6076717",
"0.60622376",
"0.6043503",
"0.6015993",
"0.5977318",
"0.5946986",
"0.5894877",
"0.5889159",
"0.5798418",
"0.5779504",
"0.576346",
"0.57560277",
"0.56222934",
"0.5565237",
"0.5488756",
... | 0.83082455 | 0 |
Start an nmap process with the given args on the given ips. | def nmap(nmap_args, ips):
config = Config()
arguments = ['nmap', '-Pn']
arguments.extend(ips)
arguments.extend(nmap_args)
output_file = ''
now = datetime.datetime.now()
if not '-oA' in nmap_args:
output_name = 'nmap_jackal_{}'.format(now.strftime("%Y-%m-%d %H:%M"))
path_name ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main(args):\n if '-' in args['-p']:\n tmp = args['-p'].split('-')\n tgtPorts = [str(i) for i in xrange(int(tmp[0]), int(tmp[1])+1)]\n else:\n tgtPorts = [args['-p']]\n tgtHost = args['-H']\n for tgtPort in tgtPorts:\n nmapScan(tgtHost, tgtPort)",
"def nmap_discover():\... | [
"0.71778214",
"0.65890396",
"0.65784913",
"0.61431664",
"0.6127237",
"0.60971135",
"0.59005636",
"0.535779",
"0.5355618",
"0.52643454",
"0.5208361",
"0.5177667",
"0.51740116",
"0.5138187",
"0.5101425",
"0.5043745",
"0.5043745",
"0.5043745",
"0.5043745",
"0.5043745",
"0.503599... | 0.7662415 | 0 |
Scans the given hosts with nmap. | def nmap_scan():
# Create the search and config objects
hs = HostSearch()
config = Config()
# Static options to be able to figure out what options to use depending on the input the user gives.
nmap_types = ['top10', 'top100', 'custom', 'top1000', 'all']
options = {'top10':'--top-ports 10', 'top... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main(args):\n if '-' in args['-p']:\n tmp = args['-p'].split('-')\n tgtPorts = [str(i) for i in xrange(int(tmp[0]), int(tmp[1])+1)]\n else:\n tgtPorts = [args['-p']]\n tgtHost = args['-H']\n for tgtPort in tgtPorts:\n nmapScan(tgtHost, tgtPort)",
"def nmap_discover():\... | [
"0.7025049",
"0.6521409",
"0.6378542",
"0.62963414",
"0.6219195",
"0.6097285",
"0.60449445",
"0.5851369",
"0.5845113",
"0.5843361",
"0.5717884",
"0.5716023",
"0.5675595",
"0.5556713",
"0.5540878",
"0.54813397",
"0.5472343",
"0.54518175",
"0.54498523",
"0.54407346",
"0.5436073... | 0.75665087 | 0 |
Scans available smb services in the database for smb signing and ms17010. | def nmap_smb_vulnscan():
service_search = ServiceSearch()
services = service_search.get_services(ports=['445'], tags=['!smb_vulnscan'], up=True)
services = [service for service in services]
service_dict = {}
for service in services:
service.add_tag('smb_vulnscan')
service_dict[str(se... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_samba_clients(self):\n # TODO preferably use a library, don't assume localhost.\n logging.debug(\"inspecting samba...\")\n command = 'sudo smbstatus -p | sed -n 5p | tr -s \" \" | cut -d\" \" -f4'\n output = utils.run_os_command(command)\n return output.strip().split(\"\... | [
"0.62371737",
"0.5669815",
"0.53696716",
"0.53552085",
"0.53151625",
"0.5273359",
"0.5259361",
"0.5240157",
"0.51579183",
"0.51324147",
"0.5113975",
"0.5078871",
"0.5054602",
"0.5043952",
"0.5043248",
"0.5041043",
"0.503842",
"0.5036707",
"0.50204873",
"0.5011913",
"0.5010239... | 0.6513238 | 0 |
Performs os (and domain) discovery of smb hosts. | def os_discovery():
hs = HostSearch()
hosts = hs.get_hosts(ports=[445], tags=['!nmap_os'])
# TODO fix filter for emtpy fields.
hosts = [host for host in hosts if not host.os]
host_dict = {}
for host in hosts:
host_dict[str(host.address)] = host
arguments = "--script smb-os-discov... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def nslookup(self):\n if len(self.hostnames) == 0:\n st, out = commands.getstatusoutput('get_instance_by_service %s' % self.bns)\n assert st == 0, \"Failure:'get_instance_by_service %s', errno=%d\" % (self.bns, st)\n self.hostnames = out.split('\\n')\n assert self.hos... | [
"0.57663345",
"0.5488624",
"0.53603756",
"0.5260246",
"0.52439183",
"0.5241199",
"0.52410096",
"0.5170347",
"0.51309216",
"0.5104058",
"0.50928646",
"0.50926536",
"0.5088061",
"0.5071322",
"0.50709414",
"0.5067245",
"0.5057643",
"0.50443965",
"0.50281113",
"0.5010868",
"0.500... | 0.6300907 | 0 |
Get number of nodes in an evaluator tree | def nodeCount(eval):
if not isEvaluator(eval):
return 0
return eval.ReferencedNodes().Size() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count(self):\n return self.__tree.node_count",
"def countNodes(epr):\n result = 1\n argLst = epr.args\n for arg in argLst:\n result += countNodes(arg)\n return result",
"def uniqueNodeCount(eval):\n if not isEvaluator(eval):\n return 0\n return eva... | [
"0.75622797",
"0.7529294",
"0.7479575",
"0.7247177",
"0.72267604",
"0.7162352",
"0.7160398",
"0.70068026",
"0.69996077",
"0.6992341",
"0.6980684",
"0.695798",
"0.69542134",
"0.69283307",
"0.6926007",
"0.6905633",
"0.6887969",
"0.68765336",
"0.68759674",
"0.68656826",
"0.68631... | 0.83393586 | 0 |
Get number of unique nodes in an evaluator tree | def uniqueNodeCount(eval):
if not isEvaluator(eval):
return 0
return eval.ReferencedUniqueNodes().Size() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def nodeCount(eval):\n if not isEvaluator(eval):\n return 0\n return eval.ReferencedNodes().Size()",
"def countNodes(epr):\n result = 1\n argLst = epr.args\n for arg in argLst:\n result += countNodes(arg)\n return result",
"def count_unique(self) -> int:\n ... | [
"0.7576809",
"0.7254298",
"0.71891284",
"0.71155745",
"0.70935607",
"0.70214313",
"0.6912688",
"0.6897794",
"0.6867565",
"0.6790366",
"0.67900467",
"0.6774255",
"0.6749377",
"0.6732378",
"0.672201",
"0.67205966",
"0.6686232",
"0.66795933",
"0.66662836",
"0.66526145",
"0.66101... | 0.84147877 | 0 |
Get max profiling time for an evaluator | def max(ev):
profData = getProfilingData(ev)
if profData is not None:
return profData.Tmax()
return "" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def max_time(self) -> float:\r\n if(len(self.operations_by_name) == 0):\r\n return -1\r\n return max(map(lambda x: x[\"time_step\"], self.operations_by_name.values()))",
"def max(self):\n\n return time_stat(self, stat=\"max\")",
"def getMaxSimTime(self):\n return self.max_sim... | [
"0.6709669",
"0.62209153",
"0.6059053",
"0.6050143",
"0.6025128",
"0.60107434",
"0.5955151",
"0.5945843",
"0.5939467",
"0.59079236",
"0.5812572",
"0.5812572",
"0.57888734",
"0.57609487",
"0.57224643",
"0.57156175",
"0.5695369",
"0.56885415",
"0.5660657",
"0.56372124",
"0.5609... | 0.64209914 | 1 |
Get min profiling time for an evaluator | def min(ev):
profData = getProfilingData(ev)
if profData is not None:
return profData.Tmin()
return "" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def min_time(self):\n #{{{ function to return time of first sample\n\n return self.mintime",
"def min(self):\n\n return time_stat(self, stat=\"min\")",
"def get_min_tim(self):\n return self.get_shortest_mode().tim",
"def min_time(self):\n return self._ll_tree_sequence.get_min_time(... | [
"0.65390086",
"0.6491748",
"0.6374993",
"0.62546337",
"0.62226903",
"0.61515844",
"0.5921736",
"0.5845982",
"0.5836962",
"0.58335114",
"0.5820608",
"0.5797174",
"0.57750994",
"0.5770553",
"0.57538813",
"0.57335234",
"0.57052904",
"0.57025284",
"0.56895",
"0.5687751",
"0.56761... | 0.68451685 | 0 |
Get propagated cost profiling time for an evaluator | def cost(ev):
profData = getProfilingData(ev)
if profData is not None:
return profData.PropagatedCost()
return "" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_time(self):\n return self.compute_time_without_gc() + self.gc_time",
"def computation_time(self) -> float:\r\n if self._computation_times is None:\r\n return None\r\n else:\r\n return self._computation_times[0]",
"def perf_timer():\n start_time = datetime.n... | [
"0.6636906",
"0.6144508",
"0.61103594",
"0.6105323",
"0.6021323",
"0.59983486",
"0.5941204",
"0.592668",
"0.59159535",
"0.59084445",
"0.5887483",
"0.5884865",
"0.58274376",
"0.5812681",
"0.57631546",
"0.5761986",
"0.5759631",
"0.57565475",
"0.57422686",
"0.57337075",
"0.57311... | 0.64273757 | 1 |
Get profiling call count for an evaluator | def count(ev):
profData = getProfilingData(ev)
if profData is not None:
return profData.Count()
return "" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def op_callcount(self):\r\n # timing is stored by node, we compute timing by Op on demand\r\n rval = {}\r\n for node, count in self.apply_callcount.items():\r\n rval.setdefault(node.op, 0)\r\n rval[node.op] += count\r\n return rval",
"def class_callcount(self):\r... | [
"0.645071",
"0.6406745",
"0.63925785",
"0.63677806",
"0.63302857",
"0.6281262",
"0.6211619",
"0.6148319",
"0.6045033",
"0.60330534",
"0.6007769",
"0.60064745",
"0.5980804",
"0.59685713",
"0.5929456",
"0.58637774",
"0.5863227",
"0.5843919",
"0.58364314",
"0.5831876",
"0.582873... | 0.6478726 | 0 |
Model of a pendulum | def pendulum(pos):
def x_dot(x, y):
return y
def y_dot(x, y):
return -np.sin(x)
return np.array([x_dot(pos[0], pos[1]), y_dot(pos[0], pos[1])]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, pendulum, name=\"Pendulum\", dt=0.01):\n super().__init__(name=name)\n self.pendulum = pendulum\n self.dt = dt",
"def damped_pendulum(pos):\n\n def x_dot(x, y):\n return y\n\n def y_dot(x, y):\n return -0.1*y - np.sin(x)\n\n return np.array([x_dot(po... | [
"0.68147796",
"0.6339868",
"0.6296034",
"0.60743606",
"0.5980977",
"0.5754878",
"0.5716205",
"0.56013805",
"0.5563842",
"0.54992867",
"0.54514074",
"0.5432418",
"0.543091",
"0.54245365",
"0.54043674",
"0.54034466",
"0.5398115",
"0.53881854",
"0.5375106",
"0.5373626",
"0.53723... | 0.6975272 | 0 |
Model of a damped pendulum | def damped_pendulum(pos):
def x_dot(x, y):
return y
def y_dot(x, y):
return -0.1*y - np.sin(x)
return np.array([x_dot(pos[0], pos[1]), y_dot(pos[0], pos[1])]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, pendulum, name=\"Pendulum\", dt=0.01):\n super().__init__(name=name)\n self.pendulum = pendulum\n self.dt = dt",
"def _model(self, t, theta, period, tmpid):\n template = self.templates[tmpid]\n phase = (t / period - theta[2]) % 1\n return theta[0] + th... | [
"0.6389757",
"0.62570584",
"0.6251534",
"0.6018877",
"0.5953172",
"0.58293605",
"0.58160734",
"0.5796524",
"0.57523537",
"0.56851745",
"0.56645703",
"0.5663768",
"0.56319314",
"0.562755",
"0.55919474",
"0.55872536",
"0.5567067",
"0.55479765",
"0.5503377",
"0.54973847",
"0.549... | 0.6742539 | 0 |
Hard sigmoid function For a given value u as input, it gives hard sigmoid of u as output. | def hard_sigmoid(u):
if u > 1:
ro = 1
elif u < 0:
ro = 0
else:
ro = u
return ro | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hard_sigmoid_derivative(u):\r\n if u > 1:\r\n ro = 0\r\n elif u < 0:\r\n ro = 0\r\n else:\r\n ro = 1\r\n return ro",
"def sigmoid(x):\n return 1 / (1 - (power(e,-x)))",
"def sigmoid(z):\r\n \r\n return vSigmoid(z);",
"def sigmoid(x):\n return 1 / (1 + exp(-x)... | [
"0.8340554",
"0.7792559",
"0.77599376",
"0.7747133",
"0.7747133",
"0.76981646",
"0.7667149",
"0.7664956",
"0.7651496",
"0.76462394",
"0.76462394",
"0.76407063",
"0.7631713",
"0.76259273",
"0.76033205",
"0.76024806",
"0.7595583",
"0.7590885",
"0.7590708",
"0.7586715",
"0.75819... | 0.83319825 | 1 |
Hard sigmoid function for an array of values For a given array u as input, it gives hard sigmoid of u as output. | def hard_sigmoid_array(u):
ro = np.zeros(len(u))
for i in np.arange(len(u)):
ro[i] = hard_sigmoid(u[i])
return ro | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sigmoid(t):\n return np.exp(t)/(1+np.exp(t))",
"def sigmoid(x: np.ndarray \n ) -> np.ndarray:\n return 1/(1+np.exp(-x))",
"def sigmoid(values, gain, shift):\n import numpy as np\n\n tiny = 0.000000001\n\n # Make sure argument is a numpy array\n if type(values) != np.ndarr... | [
"0.7557232",
"0.75521666",
"0.7530991",
"0.75062776",
"0.74866426",
"0.7473698",
"0.74650526",
"0.7455005",
"0.7455005",
"0.7455005",
"0.7455005",
"0.7455005",
"0.7455005",
"0.74319494",
"0.7427566",
"0.7409621",
"0.74043214",
"0.7399037",
"0.7392596",
"0.7390544",
"0.7388159... | 0.8358422 | 0 |
Derivative of hard sigmoid function For a given value u as input, it gives hard sigmoid derivative of u as output. | def hard_sigmoid_derivative(u):
if u > 1:
ro = 0
elif u < 0:
ro = 0
else:
ro = 1
return ro | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def derivative_sigmoid(x):\n return x * (1 - x)",
"def derivative_sigmoid(x):\n return x * (1 - x)",
"def sigmoid_derivative(x):\n return x * (1-x)",
"def sigmoid_derivative(x):\n return x * (1.0 - x)",
"def sigmoid_derivative(x):\n\n return sigmoid(x) * (1 - sigmoid(x))",
"def sigmoid_der... | [
"0.7970959",
"0.7970959",
"0.79495186",
"0.7897426",
"0.7845998",
"0.7710246",
"0.7476678",
"0.7226657",
"0.7202913",
"0.71984",
"0.70288426",
"0.69358486",
"0.6927546",
"0.69059795",
"0.6862626",
"0.6840817",
"0.6803506",
"0.6792324",
"0.6756603",
"0.67067933",
"0.6668996",
... | 0.8027031 | 0 |
Free phase function This function determines states dynamics and their final values, and the convergence time as output according to the free phase. | def free_phase(w, b, v, n_iter, eps, fan_in, fan_hidden, fan_out):
start_time = time.time()
s = np.asarray(
np.random.RandomState().uniform(low=-np.sqrt(6. / (fan_in + fan_out)), high=np.sqrt(6. / (fan_in + fan_out)),
size=(fan_hidden + fan_out,)))
u = np... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __update_if_required(self, time, phase):\n if (not self.__force_update) and (time, phase) == self.__last_params:\n return\n self.__last_params = (time, phase)\n self.__sin = np.sin(self.__rabi_mod * 0.5 * time)\n self.__cos = np.cos(self.__rabi_mod * 0.5 * time)\n ... | [
"0.58598506",
"0.57560414",
"0.5753303",
"0.5736742",
"0.5542678",
"0.5542645",
"0.55395633",
"0.553148",
"0.5518612",
"0.5518064",
"0.54858553",
"0.5479553",
"0.5467217",
"0.5458112",
"0.5453849",
"0.541411",
"0.5410637",
"0.54043305",
"0.5385624",
"0.5383069",
"0.5352124",
... | 0.5824797 | 1 |
Weakly clamped phase function This function determines states dynamics and their final values, and the convergence time as output according to the weakly clamped phase. | def weaklyClamped_phase(w, b, v, y_onehot, epoch, beta, n_iter, eps, fan_in, fan_hidden, fan_out):
start_time = time.time()
s = np.asarray(
np.random.RandomState().uniform(low=-np.sqrt(6. / (fan_in + fan_out)), high=np.sqrt(6. / (fan_in + fan_out)),
size=(fan_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def phasefold(t, P, t0, starting_phase=-0.5):\n t = np.array(t)\n dt = t0shft( np.array(t), P, t0)\n tshift = t + dt\n t_phasefold = np.mod(tshift - starting_phase*P, P) + starting_phase * P\n phase = t_phasefold / P\n cycle = np.floor(tshift/P - starting_phase).astype(int)\n return t_phasefol... | [
"0.57427216",
"0.5517094",
"0.531438",
"0.5293937",
"0.52501124",
"0.5207172",
"0.5200721",
"0.51790994",
"0.5178072",
"0.5168876",
"0.5124565",
"0.5105001",
"0.50900114",
"0.50700676",
"0.50423545",
"0.50392187",
"0.5019811",
"0.50197685",
"0.5018847",
"0.5014742",
"0.500329... | 0.59560907 | 0 |
This method is intended to create a new group element after the initial installation is complete. It will create a file containing the group and job selection/matchin criteria. This can then be manually merged into the existing frontend configuration file. | def get_new_config_group(self):
filename = "%(config_dir)s/%(group)s.%(time)s" % \
{ "config_dir": self.config_dir(),
"group": self.group_name(),
"time": common.time_suffix(),}
common.write_file("w", 0o644, filename, self.get_match_criteria()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def createMainGroup(self):\n\t\tmc.group( n = self.grp.name, em = True )",
"def createGroup(self, name):\n new_group = ET.SubElement(self._root,'group')\n group_name = ET.SubElement(new_group, 'name')\n group_name.text = name\n # update the document's groups\n self._groups = self._root.findall('gr... | [
"0.64204746",
"0.6273165",
"0.609973",
"0.58930635",
"0.58930635",
"0.585004",
"0.58285666",
"0.5814239",
"0.58060133",
"0.57745683",
"0.5757875",
"0.575727",
"0.5730281",
"0.5723413",
"0.5714178",
"0.5712287",
"0.56967247",
"0.5644694",
"0.56357884",
"0.5604819",
"0.5562929"... | 0.67966115 | 0 |
Return the value for a given MC sample, energy or year, and information type If information is stored for both an energy and a year, the value for the given energy will be preferentially returned. If strict checking is turned on the function will raise an error if a given dictionary or piece of information isn't found.... | def get_value(self, name, energy, year, key, strict=False):
fields = [self.__key_field_map[key][0]+"_"+energy,self.__key_field_map[key][0]+"_"+year]
if not name in self.__values_dict:
raise KeyError("ERROR MCSampleValuesHelper::Unknown process \"" + str(name) + "\"")
if not key in se... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def value(self,pt,eta,mode):\n\n self._eta_range= get_eta_key(eta)+'_2012B'\n self._pt_range= get_pt_key(pt)\n\n if mode == '0' :\n return self._map['DoubleMu17Mu8_Mu8_Tight'][self._eta_range][self._pt_range]['data']['efficiency'] \n elif mode == '+1' :\n return self._map['DoubleMu1... | [
"0.54123473",
"0.5368775",
"0.5330085",
"0.50552213",
"0.50486755",
"0.5037508",
"0.49840373",
"0.4980758",
"0.4962545",
"0.49597347",
"0.4958092",
"0.49424076",
"0.49341348",
"0.49290487",
"0.49097136",
"0.48970246",
"0.48856208",
"0.48642394",
"0.4853736",
"0.48443174",
"0.... | 0.6362816 | 0 |
Returns a dictionary of portfolio weights. | def centrality_to_portfolio_weights(weights):
# iterates over the key, value pairs in the weights dict
for key, value in weights.items():
# takes the inverse of the communicability betweeness centrality of each asset
weights[key] = 1/value
# normalization parameter for all weights to add ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def current_portfolio_weights(self) -> 'pd.Series[float]':\n position_values = pd.Series({\n asset: (\n position.last_sale_price *\n position.amount *\n asset.price_multiplier\n )\n for asset, position in self.position... | [
"0.7302032",
"0.688067",
"0.6818489",
"0.67349046",
"0.6629948",
"0.65233266",
"0.6515393",
"0.6515393",
"0.6515393",
"0.6515393",
"0.6513552",
"0.6513552",
"0.6500232",
"0.6500232",
"0.6455062",
"0.6455062",
"0.6455062",
"0.6455062",
"0.6455062",
"0.64438415",
"0.64048874",
... | 0.698716 | 1 |
Returns the cumulative returns of a portfolio. | def cumulative_returns(shares_allocation, capital, test_data):
# list of DataFrames of cumulative returns for each stock
daily_returns = []
# iterates over every stock in the portfolio
for stock in shares_allocation.index:
# multiples shares by share prices in the validation dataset
d... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cumulative_returns(self):\n return (1 + self.pct_change).cumprod()",
"def calculate_cumulative_returns_by_group(quantile_ret_ts: pd.DataFrame):\n # 1_period_return 5_period_return 10_period_return\n # factor_quantile Date\n # 1 2010-06-17 0.... | [
"0.80346304",
"0.7117688",
"0.7020555",
"0.68004584",
"0.6599235",
"0.65987766",
"0.65317065",
"0.6378568",
"0.6267627",
"0.61863387",
"0.6161118",
"0.61232454",
"0.61232454",
"0.6069886",
"0.60389215",
"0.6008858",
"0.5964947",
"0.5934377",
"0.591715",
"0.5849632",
"0.582511... | 0.76559335 | 1 |
Returns the end of year returns of a portfolio. | def end_of_year_returns(model_roi, return_type, start, end):
# converts index of datetimes to a list of strings
dates = model_roi.index.astype('str').tolist()
# list comprehension of a string of dates between the
# start and end dates
years = [str(x) for x in range(start, end + 1)]
# generate... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def end_year(self) -> float:\n\n end_year = -np.inf\n for td_table in list(self.tdve.values()) + self.transfers + self.interpops:\n if len(td_table.tvec) and np.amax(td_table.tvec) > end_year:\n end_year = np.amax(td_table.tvec)\n return end_year",
"def model_end_ye... | [
"0.66694117",
"0.6252978",
"0.5982185",
"0.5906132",
"0.59023",
"0.5769457",
"0.5755498",
"0.5709566",
"0.56960356",
"0.56714946",
"0.5662829",
"0.563564",
"0.55554664",
"0.5549461",
"0.5539725",
"0.5533944",
"0.54835814",
"0.5468832",
"0.5411401",
"0.5375918",
"0.536325",
... | 0.6676339 | 0 |
Returns average annual returns. | def avg_annual_returns(end_of_year_returns, mstat):
# imports mean stats
from scipy.stats import mstats
# converts returns dict to an array (in decimal fmt)
returns_arr = np.array(list(end_of_year_returns.values()))/100
if mstat == 'geometric':
# calculates the geometric mean
gme... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def annual_return(returns, period=DAILY):\n\n if returns.size < 1:\n return np.nan\n\n try:\n ann_factor = ANNUALIZATION_FACTORS[period]\n except KeyError:\n raise ValueError(\n \"period cannot be '{}'. \"\n \"Must be '{}', '{}', or '{}'\".format(\n ... | [
"0.7513993",
"0.7327938",
"0.7215449",
"0.6849367",
"0.6817595",
"0.68023896",
"0.66719836",
"0.66230255",
"0.6608608",
"0.6540497",
"0.64067215",
"0.6393488",
"0.6343028",
"0.6321957",
"0.63070506",
"0.62917763",
"0.6256154",
"0.6240215",
"0.61818576",
"0.60735667",
"0.60480... | 0.8158878 | 0 |
Returns the daily running 252day drawdown. | def daily_rolling_drawdown(cumulative_returns, rolling_max):
return (cumulative_returns / rolling_max) - 1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lifetime_max_drawdown(daily_drawdown):\n\n return round(daily_drawdown.min()*100, 2)",
"def _get_daily_drawing_prompt(self) -> str:\n\n site = urllib.request.urlopen(\n urllib.request.Request(\"https://reddit.com/r/SketchDaily/new\", headers={'User-Agent': 'Mozilla/5.0'}))\n site_... | [
"0.6324104",
"0.60545033",
"0.6035098",
"0.59931993",
"0.5970094",
"0.5958163",
"0.59536815",
"0.591748",
"0.5884653",
"0.5840686",
"0.57922554",
"0.56973386",
"0.5680856",
"0.5680856",
"0.5662309",
"0.56341743",
"0.5618964",
"0.5577764",
"0.55763453",
"0.55734617",
"0.556395... | 0.6346399 | 0 |
Returns the daily running 252day maximum daily drawdown. | def max_daily_rolling_drawdown(daily_drawdown, window=252, min_periods=1):
return daily_drawdown.rolling(
window=window,
min_periods=min_periods
).min() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lifetime_max_drawdown(daily_drawdown):\n\n return round(daily_drawdown.min()*100, 2)",
"def max_drawdown_date(self) -> dt.date:\n mdd_date = (self.tsdf / self.tsdf.expanding(min_periods=1).max()).idxmin().values[0].astype(dt.datetime)\n return dt.datetime.fromtimestamp(mdd_date / 1e9).date()... | [
"0.8053372",
"0.7309904",
"0.7136397",
"0.6945596",
"0.66620314",
"0.65847397",
"0.65381736",
"0.6391821",
"0.623571",
"0.61597496",
"0.59037566",
"0.5875009",
"0.5865871",
"0.58287054",
"0.5795373",
"0.5767846",
"0.57399833",
"0.56995285",
"0.5673958",
"0.56637424",
"0.56529... | 0.7519542 | 1 |
Returns the lifetime maximum drawdown. | def lifetime_max_drawdown(daily_drawdown):
return round(daily_drawdown.min()*100, 2) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def MaxLifetime(self):\r\n\t\treturn self._get_attribute('maxLifetime')",
"def max_age(self):\n return 120 if self.realtime else 1800",
"def max(self):\n\n return time_stat(self, stat=\"max\")",
"def max_frame_age(self) -> float:\n return self._max_frame_age",
"def max_time(self):\n ... | [
"0.70438933",
"0.6749617",
"0.6718662",
"0.6696578",
"0.6525013",
"0.64177185",
"0.6395959",
"0.63215995",
"0.6261537",
"0.6258824",
"0.6245386",
"0.61703086",
"0.6164336",
"0.6164336",
"0.6155133",
"0.6142087",
"0.6137692",
"0.6115013",
"0.60518104",
"0.60164064",
"0.5985856... | 0.7830443 | 0 |
Construct an ESL Receipt. | def __init__(self, db: DB, values: list, user_id: int) -> None:
super(ESLReceipt, self).__init__()
self.db = db
self.transaction_number = values[0]
self.date = format_date(values[1])
self.description = values[2]
self.memo = values[3]
self.amount_debit = values[4]... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def work_order_receipt_create(self, work_order_id, worker_id,\n worker_service_id,\n requester_id,\n receipt_create_status,\n work_order_request_hash,\n id=None):\n pass",
"def _generate_cybersource_sa_payload(*, order, receipt_url, cancel_url, ip_address):\n # http:/... | [
"0.6053351",
"0.60198313",
"0.5788419",
"0.57612604",
"0.57396764",
"0.56825536",
"0.5476821",
"0.54742515",
"0.54360664",
"0.5352504",
"0.5342289",
"0.53357846",
"0.53357846",
"0.53352183",
"0.5319554",
"0.5299511",
"0.52830905",
"0.52596617",
"0.52482724",
"0.52446",
"0.519... | 0.6187345 | 0 |
Insert this receipt into the database as well as inserting it into the transactions table, if a transaction. | def insert_to_db(self) -> None:
query = '''INSERT INTO ESLReceipts(Transaction_Number, Date, Description, Memo,
Amount_Debit, Amount_Credit, Balance, Check_Number,
Fees, Card_Type, Is_Payment, Is_Transaction, User_id)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def insert(self):\n self.getDbRecord().insert()\n\n return",
"def send_to_db(ck_transactions):\n db = DDDB()\n\n db.add_orders(ck_transactions)",
"def insert(self, sql):\n try:\n # Execute the SQL command\n self.cursor.execute(sql)\n # Commit your cha... | [
"0.6211693",
"0.6090155",
"0.59534514",
"0.5747204",
"0.5717745",
"0.57042015",
"0.57042015",
"0.57042015",
"0.56759435",
"0.5658691",
"0.5618459",
"0.56082004",
"0.5607029",
"0.56063724",
"0.5585733",
"0.5573718",
"0.55546314",
"0.5539944",
"0.5531392",
"0.5496173",
"0.54764... | 0.8284341 | 0 |
Set a Source class from the input | def _set_source(source, context):
if isinstance(source, (str, list, dict, Dataset)):
return Source(source, context)
elif isinstance(source, Source):
return source
else:
raise ValueError('Wrong source') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, source):\n self._source = source",
"def SphinxDummySourceClass(source: Any, *args: Any, **kwargs: Any) -> Any:\n return source",
"def __init__(self, source):\r\n self.source = source",
"def __init__(self, source):\n self.source = source",
"def __init__(self, sourc... | [
"0.67583483",
"0.67401874",
"0.66732496",
"0.6669555",
"0.6669555",
"0.65352905",
"0.65030694",
"0.63952017",
"0.6294075",
"0.6294075",
"0.6294075",
"0.6294075",
"0.6294075",
"0.6294075",
"0.6294075",
"0.62846047",
"0.62708694",
"0.6204473",
"0.61683613",
"0.61246663",
"0.608... | 0.72986305 | 0 |
Set a Style class from the input | def _set_style(style):
if isinstance(style, (str, dict)):
return Style(style)
elif isinstance(style, Style):
return style
else:
return Style() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_style(self):",
"def set_style(self, style):\n if isinstance(style, string_types):\n style = get_style_by_name(style)\n self._style = style\n self._clear_caches()",
"def style(self, style):\n\n self.container['style'] = style",
"def update_css_class(kwargs, class... | [
"0.654943",
"0.63310474",
"0.6265196",
"0.6194581",
"0.61655325",
"0.61655325",
"0.61425185",
"0.6124288",
"0.6023133",
"0.60221726",
"0.6001759",
"0.59781164",
"0.59699464",
"0.5902382",
"0.58698934",
"0.58513117",
"0.5782348",
"0.57525957",
"0.57379335",
"0.573579",
"0.5732... | 0.6732158 | 0 |
Set a Popup class from the input | def _set_popup(popup):
if isinstance(popup, dict):
return Popup(popup)
elif isinstance(popup, Popup):
return popup
else:
return Popup() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_popup(self):\n self.popup = Popup(Point(0, 2), self, \"\", \"\")\n self.popup.set_highlight_color(self.graphics.HIGHLIGHT)\n self.popup.set_secondary_color(self.graphics.DIM)\n title_color = self.graphics.BRIGHT | self.graphics.UNDERLINE\n self.popup.set_title_color(titl... | [
"0.63107663",
"0.6060422",
"0.5535878",
"0.52886254",
"0.52468014",
"0.52125245",
"0.51682144",
"0.5146479",
"0.5079666",
"0.50717413",
"0.50559866",
"0.5050433",
"0.49416202",
"0.4940349",
"0.48901185",
"0.4874202",
"0.48704216",
"0.48458034",
"0.4833469",
"0.47811547",
"0.4... | 0.6512138 | 0 |
Set a Legend class from the input | def _set_legend(legend):
if isinstance(legend, dict):
return Legend(legend)
elif isinstance(legend, Legend):
return legend
else:
return Legend() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def legend(self, legend):\n\n self.container['legend'] = legend",
"def legend(self, legend):\n\n self._legend = legend",
"def legend (self, **kwargs):\n axes = self.twin_axes or self.axes\n self.mpl_legend = axes.legend (self.mpl_lines, self.labels, **kwargs)",
"def finish (self, ... | [
"0.6538302",
"0.64451087",
"0.63078874",
"0.60143113",
"0.5830607",
"0.5821305",
"0.5782544",
"0.5664723",
"0.5637923",
"0.55676806",
"0.5538643",
"0.55200446",
"0.5487594",
"0.54669875",
"0.54185116",
"0.54073274",
"0.5400403",
"0.53886503",
"0.53818643",
"0.53346527",
"0.53... | 0.67842346 | 0 |
generates a list of dice values into the class attribute dice. Increments throw number attribute. | def throw_dice(self):
self.dice = []
for i in range (6):
die = random.randint(1, 6)
self.dice.append(die)
self.num_throws += 1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def roll_dice():\n rolled_number = []\n for number in range(0,4):\n rolled_number.append(random.randint(1, 6))\n \n rol\n \n \n class Dog():\n def __init__(self, name, age):\n self.name = name",
"def rollDices():\n for i in range(5):\n dices[i] = randint(1,... | [
"0.7211979",
"0.6997264",
"0.6851038",
"0.6751333",
"0.6729713",
"0.668519",
"0.6677819",
"0.66247433",
"0.65643424",
"0.6544101",
"0.6543014",
"0.6510373",
"0.6505515",
"0.6487591",
"0.6461432",
"0.6459857",
"0.64389354",
"0.6434398",
"0.64102566",
"0.6345126",
"0.63131344",... | 0.73881346 | 0 |
Calculates points from current dice roll. | def get_points(self):
self.round_points = 0
for die in self.dice:
if die == 1:
self.round_points += 100
elif die == 5:
self.round_points += 50
return self.round_points | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def assign_points(self, dice):\n if not self.assigned:\n self._assigned = True\n self._points = self._calculate_points(dice)",
"def calculate_points(self):\n points = 0\n for power in self.stats['powers']:\n points += self.stats['powers'][power]\n retu... | [
"0.66966766",
"0.66681296",
"0.6637562",
"0.65762514",
"0.6406548",
"0.62852454",
"0.6266145",
"0.6250244",
"0.62489074",
"0.6243738",
"0.615768",
"0.6100919",
"0.60981864",
"0.60895824",
"0.608306",
"0.6028972",
"0.59434074",
"0.5937676",
"0.5882016",
"0.5868866",
"0.5841612... | 0.7415062 | 0 |
Calcualtes the name of the currency using the initials. | def currency_name(self, init):
c2 = CurrencyCodes()
c_name = c2.get_currency_name(init)
return c_name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def currency_word(self):\n result = \" \"\n for cr in self:\n if cr.currency_id.name == 'USD':\n result = \" Dollar\"\n elif cr.currency_id.name == 'EUR':\n result = \" Euro\"\n elif cr.currency_id.name == 'JPY':\n result =... | [
"0.6545595",
"0.65187955",
"0.6400594",
"0.61858106",
"0.6183995",
"0.5940923",
"0.5884641",
"0.58576405",
"0.57543",
"0.5593448",
"0.55822915",
"0.5562207",
"0.55397344",
"0.5527879",
"0.5522243",
"0.55098426",
"0.54883844",
"0.54776466",
"0.54487824",
"0.54059935",
"0.53924... | 0.73644185 | 0 |
Calculates the latest rate for the currency at hand. | def currency_rate(self, init):
curr = CurrencyRates()
curr_rate = curr.get_rates(init)
return curr_rate | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def exchange_rate(self):\n res = r.get(self.url + self.current_rate)\n return self.execute(res)",
"def get_current_rate(self):\n pass",
"def update(self):\n self.rate = self.exchange.latest()",
"def api_call(cls, currency):\n headers = {\"x-accept-version\": \"2.0.0\", \"Ac... | [
"0.7194681",
"0.7087124",
"0.7015733",
"0.6857771",
"0.6801177",
"0.6785793",
"0.66941553",
"0.66645527",
"0.66415185",
"0.6638817",
"0.6485171",
"0.6424446",
"0.6401379",
"0.63694507",
"0.63674176",
"0.633374",
"0.6300826",
"0.628026",
"0.62679833",
"0.62639594",
"0.62147737... | 0.713497 | 1 |
Calculates the latest conversion rate for the currency at hand. | def conversion_rate(self, init, new_currency):
curr = CurrencyRates()
curr_conv_rate = curr.get_rate(init, new_currency)
return curr_conv_rate | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def currency_rate(self, init):\r\n\r\n curr = CurrencyRates()\r\n curr_rate = curr.get_rates(init)\r\n return curr_rate",
"def get_currency_exchange_rate(self, from_currency, to_currency):\n _FUNCTION_KEY = 'CURRENCY_EXCHANGE_RATE'\n return _FUNCTION_KEY, 'Realtime Currency Exc... | [
"0.6993551",
"0.69812477",
"0.6692026",
"0.666445",
"0.6645402",
"0.6555873",
"0.6546272",
"0.6487058",
"0.64221525",
"0.6406838",
"0.64052564",
"0.6369392",
"0.6346241",
"0.63396156",
"0.63319975",
"0.6328635",
"0.6302605",
"0.6302515",
"0.618671",
"0.61817455",
"0.60828835"... | 0.74947244 | 0 |
Converts an amount from the currency at hand to a new currency. | def convert_amount(self, init, new_currency, amount):
curr = CurrencyRates()
curr_conversion = curr.convert(init, new_currency, amount)
return curr_conversion | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _convert(self, from_amount, to_currency, company, date, round=True):\n self, to_currency = self or to_currency, to_currency or self\n assert self, \"convert amount from unknown currency\"\n assert to_currency, \"convert amount to unknown currency\"\n assert company, \"convert amount... | [
"0.73006153",
"0.72782034",
"0.71290565",
"0.70164573",
"0.6842994",
"0.6626046",
"0.6571269",
"0.65345883",
"0.6460881",
"0.64539254",
"0.6389461",
"0.6372568",
"0.6338758",
"0.6223571",
"0.6182157",
"0.6140729",
"0.6137326",
"0.6085868",
"0.6061959",
"0.6049651",
"0.5981646... | 0.77393734 | 0 |
Calculates the relative symbol for the currency at hand. | def currency_symbol(self, init):
c2 = CurrencyCodes()
c_symbol = c2.get_symbol(init)
return c_symbol | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getCurrencySymbol():",
"def monetary_base(self, symbol):\n pass",
"def local_price(amount, currency):\n amt = convert(amount, currency)\n sym = symbol(currency)\n return f'{sym}{amt}'",
"def getBaseCurrency():",
"def getCurrencySymbol(id=None):",
"def create_symbol(self, base_ccy, ass... | [
"0.7532425",
"0.61583894",
"0.6051573",
"0.6010398",
"0.6007663",
"0.57941693",
"0.5785363",
"0.5702698",
"0.568727",
"0.5658896",
"0.5622147",
"0.5558757",
"0.5514153",
"0.5434841",
"0.5427567",
"0.54007",
"0.53848547",
"0.5369845",
"0.53468686",
"0.53214556",
"0.5318823",
... | 0.62263805 | 1 |
Checks whether or not an entered amount is valid. | def check_amount_validity(self, amount):
alert = "Not a valid amount. Please try again!"
if type(amount) == int or type(amount) == float:
return amount
else:
return alert | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _is_amount_valid(self):\n\t\tamount = self.entry_amount.get()\n\n\t\ttry:\n\t\t\tfloat(amount)\n\t\texcept ValueError:\n\t\t\tmessagebox.showerror(\"Invalid Amount\", \"Amount must be a positive number\")\n\t\t\treturn False\n\n\t\tif float(amount) < 0:\n\t\t\tmessagebox.showerror(\"Invalid Amount\", \"Amount ... | [
"0.82144606",
"0.7673015",
"0.75659555",
"0.6944316",
"0.6673183",
"0.65760684",
"0.6559131",
"0.6552635",
"0.6488286",
"0.64840955",
"0.6429893",
"0.6422951",
"0.6412067",
"0.6382808",
"0.63355726",
"0.63257205",
"0.6321893",
"0.63069206",
"0.626406",
"0.62407017",
"0.621087... | 0.78239405 | 1 |
featuresn least square method impletement Use sum of square error function which aroses in the maximum likehood to get liner regression param set w for supervised learning. To control overfitting, use lmd for regularization. | def least_square(features, values, w, lmd=None, regularizer=2):
if lmd == None:
lmd = 0
size = len(values)
R = lmd * eye(len(features[0, :]))
# solve the equation features'*features*w=features'b
w = linalg.solve(R+dot(features.T, features), dot(features.T, values))
return w | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def learn(self, Xtrain, ytrain):\n pass\n self.weights = np.zeros(Xtrain.shape[1],)\n\n ### YOUR CODE HERE\n \n lmbd = self.params['lamb']\n \n numsamples = Xtrain.shape[0]\n # Xless = Xtrain[:,self.params['features']]\n Xless = Xtrain\n self.we... | [
"0.59811664",
"0.59792453",
"0.5977199",
"0.5910014",
"0.57902515",
"0.57429147",
"0.5736021",
"0.5726675",
"0.5687944",
"0.55737907",
"0.55421764",
"0.55418295",
"0.5539954",
"0.5535652",
"0.5524679",
"0.5473309",
"0.5462243",
"0.54486495",
"0.5445677",
"0.54421",
"0.5438471... | 0.63457775 | 0 |
create_settings root_directory root directory of program"path/to/root" files files to be observed[files,...] variables variables to be observed[Variable,...] main_file main file of program"relative/path/from/root/to/main" output where to store PEL output "path/to/store/output" | def create_settings(root_directory, files, variables, main_file, output):
files = [format_path(f) for f in files]
variables = format_variables(variables)
settings = {
SETTINGS_ROOTDIR : root_directory if root_directory.endswith('/') else root_directory+'/',
SETTINGS_FILES : files,
SETTINGS_VARIABLES : variable... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup_files(args):\n postfix = 'reinforce'\n has_value_model = False\n if args.baseline:\n postfix = \"reinforce-baseline\"\n has_value_model = True\n elif args.actor_critic:\n postfix = \"actor-critic\"\n has_value_model = True\n elif args.a2c:\n postfix = \"a... | [
"0.61745477",
"0.61673695",
"0.6149942",
"0.6126735",
"0.59460837",
"0.59423786",
"0.5937718",
"0.5911535",
"0.58622587",
"0.5852425",
"0.5816493",
"0.5807516",
"0.57808864",
"0.5754789",
"0.5721028",
"0.5715072",
"0.57069653",
"0.5706456",
"0.5699024",
"0.56912315",
"0.56876... | 0.7556358 | 0 |
Initialize the output dict | def init_output_dict(self):
return {
"outputs": torch.FloatTensor(),
"pred_probs": torch.FloatTensor(),
"labels": torch.LongTensor(),
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _populate_output(self):\n pass",
"def initialize_output_dict(self, label: Optional[str] = None):\n if label is not None or not self._does_output_dict_contain_info():\n for species in self.species_list:\n if label is None or species.label == label:\n ... | [
"0.7403707",
"0.7319638",
"0.719789",
"0.718091",
"0.6895616",
"0.6818378",
"0.6713962",
"0.66572535",
"0.6627214",
"0.6627214",
"0.6626906",
"0.6612285",
"0.6525927",
"0.651021",
"0.6355464",
"0.6314832",
"0.63007283",
"0.6230506",
"0.62086916",
"0.61997986",
"0.61873674",
... | 0.7332433 | 1 |
Compute epoch statistics after an epoch of training using an output_dict. | def compute_epoch_statistics(self, output_dict):
epoch_statistics = {
"auc": roc_auc_score(
output_dict["labels"].cpu().numpy(),
output_dict["pred_probs"][:, 1].cpu().numpy(),
),
"auprc": average_precision_score(
output_dict["la... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def training_epoch_end(self, outputs: Any) -> None:\n self.log_dict(self.train_metrics.compute())\n self.train_metrics.reset()",
"def validation_epoch_end(self, outputs):\n avg_loss = torch.stack([x['val_loss'] for x in outputs]).mean()\n val_acc = sum([x['n_correct_pred'] for x in ou... | [
"0.7093068",
"0.6828395",
"0.6732253",
"0.669807",
"0.669807",
"0.6676033",
"0.6524682",
"0.64946216",
"0.6488606",
"0.6488606",
"0.63934577",
"0.6391537",
"0.63756627",
"0.6371239",
"0.63657916",
"0.63108504",
"0.62925154",
"0.6290336",
"0.62839675",
"0.6260386",
"0.6257214"... | 0.82542735 | 0 |
Print method for a dictionary containing logged metrics | def print_metric_dict(self, metric_dict):
print("".join([" {}: {:4f},".format(k, v) for k, v in metric_dict.items()])) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def log_dict(dict_to_print: dict, message: str = ''):\n for k1, v1 in dict_to_print.items():\n log.info(f'{message} {k1}: {v1} ')\n print(f'{message} {k1}: {v1} ')",
"def print_metrics(result):\n logging.log(LOG_LEVEL_OUTPUT_INFO,\n '------------------------------------------------... | [
"0.68076295",
"0.6793415",
"0.6780916",
"0.66786313",
"0.66669387",
"0.6662592",
"0.6627376",
"0.64810866",
"0.6405025",
"0.64022094",
"0.6373481",
"0.6365978",
"0.6318629",
"0.6294091",
"0.6287451",
"0.6203851",
"0.6132739",
"0.6093371",
"0.60847807",
"0.60809046",
"0.607914... | 0.7865434 | 0 |
Convert an output_dict to numpy | def finalize_output_dict(self, output_dict):
return {key: output_dict[key].cpu().numpy() for key in output_dict.keys()} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _dict2arr(self, key):\r\n # Prepare the matrix for the output:\r\n arr = np.empty((self._n_process,\r\n self._n_process,\r\n self.frequencies.shape[0]))\r\n\r\n arr.fill(np.nan)\r\n\r\n # 'Translate' from dict form into matrix form:\r\n ... | [
"0.65616953",
"0.649378",
"0.6439087",
"0.6342832",
"0.6280157",
"0.62757164",
"0.6249945",
"0.6249945",
"0.6249945",
"0.6222419",
"0.62178284",
"0.6200131",
"0.6184096",
"0.6082242",
"0.6074912",
"0.5980199",
"0.5936356",
"0.59348",
"0.59199387",
"0.59100753",
"0.5909368",
... | 0.708859 | 0 |
Make segment from depth with maintaining autograds | def _depth_to_segment(self, depth):
segment = depth.clone()
segment[segment > 0] = 1
return segment | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_segments(self, set_depth=True, input_rec_track=None,\r\n overwrite_rec_seg=False): \r\n grd = self.grd\r\n if input_rec_track is None:\r\n rec_track = self.rec_track\r\n else:\r\n rec_track = input_rec_track\r\n ndetects = len(rec_trac... | [
"0.6346272",
"0.55502045",
"0.53198504",
"0.5308074",
"0.52996415",
"0.5294643",
"0.52734846",
"0.52599484",
"0.5258782",
"0.52077454",
"0.5194362",
"0.51922286",
"0.51793945",
"0.5163334",
"0.5136648",
"0.51229006",
"0.51084447",
"0.5101351",
"0.5093862",
"0.50675523",
"0.50... | 0.68593705 | 0 |
The update command can be called, requesting a requirements update. | def test_update_with_requirements(update_command, first_app, second_app):
# Configure a requirements update
options = update_command.parse_options(["-r"])
update_command(**options)
# The right sequence of things will be done
assert update_command.actions == [
# Host OS is verified
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cmd_update(self):\n self.update_repository()\n results = self.results.getvalue()\n if results:\n print('---')\n print(results, end='')",
"def update(self, **kwargs):\n self.configure(**kwargs)\n self.get_all_requirements()\n self.apply_updates(\... | [
"0.7011183",
"0.6856793",
"0.6732378",
"0.6684744",
"0.66132265",
"0.65518045",
"0.65518045",
"0.65518045",
"0.6539952",
"0.6523198",
"0.64990246",
"0.6492051",
"0.648081",
"0.64599496",
"0.6453116",
"0.63374",
"0.63153756",
"0.6298275",
"0.6262488",
"0.6257006",
"0.62292224"... | 0.6955482 | 1 |
[Not Anymore] DFSbased enumeration of each possible numset This is just brute force right now, will find faster way to do it later. | def generateNumsets(G):
# paths = []
#
# path = [0]
# for edge in nx.dfs_edges(G, 0):
# if edge[0] == path[-1]:
# path.append(edge[1])
# else:
# paths.append(path)
# search_index = 2
# while search_in... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def beautifulSubsets(self, nums: List[int], k: int) -> int:\n\n \"\"\"\n queue = deque([([], -1)])\n res = 0\n\n while queue:\n cur, idx = queue.popleft()\n res += 1\n\n for i in range(idx + 1, len(nums)):\n if nums[i] - k in cur or nums[i... | [
"0.6050747",
"0.58646107",
"0.5835313",
"0.5814192",
"0.5803843",
"0.57862395",
"0.56802076",
"0.565998",
"0.56545377",
"0.5646759",
"0.56391",
"0.56056905",
"0.56009036",
"0.557824",
"0.55607307",
"0.55480886",
"0.55398595",
"0.553104",
"0.55174726",
"0.5494305",
"0.5489702"... | 0.60728484 | 0 |
Choose the entity from the `ent_inds` which exactly matches the entity name in terms of ngram tfidf vector | def __vote_best_entity(self, ent_inds, scores, phrase):
sorted_scores = [(k, v) for k, v in
sorted(scores.items(), key=lambda s: s[1], reverse=True)]
phrase_vec = self.vectorizer.transform([phrase])
if self.args.use_mm_subset:
tfidf_cossim = linear_kernel(ph... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_entity(text_raw, id_, predictions, tok_to_orig_start_index,\n tok_to_orig_end_index):\n entity_list = []\n for i in range(len(predictions)):\n if [id_] in predictions[i]:\n j = 0\n while i + j + 1 < len(predictions):\n if [1] in predictions[... | [
"0.59135014",
"0.5836269",
"0.5584508",
"0.55675554",
"0.54100394",
"0.53996557",
"0.5396855",
"0.53903174",
"0.5357121",
"0.5339213",
"0.5294186",
"0.52863014",
"0.52570397",
"0.52552134",
"0.5253027",
"0.5250587",
"0.52390045",
"0.5228001",
"0.52206033",
"0.5211869",
"0.520... | 0.5915391 | 0 |
Generates a class which raises an import error when initialised. e.g. SomeClass = missing_import('SomeClass') will make SomeClass() raise ImportError | def missing_import(name, fail_msg=''):
def init(self, *args, **kwargs):
raise ImportError(
f'The class {name} you tried to call is not importable; '
f'this is likely due to it not doing installed. '
f'{f"Fail Message: {fail_msg}" if fail_msg else ""}'
)
return... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def import_class(import_str):\n mod_str, _sep, class_str = import_str.rpartition('.')\n try:\n __import__(mod_str)\n return getattr(sys.modules[mod_str], class_str)\n except (ImportError, ValueError, AttributeError), exc:\n logging.debug('Inner Exception: %s', exc)\n raise",
... | [
"0.6505684",
"0.6362478",
"0.62814814",
"0.6249061",
"0.6086552",
"0.60478055",
"0.60290587",
"0.60029995",
"0.5892807",
"0.586532",
"0.57888514",
"0.5755527",
"0.5744472",
"0.5704701",
"0.56653976",
"0.56465465",
"0.55793685",
"0.5562586",
"0.55564654",
"0.5541481",
"0.55187... | 0.71129656 | 0 |
Tournament Method Divide the array into two parts and compare the maximums and minimums of the two parts to get the maximum and the minimum of the whole array. | def getminmax_tournament(arr, low, high):
if low == high:
return arr[low], arr[low]
if abs(low - high) == 1:
min_num = None
max_num = None
if arr[low] > arr[high]:
max_num = arr[low]
min_num = arr[high]
else:
max_num = arr[high]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def min_max(arr, arr_size):\n max_t = arr[0]\n min_t = arr[0]\n for i in range(arr_size):\n if arr[i] > max_t:\n max_t = arr[i]\n if arr[i] < min_t:\n min_t = arr[i]\n return min_t, max_t",
"def tournament( pl, game ):\r\n\tlosses=[0... | [
"0.6058381",
"0.55852354",
"0.5572735",
"0.5561582",
"0.54773295",
"0.5432018",
"0.5413174",
"0.53873384",
"0.5380784",
"0.537343",
"0.53635126",
"0.5344056",
"0.53209466",
"0.53140825",
"0.53017104",
"0.5293402",
"0.5270293",
"0.52500576",
"0.5192956",
"0.5190301",
"0.518893... | 0.68295705 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.