query stringlengths 10 2k | document stringlengths 20 51.2k | metadata dict | negatives listlengths 0 101 | negative_scores listlengths 0 101 | document_score stringlengths 3 10 | document_rank stringclasses 102
values |
|---|---|---|---|---|---|---|
Returns the northernmost latitude (y) value of this box | def north(self):
return self.north_west.ns | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def northing(self):\r\n x, y = self.lonlat2xy(self.longitude, self.latitude)\r\n return y",
"def get_latitude(self):\n return self.position.get_y()",
"def get_latitude0(self):\n return self.B",
"def easting(self):\r\n x, y = self.lonlat2xy(self.longitude, self.latitude)\r\n... | [
"0.8173037",
"0.7091199",
"0.706884",
"0.7043943",
"0.70298046",
"0.68950087",
"0.67898667",
"0.67452896",
"0.6715541",
"0.66612226",
"0.6626793",
"0.6618318",
"0.6563036",
"0.6499221",
"0.6489857",
"0.64711374",
"0.6422164",
"0.642039",
"0.64178944",
"0.63988525",
"0.6396692... | 0.0 | -1 |
Returns the southernmost latitude (y) value of this box | def south(self):
return self.south_east.ns | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def northing(self):\r\n x, y = self.lonlat2xy(self.longitude, self.latitude)\r\n return y",
"def easting(self):\r\n x, y = self.lonlat2xy(self.longitude, self.latitude)\r\n return x",
"def y(self):\n return self.coords[1]",
"def y(self):\n return self._coords[1]",
... | [
"0.7226008",
"0.71624655",
"0.70173377",
"0.69554937",
"0.69368523",
"0.6747194",
"0.6746168",
"0.67419887",
"0.672914",
"0.6726784",
"0.667575",
"0.66624534",
"0.66440904",
"0.6623553",
"0.65987766",
"0.65948105",
"0.65867144",
"0.65790206",
"0.6526591",
"0.64819723",
"0.642... | 0.5992402 | 83 |
Shows your profile if it exists | async def fix_bws_rank(ctx):
user = find_user_in_db(ctx.author.id)
if user is None:
await ctx.send(f"You are not registered as someone.")
return
else:
_, osu_name, rank, bws_rank, country, last_updated, badges = user
embed = discord.Embed(description=f"**▸Rank:** {rank}\n"
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def profile():\r\n user_data = load_user(current_user.id, current_user)\r\n if user_data is not None:\r\n user, followers, following = user_data\r\n\r\n return render_base_template(\"profile.html\", profile=user, followers=followers,\r\n following=following,\r... | [
"0.7245018",
"0.723895",
"0.7061014",
"0.7036423",
"0.6982154",
"0.6870462",
"0.6833645",
"0.67211664",
"0.66525596",
"0.6636437",
"0.659003",
"0.6581685",
"0.6580831",
"0.65781265",
"0.65669817",
"0.65452135",
"0.65230167",
"0.64990133",
"0.64835083",
"0.64659387",
"0.646411... | 0.0 | -1 |
Calculate the at risk group of all patients. For every patient i, this function returns the index of the first patient who died after i, after sorting the patients w.r.t. time of death. Refer to the definition of Cox proportional hazards log likelihood for | def calc_at_risk(T, O, X = None):
tmp = list(T)
T = np.asarray(tmp).astype('float64')
order = np.argsort(T)
sorted_T = T[order]
at_risk = np.asarray([list(sorted_T).index(x) for x in sorted_T]).astype('int32')
T = np.asarray(sorted_T)
O = O[order]
if X is not None:
X = X[ord... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_surgical_patients(con) -> pd.DataFrame:\n combined_diagnoses = get_reason_for_admission(con)\n return combined_diagnoses[combined_diagnoses['surgical'] == 1]",
"def new_infection_events_Garki(ind_df):\r\n first_positive = []\r\n lapsed_positive = []\r\n first_malaria_free_date = None # fi... | [
"0.501897",
"0.50003844",
"0.49462783",
"0.49183226",
"0.48094335",
"0.48047066",
"0.47480386",
"0.47249696",
"0.471031",
"0.468966",
"0.46893495",
"0.46668226",
"0.46274948",
"0.45957595",
"0.45942608",
"0.45904917",
"0.45726103",
"0.45618743",
"0.4560369",
"0.4558646",
"0.4... | 0.0 | -1 |
Checks if the request comes from a user that is admin. | def is_reader():
try:
email = decode_token(request.headers.get('Authorization')[7:])["identity"]
current_admin = Reader.query.filter_by(email=email).first()
except IndexError:
return bad_request("User is not an admin")
if current_admin is None:
return bad_request("User is not an admin") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _check_admin_only(self, request):\r\n api_key = request.params.get(self.api_field, None)\r\n\r\n if request.user is None:\r\n user = self.user_fetcher(api_key=api_key)\r\n else:\r\n user = request.user\r\n\r\n if user is not None and user.is_admin:\r\n ... | [
"0.8841757",
"0.8219326",
"0.8134677",
"0.8120395",
"0.81087875",
"0.81007725",
"0.81007725",
"0.8096001",
"0.80904895",
"0.8083905",
"0.8027866",
"0.8027228",
"0.7900616",
"0.789331",
"0.78927815",
"0.78804296",
"0.78788596",
"0.78722423",
"0.78449744",
"0.7796504",
"0.77827... | 0.6944349 | 81 |
Return the maximum ADC value, used for scaling. | def getMaxValue(self):
# TODO: make this more consistent accross versions
# This was a "fix" when we started supported PS5000a
return self.MAX_VALUE | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cmax(self):\n return self[\"cmax\"]",
"def cmax(self):\n return self['cmax']",
"def native_max_value(self) -> float:\n return TEMP_MAXIMUM",
"def get_max_value(self):\n max_value = max(self.values)\n return max_value",
"def max_value(self) -> float:\n return DE... | [
"0.75562584",
"0.7553085",
"0.7552735",
"0.74330145",
"0.741477",
"0.73668665",
"0.7273102",
"0.7244153",
"0.72127336",
"0.72092843",
"0.7173466",
"0.7155371",
"0.7136926",
"0.71156573",
"0.70434994",
"0.7037464",
"0.7036463",
"0.7012468",
"0.7000745",
"0.69960725",
"0.696182... | 0.6983538 | 20 |
Return the minimum ADC value, used for scaling. | def getMinValue(self):
return self.MIN_VALUE | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def native_min_value(self) -> float:\n return TEMP_MINIMUM",
"def min_value(self) -> float:\n return DEFAULT_MIN_VALUE",
"def _minimum(self) -> float:\n return self._config[CONF_MIN]",
"def min(self) -> float:\n return stats.min(self)",
"def getMinAbundanceOfClrSample(self):\n ... | [
"0.74220705",
"0.7348584",
"0.7188209",
"0.70937306",
"0.7077449",
"0.707502",
"0.70294356",
"0.7028129",
"0.70190513",
"0.7012942",
"0.70107085",
"0.69891375",
"0.69365716",
"0.69323313",
"0.6881551",
"0.68442124",
"0.67836374",
"0.67836374",
"0.67711663",
"0.67711663",
"0.6... | 0.6862799 | 15 |
Set the range for the EXT trigger channel. This is only implemented for PS4000 series devices where the only acceptable values for VRange are 0.5 or 5.0. | def setExtTriggerRange(self, VRange=0.5):
VRangeAPI = None
for item in self.CHANNEL_RANGE:
if np.isclose(item["rangeV"], VRange):
VRangeAPI = item
break
if VRangeAPI is None:
raise ValueError('Provided VRange is not valid')
self._... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_accel_range(self, accel_range):\r\n # First change it to 0x00 to make sure we write the correct value later\r\n self.bus.write_byte_data(self.deviceaddress, self.accel_config, 0x00)\r\n\r\n # Write the new range to the ACCEL_CONFIG register\r\n self.bus.write_byte_data(self.devi... | [
"0.6514397",
"0.6509844",
"0.646073",
"0.6149011",
"0.61339295",
"0.6062431",
"0.60090643",
"0.59642726",
"0.59495276",
"0.593697",
"0.5906719",
"0.58192825",
"0.5766832",
"0.5634188",
"0.5579621",
"0.5547643",
"0.5547073",
"0.55299973",
"0.5518985",
"0.5503746",
"0.5496144",... | 0.8573255 | 0 |
Return connected units as serial numbers as list of strings. | def enumerateUnits(self):
return self._lowLevelEnumerateUnits() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def enumerate_units():\n count = c_int16()\n size = c_int16(1023)\n serials = (c_int8 * size.value)()\n libtype = 'windll' if IS_WINDOWS else 'cdll'\n sdk = LoadLibrary('ps5000a', libtype)\n result = sdk.lib.ps5000aEnumerateUnits(byref(count), byref(serials), byref(size))\n if result != PICO_O... | [
"0.63199675",
"0.6009037",
"0.5999887",
"0.5953307",
"0.5913185",
"0.5901766",
"0.5872697",
"0.5872697",
"0.585725",
"0.5814489",
"0.5787047",
"0.5756824",
"0.5730717",
"0.570653",
"0.57064074",
"0.5705864",
"0.5690127",
"0.5667687",
"0.565771",
"0.56302893",
"0.56248766",
... | 0.0 | -1 |
Set logging level according to whatever value is stored in the environment variable. Order of "if" checks is prioritized by anticipated frequency | def set_logging_level(
manually_set_level=None, environment_variable_key="LOGGING_LEVEL"
):
logger = logging.getLogger()
level = (
os.environ.get(environment_variable_key)
if environment_variable_key
else manually_set_level
)
if level == "INFO":
logger.setLevel(loggin... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def guess_and_set_min_level(self) -> \"Logger\":\n\n env_vars = [\"PYFUNCEBLE_DEBUG_LVL\", \"PYFUNCEBLE_LOGGING_LVL\"]\n\n env_var_helper = EnvironmentVariableHelper()\n env_var_found = False\n\n for env_var in env_vars:\n if env_var_helper.set_name(env_var).exists():\n ... | [
"0.67597663",
"0.6548691",
"0.6503005",
"0.6344647",
"0.6207006",
"0.61388904",
"0.61005825",
"0.60507625",
"0.6049592",
"0.6042728",
"0.598542",
"0.59827876",
"0.59588456",
"0.5952133",
"0.58999264",
"0.5837111",
"0.58362633",
"0.5816679",
"0.5806134",
"0.580072",
"0.5796609... | 0.70686895 | 0 |
Initialize charging station connection. | def __init__(
self,
keba,
device_info: ChargingStationInfo,
loop=None,
periodic_request: bool = True,
refresh_interval_s: int = 5,
refresh_interval_fast_polling_s: int = 1,
) -> None:
# super().__init__(host, self.hass_callback)
sel... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _initialize(self):\n self.flush()\n print(\"Initializing sensor...\")\n try:\n self.get_sample()\n print('Initialization successful')\n except:\n print('Initialization failed. Please disconnect and reconnect sensor.')",
"async def init(self):\n ... | [
"0.6642998",
"0.643647",
"0.63186747",
"0.6303991",
"0.6227921",
"0.6211244",
"0.6181869",
"0.61746716",
"0.61621594",
"0.6158604",
"0.6139265",
"0.6116205",
"0.6094739",
"0.60852104",
"0.6042763",
"0.604232",
"0.5992218",
"0.5952974",
"0.5932269",
"0.5930774",
"0.59260815",
... | 0.5529921 | 95 |
Unlock the socket. For this command you have to disable the charging process first. Afterwards you can unlock the socket. | async def unlock_socket(self, **kwargs) -> None: # pylint: disable=unused-argument
await self._send("unlock") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stop_socket(self):\n self.socket.shutdown(socket.SHUT_RDWR)",
"async def async_unlock(self, **kwargs: Any) -> None:\n if not await self._node.secure_unlock():\n raise HomeAssistantError(f\"Unable to unlock device {self._node.address}\")",
"def _unlock(self, fd):\n fcntl.lock... | [
"0.6802666",
"0.67976046",
"0.63873225",
"0.60683",
"0.60019237",
"0.59823465",
"0.596635",
"0.5950885",
"0.5916946",
"0.58824915",
"0.58802664",
"0.5873205",
"0.58641315",
"0.5857665",
"0.5841081",
"0.58273053",
"0.5826547",
"0.58191764",
"0.580191",
"0.5789088",
"0.57618517... | 0.872766 | 0 |
Creates and saves a User with the given email, username and password. | def create_user(self, email, password):
if not email:
raise ValueError('Users must have an email address')
if not password:
raise ValueError('Password is required')
user = self.model(
email=self.normalize_email(email),
)
user.set_password(pas... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _create_user(self, email, password,username, **extra_fields):\r\n if not email:\r\n raise ValueError('The given email must be set')\r\n if not username:\r\n raise ValueError('The given username must be set')\r\n email = self.normalize_email(email)\r\n user = se... | [
"0.8635576",
"0.84807277",
"0.8440991",
"0.8421272",
"0.8409197",
"0.8402626",
"0.8398233",
"0.8383942",
"0.8354441",
"0.83158565",
"0.8307883",
"0.82789755",
"0.82615095",
"0.82203734",
"0.82171905",
"0.8194278",
"0.81932116",
"0.8185191",
"0.8171665",
"0.8171403",
"0.815163... | 0.0 | -1 |
Creates and saves a User with the given email, username and password. | def create_superuser(self, email, password):
user = self.create_user(
email=email,
password=password,
)
user.is_staff = True
user.is_teacher = True
user.save(using=self._db)
# generate a staff detail with random ID
from assignments.models i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _create_user(self, email, password,username, **extra_fields):\r\n if not email:\r\n raise ValueError('The given email must be set')\r\n if not username:\r\n raise ValueError('The given username must be set')\r\n email = self.normalize_email(email)\r\n user = se... | [
"0.8635576",
"0.84807277",
"0.8440991",
"0.8421272",
"0.8409197",
"0.8402626",
"0.8398233",
"0.8383942",
"0.8354441",
"0.83158565",
"0.8307883",
"0.82789755",
"0.82615095",
"0.82203734",
"0.82171905",
"0.8194278",
"0.81932116",
"0.8185191",
"0.8171665",
"0.8171403",
"0.815163... | 0.0 | -1 |
Return True if a number is prime and False otherwise. | def is_prime(n):
if n == 1:
return False
else:
i = 2
while i < n:
if n % i == 0:
return False
i += 1
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_prime(number):\n\t\n\tif number < 2: return False\n\telif number == 2: return True\n\telif number % 2 == 0: return False\n\telse:\n\t\tfor x in range(2, number):\n\t\t\tif number % x == 0:\n\t\t\t\treturn False\n\t\telse:\n\t\t\treturn True",
"def is_prime_number(number_):\n flag = 0\n for values in... | [
"0.8282519",
"0.8246728",
"0.82139134",
"0.81972986",
"0.81892836",
"0.8171325",
"0.8133826",
"0.80697376",
"0.80539393",
"0.80282617",
"0.80153066",
"0.80120593",
"0.79991156",
"0.7992172",
"0.79767275",
"0.79750526",
"0.7954117",
"0.7931414",
"0.7926193",
"0.792192",
"0.791... | 0.75026804 | 49 |
Return the next prime greater than n. | def next_prime(n):
i = n + 1
while not is_prime(i):
i += 1
return i | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_larger_prime(n):\n result = n + (1 if n % 2 == 0 else 2)\n while not is_prime(result):\n result += 2\n return result",
"def nth_prime(n):\n # Tweaked version of the itertools nth recipe\n return next(islice(generate_primes(), n-1, None), None)",
"def nthPrime(n):\n return (j for i, j in ... | [
"0.7881514",
"0.75169104",
"0.7296439",
"0.7261415",
"0.7177585",
"0.70906055",
"0.7077313",
"0.6956592",
"0.68918353",
"0.68890387",
"0.68747556",
"0.6780663",
"0.6778611",
"0.6707346",
"0.67064214",
"0.66767657",
"0.66705596",
"0.66652083",
"0.66429394",
"0.6612685",
"0.660... | 0.7365508 | 2 |
Returns whether the Perfect Piggy diceswapping rule should occur. | def is_perfect_piggy(turn_score):
# BEGIN PROBLEM 4
return (is_perfect_square(turn_score) or is_perfect_cube(turn_score)) and turn_score != 1
# END PROBLEM 4 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def game_is_tied(self):\n tie_score = False\n if self.my_score == self.opponent_score:\n tie_score = True\n my_moves = self.steps_available(self.loc)\n opponent_moves = self.steps_available(self.opponent_loc)\n if my_moves == 0 and opponent_moves == 0 and tie_score:\n ... | [
"0.6279453",
"0.6268443",
"0.60206103",
"0.5947934",
"0.5912243",
"0.5875321",
"0.58732736",
"0.58707154",
"0.5869803",
"0.5867973",
"0.58345556",
"0.5815252",
"0.5800191",
"0.5795617",
"0.5784604",
"0.5784275",
"0.5780927",
"0.5770483",
"0.57356024",
"0.5722959",
"0.5718242"... | 0.64312756 | 0 |
Return the other player, for a player PLAYER numbered 0 or 1. >>> other(0) 1 >>> other(1) 0 | def other(player):
return 1 - player | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def otherPlayer(cls, player):\n return 0 if player == 1 else 1",
"def other_player(cls, player):\n return 0 if player == 1 else 1",
"def other_player(self, player):\n if player == self.__opponent:\n return self.__pid\n else:\n return self.__opponent",
"def __... | [
"0.8185557",
"0.81336266",
"0.7927831",
"0.7878474",
"0.771178",
"0.70963603",
"0.6847596",
"0.68090963",
"0.66224766",
"0.66224766",
"0.6581127",
"0.64776134",
"0.6458407",
"0.6427077",
"0.638957",
"0.6376942",
"0.6365836",
"0.6365836",
"0.63378143",
"0.62321705",
"0.6201012... | 0.7806004 | 6 |
Returns an array of strings for use by speech and braille that represent the checked state of the object. This is typically for check boxes that are in a table. An empty array will be returned if this is not a checkable cell. | def _generateCellCheckedState(self, obj, **args):
result = []
if self._script.utilities.hasMeaningfulToggleAction(obj):
oldRole = self._overrideRole(pyatspi.ROLE_CHECK_BOX, args)
result.extend(self.generate(obj, **args))
self._restoreRole(oldRole, args)
retur... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _generateCheckedState(self, obj, **args):\n result = []\n if not args.get('mode', None):\n args['mode'] = self._mode\n args['stringType'] = 'checkbox'\n indicators = self._script.formatting.getString(**args)\n state = obj.getState()\n if state.contains(pyats... | [
"0.78597516",
"0.75153136",
"0.715974",
"0.70708823",
"0.68852395",
"0.65728337",
"0.64509827",
"0.64307785",
"0.6145154",
"0.60856634",
"0.6018546",
"0.5987553",
"0.592451",
"0.5891737",
"0.5845161",
"0.5843238",
"0.5801463",
"0.5784729",
"0.56994337",
"0.5655949",
"0.564524... | 0.7846166 | 1 |
Returns an array of strings for use by speech and braille for the toggle value of a toggle in a table cell that has a special 2 child pattern that we run into. Otherwise, an empty array is returned. | def _generateTableCell2ChildToggle(self, obj, **args):
result = []
# If this table cell has 2 children and one of them has a
# 'toggle' action and the other does not, then present this
# as a checkbox where:
# 1) we get the checked state from the cell with the 'toggle' action
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _generateTableCell2ChildLabel(self, obj, **args):\n result = []\n\n # If this table cell has 2 children and one of them has a\n # 'toggle' action and the other does not, then present this\n # as a checkbox where:\n # 1) we get the checked state from the cell with the 'toggle'... | [
"0.64175016",
"0.58864707",
"0.5802288",
"0.54427946",
"0.5432684",
"0.5315806",
"0.5289848",
"0.52799964",
"0.5205643",
"0.51921636",
"0.51733345",
"0.5110673",
"0.51007503",
"0.50254416",
"0.4996558",
"0.49788553",
"0.49487627",
"0.49424136",
"0.49372393",
"0.4926295",
"0.4... | 0.6583316 | 0 |
Computes the expectation of the weight initialization squared value. Weights are drawn from an uniform distribution. | def compute_norm_fac_per_weight(fan_in):
ksi = 1. / math.sqrt(fan_in)
return (1 / 3) * ksi ** 2 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def weights_initializer(self):\n self.weights = [np.random.normal(0, 1 / np.sqrt(x), (x, y)) for x, y in list(zip(self.structure[1:], self.structure[:-1]))]",
"def WeightInitializer():\n return np.random.uniform(-1, 1)",
"def init_weights(self):\n \n self.w = np.random.randn(self.D) / n... | [
"0.6684415",
"0.66808736",
"0.6669938",
"0.6464006",
"0.6374624",
"0.63681585",
"0.6343656",
"0.6338369",
"0.6320977",
"0.6296438",
"0.6271583",
"0.61881447",
"0.61837167",
"0.6142952",
"0.6064868",
"0.6063742",
"0.6063742",
"0.60503805",
"0.60259485",
"0.59808606",
"0.596227... | 0.0 | -1 |
Returns copy of self.table such that the largest value is in the first (upper left) cell. | def _max_rotation(self):
table = [list(self.table[0]), list(self.table[1])]
while table[0][0] != self.max_value:
table = self._rotate_cw(table)
return table | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def most_stable():\n \n \n \n \n return Z",
"def argmax(table):\n return max((v,k) for k,v in table.iteritems())[1]",
"def pop(self):\n cell = next(self.cells)\n if self.min_row == self.max_row:\n self.min_col += 1\n else:\n self.min_row += 1\n ... | [
"0.63561314",
"0.60624194",
"0.59959126",
"0.59558934",
"0.5705076",
"0.56326026",
"0.5632019",
"0.56218106",
"0.5601197",
"0.5600753",
"0.5584648",
"0.5578649",
"0.5559997",
"0.55514497",
"0.5548755",
"0.5543374",
"0.552857",
"0.55207753",
"0.5512766",
"0.55022424",
"0.54935... | 0.5584742 | 10 |
Assert that the endpoint returns 200. | def test_codes_valid(session, client, jwt, app):
rv = client.get('/api/v1/codes/errors', headers={})
assert rv.status_code == 200
assert len(rv.json.get('codes')) > 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def assert200(self, response):\n self.assertEqual(response.status_code, 200)",
"def test_response_200_on_get(self):\n pass",
"def test_site_get_status_200_code(api_client):\n r = api_client.get(path=\"/\")\n assert r.status_code == 200",
"def test_GET_call_api_and_return_200Ok(client):\n\... | [
"0.82210654",
"0.8013816",
"0.7946608",
"0.7903406",
"0.7885061",
"0.7880224",
"0.77164006",
"0.77164006",
"0.7668261",
"0.76476663",
"0.7645023",
"0.7640879",
"0.7640879",
"0.7563328",
"0.75562114",
"0.752852",
"0.752852",
"0.752852",
"0.752852",
"0.752852",
"0.752852",
"0... | 0.0 | -1 |
Assert that the endpoint returns 200. | def test_codes_invalid(session, client, jwt, app):
rv = client.get('/api/v1/codes/xxxx', headers={})
assert rv.json.get('codes') is None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def assert200(self, response):\n self.assertEqual(response.status_code, 200)",
"def test_response_200_on_get(self):\n pass",
"def test_site_get_status_200_code(api_client):\n r = api_client.get(path=\"/\")\n assert r.status_code == 200",
"def test_GET_call_api_and_return_200Ok(client):\n\... | [
"0.82210654",
"0.8013816",
"0.7946608",
"0.7903406",
"0.7885061",
"0.7880224",
"0.77164006",
"0.77164006",
"0.7668261",
"0.76476663",
"0.7645023",
"0.7640879",
"0.7640879",
"0.7563328",
"0.75562114",
"0.752852",
"0.752852",
"0.752852",
"0.752852",
"0.752852",
"0.752852",
"0... | 0.0 | -1 |
Assert that the endpoint returns 200. | def test_find_code(session, client, jwt, app):
rv = client.get('/api/v1/codes/errors', headers={})
code = rv.json.get('codes')[0].get('type')
rv = client.get(f'/api/v1/codes/errors/{code}', headers={})
assert rv.json.get('type') == code | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def assert200(self, response):\n self.assertEqual(response.status_code, 200)",
"def test_response_200_on_get(self):\n pass",
"def test_site_get_status_200_code(api_client):\n r = api_client.get(path=\"/\")\n assert r.status_code == 200",
"def test_GET_call_api_and_return_200Ok(client):\n\... | [
"0.82210654",
"0.8013816",
"0.7946608",
"0.7903406",
"0.7885061",
"0.7880224",
"0.77164006",
"0.77164006",
"0.7668261",
"0.76476663",
"0.7645023",
"0.7640879",
"0.7640879",
"0.7563328",
"0.75562114",
"0.752852",
"0.752852",
"0.752852",
"0.752852",
"0.752852",
"0.752852",
"0... | 0.0 | -1 |
Assert that the endpoint returns 200. | def test_find_codes(session, client, jwt, app, code: Code):
rv = client.get(f'/api/v1/codes/{code.value}', headers={})
assert rv.status_code == 200 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def assert200(self, response):\n self.assertEqual(response.status_code, 200)",
"def test_response_200_on_get(self):\n pass",
"def test_site_get_status_200_code(api_client):\n r = api_client.get(path=\"/\")\n assert r.status_code == 200",
"def test_GET_call_api_and_return_200Ok(client):\n\... | [
"0.82210654",
"0.8013816",
"0.7946608",
"0.7903406",
"0.7885061",
"0.7880224",
"0.77164006",
"0.77164006",
"0.7668261",
"0.76476663",
"0.7645023",
"0.7640879",
"0.7640879",
"0.7563328",
"0.75562114",
"0.752852",
"0.752852",
"0.752852",
"0.752852",
"0.752852",
"0.752852",
"0... | 0.0 | -1 |
Get a temp directory available of all the tests | def setUpClass(cls) -> None:
cls.tempdir = tempfile.TemporaryDirectory()
cls.path = cls.tempdir.name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_temp_dir():\n return tempfile.mkdtemp()",
"def get_new_temp_dir(self):\n return self.useFixture(fixtures.TempDir())",
"def tempdir(self):\n path = tempfile.gettempdir()\n return os.path.join(path, 'parquet-index-test-' + str(uuid.uuid4()))",
"def tempdir():\n\n # Create... | [
"0.8000417",
"0.78809375",
"0.7710799",
"0.77102053",
"0.7708421",
"0.7631405",
"0.75626993",
"0.7547986",
"0.7506301",
"0.74639815",
"0.74589896",
"0.74545664",
"0.7452939",
"0.74451184",
"0.73512125",
"0.7318311",
"0.731303",
"0.7265502",
"0.71361846",
"0.71241546",
"0.7094... | 0.0 | -1 |
After each test, delete the temporary directory | def tearDown(self):
self.tempdir.cleanup() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tearDown(self):\n print(\n \"\\nDeleting temporary files...\\n\")\n try:\n shutil.rmtree(TEST_DIR)\n except OSError:\n pass",
"def tearDown(self):\r\n shutil.rmtree(self.temp_dir_path)",
"def tearDown(self):\n \tshutil.rmtree(self.tempdir)",
"de... | [
"0.85222846",
"0.8487326",
"0.84253997",
"0.83541584",
"0.8202493",
"0.81914693",
"0.81845844",
"0.8141798",
"0.813982",
"0.81107527",
"0.81004846",
"0.806003",
"0.8053699",
"0.8045086",
"0.8044019",
"0.8026089",
"0.8026089",
"0.80070233",
"0.7960108",
"0.79100037",
"0.788932... | 0.8163513 | 7 |
Add enemy to enemy list | def add_enemy_to_list(name):
with open("data.json", "r") as file:
data = json.load(file)
data["enemy_data"]["names"].append(name)
with open("data.json", "w") as file2:
json.dump(data, file2, indent=4) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_enemies(self, enemies):\n if isinstance(enemies, Enemy):\n self.enemy_list.append(enemies)\n self.turn_order.add(enemies)\n elif all([isinstance(enemy, Enemy) for enemy in enemies]):\n for enemy in enemies:\n self.enemy_list.append(enemy)\n ... | [
"0.75207627",
"0.7144573",
"0.69138473",
"0.6899743",
"0.6858339",
"0.67478573",
"0.66414505",
"0.6614225",
"0.6605368",
"0.65694636",
"0.6516147",
"0.6501377",
"0.64817476",
"0.6352639",
"0.6297114",
"0.6250094",
"0.61938816",
"0.6089914",
"0.60534513",
"0.60249007",
"0.5974... | 0.7245207 | 1 |
update the critics and actors of all the agents | def update(self, samples, agent_number):
# need to transpose each element of the samples
# to flip obs[parallel_agent][agent_number] to
# obs[agent_number][parallel_agent]
obs, obs_full, action, reward, next_obs, next_obs_full, done = samples
agent = self.maddpg_agent[a... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_all_agent(self):\n for a in self.agents:\n soft_update(a.target_actor, a.actor, self.tau)\n soft_update(a.target_critic, a.critic, self.tau)\n self.num_iteration += 1",
"def update(self):\n self.reset()\n\n # Indices of agents that are playing the game... | [
"0.7793435",
"0.62337434",
"0.5746579",
"0.57021135",
"0.56952703",
"0.5685467",
"0.5654011",
"0.5617586",
"0.55508715",
"0.55255216",
"0.5490698",
"0.54705274",
"0.5440514",
"0.54386806",
"0.54381484",
"0.5408061",
"0.53959286",
"0.5368262",
"0.5361991",
"0.53616476",
"0.534... | 0.55483985 | 9 |
Asks user to specify a city, month, and day to analyze. | def get_filters():
print('Hello! Let\'s explore some US bikeshare data!')
city = str(input('Would you like to see data for Chicago, New York or Washington?\n').lower())
while city not in CITY_DATA.keys():
city = str(input('Sorry, it looks like an invalid input. Please try again: Chicago, New York o... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Raw_Data(city,month,day):\n print(\"The city you have entered is: \",city)\n print(\"The month you have entered is: \",month)\n print(\"The day you have entered is: \",day)",
"def get_filters():\n city = None\n month = None\n day = None\n while day == None:\n # TO DO: get user input f... | [
"0.66714007",
"0.65354675",
"0.64593667",
"0.6374057",
"0.6348314",
"0.63097656",
"0.62868035",
"0.6259136",
"0.62316",
"0.62130964",
"0.62050414",
"0.6181105",
"0.6171822",
"0.61686903",
"0.6158568",
"0.61582303",
"0.61532456",
"0.61444426",
"0.6131269",
"0.610484",
"0.61025... | 0.0 | -1 |
Loads data for the specified city and filters by month and day if applicable. | def load_data(city, month, day):
df = pd.read_csv(CITY_DATA[city])
df['Start Time'] = pd.to_datetime(df['Start Time'])
df['month'] = df['Start Time'].dt.month
df['weekday'] = df['Start Time'].dt.weekday_name
df['hour'] = df['Start Time'].dt.hour
if month != 'all':
month = months.index... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_data(city, month, day):\n df = pd.read_csv(CITY_DATA [city])\n \n # convert the Start Time column to datetime\n df['Start Time'] = pd.to_datetime(df['Start Time'])\n \n # extract month and day of week from Start Time to create new columns\n df['month'] = df['Start Time'].dt.month\n ... | [
"0.81320685",
"0.8108889",
"0.8045821",
"0.8042514",
"0.80090284",
"0.80071104",
"0.79991937",
"0.7998333",
"0.7988789",
"0.797905",
"0.79737365",
"0.79610896",
"0.7956163",
"0.7947432",
"0.79463065",
"0.7908287",
"0.7908229",
"0.7904569",
"0.7900715",
"0.78930074",
"0.788921... | 0.78664976 | 23 |
Displays statistics on the most frequent times of travel. | def time_stats(df):
print('\nCalculating The Most Frequent Times of Travel...\n')
print('-'*40)
start_time = time.time()
most_frequent_month_count = df[df['month'] == df['month'].mode()[0]]['month'].count()
most_frequent_month = df['month'].mode()[0]
print('\nThe most popular month is {}, whic... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def time_stats(df):\n\n print('\\nDisplaying the statistics on the most frequent times of '\n 'travel...\\n')\n start_time = time.time()\n\n # display the most common month\n most_common_month = df['Month'].mode()[0]\n print('For the selected filter, the month with the most travels is: ' +\... | [
"0.80247396",
"0.80233026",
"0.7915788",
"0.78266186",
"0.7822246",
"0.78143597",
"0.77659196",
"0.7740343",
"0.773628",
"0.77344066",
"0.76867086",
"0.7668633",
"0.7651731",
"0.7644636",
"0.76399267",
"0.76367253",
"0.7625196",
"0.7623158",
"0.7612803",
"0.76002145",
"0.7583... | 0.72042453 | 69 |
Displays statistics on the most popular stations and trip. | def station_stats(df):
print('\nCalculating The Most Popular Stations and Trip...\n')
start_time = time.time()
popular_start_station_count = df[df['Start Station'] == df['Start Station'].mode()[0]]['Start Station'].count()
popular_start_station = df['Start Station'].mode()[0]
print('\nThe most pop... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def station_stats(df):\n\n print('\\nCalculating The Most Popular Stations and Trip...\\n')\n start_time = time.time()\n\n # display most commonly used start station\n print(popular_start_station(df))\n\n # display most commonly used end station\n print(popular_end_station(df))\n\n # display m... | [
"0.7815675",
"0.7662213",
"0.7553417",
"0.74914914",
"0.74748665",
"0.7446617",
"0.7428588",
"0.74237514",
"0.74177027",
"0.7400495",
"0.7387161",
"0.7385634",
"0.73647535",
"0.735934",
"0.73566747",
"0.73548365",
"0.7351854",
"0.7351274",
"0.735057",
"0.73421645",
"0.7340198... | 0.68601453 | 90 |
Displays statistics on the total and average trip duration. | def trip_duration_stats(df):
print('\nCalculating Trip Duration...\n')
start_time = time.time()
df['Trip Duration'] = df['Trip Duration'].astype(np.float64) # Convert data type from int64 to float64 to avoid TypeError using datetime.timedelta
total_travel_time = str(datetime.timedelta(seconds=df['Trip... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def trip_duration_stats(data):\n print('\\nCalculating Trip Duration...\\n')\n start_time = time.time()\n # display total travel time\n total_trip_time= data['Trip Duration'].sum()\n print('The Total Travel Time is {} Hours'. format(total_trip_time/3600))\n # display mean travel time\n avg_tri... | [
"0.814274",
"0.8025143",
"0.80041367",
"0.79496753",
"0.7937415",
"0.79312176",
"0.7926815",
"0.7915187",
"0.79142886",
"0.7908032",
"0.79055744",
"0.7900715",
"0.7891682",
"0.78894734",
"0.7886722",
"0.78851086",
"0.7884266",
"0.7882474",
"0.78738385",
"0.78686154",
"0.78664... | 0.0 | -1 |
Function to return a tuple with the squae of a num and a string | def to_kv(k: str, v: Union[int, float]) -> Tuple[str, float]:
my_tuple = (k, v*v)
return my_tuple | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def processed(N:int)->tuple:\n l1= str(N)\n a,b = '',''\n for i in range(len(l1)):\n if l1[i] == '4':\n a+='2'\n b+='2'\n else:\n a+=str(l1[i])\n b+='0'\n return int(a), int(b)",
"def main():\n sampleTuple = (100, 200, 300)\n print(tuple... | [
"0.6646078",
"0.6228154",
"0.61565506",
"0.59388137",
"0.5852559",
"0.5832017",
"0.58082485",
"0.5801215",
"0.5766872",
"0.5740432",
"0.5685302",
"0.5649507",
"0.5627665",
"0.5614808",
"0.55979145",
"0.5584616",
"0.5544328",
"0.55387473",
"0.55262804",
"0.5523099",
"0.5498246... | 0.0 | -1 |
Retrieves a user entry by id | def get(self, **kwargs):
user_id = kwargs["id"]
user = models.User.get_by_id(user_id)
if user is None:
self.abort(422, "could not find user")
self.set_response_view_model(view_models.User.view_contract())
self.api_response = view_models.User.form(user)
self.s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(self, id):\n tmp = userDao.get_one_entry(id)\n return tmp",
"def get(id):\n return User.query.filter_by(id=id).first()",
"def get_user_by_id(self, id):\n\t\treturn self.users.get(id)",
"def get_single_user(self, id):\n for user in self.users:\n if user['id'] == ... | [
"0.8309573",
"0.8057501",
"0.80325854",
"0.8009222",
"0.7940538",
"0.7682704",
"0.76086646",
"0.75919694",
"0.75227076",
"0.7517773",
"0.7504012",
"0.7503571",
"0.74671954",
"0.74657494",
"0.74657494",
"0.74657494",
"0.74657494",
"0.7419156",
"0.741581",
"0.7412899",
"0.74097... | 0.0 | -1 |
Builds the Flask App | def build():
app = flask.Flask("cnc-forge-api")
app.api = flask_restful.Api(app)
with open("/opt/service/secret/redis.json", "r") as redis_file:
app.redis = redis.Redis(charset="utf-8", decode_responses=True, **json.loads(redis_file.read()))
app.api.add_resource(Health, '/health')
app.api... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate(self) -> Flask:\n app = Flask(self.name, *self.args, **self.kwargs)\n app = self.setup_app_config(app)\n app = self.add_app_headers(app)\n app = self.add_xsrf_error_handler(app)\n\n return app",
"def _build_flask_app(self, name):\n app = Flask(name)\n ... | [
"0.77231485",
"0.7603172",
"0.748624",
"0.72408855",
"0.7203377",
"0.71367025",
"0.7116849",
"0.7101528",
"0.7095095",
"0.70842695",
"0.7042892",
"0.7037099",
"0.70270205",
"0.69814086",
"0.69570893",
"0.69570714",
"0.6956612",
"0.69494325",
"0.6940777",
"0.69321066",
"0.6931... | 0.74496615 | 3 |
Remove the test config file. | def tearDown(self):
test_utils.delete_test_config() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tearDown(self) -> None:\n os.remove(TestConfigFile.TEST_CONFIG)",
"def clean():\n Log.d(DEBUG_TAG, \"Delete config file...\")\n try:\n os.remove(CONFIG_FILE)\n except os.error as e:\n Log.e(DEBUG_TAG, \"Delete config file%s error, reason:%s\"%(CONFIG_FILE, e))",
"def remove_us... | [
"0.82603157",
"0.7938341",
"0.75796455",
"0.7303897",
"0.72549134",
"0.7250045",
"0.7201434",
"0.7196431",
"0.71776867",
"0.7148807",
"0.71268976",
"0.7090882",
"0.7071481",
"0.70521754",
"0.7034664",
"0.70326316",
"0.70326316",
"0.7023845",
"0.6998058",
"0.69897544",
"0.6982... | 0.779682 | 2 |
finds minimum indices in an array | def nearest_min(dist_matrix):
# much faster than np.where
i, j = np.unravel_index(
np.argmin(dist_matrix),
dims=dist_matrix.shape
)
return i, j | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def argmin(self, array):\n minvalue = inf\n minindex = None\n for i in range(len(array)):\n if array[i] < minvalue:\n minvalue = array[i]\n minindex = i\n return minvalue, minindex",
"def minimo(arr):\n minVal = float('inf')\n minIdx = -1... | [
"0.7526155",
"0.7433892",
"0.73650557",
"0.73347956",
"0.73043925",
"0.7294479",
"0.72058755",
"0.71541744",
"0.71419907",
"0.7028905",
"0.6938305",
"0.68783945",
"0.6864014",
"0.68151575",
"0.6813339",
"0.676083",
"0.67506117",
"0.6743916",
"0.6729411",
"0.6728803",
"0.66797... | 0.67804635 | 15 |
Initialize the water_heater device. | def __init__(self, client, boiler):
self._client = client
self._boiler = boiler
self._operation_list = list(HA_OPMODE_TO_GH) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, hass, device: Warmup4IEDevice, client: WarmupClient):\n _LOGGER.info(\"Setting up Warmup Thermostat %s\", device.get_room_name())\n self._device = device\n self._client = client\n\n self.attributes = {}\n self._update_attributes_from_device()\n\n self._c... | [
"0.62667716",
"0.5942362",
"0.59006435",
"0.5740189",
"0.5737908",
"0.5720192",
"0.569426",
"0.5652093",
"0.56175846",
"0.5583131",
"0.55813503",
"0.55641305",
"0.5559214",
"0.55472535",
"0.5541044",
"0.5533628",
"0.55258596",
"0.5506846",
"0.54698575",
"0.5452834",
"0.544964... | 0.0 | -1 |
Return the device state attributes. | def device_state_attributes(self):
tmp = self._boiler.__dict__.items()
return {'status': {k: v for k, v in tmp if k in GH_STATE_ATTRS}} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def device_state_attributes(self):\r\n return self.attributes",
"def device_state_attributes(self):\r\n return self._attributes",
"def device_state_attributes(self):\n return self._attrs",
"def device_state_attributes(self):\n return self.attr",
"def device_state_attributes(self... | [
"0.93173087",
"0.9245708",
"0.92207897",
"0.92147964",
"0.92147964",
"0.9210798",
"0.9210798",
"0.91909975",
"0.91909975",
"0.91909975",
"0.91909975",
"0.91909975",
"0.91909975",
"0.91909975",
"0.91909975",
"0.91909975",
"0.91909975",
"0.91909975",
"0.91909975",
"0.91909975",
... | 0.84394234 | 40 |
Return max valid temperature that can be set. | def min_temp(self):
return GH_MIN_TEMP | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def max_temperature(self):\n mini, maxi = ct.c_int(), ct.c_int()\n self.lib.GetTemperatureRange(ct.pointer(mini), ct.pointer(maxi))\n return maxi.value",
"def locked_temp_max(self) -> int:\r\n # TODO: Force this to return an int.\r\n if self.temperature_scale == \"C\":\r\n ... | [
"0.7610117",
"0.74711955",
"0.74485534",
"0.74425983",
"0.7331048",
"0.73265946",
"0.7324182",
"0.7318453",
"0.7316482",
"0.72396296",
"0.7217405",
"0.7177121",
"0.7117323",
"0.70919865",
"0.68738693",
"0.68283707",
"0.67236835",
"0.67182505",
"0.6662115",
"0.6626988",
"0.659... | 0.0 | -1 |
Return max valid temperature that can be set. | def max_temp(self):
return GH_MAX_TEMP | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def max_temperature(self):\n mini, maxi = ct.c_int(), ct.c_int()\n self.lib.GetTemperatureRange(ct.pointer(mini), ct.pointer(maxi))\n return maxi.value",
"def locked_temp_max(self) -> int:\r\n # TODO: Force this to return an int.\r\n if self.temperature_scale == \"C\":\r\n ... | [
"0.7610117",
"0.74711955",
"0.74485534",
"0.74425983",
"0.7331048",
"0.73265946",
"0.7318453",
"0.7316482",
"0.72396296",
"0.7217405",
"0.7177121",
"0.7117323",
"0.70919865",
"0.68738693",
"0.68283707",
"0.67236835",
"0.67182505",
"0.6662115",
"0.6626988",
"0.6598519",
"0.656... | 0.7324182 | 6 |
Get an identifier of this product used by the IEM | def get_product_id(self):
pid = "%s-%s-%s-%s" % (self.valid.strftime("%Y%m%d%H%M"),
self.source, self.wmo, self.afos)
return pid.strip() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def product_id(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"product_id\")",
"def product_id(self) -> pulumi.Input[str]:\n return pulumi.get(self, \"product_id\")",
"def getId(self):\n return _libsbml.GeneProduct_getId(self)",
"def product_id(self):\n return self._produ... | [
"0.80947524",
"0.7656646",
"0.7540833",
"0.7490796",
"0.7490796",
"0.7490796",
"0.7490796",
"0.7473361",
"0.74033344",
"0.72727764",
"0.7001536",
"0.69974697",
"0.696872",
"0.6949469",
"0.68776137",
"0.6847264",
"0.68438613",
"0.67738664",
"0.67699814",
"0.6766168",
"0.673593... | 0.73596233 | 9 |
Route for getting either a supporting file or the root index.html file for the UI | def render_file(path: str):
if path != "" and os.path.exists(os.path.join(current_app.config["UI_PATH"], path)):
_LOGGER.info(
"sending {} file from {}".format(path, current_app.config["UI_PATH"])
)
return send_from_directory(current_app.config["UI_PATH"], path)
else:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index(self):\n single = os.path.join(\n os.path.dirname(os.path.abspath(__file__)),\n 'index.html')\n return serve_file(single)",
"def home():\n return make_response(open('app/templates/index.html').read())",
"def index(path):\n return render_template('index.html')... | [
"0.7691439",
"0.74965346",
"0.7394288",
"0.73789537",
"0.729984",
"0.7279394",
"0.7250933",
"0.7233653",
"0.7210124",
"0.7183364",
"0.7183351",
"0.7174102",
"0.71048576",
"0.71037334",
"0.71000904",
"0.71000904",
"0.7090237",
"0.70599145",
"0.70564705",
"0.70564705",
"0.70459... | 0.0 | -1 |
Creates an Agency from a dict. Checks correctness after creation. | def from_dict(data):
ret = Agency()
for key, value in data.items():
ret.setkey(key, value)
ret.verify()
return ret | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_dict(cls, dct):\n pass",
"def from_gtfs(keys, data):\n ret = Agency()\n for key, value in zip(keys, data):\n ret.setkey(key, value)\n ret.verify()\n return ret",
"def _from_dict(cls, _dict):\n return cls.from_dict(_dict)",
"def _from_dict(cls, _di... | [
"0.6009804",
"0.5934105",
"0.58895844",
"0.58895844",
"0.58895844",
"0.58895844",
"0.58895844",
"0.58895844",
"0.58895844",
"0.58895844",
"0.58895844",
"0.58895844",
"0.58895844",
"0.58895844",
"0.58895844",
"0.58895844",
"0.58895844",
"0.58895844",
"0.58895844",
"0.58895844",
... | 0.8378693 | 0 |
Return the df from that file. | def write_response(response):
text_r = response.text
# Individua le righe del file
lines = text_r.strip().split('\n')
""" Crea df dove ogni linea corrisponde ad una riga del df
In questa operazione non si ha ancora la divisione per le singole colonne
questo dipende dalla response ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_file(fname: str) -> pd.DataFrame:\n raw_data = (\n pd.read_hdf(fname).to_frame().reset_index(level=[0, 1]).loc[ANALYSIS_DATE]\n )\n raw_data[\"date\"] = raw_data.index\n return raw_data",
"def get_file_df(filepath):\n dd = [json.loads(f) for f in open(filepath).... | [
"0.73206097",
"0.7273985",
"0.72532266",
"0.725288",
"0.72142917",
"0.70904326",
"0.7084267",
"0.70563334",
"0.70420986",
"0.69824964",
"0.69229513",
"0.68404067",
"0.68404067",
"0.68404067",
"0.68379134",
"0.6834317",
"0.6807396",
"0.6716032",
"0.6659324",
"0.66523355",
"0.6... | 0.0 | -1 |
Save settings contained within the .json and .js settings files. | def Save(self, settingsfile):
try:
with codecs.open(settingsfile, encoding="utf-8-sig", mode="w+") as f:
json.dump(self.__dict__, f, encoding="utf-8", ensure_ascii=False)
with codecs.open(settingsfile.replace("json", "js"), encoding="utf-8-sig", mode="w+") as f:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_settings(self):\n with open(self.settings_path, \"w\") as f:\n json.dump(self.settings, f, indent=4)",
"def saveSettings(self):\n helpers.saveFile(self.dataDir, self.settingsFilename, json.dumps(self.settings))",
"def saveSettings():\t\n\tglobal settings\n\tfout = open(config... | [
"0.8557654",
"0.8479817",
"0.84648174",
"0.8247739",
"0.8107492",
"0.80212617",
"0.79664224",
"0.7918237",
"0.76606166",
"0.7643112",
"0.75955284",
"0.7537307",
"0.7505763",
"0.7473185",
"0.7244251",
"0.71832156",
"0.71723247",
"0.71697444",
"0.7119456",
"0.7056987",
"0.70531... | 0.74582314 | 14 |
Format the sentence divided by spaces in to camelCaseSpelling | def format_camel(text):
output = ""
for i,w in enumerate(text.split(" ")):
if i > 0:
output += w[0].upper() + w[1:]
else:
output += w
return output | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_normalised_phrase(self, sentence):\n return re.sub(r'[\\W_ ]+', ' ', sentence).lower()",
"def camel_to_spaces(s):\n subbed = _underscorer1.sub(r'\\1 \\2', s)\n return _underscorer2.sub(r'\\1 \\2', subbed).lower()",
"def _camelify(words):\n newText = ''\n for word in words:\n if ne... | [
"0.73090994",
"0.72395027",
"0.7106232",
"0.70089257",
"0.6961377",
"0.69247425",
"0.6841329",
"0.6785974",
"0.6770731",
"0.66761297",
"0.66446626",
"0.66296375",
"0.66296375",
"0.66161925",
"0.6579748",
"0.65370876",
"0.65228355",
"0.6521351",
"0.64494944",
"0.6436152",
"0.6... | 0.7426275 | 0 |
Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero. | def three_sum(nums: List[int]) -> List[List[int]]:
size = len(nums)
res = list()
if size < 3:
return res
#
nums.sort()
seen_dict = dict()
for i in range(size - 2):
num = nums[i]
if num in seen_dict:
continue
#
seen_dict[num] = 1
t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def threesumzero(a):\n result = set() # set to eliminate deuplicates!\n a.sort() # sort it\n n = len(a) # number of items in a\n for x in a: # for each element in a, see if its part of some triplet\n target_sum = 0 - x # x and other two items must sum to 0, so other two must sum to -x\n ... | [
"0.74995184",
"0.6807669",
"0.66731316",
"0.66455746",
"0.65322167",
"0.63680613",
"0.63485014",
"0.6313556",
"0.6306352",
"0.6225103",
"0.6220736",
"0.60896564",
"0.60747087",
"0.60718614",
"0.6049467",
"0.6044564",
"0.60016406",
"0.59917116",
"0.5980008",
"0.5976277",
"0.59... | 0.57478637 | 38 |
Validate the password that the user gave. | def validate_password(self, password):
# This will raise a ValidationError if it fails.
password_validation.validate_password(password)
return password | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_valid_password(self):\n pass_field = Field(\"\".join(['x' * (int(self.app.config['MAX_PWD_LEN']))]))\n\n valid_password(None, pass_field)",
"def validate_password(data):\n\n if \"password\" not in data:\n return False\n password = data[\"password\"]\n if len(password) < 4 o... | [
"0.8092302",
"0.78717",
"0.7847557",
"0.7838408",
"0.7806384",
"0.78028417",
"0.7801196",
"0.77922606",
"0.77895856",
"0.7763571",
"0.7758819",
"0.7729701",
"0.77275616",
"0.7719578",
"0.7700801",
"0.767292",
"0.76702726",
"0.7658963",
"0.76577514",
"0.7656788",
"0.7646463",
... | 0.7948696 | 1 |
Generates a random 3D unit vector (direction) with a uniform spherical distribution | def random_three_vector():
phi = config.random.uniform(0, np.pi * 2)
costheta = config.random.uniform(-1, 1)
theta = np.arccos(costheta)
x = np.sin(theta) * np.cos(phi)
y = np.sin(theta) * np.sin(phi)
z = np.cos(theta)
return x, y, z | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rndSphere():\n sph = [0,0,0]\n \n sph[2] = random.uniform(-1.0,1.0)\n z2 = math.sqrt(1.0 - sph[2]*sph[2])\n phi = (2. * math.pi) * random.random()\n sph[0] = z2 * math.cos(phi)\n sph[1] = z2 * math.sin(phi)\n \n return sph",
"def rand_unit_vect_3D():\n xyz = np.random.nor... | [
"0.712667",
"0.70134175",
"0.6973644",
"0.6965655",
"0.6919834",
"0.6893882",
"0.6756543",
"0.67218494",
"0.6658979",
"0.6642232",
"0.6616335",
"0.66099644",
"0.65963835",
"0.65433717",
"0.6478685",
"0.6400619",
"0.6388276",
"0.6335655",
"0.6297577",
"0.6248027",
"0.6202129",... | 0.6695186 | 8 |
Get a user by id | def get_user_by_id(self, user_id):
query = "SELECT * FROM users WHERE user_id = %s"
self.cursor.execute(query,[user_id])
result = self.cursor.fetchone()
return result | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_user_by_id(self, id):\n\t\treturn self.users.get(id)",
"def get_user(id):\n pass",
"def get(id):\n return User.query.filter_by(id=id).first()",
"def getUser(self, id : int) -> bbUser.bbUser:\n id = self.validateID(id)\n return self.users[id]",
"def get(self, id):\n\t\ttry:\n... | [
"0.8864504",
"0.87704843",
"0.8740833",
"0.8554642",
"0.8504539",
"0.8469546",
"0.84685934",
"0.84557086",
"0.84486854",
"0.835241",
"0.83285975",
"0.8327167",
"0.8313935",
"0.8302917",
"0.8269085",
"0.8265841",
"0.8265841",
"0.8265841",
"0.8265841",
"0.82535756",
"0.82497597... | 0.8164781 | 29 |
Set up a user for testing login.. | def setUp(self):
user = UserFactory(username='mike', email='mike@ike.net')
user.set_password('password')
user.save() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup_user(self):\r\n self.email = 'foo@test.com'\r\n self.password = 'bar'\r\n self.username = 'test'\r\n self.create_account(self.username,\r\n self.email, self.password)\r\n self.activate_user(self.email)\r\n self.login(self.email, self.pa... | [
"0.8567419",
"0.81652975",
"0.81637216",
"0.8143983",
"0.80611825",
"0.80477697",
"0.80252427",
"0.8007449",
"0.7977663",
"0.7932932",
"0.7908676",
"0.7880863",
"0.7880021",
"0.7850239",
"0.78186995",
"0.7779807",
"0.7729569",
"0.769425",
"0.769124",
"0.769124",
"0.769124",
... | 0.7909903 | 10 |
Test that home route has a 200 response code. | def test_journal_route_has_200_response(self):
self.client.login(username='mike', password='password')
response = self.client.get(reverse_lazy('journal'))
self.assertEqual(response.status_code, 200) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_home_status_code(self):\n result = self.app.get('/')\n self.assertEqual(result.status_code, 200)",
"def test_home_route_is_status_ok(self):\n response = self.client.get(\"/\")\n self.assertTrue(response.status_code == 200)",
"def test_status_home(self):\n self.assert... | [
"0.8968988",
"0.8833738",
"0.86914694",
"0.8362857",
"0.81079036",
"0.8064336",
"0.803854",
"0.8009026",
"0.79975283",
"0.79687226",
"0.78929687",
"0.7766967",
"0.7766967",
"0.7766967",
"0.7766967",
"0.7766967",
"0.7766967",
"0.7766967",
"0.7766967",
"0.7766967",
"0.7766967",... | 0.70018405 | 92 |
Test that home route has a 200 response code. | def test_create_journal_route_has_200_response(self):
self.client.login(username='mike', password='password')
response = self.client.get(reverse_lazy('create_journal'))
self.assertEqual(response.status_code, 200) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_home_status_code(self):\n result = self.app.get('/')\n self.assertEqual(result.status_code, 200)",
"def test_home_route_is_status_ok(self):\n response = self.client.get(\"/\")\n self.assertTrue(response.status_code == 200)",
"def test_status_home(self):\n self.assert... | [
"0.8968988",
"0.8833738",
"0.86914694",
"0.8362857",
"0.81079036",
"0.8064336",
"0.803854",
"0.8009026",
"0.79975283",
"0.79687226",
"0.78929687",
"0.7766967",
"0.7766967",
"0.7766967",
"0.7766967",
"0.7766967",
"0.7766967",
"0.7766967",
"0.7766967",
"0.7766967",
"0.7766967",... | 0.0 | -1 |
Test that a user can only create a journal entry if logged. | def test_create_journal_route_accessible_when_logged_in(self):
self.client.login(username='mike', password='password')
response = self.client.get(reverse_lazy('create_journal'))
self.assertEqual(response.status_code, 200) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_create_journal_route_accessible_only_if_logged_in(self):\n response = self.client.get(reverse_lazy('create_journal'))\n self.assertEqual(response.status_code, 302)",
"def test_user_does_not_create_log(self):\n user = UserFactory.create()\n self.request.user = user\n us... | [
"0.7454325",
"0.7039992",
"0.6864036",
"0.68615115",
"0.65915525",
"0.6441175",
"0.6264454",
"0.62089926",
"0.61062616",
"0.60613185",
"0.60062087",
"0.5965917",
"0.59638494",
"0.5907406",
"0.5883169",
"0.58725154",
"0.58709425",
"0.5858532",
"0.58444816",
"0.58284324",
"0.58... | 0.70603704 | 1 |
Append key values to another dict with the same keys. | def append2dict(main_dict, *dicts):
# Multiples dictionaries to merge
for d in dicts:
for (key, value) in d.items():
# Test if the dictionary to append have the key
try:
main_dict[key].append(value)
# If not, create the key and merge the value
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _merge(old_dict, new_dict):\n dict3 = old_dict.copy()\n for k, v in new_dict.items():\n if k in dict3:\n dict3[k].append(v)\n else:\n dict3[k] = [v]\n return dict3",
"def __iadd__(self, other):\n if not isinstance(other, dict):\n msg = 'Can not c... | [
"0.761868",
"0.7320622",
"0.7264299",
"0.7261883",
"0.72461456",
"0.7105629",
"0.71054024",
"0.7059993",
"0.7056007",
"0.7002684",
"0.7002684",
"0.69979066",
"0.69800407",
"0.69702154",
"0.69489527",
"0.69252527",
"0.6870841",
"0.685961",
"0.6841138",
"0.68257046",
"0.6811402... | 0.6312285 | 59 |
Serialize recursively a list to another list composed of basic python object (list, dict, int, float, str...) | def serialize_list(data):
new_data = []
for value in data:
if isinstance(value, list):
new_data.append(serialize_list(value))
elif isinstance(value, dict):
new_data.append(serialize_dict(value))
elif isinstance(value, int) or isinstance(value, float) or isinstance... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def serialize_list(self, obj):\n return self.serialize_tuple(obj)",
"def serialize_object(obj):\n if obj is None:\n return obj\n\n if isinstance(obj, etree._Element):\n return obj\n\n if isinstance(obj, list):\n return [serialize_object(sub) for sub in obj]\n\n result = Or... | [
"0.6896342",
"0.6492682",
"0.64743435",
"0.64743435",
"0.6473793",
"0.6349664",
"0.6349664",
"0.6349664",
"0.63097835",
"0.63022345",
"0.62427187",
"0.6200168",
"0.61150545",
"0.60014796",
"0.60004",
"0.5997754",
"0.59920305",
"0.5988519",
"0.5968988",
"0.5951313",
"0.5945658... | 0.668352 | 1 |
r"""Get an attribute recursively. | def rgetattr(obj, attr, *args):
def _getattr(obj, attr):
return getattr(obj, attr, *args)
return functools.reduce(_getattr, [obj] + attr.split('.')) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_attr_recursive(self, name, memo=None):\n # `name` is dot-delimited, so split it up into distinct names:\n name_list = name.split('.')\n # The first name has special treatment, since it might need to\n # be dynamically built:\n top_attr_name = name_list[0]\n # NOTE... | [
"0.7474846",
"0.7153808",
"0.71363187",
"0.7023625",
"0.70105433",
"0.68282807",
"0.67382437",
"0.6680349",
"0.66647214",
"0.655203",
"0.652388",
"0.651328",
"0.64850074",
"0.6449671",
"0.6426947",
"0.6424302",
"0.6422253",
"0.64146745",
"0.64083445",
"0.64053845",
"0.6402996... | 0.61479867 | 35 |
Get the logits of NCE estimated probability for target and noise Both NCE and sampled_softmax are unchanged when the probabilities are scaled evenly, here we subtract the maximum value as in softmax, for numeric stability. | def _get_logit(self, input, target_idx, noise_idx):
target_logit, noise_logit = self.get_score(input, target_idx, noise_idx)
target_logit = target_logit.sub(self.norm_term)
noise_logit = noise_logit.sub(self.norm_term)
return target_logit, noise_logit | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def nce_logprobs(self, logit_target_in_model, logit_noise_in_model, logit_noise_in_noise, logit_target_in_noise):\n\n # NOTE: prob <= 1 is not guaranteed\n logit_model = torch.cat([logit_target_in_model.unsqueeze(2), logit_noise_in_model], dim=2)\n logit_noise = torch.cat([logit_target_in_nois... | [
"0.72175956",
"0.67632514",
"0.60848016",
"0.60833734",
"0.59923303",
"0.59795344",
"0.59593785",
"0.5932857",
"0.5932428",
"0.5878064",
"0.58604705",
"0.5827933",
"0.58246285",
"0.58109814",
"0.580438",
"0.5772957",
"0.5747648",
"0.5742967",
"0.5713755",
"0.5694718",
"0.5686... | 0.60539824 | 4 |
Compute the sampled softmax based on the tensorflow's impl | def sampled_softmax_logprobs(self, logit_target_in_model, logit_noise_in_model, logit_noise_in_noise, logit_target_in_noise):
logits = torch.cat([logit_target_in_model.unsqueeze(2), logit_noise_in_model], dim=2)
q_logits = torch.cat([logit_target_in_noise.unsqueeze(2), logit_noise_in_noise], dim=2)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_softmax_base():\n x = np.array([[[2.0, 3.0, 4.0, 5.0],\n [3.0, 4.0, 5.0, 6.0],\n [7.0, 8.0, 8.0, 9.0]],\n [[1.0, 2.0, 3.0, 4.0],\n [5.0, 6.0, 7.0, 8.0],\n [6.0, 7.0, 8.0, 9.0]]])\n res = np.a... | [
"0.72375625",
"0.71592647",
"0.7141543",
"0.7124955",
"0.709431",
"0.7092487",
"0.7092487",
"0.7082904",
"0.70629096",
"0.7051943",
"0.70487213",
"0.70325476",
"0.70325476",
"0.70313686",
"0.70313686",
"0.70313686",
"0.70313686",
"0.70313686",
"0.70313686",
"0.70313686",
"0.7... | 0.0 | -1 |
Returns the ID of the chain object. It does not matter if the id has been changes after adding the chain the to complex. It returns the "real" id of the chain object | def get_chain_name (chain):
if "-" in chain.id:
id_chain=chain.id[-1]
else:
id_chain=chain.id
return id_chain | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_id(self):\n\n\t\treturn self.__id",
"def get_id(self):\n return self.__id",
"def get_id(self):\n return self.__id",
"def id(self):\n\t\treturn self.__id",
"def getid(self):\n if self.Id is None:\n return self.internalid\n else:\n return self.Id",
... | [
"0.64789414",
"0.64199543",
"0.64199543",
"0.6401988",
"0.6400864",
"0.6400864",
"0.6400864",
"0.6400864",
"0.6400864",
"0.6400864",
"0.6396841",
"0.6396841",
"0.6396841",
"0.6396841",
"0.6396841",
"0.6396841",
"0.6396841",
"0.6396841",
"0.6396841",
"0.6396841",
"0.6396841",
... | 0.6789862 | 0 |
Function that changes the name of the new chains to be added to the complex, it adds a letter from the alphabet before the real ID separated by a "" | def change_names (fixed_structure, moving_structure, index):
for chain in moving_structure[0]:
chain.id = utilities.merged_list[index]+"-"+chain.id
index +=1
return (fixed_structure, moving_structure, index) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _fix_chainID(self):\n\n from string import ascii_uppercase\n\n # get the current names\n data = self.get('chainID')\n natom = len(data)\n\n #get uniques\n chainID = []\n for c in data:\n if c not in chainID:\n chainID.append(c)\n\n ... | [
"0.6926116",
"0.60350186",
"0.60258704",
"0.6007591",
"0.5950556",
"0.5924839",
"0.58528405",
"0.5840551",
"0.5680777",
"0.56515217",
"0.56277215",
"0.56207675",
"0.5593432",
"0.55552065",
"0.5544808",
"0.5507894",
"0.5491381",
"0.5483248",
"0.54693663",
"0.5440123",
"0.54387... | 0.60154825 | 3 |
Class method which checks if the given value is an `Option`. Returns `True` if it is. | def is_option(cls: Type['Option[T]'], value: Any) -> bool:
return isinstance(value, Option) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _is_opt(self, opt):\r\n\r\n # TODO: raise BadOptionError for unknown option\r\n if len(opt) < 2 or opt[0] != '-':\r\n return False\r\n if opt[1] != '-':\r\n return self._short_opt.get(opt[0:2]) is not None\r\n try:\r\n if \"=\" in opt:\r\n ... | [
"0.67180294",
"0.644909",
"0.62299746",
"0.6211447",
"0.6131447",
"0.6097059",
"0.60543674",
"0.59446865",
"0.5943079",
"0.59417915",
"0.59372663",
"0.5894563",
"0.5870201",
"0.58435833",
"0.58040565",
"0.57954943",
"0.5792939",
"0.5746857",
"0.57454437",
"0.5744768",
"0.5737... | 0.87929916 | 0 |
Constructs a ResNet50 model. | def resnet50_earlyexit(**kwargs):
model = ResNetEarlyExit(Bottleneck, [3, 4, 6, 3], **kwargs)
return model | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def resnet50(pretrained=False, **kwargs):\n model = ResNet(Bottleneck, [3, 4, 6, 3], **kwargs)\n if pretrained:\n model.load_state_dict(model_zoo.load_url(model_urls['resnet50']))\n fc = transfer_fc(model.fc)\n model.fc = fc\n return model",
"def resnet50(**kwargs):\n model = ResNet(... | [
"0.755625",
"0.7553112",
"0.7474026",
"0.7474026",
"0.7474026",
"0.7474026",
"0.74543184",
"0.73849267",
"0.73849267",
"0.73605144",
"0.735356",
"0.7241305",
"0.7241305",
"0.718981",
"0.71567255",
"0.7100313",
"0.70160615",
"0.6966828",
"0.68684405",
"0.6820117",
"0.67994595"... | 0.5979895 | 85 |
Min step of the minimax algorithm. | def _min_value(
self,
state: TwoPlayerGameState,
depth: int,
) -> float:
if state.end_of_game or depth == 0:
minimax_value = self.heuristic.evaluate(state)
else:
minimax_value = np.inf
successors = self.generate_successors(stat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def minim(self) -> int:\n\t\treturn 2",
"def minimize(self):\n pass",
"def one_cycle(self):\n self.nstep += 1\n new_global_min = False\n\n accept, minres = self._monte_carlo_step()\n\n if accept:\n self.energy = minres.fun\n self.x = np.copy(minres.x)\n ... | [
"0.74909216",
"0.6502346",
"0.64237064",
"0.6418244",
"0.6352389",
"0.63380665",
"0.63229454",
"0.63112587",
"0.6275154",
"0.62703514",
"0.62668175",
"0.623938",
"0.6237472",
"0.6223793",
"0.62124515",
"0.62124515",
"0.61966765",
"0.6194855",
"0.6193998",
"0.6168595",
"0.6160... | 0.63414204 | 5 |
Max step of the minimax algorithm. | def _max_value(
self,
state: TwoPlayerGameState,
depth: int,
) -> float:
if state.end_of_game or depth == 0:
minimax_value = self.heuristic.evaluate(state)
else:
minimax_value = -np.inf
successors = self.generate_successors(sta... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def minim(self) -> int:\n\t\treturn 2",
"def best_step(self):\r\n return self._best_value_step",
"def _maximize(self, board, possible_actions, depth_limit, alpha, beta):\r\n pass",
"def maximize(self):\n raise NotImplementedError",
"def maxim(self) -> (int, float('inf')):\n\t\treturn 2",
... | [
"0.67484635",
"0.67362964",
"0.6595354",
"0.65674037",
"0.65080017",
"0.6462683",
"0.6455741",
"0.64522177",
"0.6421434",
"0.64014816",
"0.6369479",
"0.63460934",
"0.6338692",
"0.6336562",
"0.62939847",
"0.6289916",
"0.6255334",
"0.6232077",
"0.62190896",
"0.61707526",
"0.615... | 0.6816621 | 0 |
The Azure Region in which the Key Vault managed Hardware Security Module exists. | def location(self) -> str:
return pulumi.get(self, "location") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def region(self):\n return self.config.region",
"def get_region(self):\n return self.creds.get('region_name')",
"def region(self) -> str:\n return pulumi.get(self, \"region\")",
"def region(self) -> str:\n return pulumi.get(self, \"region\")",
"def region(self) -> str:\n ... | [
"0.7266168",
"0.7237674",
"0.70635974",
"0.70635974",
"0.70635974",
"0.70635974",
"0.70635974",
"0.70635974",
"0.693939",
"0.68693393",
"0.68693393",
"0.68693393",
"0.68693393",
"0.6813604",
"0.6809065",
"0.6690985",
"0.6690985",
"0.66757965",
"0.66209483",
"0.66209483",
"0.6... | 0.0 | -1 |
The Name of the SKU used for this Key Vault Managed Hardware Security Module. | def sku_name(self) -> str:
return pulumi.get(self, "sku_name") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def vm_sku_name(self) -> str:\n return pulumi.get(self, \"vm_sku_name\")",
"def sku_name(self) -> pulumi.Output[Optional[str]]:\n return pulumi.get(self, \"sku_name\")",
"def sku_name(self) -> Optional[pulumi.Input[str]]:\n return pulumi.get(self, \"sku_name\")",
"def sku_name(self) -> O... | [
"0.8121262",
"0.79325676",
"0.7739485",
"0.7739485",
"0.7579729",
"0.7579729",
"0.7389494",
"0.7327727",
"0.73114425",
"0.7281661",
"0.71447146",
"0.71447146",
"0.69583124",
"0.69331557",
"0.69292045",
"0.6906445",
"0.6906445",
"0.6873477",
"0.6838579",
"0.68206424",
"0.68206... | 0.8303261 | 2 |
Sets the current driving direction and sets the driving timer accordingly. | def set_direction(self, direction: int) -> None:
self.direction = direction
if (direction == Directions.turn_left or
direction == Directions.turn_right):
self.stop_timer = time.time() + self.driving_time_turning
else:
self.stop_timer = time.time(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_direction(self, new_dir):\n self.__direction = new_dir",
"def driveSync(self,direction, speed=100):\n if direction == 1:\n print(\"Drive sync 1\")\n self.driveSpeed = speed \n if direction == -1:\n self.driveSpeed = -speed\n ... | [
"0.6608926",
"0.65660435",
"0.653478",
"0.6503984",
"0.65009046",
"0.65009046",
"0.64775205",
"0.6448301",
"0.63582534",
"0.6293403",
"0.6293403",
"0.6278547",
"0.61013895",
"0.6075105",
"0.6051007",
"0.6026443",
"0.59987295",
"0.59787923",
"0.59741753",
"0.5969381",
"0.59307... | 0.760538 | 0 |
Check if returning weak ref of a C obj. For example `git_checkout_options checkout_opts` is returning a weak reference. | def is_returnning_weak(c_type: str, jtype: str):
return c_type in LONG_ISH_WEAKREF_SET and jtype == 'jlong' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def should_check_refcount(self):\n raise NotImplementedError()",
"def resolve_ref(ref):\n if isinstance(ref, weakref.ref):\n ref = ref()\n return ref",
"def test_weakref(self):\n registry = ResultRegistry()\n er = EventualResult(None, None)\n registry.register(er)\n ... | [
"0.6626275",
"0.6454295",
"0.62101966",
"0.6130012",
"0.6118841",
"0.6100253",
"0.6042762",
"0.602644",
"0.59560275",
"0.59127533",
"0.59099925",
"0.590179",
"0.5783609",
"0.5756982",
"0.5756982",
"0.5700847",
"0.56840247",
"0.55712956",
"0.5542497",
"0.55220205",
"0.5482321"... | 0.6542793 | 1 |
JSON serializer for datetime objects to ensure that objects being saved will be able to be tracked. Will raise error if passed object it cannot serialize. | def json_datetime_serializer(obj):
if isinstance(obj, datetime):
serial = obj.isoformat()
return serial
raise TypeError("{} is not JSON serializable.".format(obj)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def json_serialize_datetime(self, obj):\n if isinstance(obj, datetime.datetime):\n return int(time.mktime(obj.timetuple()))\n\n raise TypeError(\"Type %s not serializable\" % type(obj))",
"def serialize_datetime(self, obj):\r\n if isinstance(obj, datetime.datetime):\r\n ... | [
"0.771173",
"0.74197257",
"0.7363774",
"0.7331228",
"0.72766143",
"0.72766143",
"0.72614646",
"0.7252251",
"0.7245006",
"0.72341764",
"0.7231653",
"0.72154784",
"0.71997553",
"0.71997553",
"0.71997553",
"0.71997553",
"0.7189503",
"0.71843654",
"0.7178176",
"0.7177841",
"0.716... | 0.7925466 | 0 |
Check if in the request only has only a unique combination between shift and day. | def validate_availability(self, value):
cnt = Counter()
if value:
for i in value:
day, shift = i.values()
mix_day_shift = str(day) + ', ' + str(shift)
cnt[mix_day_shift] += 1
if cnt.most_common(1)[0][1] >= 2:
raise s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_unique(self):\n pass",
"def valid_multiple_in_request(self):\n return self._repeatable[0] is True",
"def _is_unique_key(self, key):\n return self._in_keys(key, self._unique_keys)",
"def _check_occ_date(self):\n for record in self:\n count = self.search_count(\... | [
"0.5851898",
"0.5394493",
"0.5354619",
"0.53512913",
"0.5290591",
"0.52530515",
"0.52441525",
"0.52324",
"0.5178041",
"0.51483494",
"0.5106582",
"0.510037",
"0.50881714",
"0.50829184",
"0.5080927",
"0.5076379",
"0.5057633",
"0.5054936",
"0.50527745",
"0.50365835",
"0.50063187... | 0.6941287 | 0 |
Setup the gevent queue and the workers. | def __init__(self, maxsize=0, workers=10):
self.queue = JoinableQueue(maxsize=maxsize)
[spawn(self.worker) for x in range(workers)] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Initialize(self):\n self.queue_workers = [\n gevent.spawn(self._EventQueueWorker) for _ in xrange(self.num_workers)]\n self.gc_worker = gevent.spawn(self._GarbageCollectorWorker)",
"async def _setup(self):\n\n Reporter.info('Setting up workers...')\n self.workers = [asyncio.Task(se... | [
"0.7769949",
"0.7139168",
"0.6955711",
"0.6743766",
"0.66819346",
"0.6650294",
"0.66424555",
"0.64448136",
"0.63536066",
"0.63292646",
"0.624944",
"0.62140614",
"0.62063307",
"0.6204641",
"0.61613536",
"0.6154683",
"0.61263525",
"0.6087827",
"0.60686773",
"0.60517365",
"0.604... | 0.5584802 | 69 |
Do forward, backward and gradient step in parallel. | def train_step(self, samples):
# PyTorch initializes gradient buffers lazily, so the first
# train step needs to send non-empty samples to all replicas
replace_empty_samples = False
if not self._grads_initialized:
replace_empty_samples = True
self._grads_initializ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parallel_backward(losses, sync=True):\n\n def _worker(loss):\n autograd.backward(loss)\n\n threads = [threading.Thread(target=_worker, args=(loss,)) for loss in losses]\n if sync:\n for thread in threads:\n thread.start()\n for thread in threads:\n thread.joi... | [
"0.691453",
"0.6655669",
"0.6476425",
"0.63899904",
"0.62763053",
"0.6268684",
"0.6249809",
"0.6219835",
"0.6191865",
"0.6189565",
"0.6188072",
"0.6181299",
"0.6125889",
"0.6078165",
"0.60117966",
"0.6007914",
"0.60031486",
"0.5998216",
"0.5979641",
"0.5968244",
"0.59573764",... | 0.0 | -1 |
nn.utils.clip_grad_norm for flattened (contiguous) tensors. | def _clip_grads_(self, flat_grads, clipv):
norm = flat_grads.norm()
if clipv > 0 and norm > clipv:
coef = max(norm, 1e-6) / clipv
flat_grads.div_(coef)
return norm | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clip_grad_norm(grads, max_norm):\n grads_without_none = []\n orig_indices = []\n # Remove None gradients.\n for i, g in enumerate(grads):\n if g is not None:\n orig_indices.append(i)\n grads_without_none.append(g)\n total_norm = tf.norm(\n tf.stack([tf.norm(g, ord=2) for g in grads_witho... | [
"0.7292905",
"0.70816815",
"0.6999802",
"0.6975075",
"0.69559264",
"0.6948092",
"0.6917727",
"0.6909057",
"0.6829388",
"0.66394484",
"0.6619211",
"0.65782523",
"0.65581644",
"0.6532657",
"0.65101385",
"0.643352",
"0.64316124",
"0.6419963",
"0.6419963",
"0.6419963",
"0.6419963... | 0.6374938 | 22 |
Get the current learning rate. | def get_lr(self):
return self.call_async(0, '_async_get_lr').gen() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_learning_rate(self):\n config = self.config\n cur_lr = Train_model_pipeline.adjust_learning_rate(\n self.optimizer,\n self.epoch,\n config[\"training\"][\"learning_rate\"],\n decay=config[\"training\"][\"lr_decay_rate\"],\n step=config[\"... | [
"0.8338021",
"0.8257183",
"0.80368876",
"0.76718974",
"0.7653609",
"0.7651945",
"0.76396656",
"0.76396656",
"0.74942815",
"0.7460383",
"0.7419125",
"0.7365561",
"0.72476804",
"0.72476804",
"0.70984983",
"0.7093192",
"0.7053641",
"0.70433134",
"0.70149547",
"0.6989301",
"0.698... | 0.63190496 | 60 |
Adjust the learning rate depending on the validation loss. | def lr_step(self, val_loss=None, epoch=None):
lr = Future.gen_list([
self.call_async(rank, '_async_lr_step', val_loss=val_loss, epoch=epoch)
for rank in range(self.num_replicas)
])
return lr[0] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_learning_rate(self, validation_loss=None):\n if validation_loss is None:\n for scheduler in self.schedulers:\n scheduler.step()\n else:\n for scheduler in self.schedulers:\n scheduler.step(validation_loss)\n self.lr = self.optimize... | [
"0.81191456",
"0.7936515",
"0.78766936",
"0.785512",
"0.7854872",
"0.7789796",
"0.77870864",
"0.7785367",
"0.7776074",
"0.77457184",
"0.77307266",
"0.7693429",
"0.7683071",
"0.76826876",
"0.766253",
"0.76550776",
"0.764174",
"0.7638202",
"0.7632693",
"0.76292247",
"0.76261693... | 0.0 | -1 |
get quartz config object | def get_quartz_config_object(env, src):
cfg = env.configStore()
o = cfg.get(_psana.Quartz.ConfigV2, src)
if o is not None: return o
o = cfg.get(_psana.Quartz.ConfigV1, src)
if o is not None: return o
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _load_config(self):\n\n options = dict()\n\n job_stores = self.app.config.get('SCHEDULER_JOBSTORES')\n if job_stores:\n options['jobstores'] = job_stores\n\n executors = self.app.config.get('SCHEDULER_EXECUTORS')\n if executors:\n options['executors'] = ... | [
"0.6142567",
"0.58563805",
"0.5817024",
"0.5806531",
"0.580482",
"0.5803616",
"0.580205",
"0.580205",
"0.580205",
"0.580205",
"0.580205",
"0.580205",
"0.580205",
"0.580205",
"0.580205",
"0.580205",
"0.580205",
"0.580205",
"0.580205",
"0.580205",
"0.580205",
"0.580205",
"0... | 0.7785167 | 0 |
Return name of image file in current working directory with this root | def findfigure(name):
found = None
if "." in name:
if os.path.exists(name):
found = name
elif "." not in name:
for suffix in (".pdf", ".eps", ".ps", ".JPG", ".jpg", ".png"):
testfile = name + suffix
if os.path.exists(testfile):
found = test... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def imagefile(self):\n return os.path.join(self.__folder, self.__name + '.jpg')",
"def _get_image_name(self) -> str:\n dirname = os.path.basename(os.getcwd())\n default_image_name = f\"{dirname}_{self.config_name}\"\n image_name = self.config_options.get(\"image\", default_image_name)... | [
"0.786632",
"0.78609234",
"0.7424861",
"0.737362",
"0.73325926",
"0.7311707",
"0.7129474",
"0.7123577",
"0.71204376",
"0.7033828",
"0.69671804",
"0.69488907",
"0.6902777",
"0.6893927",
"0.6882196",
"0.6834376",
"0.682497",
"0.6812889",
"0.680251",
"0.6775631",
"0.6773598",
... | 0.0 | -1 |
Form output file name. | def outfigname(num, ext, char=""):
return "f{}{}{}".format(num, char, ext) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def outname(self, fileappend=''):\n if self._outname is None:\n self._outname = self.generate_outname(fileappend='')\n\n return self._outname",
"def getOutputFilename(self, filename):\n return filename[:-4] + \".txt\"",
"def create_filename (self):\n\t\tassert self.__patient_nam... | [
"0.7624078",
"0.75484014",
"0.73216164",
"0.73161376",
"0.71804863",
"0.71551675",
"0.70691735",
"0.7027036",
"0.7016375",
"0.70112383",
"0.7010359",
"0.69670796",
"0.69408983",
"0.6937287",
"0.6915561",
"0.69057035",
"0.6876231",
"0.685482",
"0.68535167",
"0.68445647",
"0.68... | 0.63679355 | 65 |
Add new tags in "new_tags" to the set of tags attached to this log manager instance, and return a new DagsterLogManager with the merged set of tags. | def with_tags(self, **new_tags):
return DagsterLogManager(
logging_metadata=self.logging_metadata._replace(**new_tags),
loggers=self._loggers,
handlers=self.handlers,
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_tag_metas(self, new_tag_metas: List[TagMeta]) -> ProjectMeta:\n return self.clone(tag_metas=self.tag_metas.add_items(new_tag_metas))",
"def tags(self, new_tags: List[str]) -> None:\n if not isinstance(new_tags, list):\n raise ExperimentDataError(f\"The `tags` field of {type(self)... | [
"0.5979848",
"0.5740028",
"0.5470231",
"0.5432234",
"0.52555025",
"0.51227975",
"0.4986611",
"0.497146",
"0.4889816",
"0.46688485",
"0.4656642",
"0.46005845",
"0.457154",
"0.45025256",
"0.45018414",
"0.44660848",
"0.44474703",
"0.4399408",
"0.43832096",
"0.43555197",
"0.43517... | 0.7944571 | 0 |
Validates a field for a valid phone number | def validate_phone(form, field):
if len(field.data) > 16:
raise ValidationError('Invalid phone number')
try:
input_number = phonenumbers.parse(field.data)
if not (phonenumbers.is_valid_number(input_number)):
raise ValidationError('Invalid phone number')
except Exception:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_phone_number(value):\n\n try:\n z = phonenumbers.parse(value, None)\n except phonenumbers.NumberParseException:\n raise forms.ValidationError(\"Enter a valid phone number.\")\n\n if not phonenumbers.is_valid_number(z):\n raise forms.ValidationError(\"Enter a valid phone n... | [
"0.83677363",
"0.83241045",
"0.81992954",
"0.8163816",
"0.812398",
"0.7893777",
"0.77964145",
"0.7727902",
"0.77080286",
"0.76732373",
"0.7634139",
"0.76136893",
"0.761128",
"0.7583921",
"0.7578268",
"0.75425816",
"0.75329864",
"0.7505469",
"0.7474268",
"0.7350862",
"0.725585... | 0.87605786 | 0 |
Validates a field for a valid phone number | def validate_subdivision(form, field):
# TODO: check to see if subdivision is in selected country
try:
pycountry.subdivisions.lookup(field.data)
except Exception:
raise ValidationError(field.data + ' is not a State / Province / Region') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_phone(form, field):\n if len(field.data) > 16:\n raise ValidationError('Invalid phone number')\n try:\n input_number = phonenumbers.parse(field.data)\n if not (phonenumbers.is_valid_number(input_number)):\n raise ValidationError('Invalid phone number')\n except... | [
"0.8760536",
"0.8367812",
"0.8324525",
"0.81999034",
"0.8163585",
"0.8125083",
"0.78939086",
"0.77962124",
"0.7727542",
"0.77089703",
"0.76728123",
"0.7635166",
"0.76130885",
"0.76118827",
"0.75831395",
"0.75777227",
"0.7542088",
"0.7533505",
"0.75056684",
"0.74741024",
"0.73... | 0.0 | -1 |
Utility function to reset the weights of the network. | def reset(self, initialization='default'):
raise NotImplementedError() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset_weights(self):\r\n self._weights = deepcopy(self._tmp_weights)\r\n self._tmp_weights = None",
"def reset_weights(self):\n self.head.reset_weights()",
"def reset_weights(self):\n self.policy_backbone.reset_weights()\n self.value_backbone.reset_weights()\n self... | [
"0.8593917",
"0.8472963",
"0.8228671",
"0.8048129",
"0.7762969",
"0.74412835",
"0.73798925",
"0.7370133",
"0.7283574",
"0.72022825",
"0.71882766",
"0.708746",
"0.7065608",
"0.7029281",
"0.7010241",
"0.6991684",
"0.695444",
"0.6923053",
"0.6908367",
"0.6908367",
"0.6908367",
... | 0.0 | -1 |
This returns a dict which is the standardised structure for serialising all states into json | def to_json(self):
return {
"state_type": self.state_type,
"state_id": self.state_id,
"public": self.public,
"private": self.private
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_state_json(self) -> Dict[str, Any]:\n return self.state_to_json()",
"def to_json(self) -> Dict[str, Any]:\n return json.loads(self.get_state().to_json())",
"def state_to_json(self) -> Dict[str, Any]:\n return self.rstate.to_json()",
"def _get_state_dict(self) -> dict:\n ret... | [
"0.8200849",
"0.7825386",
"0.7803366",
"0.7589789",
"0.7589789",
"0.75872403",
"0.75732154",
"0.73999345",
"0.73828095",
"0.73686856",
"0.7308452",
"0.72323084",
"0.72216594",
"0.7196019",
"0.7191161",
"0.71577793",
"0.71469086",
"0.7145572",
"0.71452224",
"0.71452224",
"0.71... | 0.75617945 | 7 |
Test orthogonal projection of one vector to another vector. | def test_vector_projection():
a = np.ones(3)
a_on_unitx = pr.vector_projection(a, pr.unitx)
assert_array_almost_equal(a_on_unitx, pr.unitx)
assert_almost_equal(pr.angle_between_vectors(a_on_unitx, pr.unitx), 0.0)
a2_on_unitx = pr.vector_projection(2 * a, pr.unitx)
assert_array_almost_equal(a2_o... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _orthogonal_vector(vector):\n return -1 * vector[1], vector[0]",
"def test_vector_projection_on_zero_vector():\n random_state = np.random.RandomState(23)\n for _ in range(5):\n a = pr.random_vector(random_state, 3)\n a_on_b = pr.vector_projection(a, np.zeros(3))\n assert_array_a... | [
"0.6770901",
"0.67674327",
"0.6689018",
"0.6670237",
"0.66599363",
"0.6557277",
"0.6445381",
"0.64218956",
"0.637236",
"0.62990284",
"0.61442435",
"0.61123866",
"0.6099427",
"0.6088672",
"0.60610044",
"0.6026007",
"0.5905668",
"0.58639765",
"0.58582276",
"0.5835021",
"0.58155... | 0.75394046 | 0 |
Test input validation for rotation matrix. | def test_check_matrix():
R_list = [[1, 0, 0], [0, 1, 0], [0, 0, 1]]
R = pr.check_matrix(R_list)
assert_equal(type(R), np.ndarray)
assert_equal(R.dtype, np.float64)
R_int_array = np.eye(3, dtype=int)
R = pr.check_matrix(R_int_array)
assert_equal(type(R), np.ndarray)
assert_equal(R.dtype,... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_asssert_rotation_matrix_behaves_like_check_matrix():\n random_state = np.random.RandomState(2345)\n for _ in range(5):\n a = pr.random_axis_angle(random_state)\n R = pr.matrix_from_axis_angle(a)\n original_value = R[2, 2]\n for error in [0, 1e-8, 1e-7, 1e-5, 1e-4, 1]:\n ... | [
"0.76198494",
"0.6995302",
"0.6820299",
"0.670978",
"0.6608136",
"0.6603374",
"0.65707165",
"0.65181303",
"0.6468469",
"0.6346897",
"0.6291172",
"0.62752175",
"0.6232407",
"0.62080777",
"0.6202115",
"0.618742",
"0.6177467",
"0.6146699",
"0.6122371",
"0.6122213",
"0.6104839",
... | 0.67749566 | 3 |
Test conversions between rotation matrix and quaternion. | def test_conversions_matrix_quaternion():
R = np.eye(3)
a = pr.axis_angle_from_matrix(R)
assert_array_almost_equal(a, np.array([1, 0, 0, 0]))
random_state = np.random.RandomState(0)
for _ in range(5):
q = pr.random_quaternion(random_state)
R = pr.matrix_from_quaternion(q)
pr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_to_quaternion(self):\r\n R = np.identity(3)\r\n q = to_quaternion(R)\r\n zero_vec = q - np.array([0., 0., 0., 1.])\r\n self.assertAlmostEqual(np.linalg.norm(zero_vec), 0.0)\r\n\r\n for _ in range(20):\r\n q = np.random.randn(4)\r\n q /= np.linalg.no... | [
"0.80193526",
"0.79094625",
"0.7781212",
"0.7733679",
"0.7370852",
"0.7351515",
"0.73497933",
"0.7315278",
"0.72531325",
"0.71705234",
"0.7152907",
"0.7126747",
"0.7024841",
"0.7011307",
"0.6987472",
"0.6973207",
"0.6935359",
"0.6919898",
"0.6917783",
"0.68654966",
"0.6836206... | 0.82358253 | 0 |
Test conversions between compact axisangle and quaternion. | def test_conversions_compact_axis_angle_quaternion():
q = np.array([1, 0, 0, 0])
a = pr.compact_axis_angle_from_quaternion(q)
assert_array_almost_equal(a, np.array([0, 0, 0]))
q2 = pr.quaternion_from_compact_axis_angle(a)
assert_array_almost_equal(q2, q)
random_state = np.random.RandomState(0)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_conversions_axis_angle_quaternion():\n q = np.array([1, 0, 0, 0])\n a = pr.axis_angle_from_quaternion(q)\n assert_array_almost_equal(a, np.array([1, 0, 0, 0]))\n q2 = pr.quaternion_from_axis_angle(a)\n assert_array_almost_equal(q2, q)\n\n random_state = np.random.RandomState(0)\n for ... | [
"0.71578026",
"0.67892486",
"0.67066747",
"0.6634019",
"0.6620193",
"0.66132396",
"0.6583995",
"0.65805155",
"0.65768725",
"0.6571968",
"0.6494356",
"0.6492593",
"0.6478215",
"0.638819",
"0.6378265",
"0.6212822",
"0.6184301",
"0.6151081",
"0.6124323",
"0.61219126",
"0.6080763... | 0.8033839 | 0 |
Test conversion of quaternion between wxyz and xyzw. | def test_quaternion_conventions():
q_wxyz = np.array([1.0, 0.0, 0.0, 0.0])
q_xyzw = pr.quaternion_xyzw_from_wxyz(q_wxyz)
assert_array_equal(q_xyzw, np.array([0.0, 0.0, 0.0, 1.0]))
q_wxyz2 = pr.quaternion_wxyz_from_xyzw(q_xyzw)
assert_array_equal(q_wxyz, q_wxyz2)
random_state = np.random.RandomS... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_so3_xyzw_bijective(_random_module):\n T = sample_transform(jaxlie.SO3)\n assert_transforms_close(T, jaxlie.SO3.from_quaternion_xyzw(T.as_quaternion_xyzw()))",
"def test_check_quaternion():\n q_list = [1, 0, 0, 0]\n q = pr.check_quaternion(q_list)\n assert_array_almost_equal(q_list, q)\n ... | [
"0.7026409",
"0.67457294",
"0.6717996",
"0.66186094",
"0.6506997",
"0.642514",
"0.6366318",
"0.6352576",
"0.63209",
"0.62506706",
"0.62370414",
"0.62185806",
"0.6182944",
"0.6182421",
"0.6155607",
"0.6111267",
"0.60847276",
"0.6046263",
"0.5985926",
"0.59652936",
"0.59482473"... | 0.74388933 | 0 |
Test if quaternion multiplication follows Hamilton's convention. | def test_quaternion_hamilton():
q_ij = pr.concatenate_quaternions(pr.q_i, pr.q_j)
assert_array_equal(pr.q_k, q_ij)
q_ijk = pr.concatenate_quaternions(q_ij, pr.q_k)
assert_array_equal(-pr.q_id, q_ijk) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_matrix_from_quaternion_hamilton():\n q = np.sqrt(0.5) * np.array([1, 0, 0, 1])\n R = pr.matrix_from_quaternion(q)\n assert_array_almost_equal(\n np.array([[0, -1, 0],\n [1, 0, 0],\n [0, 0, 1]]),\n R\n )",
"def is_same_quaternion(q0, q1):\r\n ... | [
"0.68623555",
"0.64047253",
"0.6300059",
"0.60610235",
"0.60184723",
"0.59799457",
"0.5941113",
"0.5696614",
"0.5696614",
"0.5615042",
"0.5550903",
"0.54939413",
"0.5489515",
"0.5483338",
"0.5454985",
"0.5452444",
"0.5450511",
"0.5447861",
"0.5435056",
"0.542706",
"0.5415491"... | 0.7402401 | 0 |
Test if quaternion rotation and multiplication are Hamiltonian. | def test_quaternion_rotation_consistent_with_multiplication():
random_state = np.random.RandomState(1)
for _ in range(5):
v = pr.random_vector(random_state)
q = pr.random_quaternion(random_state)
v_im = np.hstack(((0.0,), v))
qv_mult = pr.concatenate_quaternions(
q, p... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_quaternion_hamilton():\n q_ij = pr.concatenate_quaternions(pr.q_i, pr.q_j)\n assert_array_equal(pr.q_k, q_ij)\n q_ijk = pr.concatenate_quaternions(q_ij, pr.q_k)\n assert_array_equal(-pr.q_id, q_ijk)",
"def is_Hermitian(q_1: Qs) -> bool:\n\n hc = Hermitian_conj(q_1, q_1.rows, q_1.columns)\... | [
"0.7360241",
"0.661501",
"0.6586913",
"0.61760306",
"0.60709524",
"0.59135395",
"0.5888707",
"0.57508194",
"0.57298416",
"0.5710799",
"0.56980115",
"0.56793535",
"0.56330824",
"0.5612407",
"0.5610576",
"0.5589202",
"0.5536868",
"0.55191875",
"0.5515655",
"0.54935735",
"0.5475... | 0.5390463 | 26 |
Test angular metric of quaternions q and q. | def test_quaternion_dist_for_identical_rotations():
random_state = np.random.RandomState(0)
for _ in range(5):
q = pr.quaternion_from_axis_angle(pr.random_axis_angle(random_state))
assert_array_almost_equal(pr.matrix_from_quaternion(q),
pr.matrix_from_quaternio... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_q(self):\n assert np.allclose(self.stepper.q, self.ODE.exact(self.stepper.t), rtol=1e-3, atol=1e-5)",
"def test_check_quaternions():\n Q_list = [[1, 0, 0, 0]]\n Q = pr.check_quaternions(Q_list)\n assert_array_almost_equal(Q_list, Q)\n assert_equal(type(Q), np.ndarray)\n assert_equa... | [
"0.65812486",
"0.63682437",
"0.62707365",
"0.62577444",
"0.6152928",
"0.6128305",
"0.59861505",
"0.5902872",
"0.5889198",
"0.5887856",
"0.58824587",
"0.58787906",
"0.5865886",
"0.5857081",
"0.5853649",
"0.58215487",
"0.5812693",
"0.57913405",
"0.576557",
"0.5740266",
"0.57042... | 0.5651043 | 23 |
Test angular metric of quaternions q and ca. q. | def test_quaternion_dist_for_almost_identical_rotations():
random_state = np.random.RandomState(0)
for _ in range(5):
a = pr.random_axis_angle(random_state)
q1 = pr.quaternion_from_axis_angle(a)
r = 1e-4 * random_state.randn(4)
q2 = -pr.quaternion_from_axis_angle(a + r)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_q(self):\n assert np.allclose(self.stepper.q, self.ODE.exact(self.stepper.t), rtol=1e-3, atol=1e-5)",
"def test_check_quaternions():\n Q_list = [[1, 0, 0, 0]]\n Q = pr.check_quaternions(Q_list)\n assert_array_almost_equal(Q_list, Q)\n assert_equal(type(Q), np.ndarray)\n assert_equa... | [
"0.6432881",
"0.63669115",
"0.6307198",
"0.62803376",
"0.600475",
"0.5989186",
"0.59654045",
"0.58865666",
"0.58673596",
"0.58640534",
"0.5856488",
"0.5845763",
"0.5842495",
"0.5806429",
"0.5804048",
"0.5789136",
"0.5776353",
"0.57747257",
"0.5760685",
"0.5750213",
"0.5746283... | 0.5581739 | 27 |
Test equivalence of constants that represent no rotation. | def test_id_rot():
assert_array_almost_equal(pr.R_id, pr.matrix_from_axis_angle(pr.a_id))
assert_array_almost_equal(pr.R_id, pr.matrix_from_quaternion(pr.q_id))
assert_array_almost_equal(pr.R_id, pr.matrix_from_euler_xyz(pr.e_xyz_id))
assert_array_almost_equal(pr.R_id, pr.matrix_from_euler_zyx(pr.e_zyx_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testrotconsts(self):\r\n assert self.data.rotconsts.shape == (len(self.data.atomcoords), 3)",
"def test_not_equal_to_other_types(self):\n from pedemath.quat import Quat\n\n self.assertNotEqual(Vec3(1, -2, 3), 5)\n self.assertNotEqual(Vec3(1, -2, 3), \"abc\")\n\n self.assert... | [
"0.66059446",
"0.6270688",
"0.61368585",
"0.6078763",
"0.6030151",
"0.602586",
"0.5985331",
"0.59735966",
"0.5959248",
"0.5901648",
"0.5896601",
"0.5890921",
"0.5887384",
"0.5854365",
"0.5854225",
"0.57990503",
"0.57977736",
"0.57966346",
"0.57914954",
"0.5788889",
"0.578846"... | 0.0 | -1 |
Initialize the drawable surface | def __init__(self, surface, rect):
self.surface = surface
self.rect = rect | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_graphics(self):\n if type(self.image_ref) is Surface:\n # This is the case for the special visual effect\n self.image = self.image_ref\n else:\n image = GLOBAL.img(self.image_ref)\n if type(image) is tuple:\n # for decode purpose\n ... | [
"0.7053568",
"0.6702888",
"0.6660765",
"0.651732",
"0.6495449",
"0.6475579",
"0.6423008",
"0.6241607",
"0.62350696",
"0.6222372",
"0.621946",
"0.62041616",
"0.61815536",
"0.6154902",
"0.6130131",
"0.61234355",
"0.6111104",
"0.6104045",
"0.6071729",
"0.60600996",
"0.60506016",... | 0.6689883 | 3 |
return the effective diffusion coefficient in the porous catalyst | def D_eff(D_AB, por, tau, sigma):
return D_AB*sigma*por/tau | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def estimate_diffusion_coefficient(n_CFx: int) -> t.Diffusivity:\n return t.Diffusivity(10 ** (-4.5360 + -0.1088 * n_CFx), \"cm^2/s\")",
"def coefficient(self) -> float:\n ...",
"def diffuse_coefficient(self):\n return self._diffuse_coefficient",
"def coherence(self):\r\n return np.ab... | [
"0.68750376",
"0.6755158",
"0.6722923",
"0.65299207",
"0.6489864",
"0.6422776",
"0.64193666",
"0.6395849",
"0.63579047",
"0.6323069",
"0.62970465",
"0.6229028",
"0.62257785",
"0.62219423",
"0.6183919",
"0.6125393",
"0.6114657",
"0.6082984",
"0.6075881",
"0.6062295",
"0.604915... | 0.0 | -1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.