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 |
|---|---|---|---|---|---|---|
Returns the result of NoneToEmptyQuerySet instead of a regular QuerySet. | def get_queryset(self):
return NoneToEmptyQuerySet(self.model, using=self._db) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def none(self):\n clone = self._chain()\n clone.query.set_empty()\n return clone",
"def query_none(self):\n return multisearch.queries.QueryNone().connect(self)",
"def get_inititially_selected_queryset(self):\n return self.model.objects.none()",
"def queryset(cls):\n ... | [
"0.7153786",
"0.6839473",
"0.67798024",
"0.65623015",
"0.6502179",
"0.64747626",
"0.639812",
"0.62542117",
"0.62088317",
"0.6175962",
"0.612903",
"0.61209935",
"0.6069687",
"0.6062007",
"0.603136",
"0.603136",
"0.6014894",
"0.6001097",
"0.5988454",
"0.59800255",
"0.5971937",
... | 0.81059086 | 0 |
Returns patients national_register number. | def get_patient_nr(segment):
try:
national_register = str(segment[19])
except IndexError:
nr_list = segment[2:5]
national_register = [nr for nr in nr_list if str(nr) is not ""].pop()[0]
national_register = str(national_register).split("^")[0]
return national_register | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def NationalId(self, reg_national_id = VALUE_NOT_SET):\n if reg_national_id != VALUE_NOT_SET:\n self.__reg_national_id = reg_national_id\n try:\n self.__contact.AdditionalInfo().NationalId(self.__reg_national_id)\n except:\n pass\n else:\... | [
"0.66016203",
"0.6289969",
"0.6102104",
"0.5900346",
"0.5710991",
"0.55914414",
"0.5551875",
"0.5381666",
"0.5263739",
"0.52501005",
"0.52330846",
"0.5195872",
"0.5188023",
"0.5176298",
"0.5157799",
"0.5137127",
"0.51337564",
"0.51201624",
"0.50747806",
"0.5074338",
"0.505832... | 0.73100704 | 0 |
generate number of nonrepeated integers from start_num to total_nums returns an array random_sampling(10, 5) >>> [7 2 8 1 6] random_sampling(10, 5) >>> [7 4 9 5 10] | def random_sampling(total_nums: int, samples_needed: int, start_num=1):
target = np.arange(start_num, total_nums + 1)
np.random.shuffle(target)
return target[:samples_needed] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sample(self, start: typing.Any, num: int) -> typing.List[typing.Any]:\r\n\r\n if num >= len(self.values):\r\n return self.values.copy()\r\n\r\n if start is None:\r\n sample_inds = np.random.choice(len(self.values), (num,), replace=False)\r\n result = []\r\n ... | [
"0.6939259",
"0.6853743",
"0.6727879",
"0.65090746",
"0.62980384",
"0.6265991",
"0.6237015",
"0.62102294",
"0.6175416",
"0.6145259",
"0.61196",
"0.61109567",
"0.60812664",
"0.60556835",
"0.60154754",
"0.6010604",
"0.60057276",
"0.5926939",
"0.58962446",
"0.58557844",
"0.58265... | 0.8022756 | 0 |
check whether the unit is in the lst | def _is_unit_in(unit, lst):
unit = unit.lower()
for target_unit in lst:
if unit == target_unit.lower():
return target_unit
return '' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isValidUnit(unit):\n\tfor i in Units:\n\t\tif (unit == i):\n\t\t\treturn True;\n\treturn False",
"def sublist_in(lst, sublst):\n for i in sublst:\n if i not in lst:\n return False\n return True",
"def in_list(value, arg):\r\n return value in arg",
"def _listCont... | [
"0.6937849",
"0.6817708",
"0.65098494",
"0.6484",
"0.63293135",
"0.6287344",
"0.62683535",
"0.6236008",
"0.62134445",
"0.62023246",
"0.61684275",
"0.6140249",
"0.61158067",
"0.6043543",
"0.5986853",
"0.59752864",
"0.59732264",
"0.5959892",
"0.5944591",
"0.5905",
"0.58932436",... | 0.8387957 | 0 |
Send request to Google Drive API for getting link for file upload. | def get_upload_link(self, file_path: Path, parent_id="root") -> str:
headers = {
"X-Upload-Content-Type": mimetypes.guess_type(file_path)[0]
}
headers.update(self._auth_headers)
metadata = {"name": file_path.name}
if parent_id is not None:
metadata["parent... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def upload_and_get_url(file_to_upload, extension):\n\timport string, random\n\tfilename = binascii.b2a_hex(os.urandom(30))+extension\n\tput = client.put_file(filename, file_to_upload) \n\tshare = client.share(filename, short_url=False)\n\treturn {'url':share['url'].replace('https://www.dropbox.com/', 'https://dl.d... | [
"0.629661",
"0.59118974",
"0.5861336",
"0.5785015",
"0.56854594",
"0.5671264",
"0.5643907",
"0.55771196",
"0.55718833",
"0.5571333",
"0.55160505",
"0.5500681",
"0.5444948",
"0.542816",
"0.54246205",
"0.5399978",
"0.5399548",
"0.5388684",
"0.5385448",
"0.5375895",
"0.53526807"... | 0.67060584 | 0 |
Tails nginx access log. | def log_access():
# todo use project prefix
tail('/var/log/nginx/access.log') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def log_error():\n # todo use project prefix\n tail('/var/log/nginx/error.log')",
"def access(self, resp, req, environ, request_time):\n if not (self.cfg.accesslog or self.cfg.logconfig or self.cfg.syslog):\n return\n\n msg = self.make_access_message(resp, req, environ, request_tim... | [
"0.71649444",
"0.6020338",
"0.5839621",
"0.57444555",
"0.570898",
"0.56940126",
"0.5615497",
"0.548707",
"0.5479375",
"0.5444182",
"0.54207987",
"0.54116344",
"0.5401756",
"0.5399951",
"0.5395875",
"0.53851336",
"0.5339138",
"0.53042936",
"0.5286223",
"0.5286223",
"0.5274661"... | 0.86370623 | 0 |
Tails nginx error log. | def log_error():
# todo use project prefix
tail('/var/log/nginx/error.log') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def log_access():\n # todo use project prefix\n tail('/var/log/nginx/access.log')",
"def log_error(err):\n print(err)",
"def error(log):\n write(syslog.LOG_ERR, 'error', '{log}'.format(log=log))",
"def server_error(request):\n return defaults.server_error(request, template_name=get_templat... | [
"0.6549008",
"0.62931883",
"0.61826575",
"0.6105795",
"0.6037308",
"0.6025911",
"0.60161215",
"0.60078406",
"0.59673744",
"0.59673744",
"0.5940494",
"0.59188306",
"0.5908574",
"0.5888863",
"0.5888863",
"0.58471155",
"0.58282167",
"0.58250487",
"0.5820823",
"0.5817737",
"0.580... | 0.856961 | 0 |
Bootstraps nginx for the project. | def bootstrap():
nginx_config = path.join(get_paths(NAME_CONFIGS_DIR)[1], 'nginx.conf')
path_sites = '/etc/nginx/sites-enabled/'
rm(path.join(path_sites, 'default'), use_local=False)
sudo(get_symlink_command(nginx_config, '%s%s.conf' % (path_sites, PROJECT_NAME)))
reload() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def nginx(self):\n self.summarize_operation(\"Installing Nginx Web Server\")\n self.install_package(\"nginx\")",
"def setup():\n print(cyan('Configuring nginx on {}'.format(env.stage)))\n context = {\n 'ssl_letsencrypt': False,\n 'ssl_with_dhparam': False,\n 'ssl_cert': N... | [
"0.6946683",
"0.68339086",
"0.6736881",
"0.6537954",
"0.63398385",
"0.63153815",
"0.62829506",
"0.6135878",
"0.6111358",
"0.60804033",
"0.602504",
"0.60229063",
"0.5952751",
"0.59519655",
"0.5951644",
"0.58362174",
"0.58080506",
"0.5803091",
"0.5800632",
"0.5778559",
"0.57421... | 0.76118577 | 0 |
Attaches a parse action to an item. | def attach(action, item):
return _coconut_tail_call(item.copy().addParseAction, action) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_action(self, action):\n self.action = action",
"def add_action(self, action):\n self.action = action",
"def add_action(self, action):\n self._main_model.add_action(action)",
"def add_process_action(self, item: BaseAction, name='operator'):\n assert isinstance(item, BaseAct... | [
"0.6405063",
"0.6405063",
"0.62307304",
"0.61999774",
"0.6091698",
"0.6010611",
"0.5912827",
"0.5909748",
"0.5814998",
"0.58144563",
"0.5787067",
"0.5750876",
"0.57430863",
"0.56694263",
"0.55672914",
"0.55672914",
"0.5532909",
"0.5463518",
"0.54311395",
"0.54271877",
"0.5420... | 0.8182464 | 0 |
Call an action on the tokens in item. | def call(action, item):
@_coconut_tco
def parse_action(o, l, tokens):
return _coconut_tail_call(action, *tokens)
return _coconut_tail_call(attach, parse_action, item) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def action(self,item):\r\n pass",
"def call_action(self, action):\n pass",
"def perform_action(self, action):\n method_name = action.text().lower()\n method_name = method_name + \"_action\"\n action_method = getattr(self, method_name)\n action_method()",
"def take_ac... | [
"0.6790572",
"0.65055597",
"0.6037865",
"0.5958701",
"0.5913648",
"0.58598894",
"0.5855038",
"0.5815457",
"0.57961285",
"0.5775933",
"0.5751238",
"0.57407653",
"0.5660209",
"0.56446564",
"0.56096655",
"0.56033003",
"0.55992115",
"0.55992115",
"0.55992115",
"0.55992115",
"0.55... | 0.67722493 | 1 |
Parses text using grammar. | def parse(grammar, text):
return _coconut_tail_call(grammar.parseWithTabs().parseString, text) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_grammar_parse():\n print u\"%s: Grammar test\" % (__file__, )\n print u\"Deriving grammar from parsed TIGER corpus sentences\"\n #tiger_corpus = TigerCorpusReader()\n tiger_corpus = _cached(None, CORPUS_PATH, TigerCorpusReader)\n grammar_parser = tiger_corpus.viterbi_parser(False)\n gram... | [
"0.7438956",
"0.6839297",
"0.6833501",
"0.6627518",
"0.6413575",
"0.63192075",
"0.6316696",
"0.62633437",
"0.6251801",
"0.6249832",
"0.6247163",
"0.624255",
"0.6229667",
"0.62108105",
"0.6172942",
"0.61631256",
"0.61048704",
"0.6097311",
"0.6084603",
"0.6068059",
"0.6064345",... | 0.71178925 | 1 |
Parses the given formula into an expression. | def expr(formula):
result = Grammar.formula.parseWithTabs().parseString(formula)
assert len(result) == 1, results
return result[0] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parseFormula(*args):\n return _libsbml.parseFormula(*args)",
"def parse_formula(formula, periodic_table_dict):\n assert isinstance(formula, str), \\\n \"wrong data type for parameter formula; \" \\\n f\"formula is a {type(formula)} but must be a string\"\n assert isinstance(periodic_tabl... | [
"0.7322546",
"0.7138543",
"0.7075242",
"0.6896647",
"0.6446701",
"0.63971233",
"0.63839394",
"0.6323644",
"0.61507833",
"0.6126146",
"0.61016905",
"0.6096829",
"0.60423255",
"0.5981129",
"0.59614676",
"0.5929405",
"0.5919705",
"0.59168255",
"0.5858516",
"0.5850218",
"0.581926... | 0.7608469 | 0 |
JB2008 is an empirical, global reference atmospheric model of the Earth from 90 km above the sea level to the exosphere up to 2500 km. A primary use of this model is to aid predictions of satellite orbital decay due to the atmospheric drag. | def jb2008(t,location,swdata):
lat,lon,h = location
t = Time(t,location=(str(lon)+'d',str(lat)+'d'))
AMJD = t.mjd
ydhms = np.array(t.yday.split(':'),dtype=float)
YRDAY = ydhms_days(ydhms)
sunpos = get_sun(t)
SUN = (sunpos.ra.rad,sunpos.dec.rad)
sat_ra = t.sidereal_time('mean').rad
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _compile_model(self):\n\n\t\t\t### GC90 atmospheric model implementation\n\t\t\n\t\t\ttheta_sun, beta, alpha, am, rh, pressure = T.scalars('theta_sun', 'beta', 'alpha', 'am', 'rh', 'pressure')\n\n\t\t\twl = T.vector('wl')\n\t\t\n\t\t\twl_a = 550\n\n\t\t\ttheta_sun_ = theta_sun * np.pi / 180.\n\n\t\t\tz3 = -0.1... | [
"0.6488767",
"0.5983394",
"0.58056504",
"0.5524639",
"0.53454745",
"0.532068",
"0.5257966",
"0.5216123",
"0.5214071",
"0.5205511",
"0.5180969",
"0.5176467",
"0.51307803",
"0.5106313",
"0.51051426",
"0.50993246",
"0.5087978",
"0.5081773",
"0.5062631",
"0.5039249",
"0.50352705"... | 0.6489016 | 0 |
r"""Get the normalized interaction matrix of users and items. Construct the square matrix from the training data and normalize it using the laplace matrix.If it is a subgraph, it may be processed by node dropout or edge dropout. | def create_adjust_matrix(self, is_sub: bool):
matrix = None
if not is_sub:
ratings = np.ones_like(self._user, dtype=np.float32)
matrix = sp.csr_matrix(
(ratings, (self._user, self._item + self.n_users)),
shape=(self.n_users + self.n_items, self.n_u... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_matrix(self):\n\n self.matrix = np.zeros((len(self.users), len(self.items)))\n\n for user in self.train_set['users']:\n for item in self.train_set['feedback'][user]:\n self.matrix[self.user_to_user_id[user]][self.item_to_item_id[item]] = \\\n se... | [
"0.5941488",
"0.57628566",
"0.5559819",
"0.5559034",
"0.5546706",
"0.54980737",
"0.545063",
"0.542479",
"0.5396878",
"0.5388655",
"0.52939355",
"0.52652526",
"0.51939404",
"0.5167611",
"0.5135756",
"0.5135118",
"0.5134718",
"0.51036704",
"0.50922585",
"0.50467175",
"0.5021418... | 0.59400547 | 1 |
r"""Convert csr_matrix to tensor. | def csr2tensor(self, matrix: sp.csr_matrix):
matrix = matrix.tocoo()
x = torch.sparse.FloatTensor(
torch.LongTensor(np.array([matrix.row, matrix.col])),
torch.FloatTensor(matrix.data.astype(np.float32)),
matrix.shape,
).to(self.device)
return x | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _sparse_mx_to_torch_sparse_tensor(sparse_mx):\n sparse_mx = sparse_mx.tocoo().astype(np.float32)\n indices = torch.from_numpy(\n np.vstack((sparse_mx.row, sparse_mx.col)).astype(np.int64))\n values = torch.from_numpy(sparse_mx.data)\n shape = torch.Size(sparse_mx.shape)\n... | [
"0.69276106",
"0.68914914",
"0.6883822",
"0.6815069",
"0.6810763",
"0.6801882",
"0.6790309",
"0.67894095",
"0.67894095",
"0.67894095",
"0.67894095",
"0.67894095",
"0.67894095",
"0.67894095",
"0.67894095",
"0.67894095",
"0.67894095",
"0.67894095",
"0.67894095",
"0.67894095",
"... | 0.8501562 | 0 |
r"""Calculate the the pairwise Bayesian Personalized Ranking (BPR) loss and parameter regularization loss. | def calc_bpr_loss(
self, user_emd, item_emd, user_list, pos_item_list, neg_item_list
):
u_e = user_emd[user_list]
pi_e = item_emd[pos_item_list]
ni_e = item_emd[neg_item_list]
p_scores = torch.mul(u_e, pi_e).sum(dim=1)
n_scores = torch.mul(u_e, ni_e).sum(dim=1)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_loss(W, b, x, y, config):\n\n # Lazy import of propper model\n if config.model_type == \"linear_svm\":\n from utils.linear_svm import model_loss\n elif config.model_type == \"logistic_regression\":\n from utils.logistic_regression import model_loss\n else:\n raise Value... | [
"0.665434",
"0.6372872",
"0.63657737",
"0.63169175",
"0.630394",
"0.6289785",
"0.61895275",
"0.61888397",
"0.6071692",
"0.60479885",
"0.60272676",
"0.6005736",
"0.5959333",
"0.5951157",
"0.5942582",
"0.58722335",
"0.58641475",
"0.58638585",
"0.58313906",
"0.58254933",
"0.5822... | 0.6918401 | 0 |
Set theme by replacing theme name in string. Unable to load settings as JSON since it contains comments. | def set_terminal_theme(theme: ApplicationTheme):
# Change current mode.
path = theme.path
try:
with open(path, 'r', encoding='utf-8') as f:
pass
except FileNotFoundError:
path = theme.windows_path
try:
with open(path, 'r+', encoding='utf-8') as f:
sett... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def theme(self, theme):\n\n self._theme = theme",
"def set_theme(self, theme_id, is_custom):\n\t\tdata = {\"theme_id\": theme_id, \"is_custom\":is_custom}\n\t\tresponse = self.client.post(self._endpoint + \"/theme\", content=data)\n\t\treturn bool(response.json[\"success\"])",
"async def set_configurato... | [
"0.6650379",
"0.64222986",
"0.639758",
"0.616589",
"0.61271924",
"0.61271924",
"0.610042",
"0.6088045",
"0.6049509",
"0.601783",
"0.59687114",
"0.59586835",
"0.5929658",
"0.5916926",
"0.58673555",
"0.58390814",
"0.58021486",
"0.5781175",
"0.57646275",
"0.565569",
"0.55316144"... | 0.6806927 | 0 |
Return current app mode. Return light theme by default to toggle to dark theme. | def get_current_app_mode() -> ThemeMode:
theme: ApplicationTheme = themes[0]
# Change current mode.
path = theme.path
try:
with open(path, 'r', encoding='utf-8') as f:
pass
except FileNotFoundError:
path = theme.windows_path
try:
with open(path, 'r', encoding... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_current_mode() -> ThemeMode:\n try:\n # test:\n assert False\n # todo: Check platform and add more platforms.\n with winreg.OpenKey(\n winreg.HKEY_CURRENT_USER,\n (r'SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Themes'\n r'\\Pers... | [
"0.8376423",
"0.78625804",
"0.72527236",
"0.693797",
"0.6717479",
"0.66852087",
"0.6549633",
"0.6545833",
"0.648958",
"0.6443121",
"0.64392096",
"0.6436298",
"0.64200485",
"0.64200485",
"0.63986427",
"0.6395614",
"0.63905364",
"0.63757384",
"0.63618475",
"0.635668",
"0.632926... | 0.86299425 | 0 |
Get toggled mode based on current mode. | def get_toggled_mode(current_mode: ThemeMode) -> ThemeMode:
return (ThemeMode.light
if current_mode == ThemeMode.dark else ThemeMode.dark) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def currentMode(self):\n logger.debug(\"Func: currentMode/getter\")\n\n return self._currentsDict[\"currentMode\"]",
"def getMode(self):\n return self._mode",
"def get_mode(self):\r\n return self._api.get_mode()",
"def get_mode(self):\r\n return self.mode",
"def getMode(s... | [
"0.7412477",
"0.73822623",
"0.7310764",
"0.72858244",
"0.7279957",
"0.7266004",
"0.7142095",
"0.7127457",
"0.71190304",
"0.7054686",
"0.70420915",
"0.70306844",
"0.7006925",
"0.70064867",
"0.7002522",
"0.7002522",
"0.69996244",
"0.69996244",
"0.69996244",
"0.6995646",
"0.6995... | 0.78654677 | 0 |
Return the correct corpus object based on its name | def get_corpus_object(corpus_name):
if corpus_name.startswith("yelp"):
return CorpusYelp(make_storagedir(corpus_name), GLOVEPATH, *JSONS)
elif corpus_name == "newsgroup":
return CorpusNewsgroup(make_storagedir(corpus_name), GLOVEPATH)
raise Exception("Unknown corpus", corpus_name) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_corpus(self, corpus_id, check_s3=True, use_cache=True):\n logger.info('Getting corpus \"%s\"' % corpus_id)\n corpus = self.corpora.get(corpus_id)\n if corpus:\n logger.info('Found corpus loaded in memory')\n if check_s3 and corpus is None:\n logger.info('Co... | [
"0.6308614",
"0.62685776",
"0.6111454",
"0.58663565",
"0.58633125",
"0.5845339",
"0.58237785",
"0.5698772",
"0.568142",
"0.56518525",
"0.56081927",
"0.56001306",
"0.55864257",
"0.558398",
"0.5556574",
"0.55449194",
"0.5541751",
"0.5540914",
"0.5539149",
"0.5535262",
"0.551453... | 0.832889 | 0 |
Prepare the corpus by storing all necessary files in the storage directory. | def prepare(self):
if len(os.listdir(self.storagedir)):
raise Exception("There are already files in", self.storagedir + ".", "Delete manually!")
self.worddict = {"__pad__": 0, "__oov__": 1}
self.classdict = {}
self.raw_documents, self.tokenized_documents = {}, {}
self.X, self.Y = {}, {}
for dataset i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prepare_storage(self):\n self.logger.info(\"Preparing storage for your data...\")\n try:\n self.dir.mkdir(exist_ok=True)\n self.full_path_to_file.touch(exist_ok=True)\n except PermissionError:\n logging.error(\n \"Conversion cannot be perform... | [
"0.69453984",
"0.6603966",
"0.6573424",
"0.6545188",
"0.65138906",
"0.632627",
"0.62835425",
"0.61928576",
"0.6123658",
"0.60845476",
"0.60845387",
"0.60704917",
"0.5924847",
"0.59139764",
"0.58902586",
"0.58792746",
"0.58648723",
"0.5857053",
"0.58545303",
"0.58353883",
"0.5... | 0.7673869 | 0 |
Reverse class and word dicts; important for printing + sanity checks | def reverse_dicts(self):
self.rev_worddict = {self.worddict[word]: word for word in self.worddict}
self.rev_classdict = {self.classdict[cl]: cl for cl in self.classdict} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_out_dict(word_dict):\n for word_class in WORD_CLASSES:\n \n last_word = \"\"\n if(word_class in word_dict):\n print(f\"{word_class}:\")\n for word in sorted(word_dict[word_class]):\n if(word != last_word):\n spacing = \" \"*(... | [
"0.6163783",
"0.6111584",
"0.6011043",
"0.58762485",
"0.57324934",
"0.56964797",
"0.5493276",
"0.5481346",
"0.5362323",
"0.53582937",
"0.53480667",
"0.5343946",
"0.53259176",
"0.5273454",
"0.5263223",
"0.52587146",
"0.52427524",
"0.52360916",
"0.52260363",
"0.5223694",
"0.514... | 0.8249116 | 0 |
Trim all samples in a batch to MAXLENGTH and pad them to identical lengths. | def trim_and_pad_batch(self, batch):
maxlength = min(self.MAXLENGTH, max([len(x) for x in batch]))
batch = [x[:maxlength] for x in batch]
batch = [np.concatenate([x, np.zeros(maxlength - x.shape[0])]) for x in batch]
return batch | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Batch_Size_Normalization(batch, batch_len, pad_token, batch_size):\n max_length = max(batch_len)\n current_batch_len = len(batch)\n need_more = batch_size-current_batch_len\n if need_more==0:\n return batch\n\n padding_array = np.ones(max_length)*pad_token\n for i in range(need_more):\... | [
"0.73393714",
"0.6794169",
"0.66928875",
"0.66109043",
"0.66104877",
"0.6500822",
"0.648561",
"0.6474067",
"0.64650595",
"0.6460871",
"0.64459044",
"0.6353153",
"0.6303142",
"0.6301248",
"0.6236003",
"0.6220014",
"0.6217669",
"0.61584425",
"0.6154803",
"0.6134153",
"0.6132086... | 0.84682834 | 0 |
A number of checks to make sure that data is generated correctly | def sanity_check(self):
self.load_full()
generators_not_shuffling = {dataset: self.get_generator(dataset, 16, False) for dataset in self.DATASETS}
generators_shuffling = {dataset: self.get_generator(dataset, 16, True) for dataset in self.DATASETS}
steps_per_epoch = {dataset: self.get_steps_per_epoch(dataset, 16... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _validate_create_data(self, data):\n return",
"def make_row(invalid_data=[]):\n\n ### Database Identifiers ###\n \n # phac_sample_id, valid/invalid error-grid information.\n phac_sample_id, phac_sample_id_error = lib.random_phac_id(invalid_data)\n # umbrella_bioproject_accession, valid/invalid er... | [
"0.642721",
"0.6373624",
"0.6359462",
"0.6284069",
"0.6282984",
"0.62758946",
"0.6215182",
"0.6175615",
"0.6174221",
"0.60827786",
"0.60755163",
"0.60731363",
"0.60609025",
"0.6060827",
"0.60487986",
"0.60403043",
"0.6025824",
"0.5965346",
"0.5924284",
"0.5900212",
"0.589654"... | 0.6542045 | 0 |
Delete any documents that do not contain any words (i.e., that were blankonly). | def delete_empty_documents(self, dataset):
print("Deleting empty documents in", dataset)
number_documents = len(self.raw_documents[dataset])
indices = list(filter(lambda x:len(self.raw_documents[dataset][x].strip()), range(number_documents)))
self.raw_documents[dataset] = [self.raw_documents[dataset][idx] for ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_search_words(self,\r\n index,\r\n entrytext):\r\n\r\n for a_temp in DELETECHARACTERS:\r\n entrytext = entrytext.replace(a_temp, BLANK)\r\n\r\n for w in set(entrytext.split()):\r\n w = w.strip()\r\n\r\n i... | [
"0.6694606",
"0.6575149",
"0.6434805",
"0.642709",
"0.6385204",
"0.63672984",
"0.634992",
"0.6281326",
"0.6239466",
"0.6194086",
"0.6189664",
"0.61618084",
"0.60838485",
"0.6070476",
"0.60552865",
"0.60512906",
"0.6034264",
"0.6008207",
"0.60043776",
"0.59701675",
"0.5938523"... | 0.6804529 | 0 |
Make a dictionary that maps class names to class indices (e.g., 'sci.med' > 16) | def make_classdict(self):
target_names = self.fetched["train"].target_names
self.classdict = {target_names[idx]: idx for idx in range(len(target_names))} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_class_indices(self) -> None:\n\n categories = list(np.loadtxt(self.path_manager.categories_file(), delimiter=\",\", dtype=str))\n\n if self.include_noise_samples and not self.multi_label_classification:\n categories.append(\"noise\")\n\n self.class_to_idx = {}\n\n ... | [
"0.74361056",
"0.6919908",
"0.691097",
"0.6642148",
"0.65950876",
"0.65944433",
"0.6566511",
"0.6437376",
"0.64369416",
"0.6416564",
"0.64126706",
"0.6313515",
"0.6301658",
"0.62353253",
"0.62277764",
"0.619924",
"0.61336446",
"0.61074406",
"0.61074406",
"0.6103345",
"0.60832... | 0.7211998 | 1 |
Randomly split test set into a development set and test set. | def split_dev(self):
print("Splitting test set into dev and test set")
old_length = len(self.X["test"])
indices = list(range(old_length))
np.random.seed(0)
np.random.shuffle(indices)
split = int(len(indices) * 0.5)
split_indices = {"test": indices[:split], "dev": indices[split:]}
for dataset in ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_test_split(self, fraction=0.1):\n rng = np.random.default_rng(42)\n test_size = int(round(len(self.all_asset_ids) * fraction))\n test_ids = rng.choice(self.all_asset_ids, size=test_size, replace=False)\n train_ids = [i for i in self.all_asset_ids if i not in test_ids]\n return train_ids, tes... | [
"0.698954",
"0.69709396",
"0.6902135",
"0.682831",
"0.6715769",
"0.6669737",
"0.6603875",
"0.65580153",
"0.6555963",
"0.65162206",
"0.6474494",
"0.64725906",
"0.647088",
"0.64632493",
"0.64603686",
"0.6457878",
"0.6446857",
"0.64376503",
"0.643528",
"0.64349276",
"0.6430532",... | 0.7523906 | 0 |
Do whatever is needed to get the latest version of QMK. | def checkout_qmk():
if exists('qmk_firmware'):
rmtree('qmk_firmware')
if not fetch_source(repo_name(QMK_GIT_URL)):
git_clone(QMK_GIT_URL, QMK_GIT_BRANCH) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_version(self):",
"def official(ctx, build_number):\n # TODO: Cache API calls to be nice too kashike and the gang\n minecraft_version = ctx.parent.minecraft_version\n known_builds = minecraft_version.known_paper_builds\n if not known_builds:\n raise ClickException()\n if build_numbe... | [
"0.5923272",
"0.5622764",
"0.5596445",
"0.55303633",
"0.5479055",
"0.5452292",
"0.54056835",
"0.53974205",
"0.5389159",
"0.52894413",
"0.5285599",
"0.5211881",
"0.51361364",
"0.5123653",
"0.51163065",
"0.50818145",
"0.5076435",
"0.5060229",
"0.50591344",
"0.50368387",
"0.5012... | 0.5705583 | 1 |
Returns the first firmware file we find. Since `os.listdir()` gives us unordered results we can not guarantee which file will be delivered in the case of multiple firmware files. The assumption is that there will only be one. | def find_firmware_file(dir='.'):
for file in os.listdir(dir):
if file[-4:] in ('.hex', '.bin'):
return file | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_first_file(cmds):\n for cmd in cmds:\n all_files = glob.glob(cmd)\n if all_files:\n for f in all_files:\n if not os.path.isdir(f):\n return f\n return ''",
"def file_by_file_name(self, file_name):\n ls = self.files.filter_by(file_nam... | [
"0.68375444",
"0.623134",
"0.6199951",
"0.61806196",
"0.6148428",
"0.61270714",
"0.604337",
"0.596648",
"0.5896954",
"0.5851519",
"0.58341783",
"0.573287",
"0.5659242",
"0.56275743",
"0.5621168",
"0.5618226",
"0.55866677",
"0.55660284",
"0.55612564",
"0.5510262",
"0.54942906"... | 0.724475 | 0 |
Returns the current commit hash for qmk_firmware. | def git_hash():
if not exists('qmk_firmware'):
checkout_qmk()
return open('qmk_firmware/version.txt').read().strip() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_current_commit_hash() -> FullCommitHash:\n return get_commit_hash(\"HEAD\")",
"def get_current_commit_sha():\n return check_output(\n \"git rev-parse HEAD\".split(\" \")\n ).decode('utf-8').strip()",
"def hash(self):\n return os.popen('git rev-parse HEAD').read().... | [
"0.74238664",
"0.7278766",
"0.72667676",
"0.72525537",
"0.7007958",
"0.6995691",
"0.69499105",
"0.6931288",
"0.6799906",
"0.66811436",
"0.6649926",
"0.66440505",
"0.65005773",
"0.6496114",
"0.64755714",
"0.64672005",
"0.6448488",
"0.6445584",
"0.63836896",
"0.63330364",
"0.62... | 0.82095015 | 0 |
Returns the name a git URL will be cloned to. | def repo_name(git_url):
name = git_url.split('/')[-1]
if name.endswith('.git'):
name = name[:-4]
return name.lower() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def name(self):\n\n return maybe_string(C.git_remote_name(self._remote))",
"def github_name(self):\n return self.github_url.replace(\"https://github.com/\", '')",
"def get_description():\n return \"Clone git repository\"",
"def get_repository_name(self) -> str:\n repository = gitu... | [
"0.7506016",
"0.72617567",
"0.6814538",
"0.65614426",
"0.65522015",
"0.64951706",
"0.64725816",
"0.64274853",
"0.6425776",
"0.64068073",
"0.6405401",
"0.64011246",
"0.6305832",
"0.62928927",
"0.6289829",
"0.62784463",
"0.62570053",
"0.62369084",
"0.62100714",
"0.62023157",
"0... | 0.746084 | 1 |
Randomizes values in object marked with rand(). Recurses to subobjects randomizing them as well. | def randomize(self, recurse=True):
try:
ok = True
if recurse:
for entry in self._sv_rand_obj:
obj = entry
if hasattr(self, entry):
obj = getattr(self, entry)
ok = ok and obj.randomize()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def totem_random():\n random_head()\n random_head()\n random_head()",
"def random_sample_objs(num_per_cat):\n\n obj_path_lists = load_object_lists(g_render_objs)\n obj_path_list = []\n\n for pathes in obj_path_lists:\n pathes = list(pathes)\n random.shuffle(pathes)\n ... | [
"0.6240906",
"0.62271875",
"0.6076071",
"0.5918611",
"0.59176767",
"0.59119755",
"0.59012204",
"0.5833525",
"0.5817845",
"0.57702124",
"0.57597",
"0.57309014",
"0.57125634",
"0.5709052",
"0.56631804",
"0.56394345",
"0.56143695",
"0.5610658",
"0.55661714",
"0.5546848",
"0.5544... | 0.69015443 | 0 |
Parse a rule set asynchronously. | async def parse_async(data: aiofiles.threadpool.text.AsyncTextIOWrapper):
is_first_line = True
ruleset = RuleSet()
while True:
line = await data.readline()
if line == "":
break
line = line.strip(" \r\n\t")
if is_first_line:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse(self) -> None:\n self._parse_zone_files()\n self._process_rules()\n self._process_zones()\n self._process_links()",
"def parse(data: Union[str, TextIOWrapper]):\n if isinstance(data, str):\n data = StringIO(data)\n\n is_first_line = True\n rul... | [
"0.5776509",
"0.5768841",
"0.54795384",
"0.54349685",
"0.5426252",
"0.53731555",
"0.5317084",
"0.53067213",
"0.5140386",
"0.5115144",
"0.5066078",
"0.5032859",
"0.50225914",
"0.49897945",
"0.49722442",
"0.49702734",
"0.49672022",
"0.49549806",
"0.4954756",
"0.4916311",
"0.490... | 0.74030197 | 0 |
Parse a rule set synchronously. | def parse(data: Union[str, TextIOWrapper]):
if isinstance(data, str):
data = StringIO(data)
is_first_line = True
ruleset = RuleSet()
while True:
line = data.readline()
if line == "":
break
line = line.strip(" \r\n\t")
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def parse_async(data: aiofiles.threadpool.text.AsyncTextIOWrapper):\n is_first_line = True\n ruleset = RuleSet()\n while True:\n line = await data.readline()\n\n if line == \"\":\n break\n\n line = line.strip(\" \\r\\n\\t\")\n\n ... | [
"0.73269176",
"0.5711133",
"0.55420655",
"0.55174935",
"0.5448098",
"0.54066694",
"0.5374",
"0.53189385",
"0.5308426",
"0.51307917",
"0.512296",
"0.5103619",
"0.50919634",
"0.50901014",
"0.50792754",
"0.50773793",
"0.507417",
"0.50535357",
"0.5050032",
"0.50406975",
"0.504024... | 0.64185977 | 1 |
Adds a list of rules to the rule set. | def add_rules(self, rules: List[Rule]):
self.rules.extend(rules) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_rules ( self, *rule_str_list ):\n for rule_str in rule_str_list:\n self.add_rule ( rule_str )\n return True",
"def add_rules(self, rules: List[validation.rule.Rule]):\n for rule in rules:\n self.add_rule(rule)\n\n return self",
"def add_rule_list ( self, rule_... | [
"0.8215396",
"0.80462503",
"0.7864414",
"0.77492636",
"0.76693547",
"0.7512411",
"0.74834245",
"0.71834457",
"0.69023085",
"0.68825233",
"0.66729355",
"0.66096354",
"0.65939915",
"0.6524499",
"0.6492519",
"0.64312977",
"0.64005846",
"0.638603",
"0.6284601",
"0.6266898",
"0.61... | 0.8734778 | 0 |
Check all sheets in the workbook to obtain the list of valid sheets to further parse. Each sheet name should be the same as an existing .xml template (without the extension) | def check_workbook_sheets(workbook):
sheets_in_file = workbook.sheetnames
valid_sheets_template = []
for sheet in sheets_in_file:
# check if a template with that name exists in templates folder
if os.path.isfile(os.path.join(cd,'templates', sheet + '.xml')):
logger.info('{} is a ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getAllSheetNames(self):\n\n\t\t\treturn self.thing.get_sheet_names()",
"def get_sheet_names(file_path):\n with open_xlsb(file_path) as wb:\n return wb.sheets",
"def parse_xlsx_sheet(f, n=0):\n xl_file = pd.ExcelFile(f)\n dfs = xl_file.parse(xl_file.sheet_names[n], na_values=['n.a.',... | [
"0.6480486",
"0.62321484",
"0.6102045",
"0.6042753",
"0.60415035",
"0.6017387",
"0.5958113",
"0.5919455",
"0.58910537",
"0.586762",
"0.5831217",
"0.58204114",
"0.57018733",
"0.5696104",
"0.5658321",
"0.5646158",
"0.557631",
"0.5548769",
"0.5541189",
"0.55251616",
"0.55234045"... | 0.7973267 | 0 |
Keep adding new substitutions until the message is solved. | def show_message(message):
mapped = {}
quit = False
while len(mapped) < 26 and not quit:
substitution = input(
"Enter a letter and replacement of the form 'A>E' or hit 'Q' to quit: "
).upper()
if substitution == "Q":
quit = True
mapping = re.match("^([... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process(self, message: Message, **kwargs: Any) -> None:\n\n try:\n textdata = message.data[\"text\"]\n # print(\"text :::\" + textdata)\n textdata = textdata.split()\n new_message = \" \".join(spell.correction(w) for w in textdata)\n # print(\"after... | [
"0.59329295",
"0.5883782",
"0.5835631",
"0.57818395",
"0.57778156",
"0.57778156",
"0.5663148",
"0.55577374",
"0.5523293",
"0.5490194",
"0.5489795",
"0.5450665",
"0.54440415",
"0.54250085",
"0.5379858",
"0.53482586",
"0.5345884",
"0.53051066",
"0.5301084",
"0.5265086",
"0.5214... | 0.5889453 | 1 |
low mobility users are considered, i.e. the user only move one pixel every frame. different mobility trajectories will be tested to present the robustness of the neural network | def _move_user(self):
self.terminal = False
mobility_speed = 1
for i in range(self.num_user):
move_x = random.randint(-mobility_speed, mobility_speed)
user_x_tmp = self.users[i][0] + move_x
move_y = random.randint(-mobility_speed, mobility_speed)
user_y_tmp = s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def learning_Utility(self):\n # Shape the input that we give to the neural network with the value of sensors, the previous actions the life of the agent \n # Get the results from the sensors according the different movement executed by the agent \n sensors_result_N = self.agent.sensors(self, d... | [
"0.5938562",
"0.5617327",
"0.5616308",
"0.5608997",
"0.55897117",
"0.5548204",
"0.55414164",
"0.55012023",
"0.54698473",
"0.54584825",
"0.545472",
"0.5438623",
"0.54276806",
"0.53923744",
"0.53894335",
"0.5388711",
"0.53810763",
"0.5372899",
"0.5371992",
"0.53697884",
"0.5363... | 0.5641281 | 1 |
get the rates of the user in all the cells if this user connects to the cell. return the array "rate" to represent the rate in the cells | def get_rate_all_cell(self, users, cells, resource_id, resource_length, transmit_power):
channels_square = np.random.rayleigh(1,[self.num_user, self.num_cell,self.num_rb]) # the fast fading from the user to all the cells
distance = np.zeros([self.num_user, self.num_cell])
fadings = np.zeros([self.num... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rates(self):\n return self._rates",
"def get_all_rates(user_email):\r\n connect(\"mongodb://vcm-3594.vm.duke.edu:27017/heart_rate_app\")\r\n user = models.User.objects.raw({\"_id\": user_email}).first()\r\n heart_rate_list = user.heart_rate\r\n return heart_rate_list",
"def get_meanrates... | [
"0.6332212",
"0.6278733",
"0.572722",
"0.57220495",
"0.5603388",
"0.54084355",
"0.54059494",
"0.5383069",
"0.53778595",
"0.5357621",
"0.5314365",
"0.52889997",
"0.52815014",
"0.52774554",
"0.5253968",
"0.52490884",
"0.52340025",
"0.5228531",
"0.51897985",
"0.51748776",
"0.516... | 0.7348139 | 0 |
split board for possible winning combinations | def split_board(board):
row1 = board[0]
row2 = board[1]
row3 = board[2]
diag1 = [row1[0], row2[1], row3[2]]
diag2 = [row1[2], row2[1], row3[0]]
col1 = [row1[0], row2[0], row3[0]]
col2 = [row1[1], row2[1], row3[1]]
col3 = [row1[2], row2[2], row3[2]]
return [row1, row2, row3, diag1, di... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_boards():\n\n print \"Generating data, please hold on...\"\n # a list for turns, each which is a list of boards, which are unique layouts\n # a completely blank layout is always the start of the game, counting for turn 0\n game = [[Board(' ' * 9, 1)]]\n\n # there are at most 9 turns in ... | [
"0.67916846",
"0.67237663",
"0.6480683",
"0.6409748",
"0.6335073",
"0.63155794",
"0.63097256",
"0.6248745",
"0.62057847",
"0.6170299",
"0.61603934",
"0.61360604",
"0.61272645",
"0.6101587",
"0.6100307",
"0.606914",
"0.6065865",
"0.6051618",
"0.6051436",
"0.6048999",
"0.600091... | 0.7114458 | 0 |
Converts protein in dataframe representation to a graph compatible with PytorchGeometric | def prot_df_to_graph(df, edge_dist_cutoff=4.5):
node_pos = torch.FloatTensor(df[['x', 'y', 'z']].to_numpy())
kd_tree = ss.KDTree(node_pos)
edge_tuples = list(kd_tree.query_pairs(edge_dist_cutoff))
edges = torch.LongTensor(edge_tuples).t().contiguous()
node_feats = torch.FloatTensor([one_of_k_enco... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def simplify_directed_as_dataframe(df: gpd.GeoDataFrame) -> gpd.GeoDataFrame:\n df.reset_index(inplace=True)\n\n g = gt.Graph(directed=True)\n osm_id = g.new_edge_property('string')\n highway = g.new_edge_property('string')\n level = g.new_edge_property('int')\n lanes = g.new_edge_property('int')... | [
"0.60133654",
"0.5954496",
"0.59516835",
"0.58714",
"0.58600146",
"0.5818354",
"0.5695479",
"0.569264",
"0.5662987",
"0.56239504",
"0.5616005",
"0.5606451",
"0.5593581",
"0.55643904",
"0.5515475",
"0.5462075",
"0.5348582",
"0.5319932",
"0.5309101",
"0.5305843",
"0.5292806",
... | 0.70136577 | 0 |
Converts Mol object to a graph compatible with PytorchGeometric | def mol_to_graph(mol):
node_pos = torch.FloatTensor(dt.get_coordinates_of_conformer(mol))
bonds = dt.get_bonds_matrix(mol)
edge_tuples = np.argwhere(bonds)
edges = torch.LongTensor(edge_tuples).t().contiguous()
node_feats = torch.FloatTensor([one_of_k_encoding_unk(a.GetSymbol(), mol_atoms) for a in... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mol2graph(mol):\n mol = AllChem.AddHs(mol)\n N = mol.GetNumAtoms()\n try:\n pos = rdkit_conformation(mol)\n assert pos is not None, \"no conformations found\"\n except Exception:\n return None\n types = {\"H\": 0, \"C\": 1, \"N\": 2, \"O\": 3, \"F\": 4}\n type_idx = []\n ... | [
"0.73351014",
"0.6501513",
"0.6270673",
"0.6243756",
"0.6010345",
"0.59381574",
"0.58269167",
"0.5807672",
"0.57851845",
"0.5736497",
"0.57161045",
"0.5700733",
"0.5676337",
"0.5675818",
"0.56719494",
"0.5665272",
"0.56213564",
"0.56110346",
"0.5556434",
"0.5519203",
"0.54960... | 0.7213457 | 1 |
Takes a relaxed optimum, returns best attainable integer objective value, and the corresponding assignments. Neighbourhood argument determines the size of the area to explore, leave 0 for strictly convex problems | def discretise_solution(solution, objective, *constraints, neighbourhood=0) -> Tuple[int, Dict[str, int]]:
floors = {var: int(solution[var]) for var in solution}
headroom = BUDGET - sum(floors.values())
candidates = itertools.product(*(range(floor - neighbourhood, floor + neighbourhood + headroom + 1) for ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_objective(self):\n self.objective = 0\n for r in self.routes:\n r.update_route(self.vrpdata)\n self.objective += r.distance\n # all() returns True if all elements of the iterable are true\n self.solutionValid = (all([r.tourValid for r in self.routes]) and l... | [
"0.62577194",
"0.6052237",
"0.60442185",
"0.6013674",
"0.5907335",
"0.5766745",
"0.57452804",
"0.57290393",
"0.56316966",
"0.562369",
"0.5582277",
"0.5547593",
"0.5522649",
"0.55176646",
"0.5512541",
"0.54998076",
"0.5483097",
"0.5479488",
"0.54693836",
"0.5458687",
"0.545438... | 0.6929844 | 0 |
Find an animal by a given identifier. | def find(cls, animal_id):
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find(cls, animal_id):\n if not cls._data:\n cls._data = cls._load()\n\n try:\n animal = next(filter(lambda a: a.a_id == animal_id, cls._data))\n except StopIteration:\n animal = None\n return animal",
"def getAnimalByID(self, desiredID):\n f... | [
"0.76302874",
"0.7007676",
"0.6777905",
"0.6274848",
"0.604072",
"0.60169005",
"0.6000332",
"0.5939324",
"0.59052515",
"0.58903086",
"0.58524185",
"0.5753239",
"0.57503074",
"0.57331485",
"0.5723473",
"0.57222617",
"0.57206744",
"0.57199085",
"0.5680655",
"0.5665608",
"0.5664... | 0.8031842 | 0 |
Find an animal by a given identifier. | def find(cls, animal_id):
if not cls._data:
cls._data = cls._load()
try:
animal = next(filter(lambda a: a.a_id == animal_id, cls._data))
except StopIteration:
animal = None
return animal | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find(cls, animal_id):\n raise NotImplementedError",
"def getAnimalByID(self, desiredID):\n for enclosure in self.enclosures:\n animals = enclosure.getAnimals()\n for animal in animals:\n if(int(animal.getID()) == int(desiredID)):\n return ... | [
"0.80311835",
"0.70066816",
"0.6775904",
"0.6272476",
"0.603789",
"0.6012952",
"0.5998156",
"0.59369916",
"0.5903938",
"0.58888996",
"0.5850682",
"0.5754775",
"0.57489663",
"0.5730268",
"0.572526",
"0.57209444",
"0.5719966",
"0.5717094",
"0.5679516",
"0.566399",
"0.5663051",
... | 0.76283956 | 1 |
The imaging extractor for the MicroManager TIF image format. The image file stacks are saved into multipage TIF files in OMETIFF format (.ome.tif files), each of which are up to around 4GB in size. The 'DisplaySettings' JSON file contains the properties of MicroManager. | def __init__(self, folder_path: PathType):
self.tifffile = _get_tiff_reader()
self.folder_path = Path(folder_path)
self._ome_tif_files = list(self.folder_path.glob("*.ome.tif"))
assert self._ome_tif_files, f"The TIF image files are missing from '{folder_path}'."
# load the 'Dis... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _initWithTiffTools(self): # noqa\n dir0 = TiledTiffDirectory(self._largeImagePath, 0)\n self.tileWidth = dir0.tileWidth\n self.tileHeight = dir0.tileHeight\n self.sizeX = dir0.imageWidth\n self.sizeY = dir0.imageHeight\n self.levels = max(1, int(math.ceil(math.log(max... | [
"0.6000735",
"0.56384623",
"0.5566855",
"0.5514486",
"0.5412366",
"0.5349689",
"0.53283197",
"0.53236425",
"0.53087485",
"0.52952164",
"0.52897066",
"0.528965",
"0.52832264",
"0.52702475",
"0.52631813",
"0.52565855",
"0.52532846",
"0.5238176",
"0.52287793",
"0.5201827",
"0.51... | 0.629963 | 0 |
Loads the 'DisplaySettings' JSON file. | def _load_settings_json(self) -> Dict[str, Dict[str, str]]:
file_name = "DisplaySettings.json"
settings_json_file_path = self.folder_path / file_name
assert settings_json_file_path.exists(), f"The '{file_name}' file is not found at '{self.folder_path}'."
with open(settings_json_file_pat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def settings_show(ctx):\n path = ctx.obj['load_path']\n if not path:\n _raise_settings_not_found()\n with open(path) as handle:\n click.echo(json.dumps(json.load(handle), indent=2, sort_keys=True))",
"def load_settings(self):\n settings_file = open('./resources/settings.json')\n ... | [
"0.7461627",
"0.72369146",
"0.6850787",
"0.67616904",
"0.66776395",
"0.6638841",
"0.6594142",
"0.6445284",
"0.6434832",
"0.6389921",
"0.6286017",
"0.6267154",
"0.6226268",
"0.61028415",
"0.60572",
"0.60329616",
"0.60084164",
"0.6000126",
"0.5998964",
"0.5983447",
"0.59771",
... | 0.7851163 | 0 |
Checks the presence of each TIF file that is expected to be found in the folder. Raises an error when the files are not found with the name of the missing files. | def _check_missing_files_in_folder(self, expected_list_of_files):
missing_files = [
file_name for file_name in expected_list_of_files if self.folder_path / file_name not in self._ome_tif_files
]
assert (
not missing_files
), f"Some of the TIF image files at '{self... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_file_existence(self, files):\n if len(files) == 0:\n if self._nonfile_error is True:\n raise FileNotFound(\"No files are found.\")\n else:\n self._logger.info(\"No files are found. Nothing to do.\")\n return\n self._logger.i... | [
"0.7006741",
"0.6997435",
"0.6805607",
"0.6777416",
"0.6777416",
"0.6777416",
"0.65989196",
"0.6451509",
"0.64436173",
"0.6435952",
"0.6428609",
"0.6395577",
"0.638387",
"0.63489914",
"0.6331966",
"0.6324175",
"0.62889266",
"0.6280295",
"0.6255856",
"0.6182966",
"0.6163986",
... | 0.77541596 | 0 |
Overrides the parent class method as none of the properties that are checked are from the subimaging extractors. | def _check_consistency_between_imaging_extractors(self):
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_attributes(self):\n\n pil_image = PILImage.open(self.path)\n\n # Get the exif data\n # Thanks https://gist.github.com/erans/983821\n exif_data = {}\n info = pil_image._getexif()\n if info:\n for tag, value in info.items():\n decoded = PILE... | [
"0.5506078",
"0.5503185",
"0.54317933",
"0.5414659",
"0.53938776",
"0.5389262",
"0.53448987",
"0.5292467",
"0.52401125",
"0.5235796",
"0.5221946",
"0.52103263",
"0.5196668",
"0.51837295",
"0.51525956",
"0.51208216",
"0.510319",
"0.50949574",
"0.50949574",
"0.50895756",
"0.508... | 0.65462357 | 0 |
run scenario for application in its own process | def _run_scenario(app, scenario):
args = [app, '-scenario', scenario]
# run app in its own process
process = Popen(args, stdout=PIPE, shell=True)
(output, _) = process.communicate()
exit_code = process.wait()
return output, exit_code | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main():\n\n run_manual_session()\n # run_automated_session()",
"def main():\n tng.api.runner()",
"def run():\n main()",
"def _run_scenario(self, cls, method_name, context, args, config):",
"def _run(self, scenario_file, scenario_name, extra=None):\n merged = copy.deepcopy(self._defau... | [
"0.6976264",
"0.65309536",
"0.64809436",
"0.64740014",
"0.64649725",
"0.6399869",
"0.63348377",
"0.62444615",
"0.6234889",
"0.62212366",
"0.6195266",
"0.61911964",
"0.6187535",
"0.6186784",
"0.6178164",
"0.6177424",
"0.6169644",
"0.6124373",
"0.6120239",
"0.6083581",
"0.60827... | 0.7338168 | 0 |
compare outputs, returns False if it's different, True otherwise | def _compare_output(standart_output, testing_output):
standart_output_array = standart_output.splitlines()
testing_output_array = testing_output.splitlines()
standart_output_array_len = len(standart_output_array)
testing_output_array_len = len(testing_output_array)
if standart_output_array_len != t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_output(output, expected_output):\n o = copy.deepcopy(output) # so that we don't mutate input\n e = copy.deepcopy(expected_output) # so that we don't mutate input\n \n o.sort()\n e.sort()\n return o == e",
"def check_input_matches_expected_output(in_, out):\n ...",
"def __compar... | [
"0.79265803",
"0.74069077",
"0.72331935",
"0.71759",
"0.70107216",
"0.6955179",
"0.6787494",
"0.6734162",
"0.6728881",
"0.6648757",
"0.6583574",
"0.65713054",
"0.6468473",
"0.64636075",
"0.64503294",
"0.64418304",
"0.64396334",
"0.6366613",
"0.6365131",
"0.6356849",
"0.634446... | 0.75788146 | 1 |
Regression test for failure in guess_from_peak with pandas (GH 629). | def test_pandas_guess_from_peak():
data = pandas.read_csv(os.path.join(os.path.dirname(__file__), '..',
'examples', 'peak.csv'))
xdat, ydat = np.loadtxt(os.path.join(os.path.dirname(__file__), '..',
'examples', 'peak.csv'),
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_bad_peak(self, off_by_factor, test_peak_idx):\n test_data = self.get_test_peaks(self.n_top)\n test_data[test_peak_idx]['area_per_channel'][:self.n_top] = 1\n area = np.sum(test_data[test_peak_idx]['area_per_channel'])\n\n # Set the area field to a wrong value\n area *= o... | [
"0.6352631",
"0.63467467",
"0.6218063",
"0.61771286",
"0.61376494",
"0.6005803",
"0.5727839",
"0.5694754",
"0.56714135",
"0.5637121",
"0.56249833",
"0.561662",
"0.5611265",
"0.5559535",
"0.55383015",
"0.55307746",
"0.5520142",
"0.5477735",
"0.5476395",
"0.545806",
"0.54311544... | 0.80317634 | 0 |
Gets DICOM metadata and slice counts. | def get_dicom_metadata_and_slice_counts(dicom_path):
row = {
'dicom_path': dicom_path,
'dicom_metadata': {},
'slice_count': None,
'errors': []
}
# Get metadata
try:
row['dicom_metadata'] = get_dicom_metadata(dicom_path)
except Exception as e:
row['err... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_dicom_info(paths, index_col=None, verbose=False):\n meta_info = []\n paths = tqdm_notebook(paths, leave=False) if verbose else paths\n for path in paths:\n first_slice = dicom.read_file(os.path.join(path, os.listdir(path)[0]))\n\n if hasattr(first_slice, 'PatientAge'):\n p... | [
"0.6424663",
"0.59566057",
"0.58930385",
"0.5818665",
"0.5814221",
"0.57977295",
"0.57840246",
"0.5772847",
"0.57435006",
"0.56656504",
"0.5658038",
"0.5641532",
"0.56383723",
"0.56025904",
"0.55888975",
"0.55741364",
"0.55658495",
"0.55618054",
"0.5559657",
"0.5545981",
"0.5... | 0.6962867 | 0 |
Extracts and saves metadata from DICOMs to a JSON file. | def main(directory, results_path):
dicom_paths = []
for root, _, files in os.walk(directory):
dicom_paths.extend([os.path.abspath(os.path.join(root, f)) for f in files if f.endswith('.dcm')])
metadata = p_umap(get_dicom_metadata_and_slice_counts, dicom_paths)
with open(results_path, 'w') ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_coco_json(filepath, dataset_dicts, name_to_id, **kwargs):\n info = {\n \"description\": kwargs.get(\"description\", \"\"),\n \"url\": kwargs.get(\"url\", \"\"),\n \"version\": kwargs.get(\"version\", \"0.0\"),\n \"year\": kwargs.get(\"year\", \"2017\"),\n \"contributor\": kwargs... | [
"0.63418406",
"0.62112826",
"0.6191978",
"0.61205125",
"0.6097923",
"0.6090426",
"0.6090426",
"0.6060568",
"0.60041976",
"0.59929466",
"0.5960822",
"0.59558105",
"0.59513503",
"0.59337825",
"0.58999234",
"0.5899028",
"0.58739734",
"0.58179253",
"0.58143944",
"0.5811671",
"0.5... | 0.6411829 | 0 |
Flips the x axis of the sprites in the animation dict | def flip_sprites_ver(self):
for action_key, sprites_list in self.__animation_dict.items():
for i in range(0, len(sprites_list)):
sprite = sprites_list[i]
self.__animation_dict[action_key][i] = pygame.transform.flip(sprite, True, False)
return self.__animation_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def flip_x(self):\n self.x_lim_helper.flip_limits()",
"def flip_x(self):\n self.x_lim_helper.flip_limits()",
"def update(self):\n self.x -= self.settings.alien_speed\n self.rect.x = self.x",
"def update(self, *args):\n self.rect.x -= args[0]",
"def run_away(self):\n ... | [
"0.615194",
"0.615194",
"0.5989319",
"0.591035",
"0.5904254",
"0.5784169",
"0.5778955",
"0.5711087",
"0.57007563",
"0.567451",
"0.5656962",
"0.56518966",
"0.56500417",
"0.5646839",
"0.5627378",
"0.562395",
"0.5587976",
"0.5553772",
"0.5546981",
"0.5523815",
"0.5520741",
"0.... | 0.70556337 | 0 |
Returns the next sprite in the animation | def get_next_sprite(self, animation_key: str) -> pygame.Surface:
if animation_key != self.__animation_key:
# if changed to new animation, update key and reset sprite index
self.__animation_key = animation_key
self.__sprite_index = 0
else:
self.__sprite_in... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def next(self):\n if self.currentframe < (self.nframes - 1) and self.nframes > 1:\n return self.getframe(self.currentframe + 1)\n else:\n newobj = pixiimage()\n newobj.read(next_filename(\n self.sequencefilename))\n return newobj",
"def get... | [
"0.75395054",
"0.7056382",
"0.7038139",
"0.67889154",
"0.6664965",
"0.6642788",
"0.65511084",
"0.64758456",
"0.64718986",
"0.64679015",
"0.6447958",
"0.64096516",
"0.6400497",
"0.6388563",
"0.6352001",
"0.6308606",
"0.6304391",
"0.62203544",
"0.619649",
"0.61768264",
"0.61615... | 0.77982426 | 0 |
Returns the last sprite in sprite list For example, if character died | def get_last_sprite(self) -> pygame.Surface:
return self.__animation_dict[self.__animation_key][-1] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_sprite(idx):\n #print \"in get_sprite: idx = %s\" % str(idx)\n return _sprite_list[idx]",
"def sprites():\n return Globals.instance.sprites",
"def get_sprites(self):\n return self.sprites",
"def last_move(self):\n if len(self.moves) > 0:\n return self.moves[-1]\n ... | [
"0.6691533",
"0.6243963",
"0.6177253",
"0.6057014",
"0.58091295",
"0.57937825",
"0.57309914",
"0.572952",
"0.5723726",
"0.5598326",
"0.555927",
"0.55025303",
"0.54774576",
"0.54520583",
"0.54414",
"0.5431055",
"0.5420827",
"0.5376655",
"0.5364521",
"0.5362938",
"0.53562945",
... | 0.7524934 | 0 |
Check url structure and append robots.txt if needed | def check_robots_url(url):
robots_url = str(url)
if "robots.txt" not in robots_url and not robots_url.endswith("/"):
robots_url += "/"
if "robots.txt" not in robots_url:
robots_url += "robots.txt"
return robots_url | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scan_robots_txt():\r\n target_robots_txt=provided_url+\"/robots.txt\"\r\n if verbose_flag: print \"\\t[.] Trying to access robots.txt file...\",#+target_robots_txt\r\n try:\r\n response = urllib2.urlopen(target_robots_txt)\r\n html = response.read()\r\n get_robots = string.find(ht... | [
"0.6742358",
"0.6689748",
"0.66451997",
"0.6332824",
"0.63311726",
"0.6183234",
"0.61594445",
"0.6136241",
"0.61297",
"0.5925847",
"0.58510363",
"0.582927",
"0.5825505",
"0.58237547",
"0.58209825",
"0.5775085",
"0.57670903",
"0.57559365",
"0.5690286",
"0.56492555",
"0.5645775... | 0.7559549 | 0 |
Get robots.txt file for page. Check url structure and append robots.txt to the url. Return True if robots exists | def parse_robots_file(self):
self.file_exists = False
# set robots url to fetch
logger.info("Setting url %s for robot parser" % self.page_url)
self.rp.set_url(self.page_url)
# request and read robots file
try:
logger.info("Reading robots file")
#... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scan_robots_txt():\r\n target_robots_txt=provided_url+\"/robots.txt\"\r\n if verbose_flag: print \"\\t[.] Trying to access robots.txt file...\",#+target_robots_txt\r\n try:\r\n response = urllib2.urlopen(target_robots_txt)\r\n html = response.read()\r\n get_robots = string.find(ht... | [
"0.75338644",
"0.7229949",
"0.7161735",
"0.6846011",
"0.6601533",
"0.629665",
"0.6273722",
"0.62177044",
"0.60517365",
"0.5884712",
"0.58631",
"0.5820886",
"0.578991",
"0.56561613",
"0.5512568",
"0.54888403",
"0.5480792",
"0.54774743",
"0.5471965",
"0.5454341",
"0.53910303",
... | 0.7511645 | 1 |
Returns the value of the Crawldelay parameter from robots.txt for the useragent | def get_crawl_delay(self, useragent="*"):
crawl_delay = None
try:
crawl_delay = self.rp.crawl_delay(useragent=useragent)
logger.info("Crawl delay is %s" % crawl_delay)
except Exception as e:
logger.error("get_crawl_delay:\n%s" % e)
if not crawl_delay:... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_crawl_delay(self, user_agent):\n # See is_allowed() comment about the explicit unicode conversion.\n if (PY_MAJOR_VERSION < 3) and (not isinstance(user_agent, unicode)):\n user_agent = user_agent.decode()\n \n for ruleset in self.__rulesets:\n if ruleset.does_u... | [
"0.7789313",
"0.5887371",
"0.5884171",
"0.57044154",
"0.5572303",
"0.5548567",
"0.5548567",
"0.55444604",
"0.5530305",
"0.5528713",
"0.54890287",
"0.5435754",
"0.5419857",
"0.5419857",
"0.5396618",
"0.5396618",
"0.53639984",
"0.5342837",
"0.5294328",
"0.52888495",
"0.5260958"... | 0.8257991 | 0 |
Returns the contents of the Requestrate parameter from robots.txt as a named tuple RequestRate(requests, seconds) | def get_request_rate(self, useragent="*"):
request_rate = None
try:
request_rate = self.rp.request_rate(useragent=useragent)
logger.info("Request rate is %s" % request_rate)
except Exception as e:
logger.error("get_request_rate:\n%s" % e)
return reques... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def siterequestsrate(self) :\n\t\ttry :\n\t\t\treturn self._siterequestsrate\n\t\texcept Exception as e:\n\t\t\traise e",
"def siterequestbytesrate(self) :\n\t\ttry :\n\t\t\treturn self._siterequestbytesrate\n\t\texcept Exception as e:\n\t\t\traise e",
"def comprequestsrate(self) :\n\t\ttry :\n\t\t\treturn sel... | [
"0.6327506",
"0.5678047",
"0.55996656",
"0.5502806",
"0.545893",
"0.5456424",
"0.5284817",
"0.52221596",
"0.5162433",
"0.5161297",
"0.51498294",
"0.5068385",
"0.5044967",
"0.5042247",
"0.50102216",
"0.50058067",
"0.5000684",
"0.49567366",
"0.4914902",
"0.490219",
"0.48897147"... | 0.5738091 | 1 |
Use downloader class to download robots content | def get_robots_content(self):
logger.info("Preparing to download robots.txt content")
downloader = HttpDownloader()
self.content, self.status_code = downloader.get_robots_file(base_url=self.page_url)
logger.info("GET robots.txt status code %s" % self.status_code)
return self.cont... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def download(self, url_match):\n pass",
"def download_files(self):",
"def download(self):\n pass",
"def download(self):\n pass",
"def download():\n raise NotImplementedError",
"def _download(self) -> None:\n download_url(\n self.url,\n self.root,\n ... | [
"0.65913963",
"0.65802735",
"0.65436876",
"0.65436876",
"0.64683807",
"0.63875604",
"0.6203839",
"0.6203839",
"0.616315",
"0.6087331",
"0.6015616",
"0.59887785",
"0.59874886",
"0.5918728",
"0.5914998",
"0.5911914",
"0.5902355",
"0.5900686",
"0.5893974",
"0.5892995",
"0.588976... | 0.67410594 | 0 |
Convert robots.txt file content to lowercase and extract sitemaps urls | def parse_sitemap_url_in_robots_file(self):
logger.info("parsing robots.txt content for sitemap urls")
if self.content is None:
logger.info("WARNING: No robots.txt content. Did we download it?")
return []
r_content = self.content
return [url.strip() for url in r_c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def urls_from_robots_txt(response):\n\n url = URL(response.request_url or response.url or '')\n if url.parsed.path != '/robots.txt':\n return\n\n charset = response.headers.get_content_charset()\n lines = getreader(charset or 'ISO-8859-1')(response)\n\n for line in lines:\n\n content, ... | [
"0.6761084",
"0.61843455",
"0.60378224",
"0.5948536",
"0.5892525",
"0.5892525",
"0.57666415",
"0.5755179",
"0.5666788",
"0.56598395",
"0.5597148",
"0.5591755",
"0.5573382",
"0.55489755",
"0.5531501",
"0.5512299",
"0.54846275",
"0.5470616",
"0.54641443",
"0.54299873",
"0.54183... | 0.72516406 | 0 |
This class extract the k space center for a given threshold or it estimate the threshold if any is provided using the density of the sampling scheme and the resolution. | def extract_k_space_center(samples, samples_locations,
thr=None, img_shape=None):
if thr is None:
if img_shape is None:
raise ValueError('target image cartesian image shape must be fill')
raise NotImplementedError
else:
samples_thresholded = np.copy... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate_cluster_center(self, threshold):\n gamma = self.gamma\n self.cluster_center = np.where(gamma >= threshold)[0]",
"def Kernel_Centering(self, K):\n N = K.shape[0]\n one_N = np.ones((N, N), dtype=int) / N\n K_centered = K - np.dot(one_N, K) - np.dot(K, one_N) + np.do... | [
"0.7333818",
"0.6014299",
"0.582175",
"0.57883704",
"0.5583449",
"0.5554224",
"0.55462104",
"0.55246294",
"0.54333395",
"0.5433152",
"0.5392117",
"0.5378486",
"0.5357262",
"0.5336717",
"0.53128767",
"0.5299214",
"0.5290008",
"0.5266712",
"0.52638024",
"0.5260647",
"0.52594644... | 0.70003974 | 1 |
The function changes the MACaddress in the terminal | def change_mac(interface, mac):
print("Changing MAC-address for " + interface + " to " + mac)
subprocess.call(["sudo", "ifconfig", interface, "down"])
subprocess.call(["sudo", "ifconfig", interface, "hw", "ether", mac])
subprocess.call(["sudo", "ifconfig", interface, "up"]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setMAC( self, intf, mac ):\n result = self.cmd( 'ifconfig', intf, 'down' )\n result += self.cmd( 'ifconfig', intf, 'hw', 'ether', mac )\n result += self.cmd( 'ifconfig', intf, 'up' )\n return result",
"def mac(self, mac):\n\n self._mac = mac",
"def set_macaddr(self):\n ... | [
"0.72254115",
"0.69612145",
"0.69025207",
"0.6790145",
"0.66290456",
"0.66290456",
"0.6565931",
"0.6531552",
"0.6531392",
"0.6399722",
"0.6392332",
"0.63814545",
"0.63762426",
"0.6367128",
"0.6363824",
"0.63464564",
"0.6289979",
"0.6285869",
"0.62839067",
"0.62839067",
"0.628... | 0.78580296 | 0 |
Makes a `DPQuery` to estimate vector averages with differential privacy. Supports many of the types of query available in tensorflow_privacy, including nested ("pervector") queries as described in | def build_dp_query(clip,
noise_multiplier,
expected_total_weight,
adaptive_clip_learning_rate=0,
target_unclipped_quantile=None,
clipped_count_budget_allocation=None,
expected_num_clients=None,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _dp_factory(\n config: DifferentialPrivacyConfig\n) -> dp_factory.DifferentiallyPrivateFactory:\n if isinstance(config.clipping, FixedClippingConfig):\n stddev = config.clipping.clip * config.noise_multiplier\n query = tfp.GaussianAverageQuery(\n l2_norm_clip=config.clipping.clip,\n sum... | [
"0.5372152",
"0.5321666",
"0.5211199",
"0.49721992",
"0.4915922",
"0.48811898",
"0.48454094",
"0.48221052",
"0.478017",
"0.47760567",
"0.47605318",
"0.47502336",
"0.47432417",
"0.47428623",
"0.47286534",
"0.47261417",
"0.47241876",
"0.47212532",
"0.46996614",
"0.467656",
"0.4... | 0.619264 | 0 |
Makes a `DPQuery` for a single vector. | def make_single_vector_query(vector_clip):
if not adaptive_clip_learning_rate:
return tensorflow_privacy.GaussianAverageQuery(
l2_norm_clip=vector_clip,
sum_stddev=vector_clip * noise_multiplier * num_vectors**0.5,
denominator=expected_total_weight)
else:
# Without geom... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def buildQueryVector(self, termList):\n\t\tquery = self.createVector(\" \".join(termList))\n\t\treturn query",
"def _to_full_vector(self, query_vector: List[Tuple[str, float]]) -> np.array:\n terms = list(self.index.get_terms())\n terms.sort()\n vector = np.zeros(len(terms))\n\n for (... | [
"0.6026326",
"0.57896304",
"0.5707533",
"0.5655956",
"0.56433105",
"0.547512",
"0.5135332",
"0.5110416",
"0.51029265",
"0.5101445",
"0.5064414",
"0.5043928",
"0.49734947",
"0.4960525",
"0.492408",
"0.4906989",
"0.4903896",
"0.4903558",
"0.48995522",
"0.4866237",
"0.4851582",
... | 0.5944965 | 1 |
Builds a stateful aggregator for tensorflow_privacy DPQueries. The returned StatefulAggregateFn can be called with any nested structure for the values being statefully aggregated. However, it's necessary to provide two functions as arguments which indicate the properties (the tff.Type and the AnonymousTuple conversion)... | def build_dp_aggregate(query,
value_type_fn=_default_get_value_type_fn,
from_tff_result_fn=_default_from_tff_result_fn):
@computations.tf_computation
def initialize_fn():
return query.initial_global_state()
def next_fn(global_state, value, weight=None):
"""D... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def next_fn(global_state, value, weight=None):\n # Weighted aggregation is not supported.\n # TODO(b/140236959): Add an assertion that weight is None here, so the\n # contract of this method is better established. Will likely cause some\n # downstream breaks.\n del weight\n\n ####################... | [
"0.5205584",
"0.50918466",
"0.49902079",
"0.49407372",
"0.48865604",
"0.4854592",
"0.48124307",
"0.47931963",
"0.47534996",
"0.4630074",
"0.46221364",
"0.46129766",
"0.45933208",
"0.4583318",
"0.45298833",
"0.4529272",
"0.4526826",
"0.45066252",
"0.4489301",
"0.4479052",
"0.4... | 0.7343632 | 0 |
Yield every PDF file that is downloaded. | def yield_pdfs(DATA_PDFS_DIR, websites):
for name, url in websites:
filenames = set()
path_to_pdfs = os.path.join(DATA_PDFS_DIR, name)
for dirpath, dirnames, filenames in os.walk(path_to_pdfs):
for filename in filenames:
# If it's not a PDF, conti... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def download_all(self, to: str = None) -> Generator:\n\n for filename in self.list_files():\n yield (self.download(filename, to))",
"def download_files(self):",
"def scrape_pdfs(db):\n process = CrawlerProcess()\n process.crawl(PdfSpider, db=db)\n process.start()",
"def get_all_pdf... | [
"0.6822793",
"0.6721558",
"0.66759354",
"0.6617647",
"0.6446902",
"0.6425581",
"0.63709795",
"0.63346994",
"0.62653714",
"0.6243494",
"0.6221893",
"0.6189859",
"0.6175602",
"0.61660016",
"0.61469537",
"0.6129171",
"0.61226255",
"0.60770833",
"0.60222864",
"0.6008036",
"0.5953... | 0.6771452 | 1 |
Convert PDF files to TXT files. | def convert_to_txt(DATA_PDFS_DIR, websites):
# Create folder for data if it does not exist
if not os.path.exists(DATA_TXTS_DIR):
os.makedirs(DATA_TXTS_DIR)
for name, url in websites:
folder_name = os.path.join(DATA_TXTS_DIR, name)
# Create folder for data if it does not exis... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _pdf_to_txt(file_path, dst_dir, file_name):\n if file_name is None:\n file_name = os.path.split(file_path)[1]\n file_dst = os.path.join(dst_dir, re.sub(r'\\.pdf$', '.txt', file_name))\n return subprocess.call([\"pdftotext\", \"-layout\", file_path, file_dst])",
"def convert_pdf_to_txt(pdf):\... | [
"0.73306847",
"0.68060315",
"0.6701258",
"0.6658829",
"0.65699595",
"0.64769423",
"0.6445748",
"0.6442936",
"0.63904786",
"0.6377024",
"0.637628",
"0.6308003",
"0.61818826",
"0.6172947",
"0.61256874",
"0.6095832",
"0.60952777",
"0.6089114",
"0.6080539",
"0.6035929",
"0.601920... | 0.7599669 | 0 |
Get the URL for themoviedb API given the suffix | def getMovieDBUrl(suffix):
return "https://api.themoviedb.org/3/" + suffix + "?api_key=670a2f04173250a43eca59d9e2c922d9" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def url(self, suffix: str, *, version: Optional[str] = None,\n query: Union[None, dict, MultiValueDict] = None,\n **kwargs: Any) -> str:\n name = self.url_name_format.format(\n version=version,\n app_label=self.app_label,\n basename=self.basename,\n ... | [
"0.6358041",
"0.6207377",
"0.61981964",
"0.61689705",
"0.60952246",
"0.60581464",
"0.587869",
"0.5874134",
"0.5837255",
"0.58243454",
"0.5790284",
"0.5762941",
"0.57506764",
"0.57333446",
"0.57219446",
"0.57161736",
"0.5715801",
"0.5709266",
"0.5704843",
"0.57006556",
"0.5690... | 0.7512384 | 0 |
Return the contents of a Homebrew formula for the DC/OS E2E CLI. | def get_homebrew_formula(archive_url: str, head_url: str) -> str:
repository_root = Path(__file__).parent.parent
direct_requires = _get_dependencies(
requirements_file=repository_root / 'requirements.txt',
)
indirect_requires = _get_dependencies(
requirements_file=repository_root / 'indi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def maint_brew():\n os.system('brew update')",
"def getFormula(self):\n dataDict = self.__dict__\n # get formula dictionary\n dd = {}\n for ca in self.chemAtoms:\n if isinstance(ca, ChemAtom):\n ss = ca.elementSymbol\n ii = dd.get(ss)\n if ii is None:\n dd[ss] = ... | [
"0.559126",
"0.5487508",
"0.5301324",
"0.52315724",
"0.5222269",
"0.5152385",
"0.49850598",
"0.49735066",
"0.48927054",
"0.48673534",
"0.48570484",
"0.47895178",
"0.47872412",
"0.47452047",
"0.4740367",
"0.47386047",
"0.46923408",
"0.46212888",
"0.46167478",
"0.46099424",
"0.... | 0.7325217 | 0 |
Get an overview of all packages on versionlock | def fct_versionlock(module, repo_mgr, action, package=''):
if repo_mgr != 'dnf':
quiet_opt = '-q'
else:
quiet_opt = ''
rc_code, out, err = module.run_command("/usr/bin/%s %s versionlock %s %s"
% (repo_mgr, quiet_opt, action, package), environ_update... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_packages(self):\n for tag, pkg in PACKAGES.iteritems():\n print \"{tag} - {label}\".format(tag=tag, label=pkg['label'])",
"def list_packages(pretty=False) -> Dict:\n\n packages = dict()\n lp = Commands._list_packages()\n inst_packages = lp.stdout.split('\\n')[:-1]\... | [
"0.65914",
"0.6480198",
"0.6449912",
"0.640737",
"0.6321675",
"0.63007045",
"0.6298328",
"0.6275694",
"0.626345",
"0.625837",
"0.62422013",
"0.623043",
"0.6204857",
"0.6185309",
"0.6110554",
"0.6101472",
"0.6063488",
"0.6059704",
"0.60572505",
"0.6043046",
"0.60205954",
"0.... | 0.6538873 | 1 |
Check that the 'alias' attribute is validated as nonblank during PUTs | def test_alias_put(self):
response = self.api_client.post(
"/api/storage_resource/",
data={"plugin_name": "loadable_plugin", "class_name": "TestScannableResource", "attrs": {"name": "foobar"}},
)
self.assertHttpCreated(response)
resource = self.deserialize(respons... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_on_put_request(self, data, **kwargs):\n if request.method == \"PUT\":\n if \"bio\" not in data or \"website\" not in data:\n raise ValidationError(\"Missing one or more fields.\")",
"def clean_alias(self):\n alias = self.cleaned_data.get('alias')\n if n... | [
"0.63717985",
"0.6264584",
"0.5931844",
"0.582979",
"0.5747125",
"0.55830914",
"0.55746233",
"0.54520816",
"0.5448109",
"0.5446918",
"0.5386774",
"0.5382032",
"0.53581345",
"0.5350065",
"0.53417295",
"0.5282094",
"0.5280501",
"0.5279442",
"0.5270164",
"0.52482396",
"0.521327"... | 0.6772069 | 0 |
Adds an atom to the atom list. The atom comes with all the information usually found in a PDB file. | def add_atom(atom_list, atom_name, residue_name, residue_number, x, y, z, atom_number):
atom_list.append(Atom(atom_number, atom_name, residue_name, residue_number, x, y, z))
return atom_list | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def addAtom(self, atom):\n atomname = atom.get(\"name\")\n self.atoms[atomname] = atom",
"def add(self, atom, reset_id=False):\n if reset_id:\n atom.id = self.natoms\n self.atoms.append(atom)\n self.natoms += 1\n self.atomtypes[atom.z] += 1\n try:\n ... | [
"0.7738185",
"0.73664606",
"0.717241",
"0.69871163",
"0.69803953",
"0.6962289",
"0.6714973",
"0.66158295",
"0.65712506",
"0.62302136",
"0.61181337",
"0.5887279",
"0.58824146",
"0.5682133",
"0.5647615",
"0.5622517",
"0.5587636",
"0.5567386",
"0.5562684",
"0.54838705",
"0.54813... | 0.77166885 | 1 |
Removes an atom from the atom list. | def remove_atom(atom_list, atom):
del atom_list[atom.atom_number - 1]
del atom
return atom_list | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove(self, atom):\n try:\n self.hutch.remove_atom(atom)\n except:# AttributeError or ValueError:\n pass\n self.atoms.remove(atom)\n self.natoms -= 1\n self.atomtypes[atom.z] -= 1",
"def remove_atom(self, atom):\n assert atom.fragment == self\n... | [
"0.81816506",
"0.80600256",
"0.8004338",
"0.78485745",
"0.7643243",
"0.6889501",
"0.66275686",
"0.6609807",
"0.65377444",
"0.6481494",
"0.6470861",
"0.6396034",
"0.63607514",
"0.6304145",
"0.62966335",
"0.62059665",
"0.6186287",
"0.6181248",
"0.6177689",
"0.6134772",
"0.61347... | 0.8369816 | 0 |
This is the function used to generate a pristine graphene sheet. To fit PDB standards, all distances are expressed in Angstroms. | def generate_pristine_graphene(x_dim, y_dim, filename1):
y_number = round(y_dim / 1.228)
x_number = int(x_dim / 2.127)
x_addition = (x_dim / 2.127 ) % 1
list_of_coords = []
a = 0
b = 0
c = 0
list_of_coords = fill_row(list_of_coords, y_number, a,b,c, [], 5, prev = False)
for i in rang... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_full_graph(self):",
"def exercise():\n pi_good = get_pdb_inputs(pdb_str=pdb_str_answer, restraints=False)\n map_data = get_map(xrs=pi_good.xrs)\n xrs_good = pi_good.xrs.deep_copy_scatterers()\n pi_good.ph.write_pdb_file(file_name=\"answer.pdb\",\n crystal_symmetry=xrs_good.crystal_symmetry())\n ... | [
"0.58074695",
"0.57570565",
"0.57222885",
"0.5640091",
"0.5625568",
"0.55195504",
"0.54763794",
"0.5466902",
"0.5465751",
"0.5380728",
"0.5379968",
"0.5362736",
"0.53350985",
"0.5326548",
"0.5293786",
"0.5284745",
"0.52768046",
"0.5273772",
"0.5266911",
"0.5259586",
"0.525841... | 0.61681694 | 0 |
This is the function used to write a PDB file using the list of coordinates from generate_pristine_graphene. | def writepdb3(list_of_coords, name):
list_of_coords2 = []
for elem in range(len(list_of_coords)):
if (list_of_coords[elem] not in list_of_coords2):
list_of_coords2.append(list_of_coords[elem])
os.chdir(os.getcwd())
if ((".pdb" not in name) and (".PDB" not in name)):
string = ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def writepdb(self,fname):\n pdbfile = open(fname + \".pdb\", \"w\")\n for a in self.atoms:\n pdbfile.write(str(a.type) + \"\\t\" + str(a.x) + \"\\t\" + str(a.y) + \"\\t\" + str(a.z) + \"\\n\")\n pdbfile.close()",
"def write_pdb(filename, trajectory, atoms):\n\n ... | [
"0.65731066",
"0.65483725",
"0.6508823",
"0.64895844",
"0.6416523",
"0.6411054",
"0.63768214",
"0.637249",
"0.6244294",
"0.6212441",
"0.6167435",
"0.61630696",
"0.60493743",
"0.600561",
"0.5847776",
"0.5835643",
"0.5829231",
"0.5789734",
"0.5777291",
"0.57600725",
"0.5759356"... | 0.74563414 | 0 |
Used to fill a row of hexagons given a starting point XYZ coords. (here a,b,c) and the number of "halves" of a hexagon to add. | def fill_row(list_of_coords, halves, a,b,c, takeout, full=6, prev = False):
for i in range(int(halves / 2 )):
list_of_coords = fill_hexagon(list_of_coords, a, b, c, takeout, full, prev)
a += 2.456
if ((halves % 2 == 1) and (prev == False)):
takeout.append(3)
takeout.append(4)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fill_hexagon(list_of_coords, a, b, c, takeout, full = 6, prev = False):\n list_of_vertices = [[a, b, c], [a, b + 1.418, c], [a + 1.228, b + 2.127, c], [a + 2.456, b + 1.418, c], [a + 2.456, b, c], [a + 1.228, b - 0.705, c]]\n for element in range(full):\n if (check_me(list_of_vertices[element], li... | [
"0.6539534",
"0.6279681",
"0.6237863",
"0.60956645",
"0.6078617",
"0.6058243",
"0.6041687",
"0.5934111",
"0.5687956",
"0.5640309",
"0.55998814",
"0.5536763",
"0.5532874",
"0.55301476",
"0.55035007",
"0.54992265",
"0.5495786",
"0.5466942",
"0.5389856",
"0.5386232",
"0.5349324"... | 0.7418444 | 0 |
Given the XYZ coordinates (here a,b,c) of a carbon atom, this function is used to find the coordinates of the other atoms making up the hexagon. Takeout takes out one of the 6 atoms making up the hexagon. "prev" is used to know whether the row is an odd number row or not. | def fill_hexagon(list_of_coords, a, b, c, takeout, full = 6, prev = False):
list_of_vertices = [[a, b, c], [a, b + 1.418, c], [a + 1.228, b + 2.127, c], [a + 2.456, b + 1.418, c], [a + 2.456, b, c], [a + 1.228, b - 0.705, c]]
for element in range(full):
if (check_me(list_of_vertices[element], list_of_co... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def xy(self,output):\n ll=len(output)\n if ll:\n xy=[]\n for i in range(0,ll-2,2):\n xynow=(float(output[i]),float(output[i+1]))\n flag=1\n for j in xy:\n if (j == xynow):\n flag=0\n if flag:\n xy.append(xynow)\n else:\n xy=None\n ... | [
"0.5732354",
"0.5492416",
"0.5443659",
"0.5314317",
"0.52794427",
"0.5084408",
"0.5077427",
"0.5059381",
"0.5050891",
"0.50432587",
"0.50337404",
"0.5008957",
"0.49690297",
"0.4937745",
"0.4936674",
"0.4928313",
"0.49259818",
"0.49203378",
"0.49002165",
"0.48991254",
"0.48667... | 0.5655109 | 1 |
Function used to take the list of coordinates and add an Atom object instance for each coordinate triplet | def pristine_coords_to_objects(list_of_coords):
list_of_objects = []
for element in range(len(list_of_coords)):
list_of_objects.append(Atom(element, "CX", "GGG", element, list_of_coords[element][0], list_of_coords[element][1], list_of_coords[element][2]))
return list_of_objects | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_atom(atom_list, atom_name, residue_name, residue_number, x, y, z, atom_number):\n atom_list.append(Atom(atom_number, atom_name, residue_name, residue_number, x, y, z))\n return atom_list",
"def __add__(self, coordinate_list):\n if not isinstance(coordinate_list, list):\n raise Typ... | [
"0.68043524",
"0.6438199",
"0.61907",
"0.6102074",
"0.5922237",
"0.59002936",
"0.58685565",
"0.5867035",
"0.5844601",
"0.5833002",
"0.57233095",
"0.5714247",
"0.57074636",
"0.57025313",
"0.56459725",
"0.5587802",
"0.55776983",
"0.55396456",
"0.54852694",
"0.5476022",
"0.54275... | 0.67977816 | 1 |
Reads in a GO layer where C atom name is "CX", residue name is 'GGG' | def read_in_GO(pdbfile):
with open(pdbfile, "r") as f:
filedata = f.read()
filedata = filedata.replace("C GRA X", "CX GGG ")
content = filedata.splitlines()
atom_lines = [x.split() for x in content if (('ATOM' in str(x)) and (('C1A' in str(x)) or ('E1A' in str(x)) or ('H1A' in st... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_graph( gname ):\n return NX.read_gpickle( gname )",
"def get_c(layer_configs):\n net_config = layer_configs['000_net']\n return net_config.get('channels', 3)",
"def readGromacs(self, phys, topname, parname, gbname=\"\"):\r\n\r\n\tgroTop = GromacsTopologyReader.GromacsTopology()\r\n\tgroPar = ... | [
"0.5499076",
"0.5181781",
"0.5174483",
"0.51446635",
"0.5089358",
"0.50796044",
"0.4983791",
"0.49594125",
"0.49416086",
"0.4940975",
"0.48735794",
"0.48544577",
"0.4854051",
"0.48317352",
"0.48188177",
"0.4807219",
"0.4803295",
"0.47887984",
"0.47845027",
"0.4778551",
"0.476... | 0.5859266 | 0 |
Creates bond_id of two atoms, taking into account their residue names and atom_names. | def get_bond_id(atom1, atom2):
id1 = [str(atom1.atom_name) + str(atom2.atom_name) + str(atom1.residue_name) + str(atom2.residue_name), str(atom2.atom_name) + str(atom1.atom_name) + str(atom2.residue_name) + str(atom1.residue_name)]
return id1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_bond_name(bond):\n return (bond.atom1.res_name +\n bond.atom1.res_num + ' ' + \n bond.atom1.chain + ' ' + \n bond.atom1.name + ' : ' + \n bond.atom2.res_name +\n bond.atom2.res_num + ' ' + \n bond.atom2.chain + ' ' + \n bond.a... | [
"0.5819093",
"0.57624966",
"0.54944396",
"0.5307146",
"0.52600217",
"0.51862395",
"0.51709616",
"0.5157357",
"0.51250386",
"0.50164276",
"0.4948787",
"0.49435005",
"0.49417323",
"0.49354196",
"0.4890637",
"0.48039883",
"0.47693184",
"0.4759231",
"0.47442615",
"0.47202095",
"0... | 0.74954826 | 0 |
A potential bond between two atoms is verified in the bond_list taking into account its id resulting from get_bond_id and distance between the two atoms. | def check_bond(atom1, atom2):
check = False
for bond in bond_list:
if (((bond.identity == get_bond_id(atom1, atom2)[0]) or (bond.identity == get_bond_id(atom1, atom2)[1])) and 0.975 * bond.length <= calculate_3D_distance_2_atoms(atom1, atom2) <= 1.025 * bond.length):
check = True
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validBond(index1, index2, direction):\n #print \"?valid bond: \", allAtoms[index1].pos, \" , \", allAtoms[index2].pos, direction\n cell1 = index1/numAtomsPerCell\n cell2 = index2/numAtomsPerCell\n #Find the coordinates of the cell in units of interaction cells\n ... | [
"0.6186295",
"0.61098385",
"0.6053151",
"0.6040306",
"0.5994569",
"0.589903",
"0.5815888",
"0.57699937",
"0.5749555",
"0.56967866",
"0.56847703",
"0.5631913",
"0.5624613",
"0.5601342",
"0.5586704",
"0.55862606",
"0.556935",
"0.5522519",
"0.55160606",
"0.54544383",
"0.5427041"... | 0.65880626 | 0 |
Similar to check_bond, but using two specified bond_lists from the three available. Used when placing hydrogen atoms in add_rGO_PEG_NH2 | def check_if_no_bond(atom1, atom2, bond_list, bond_generic):
check = False
for bond in bond_list:
if ((bond.identity == get_bond_id(atom1, atom2)[0]) or (bond.identity == get_bond_id(atom1, atom2)[1]) and calculate_3D_distance_2_atoms(atom1, atom2) > 1.05 * bond.length):
check = True
for... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bond_atoms(atom_list):\n pass",
"def check_bond(atom1, atom2):\n check = False\n for bond in bond_list:\n if (((bond.identity == get_bond_id(atom1, atom2)[0]) or (bond.identity == get_bond_id(atom1, atom2)[1])) and 0.975 * bond.length <= calculate_3D_distance_2_atoms(atom1, atom2) <= 1.025 * ... | [
"0.6599388",
"0.6574891",
"0.64686096",
"0.633723",
"0.6056417",
"0.59623265",
"0.58595073",
"0.5820499",
"0.5757483",
"0.5666385",
"0.56229997",
"0.5556167",
"0.5555862",
"0.5525133",
"0.54775256",
"0.5410893",
"0.5405527",
"0.540433",
"0.5381466",
"0.5361995",
"0.53291494",... | 0.7158534 | 0 |
Based on the get_bond_id output, determine whether an atom is connected to a functional group. Used when removing functional groups. | def check_connected(chosen_atom, identified_bonds):
check = False
for bond in identified_bonds:
if (("E1AE1A" in str(get_bond_id(chosen_atom, bond[0])[0])) or ("C1AC1A" in str(get_bond_id(chosen_atom, bond[0])[0])) or ("H1AH1A" in str(get_bond_id(chosen_atom, bond[0])[0])) or ("P1AP1A" in str(get_bond_i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_connected(self):\n if self._connected:\n return True\n else:\n return perms_are_connected(self._g, self.degree())",
"def _is_connected(self, z, F_j):\n return z in F_j or any(not self._graph.has_edge(x, z) for x in F_j)",
"def can_group(self) -> bool:\n ... | [
"0.5639041",
"0.5602656",
"0.55000603",
"0.5435613",
"0.54332566",
"0.54201615",
"0.5411788",
"0.5391956",
"0.53430617",
"0.5339298",
"0.5338788",
"0.53010756",
"0.52887666",
"0.52853286",
"0.5270862",
"0.52645504",
"0.5260643",
"0.52565795",
"0.52476025",
"0.5202234",
"0.518... | 0.58683366 | 0 |
The identify_bonds function finds the neighbours of the given atom in a distance based manner. This distance is different for when placing GO groups to when placing PEGNH2 chains and also when placing hydrogens vs the skeleton of the PEGNH2 chains. The function then uses the check_bond function to identify valid bonds. | def identify_bonds(chosen_atom, atom_list):
list_of_hydrogens = ['H15', 'H14', 'H13', 'H12', 'H11', 'H10', 'H9', 'H8', 'H7', 'H6', 'H5', 'H4', 'H3', 'H2', 'H1']
if ((chosen_atom.atom_name not in list_of_hydrogens) and (chosen_atom.residue_name != "P1A")):
nearby_atoms_crude = [atom for atom in atom_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extract_bonds(self):\n atom_types = self.contents['Sub_ID']\n atom_ids = self.contents['ID']\n bond_list = []\n for key, value in self.bonds.items():\n a = value[0]\n b = value[1]\n\n A = np.asarray(atom_types).reshape(-1, 3)\n B = np.asar... | [
"0.60463786",
"0.6027861",
"0.5813208",
"0.5661234",
"0.565953",
"0.55833775",
"0.5567187",
"0.5551988",
"0.55498964",
"0.55498964",
"0.55498964",
"0.55277956",
"0.5524735",
"0.54772073",
"0.5472997",
"0.5457496",
"0.5425234",
"0.541873",
"0.54183525",
"0.5397761",
"0.5383754... | 0.72122157 | 0 |
Random top or below draw. | def top_or_down():
ct = random.randint(1,2)
if (ct == 1):
return 1
else:
return -1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_random_pos_on_top(self):\n # z = self._top_position() - self.offset\n z = self.upper_vertex[2] - self.offset\n x_lower, x_upper = self._shrink_range_by_padding(self._x_range())\n y_lower, y_upper = self._shrink_range_by_padding(self._y_range())\n x = random.uniform(x_low... | [
"0.6487723",
"0.63800305",
"0.6365905",
"0.63507515",
"0.63405263",
"0.62501454",
"0.6246273",
"0.6160172",
"0.6147852",
"0.6105703",
"0.6098319",
"0.6077221",
"0.6057374",
"0.6048728",
"0.5955069",
"0.59546584",
"0.59428465",
"0.59113586",
"0.5909738",
"0.58938545",
"0.58804... | 0.66756016 | 0 |
Function used to create the GO morphology. The three functional groups are placed in no specific order, picking the next to be added at random. One may want to place COOH groups first due to limited space, however this is rarely an issue. 50 attempts are made for each placement. After 50 attempts the placement is consi... | def create_GO(init_file, no_COOH, no_epoxy, no_OH, filename1):
global atoms
global bond_list
bond_list = bond_list_1
atoms = read_in_graphene(init_file)
global anywhere_map
anywhere_map = get_map_anywhere(atoms)
global edge_map
edge_map = get_map_edge(atoms)
list_residue_numbers... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def groups(self):\n\n\t\tprint \"completed minimization\"\n\t\tcopy(self.rootdir+'counterions-minimized.gro',self.rootdir+'system.gro')\n\t\tcopy(self.rootdir+'counterions.top',self.rootdir+'system.top')\n\t\tif self.simscale == 'aamd': grouptype = 'standard'\n\t\tif self.simscale == 'cgmd': grouptype = 'cgmd_wate... | [
"0.5894876",
"0.5781242",
"0.5730517",
"0.551671",
"0.5376357",
"0.5370456",
"0.53144366",
"0.52874845",
"0.5274694",
"0.52378386",
"0.52260196",
"0.52198815",
"0.5218324",
"0.5208903",
"0.52020997",
"0.5184273",
"0.51820487",
"0.5179254",
"0.5168983",
"0.51290977",
"0.511060... | 0.6625531 | 0 |
Function used to add carboxyl atoms. Atom placement follows a geometrical approach. Atom chosen CX atom. Atom_list the atom list so far. Added_functional_groups the number of functional groups added so far. Ct the random top or below coordinate. Adds 4 atoms and replaces 1 (5 in total). | def add_carboxyl(atom, atom_list, added_functional_groups, ct):
global anywhere_map
global edge_map
current_size = len(atom_list)
placed = 0
alpha = random.randint(0,359)
x = atom.x
y = atom.y
z = atom.z
while (placed <= 359):
alpha += 1
carbon_atom = Atom(curren... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_epoxy(atom, atom_list, added_functional_groups, ct):\n global anywhere_map\n global edge_map\n current_size = len(atom_list)\n list_of_n = [x[0] for x in identify_bonds(atom, atom_list) if (x[0].atom_name != \"CY\")]\n if (len(list_of_n) != 0):\n atom2 = random.choice(list_of_n)\n ... | [
"0.6713287",
"0.64211106",
"0.54855675",
"0.53145826",
"0.5277012",
"0.5246398",
"0.5020401",
"0.49865887",
"0.49251515",
"0.49135336",
"0.48709583",
"0.48675424",
"0.4806133",
"0.48057967",
"0.48043397",
"0.47737265",
"0.4768227",
"0.47265372",
"0.47006288",
"0.47002664",
"0... | 0.81036085 | 0 |
Function used to add epoxy atoms. Atom placement follows a geometrical approach. Atom chosen CX atom. Atom_list the atom list so far. Added_functional_groups the number of functional groups added so far. Ct the random top or below coordinate. Ads 1 atom and replaces 2 (3 in total). | def add_epoxy(atom, atom_list, added_functional_groups, ct):
global anywhere_map
global edge_map
current_size = len(atom_list)
list_of_n = [x[0] for x in identify_bonds(atom, atom_list) if (x[0].atom_name != "CY")]
if (len(list_of_n) != 0):
atom2 = random.choice(list_of_n)
epoxy_atom... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_carboxyl(atom, atom_list, added_functional_groups, ct):\n \n global anywhere_map\n global edge_map\n current_size = len(atom_list)\n placed = 0\n alpha = random.randint(0,359)\n x = atom.x\n y = atom.y\n z = atom.z\n while (placed <= 359):\n alpha += 1\n carbon_a... | [
"0.7185367",
"0.68237245",
"0.53464985",
"0.5098716",
"0.5038443",
"0.50046945",
"0.4927326",
"0.48727",
"0.4871286",
"0.4780769",
"0.47495335",
"0.46799132",
"0.46702334",
"0.46233776",
"0.46228707",
"0.46093047",
"0.45706904",
"0.4547904",
"0.45355213",
"0.4534909",
"0.4524... | 0.79223156 | 0 |
Function used to add hydroxyl atoms. Atom placement follows a geometrical approach. Atom chosen CX atom. Atom_list the atom list so far. Added_functional_groups the number of functional groups added so far. Ct the random top or below coordinate. Ads 2 atom and replaces 1 (3 in total). | def add_hydroxyl(atom, atom_list, added_functional_groups, ct):
global anywhere_map
global edge_map
current_size = len(atom_list)
placed = 0
alpha = random.randint(0,359)
while (placed <= 359):
alpha += 1
oxygen_atom = Atom(current_size + 1, 'OL', 'H1A', str(added_functional_grou... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_carboxyl(atom, atom_list, added_functional_groups, ct):\n \n global anywhere_map\n global edge_map\n current_size = len(atom_list)\n placed = 0\n alpha = random.randint(0,359)\n x = atom.x\n y = atom.y\n z = atom.z\n while (placed <= 359):\n alpha += 1\n carbon_a... | [
"0.7154419",
"0.67589873",
"0.57363045",
"0.535511",
"0.4996133",
"0.48109645",
"0.47990066",
"0.47966743",
"0.47704136",
"0.47679663",
"0.47478798",
"0.46701872",
"0.46699533",
"0.45923892",
"0.45877713",
"0.45871854",
"0.4581873",
"0.45516774",
"0.45335245",
"0.45293304",
"... | 0.8013859 | 0 |
Used to remove pct_C1A of present carboyl groups etc. | def remove_functional_groups(pct_C1A, pct_E1A, pct_H1A, atom_list):
carboxyl_map = get_carboxyl_map(atom_list)
epoxy_map = get_epoxy_map(atom_list)
hydroxyl_map = get_hydroxyl_map(atom_list)
remove_C1A = round(len(carboxyl_map) * pct_C1A)
remove_E1A = round(len(epoxy_map) * pct_E1A)
remove_H1A =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clean_pcts(x):\n # if not enough data, will be '-' with investing.com\n if x == '-' or pd.isnull(x):\n return np.nan\n elif x == 'unch':\n return float(0)\n elif type(x) == float:\n return x\n\n new_x = x.replace('+', '')\n new_x = new_x.replace('%', '')\n new_x = floa... | [
"0.5649863",
"0.5551654",
"0.5408934",
"0.5392904",
"0.5384694",
"0.5327598",
"0.5312385",
"0.52710336",
"0.5259765",
"0.52368516",
"0.5205838",
"0.5197768",
"0.5163567",
"0.5161844",
"0.51593155",
"0.5124159",
"0.5100206",
"0.50965226",
"0.50911784",
"0.50842947",
"0.5082043... | 0.6484074 | 0 |
Used to find the highest / last residue number. | def find_highest_resnum(atom_list):
resnum = 0
for element in atom_list:
if (int(element.residue_number) > int(resnum)):
resnum = int(element.residue_number)
return resnum | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def max_known_number(self):\n return len(self.number_list)-1",
"def _find_last_seq(self, index_name):\n self.logger.info(\"Finding max seq for index %s\" % index_name)\n search_body = {\n \"query\": { \"match_all\": {}},\n \"size\": 1,\n \"sort\": [{\n ... | [
"0.68624806",
"0.66956",
"0.6682083",
"0.666168",
"0.6642356",
"0.6617765",
"0.6590314",
"0.6423238",
"0.639916",
"0.63857675",
"0.6384603",
"0.63456",
"0.6342565",
"0.62859154",
"0.6276478",
"0.6270209",
"0.625253",
"0.6246631",
"0.6221926",
"0.62047595",
"0.61829454",
"0.... | 0.7257084 | 0 |
Using the given XYZ coordinates as the center of the sphere, and the typical bond distance of the two atoms of interest we plot random points on a sphere. In a similar manner, we then imagine the spheres of nearby atoms (centers and radii) and test the distance between each random point and nearby atoms. If too small, ... | def fix_sphere_m (center_x, center_y, center_z, radius, centers, radii, len_points):
g_x = []
g_y = []
g_z = []
points = [hydrogen_coord_gen(center_x, center_y, center_z, radius) for i in range(0, len_points)]
x = [points[i][0] for i in range(0, len(points))]
y = [points[i][1] for ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def onsphere(size=None):\n xy = oncircle(size)\n z = 2.*random(xy.shape[:-1] + (1,)) - 1.\n xy *= sqrt(1. - z*z)\n return concatenate((xy, z), axis=-1)",
"def randomPointOnSphere(r):\n x = np.random.normal()\n y = np.random.normal()\n z = np.random.normal()\n point = np.array([x, y, z])\n... | [
"0.6930963",
"0.66714126",
"0.6644508",
"0.66359216",
"0.6561048",
"0.6553409",
"0.65208846",
"0.6480456",
"0.64685297",
"0.6395999",
"0.63253003",
"0.6318254",
"0.62989146",
"0.6154179",
"0.61475766",
"0.6072959",
"0.6036923",
"0.60270894",
"0.6024006",
"0.602383",
"0.601213... | 0.68015945 | 1 |
Generate an Ndoped layer. N3A residue name used for N_graphitic. N2A residue name used for N_pyridinic. N2N residue name used for N_pyrrolic. | def generate_N_doping(path, N_graphitic, N_pyridinic, N_pyrrolic, filename1):
global bond_list
bond_list = bond_list_1 + bond_list_3
atom_list = read_in_graphene(path)
rings = find_rings(atom_list)
bond_list = bond_list_1 + bond_list_3
map_3, map_2, map_2n = filter_carbon_atoms(atom_list, rings)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def name_layer_factory(num=0, name_prefix=\"\", name_suffix=\"\"):\n def name_layer_fn(layer):\n return '{}{}{}-{}'.format(name_prefix, layer, name_suffix, num)\n \n return name_layer_fn",
"def make_nodes(n):\n return [\n protein(namespace='NS', name=str(i))\n for i in range(1, n... | [
"0.5972292",
"0.5662223",
"0.56469923",
"0.5564747",
"0.55152094",
"0.54774547",
"0.5452712",
"0.5438887",
"0.54362386",
"0.5432062",
"0.54218477",
"0.5421439",
"0.53894156",
"0.5386836",
"0.53205645",
"0.52842844",
"0.5282403",
"0.5278275",
"0.52094615",
"0.52000093",
"0.518... | 0.5663064 | 1 |
Returns a list of atoms representing atoms on the contour/edge of the graphenic layer and of the existing holes. Used to prevent new holes touching existing ones. | def get_contour(atom_list):
initial = [atom for atom in atom_list if ((0 < len(identify_bonds(atom, atom_list)) < 3) and (check_connected(atom, identify_bonds(atom, atom_list)) == False))]
extra_1 = []
for atom in atom_list:
neighbours = [bond[0] for bond in identify_bonds(atom, atom_list)]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_contour(hole_atoms, atom_list):\n contour_atoms = []\n extra_atoms = []\n global bond_list\n bond_list = bond_list_1\n for atom in hole_atoms:\n c = [bond[0] for bond in identify_bonds(atom, atom_list) if ((bond[0] not in hole_atoms) and (bond[0] not in contour_atoms))]\n for ... | [
"0.72873443",
"0.6582357",
"0.6486398",
"0.608028",
"0.59882003",
"0.5970188",
"0.59671474",
"0.58909136",
"0.588228",
"0.58613706",
"0.58591586",
"0.58287656",
"0.58275",
"0.582627",
"0.57437956",
"0.5704725",
"0.56897026",
"0.5658169",
"0.5642107",
"0.5628244",
"0.5623437",... | 0.67225623 | 1 |
After hole creation, some small fragments (<=6 atoms) can remain entirely isolated. These are removed using this function. | def hole_cleanup(atom_list):
joey = atom_list.copy()
while (len(joey) != 0):
for atom in joey:
takein = [atom]
source_update = takein.copy()
check = 1
while (check == 1):
source = source_update.copy()
source_update = []
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cleanup(self):\n for residue in self.debumper.biomolecule.residues:\n if not isinstance(residue, aa.Amino):\n continue\n if residue.name == \"GLH\" or \"GLH\" in residue.patches:\n if residue.has_atom(\"HE1\") and residue.has_atom(\"HE2\"):\n ... | [
"0.62030935",
"0.61782753",
"0.58885705",
"0.58629674",
"0.58593816",
"0.5856905",
"0.5852919",
"0.5848338",
"0.5808147",
"0.579738",
"0.57890904",
"0.57470953",
"0.56822985",
"0.5664445",
"0.56148964",
"0.5600071",
"0.5581873",
"0.5538892",
"0.55261403",
"0.5510979",
"0.5507... | 0.68224764 | 0 |
Returns a list of atoms representing atoms on the contour/edge of the graphenic layer and of the existing holes. Used to prevent new holes touching existing ones. | def find_contour(hole_atoms, atom_list):
contour_atoms = []
extra_atoms = []
global bond_list
bond_list = bond_list_1
for atom in hole_atoms:
c = [bond[0] for bond in identify_bonds(atom, atom_list) if ((bond[0] not in hole_atoms) and (bond[0] not in contour_atoms))]
for element in c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_contour(atom_list):\n initial = [atom for atom in atom_list if ((0 < len(identify_bonds(atom, atom_list)) < 3) and (check_connected(atom, identify_bonds(atom, atom_list)) == False))]\n \n extra_1 = []\n for atom in atom_list:\n neighbours = [bond[0] for bond in identify_bonds(atom, atom_... | [
"0.67212147",
"0.6583964",
"0.6485464",
"0.60798305",
"0.5989183",
"0.5969657",
"0.59682745",
"0.5890468",
"0.5881151",
"0.5862929",
"0.5857462",
"0.58304733",
"0.5828795",
"0.58252805",
"0.5745302",
"0.570288",
"0.5691466",
"0.5657655",
"0.56418115",
"0.56291354",
"0.5623697... | 0.72864246 | 0 |
Hole generation function. uorm "u"nidirectional or "m"ultidirectional. iore "i"nterior (not touching edges) or "e"xterior cleanup "a" if active. | def hole_generation(init_file, number_of_holes, atom_range, uorm, iore, cleanup, filename1):
global atoms
global bond_list
bond_list = bond_list_1
atoms = read_in_graphene(init_file)
holes = 0
list_of_contours = get_contour(atoms)
takein = {}
while (holes < number_of_holes):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setHolesCoordinates(self):\n #productive\n profprint()\n self.p = [[0 for j in range(63)] for j in range(3)]\n self.p[0][0]=35\n self.p[1][0]=34\n self.p[0][1]=25\n self.p[1][1]=36.679\n self.p[0][2]=17.679\n self.p[1][2]=44\n self.p[0][3]=15\n self.p[1][3]=54\n self.p[0][4]... | [
"0.5813137",
"0.57826483",
"0.57265216",
"0.5415269",
"0.52940696",
"0.51041937",
"0.5099122",
"0.50941944",
"0.50304085",
"0.50286144",
"0.50111187",
"0.50091594",
"0.5009083",
"0.4998163",
"0.4958455",
"0.49511856",
"0.4950363",
"0.49325427",
"0.49305663",
"0.49299133",
"0.... | 0.65162647 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.