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 |
|---|---|---|---|---|---|---|
return True if the current user has right to view this event | def can_view_event(event, user):
if event.privacy == Event.PRIVACY_PUBLIC:
return True
elif not user.is_active:
return False
# you're logged in
if event.privacy == Event.PRIVACY_COMPANY:
# but then it's not good enough to be contributor
if is_contributor(user):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def can_view_event(self, event, request):\n return can_view_event(event, request.user)",
"def current_user_has_access(self):\n return self.user_has_access(users.get_current_user())",
"def can_retrieve(self, user):\n return user.has_perm('agenda.can_see')",
"def can_be_viewed_by(self,user):\n... | [
"0.7915212",
"0.7818065",
"0.7703481",
"0.75753987",
"0.7568369",
"0.7486999",
"0.7486999",
"0.7486999",
"0.74635386",
"0.73556936",
"0.7343641",
"0.72791964",
"0.72654754",
"0.7238292",
"0.72046363",
"0.71644276",
"0.71246845",
"0.7109007",
"0.70908797",
"0.70885503",
"0.704... | 0.78389686 | 1 |
Prompt the user to enter their api key. | def _promptForApiKey(self, *args):
ui = e5App().getObject('UserInterface')
title = 'WakaTime'
label = ' Enter your WakaTime API Key: \n' + \
' (https://wakatime.com/settings) '
default = self._getApiKey()
text,... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def api_key(self) -> pulumi.Input[str]:\n return pulumi.get(self, \"api_key\")",
"def api_key(self) -> pulumi.Input[str]:\n return pulumi.get(self, \"api_key\")",
"def api_key(self) -> pulumi.Input[str]:\n return pulumi.get(self, \"api_key\")",
"def api_key(self) -> pulumi.Input[str]:\n ... | [
"0.7120944",
"0.7120944",
"0.7120944",
"0.7120944",
"0.6932976",
"0.68626016",
"0.68626016",
"0.6603749",
"0.65838504",
"0.65284735",
"0.6507273",
"0.6492358",
"0.64648634",
"0.64390355",
"0.63309836",
"0.6316187",
"0.63127744",
"0.62042844",
"0.6181693",
"0.6166776",
"0.6152... | 0.77280456 | 0 |
True if the string is safe to use as a filename | def is_filename_safe(value):
return value == str_to_filename(value) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_filename_safe(filename: str) -> bool:\n allowed_format = \"|\".join(FileStoreManager.ALL_FORMAT) # png|svg|jpg\n regex = f\"[a-zA-Z0-9][a-zA-Z0-9_()-\\.]*\\.({allowed_format})$\"\n return re.match(regex, filename) is not None",
"def is_filename_safe(file: Union[str, FileStorage]) -> b... | [
"0.8067586",
"0.7748462",
"0.7342562",
"0.7242904",
"0.7170299",
"0.7157121",
"0.71241206",
"0.7072818",
"0.7001556",
"0.6972817",
"0.69697255",
"0.68990976",
"0.68700737",
"0.684477",
"0.6821284",
"0.67766917",
"0.6764531",
"0.6752482",
"0.672251",
"0.6707125",
"0.6705961",
... | 0.85510355 | 0 |
Load data from a JSON string | def from_json(self, raw, session=False):
# Purposely don't catch exception - failure to serialise is fatal
data = json.loads(raw)
self.from_dict(data, session=session) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_json_str(self, json_text: str):\n\n self.data = json.loads(json_text)",
"def load_json(self):\n\n self.load_json_str(self.get_json_str())",
"def load_json(json_str):\n return _api_internal._load_json(json_str)",
"def load_json(json_string):\n return json.loads(json_string)",
"d... | [
"0.82914174",
"0.80282855",
"0.78992426",
"0.7808813",
"0.7692054",
"0.75382525",
"0.7322359",
"0.72367465",
"0.7226408",
"0.72021925",
"0.71726143",
"0.7160995",
"0.71252286",
"0.71111035",
"0.70970374",
"0.70613444",
"0.7029962",
"0.7026443",
"0.70237446",
"0.7000534",
"0.6... | 0.0 | -1 |
Find environment variables containing config data and return a dict of them | def find_environ_config_vars():
# only allow secret key and database uri for now
envvars = ["SQLALCHEMY_DATABASE_URI", "SECRET_KEY"]
results = {}
for key in envvars:
if key in os.environ:
results[key] = os.environ[key]
return results | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_environment_vars():\n return {env: os.environ[env] for env in\n params.ENV_DIRS if env in os.environ}",
"def env_dict(self): # type: () -> t.Dict[str, str]\n return dict((item[0], item[1]) for item in [e.split('=', 1) for e in self.env])",
"def get_envvar_configuration(app_name, l... | [
"0.74902755",
"0.73133004",
"0.7204992",
"0.7140691",
"0.7140691",
"0.7140691",
"0.7140691",
"0.7130744",
"0.71007246",
"0.70807976",
"0.6958684",
"0.6953522",
"0.69449145",
"0.6886404",
"0.6864564",
"0.68270713",
"0.6826755",
"0.680241",
"0.67708033",
"0.6747287",
"0.6731064... | 0.8224719 | 0 |
Returns a Flask application object | def create_app(name, path, settings_override=None,
register_security_blueprint=True):
app = Flask(name, instance_relative_config=True)
app.config.from_object("linkedlist.config") # public config
app.config.from_pyfile("config.py", silent=True) # instance config
app.config.from_object(s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def app():\n app = create_app()\n return app",
"def app():\n return create_app()",
"def get_app():\n\n global _app\n if _app is None:\n\n entrypoint = get_config().get('APP_ENTRYPOINT')\n if not entrypoint:\n raise RuntimeError('APP_ENTRYPOINT missing from config')\n ... | [
"0.842095",
"0.8246454",
"0.82030857",
"0.8168864",
"0.81045556",
"0.8066337",
"0.79880565",
"0.78597844",
"0.78327835",
"0.7810589",
"0.77686507",
"0.7738555",
"0.7729705",
"0.7726699",
"0.77229196",
"0.7715562",
"0.7682923",
"0.76532614",
"0.76347286",
"0.76232916",
"0.7598... | 0.0 | -1 |
Return a human readable representation of the model instance. | def __str__(self):
return "{}".format(self.name) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self):\n return super().__str__() + self.model.__str__()",
"def __str__(self):\n model = self._meta.verbose_name.title()\n return f\"{model:s}: {self.name:s}\"",
"def __str__(self):\n model = self._meta.verbose_name.title()\n return f\"{model:s}: {self.name:s}\"",... | [
"0.79865694",
"0.778825",
"0.778825",
"0.7578485",
"0.7573961",
"0.7508439",
"0.73869205",
"0.725669",
"0.725669",
"0.72521317",
"0.7250976",
"0.72447103",
"0.72447103",
"0.7238946",
"0.72377145",
"0.72135806",
"0.7196659",
"0.71778005",
"0.7177506",
"0.7173099",
"0.7172897",... | 0.0 | -1 |
Index function for homepage of the website | def index():
# The various forms
new_study_form = NewStudyForm(request.form)
delete_study_form = DeleteStudyForm(request.form)
connect_study_form = ConnectStudyForm(request.form)
error_messages = []
info_messages = []
if request.method == 'POST':
if new_study_form.register.data or... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def homepage():\n return render_template('home/index.html', \n title=\"Bem vindo!\")",
"def index():\r\n\r\n # initializes page title\r\n page_title = 'Home'\r\n\r\n # renders the landing page\r\n return render_template('index.html', page_title=page_title)",
"def index... | [
"0.81353927",
"0.80929625",
"0.8064895",
"0.8062962",
"0.8013738",
"0.80034924",
"0.8002165",
"0.798977",
"0.79885477",
"0.79661703",
"0.7932537",
"0.7927669",
"0.7927669",
"0.7910875",
"0.7894913",
"0.7884207",
"0.7880908",
"0.7867198",
"0.7854982",
"0.78476435",
"0.7836588"... | 0.0 | -1 |
Sets the id of this BankAccount. | def id(self, id):
self._id = id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def SetId(self, id):\n self.id = int(id)",
"def account_bank_id(self, account_bank_id):\n\n self._account_bank_id = account_bank_id",
"def set_id(self, id_):\n\n self.id_ = id_",
"def set_id(self, id):\n self.__id = id",
"def bank_id(self, bank_id):\n\n self._bank_id = ba... | [
"0.7284551",
"0.72422296",
"0.7194926",
"0.7166639",
"0.71349657",
"0.7039895",
"0.69491154",
"0.6903764",
"0.6802818",
"0.6707203",
"0.6687408",
"0.66853243",
"0.6681096",
"0.66660535",
"0.66660535",
"0.66660535",
"0.66660535",
"0.66660535",
"0.66660535",
"0.66660535",
"0.66... | 0.0 | -1 |
Sets the type of this BankAccount. | def type(self, type):
self._type = type | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def account_type(self, account_type):\n\n self._account_type = account_type",
"def account_type(self, account_type):\n\n self._account_type = account_type",
"def account_type(self, account_type):\n\n self._account_type = account_type",
"def account_type(self, account_type):\n\n se... | [
"0.7822151",
"0.7822151",
"0.7822151",
"0.7822151",
"0.7269691",
"0.7269691",
"0.7228186",
"0.7053937",
"0.69883746",
"0.6925743",
"0.68565696",
"0.6764424",
"0.6677695",
"0.6586367",
"0.6586367",
"0.65282446",
"0.65282446",
"0.65282446",
"0.6505576",
"0.64929366",
"0.6355008... | 0.66197646 | 37 |
Sets the type_text of this BankAccount. | def type_text(self, type_text):
self._type_text = type_text | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def account_type(self, account_type):\n\n self._account_type = account_type",
"def account_type(self, account_type):\n\n self._account_type = account_type",
"def account_type(self, account_type):\n\n self._account_type = account_type",
"def account_type(self, account_type):\n\n se... | [
"0.69994986",
"0.69994986",
"0.69994986",
"0.69994986",
"0.67338675",
"0.6733089",
"0.6733089",
"0.6598233",
"0.65434355",
"0.6420724",
"0.63547665",
"0.63243747",
"0.63243747",
"0.63243747",
"0.63243747",
"0.63243747",
"0.63243747",
"0.63243747",
"0.63243747",
"0.63243747",
... | 0.8325671 | 0 |
Sets the bank_id of this BankAccount. | def bank_id(self, bank_id):
self._bank_id = bank_id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def account_bank_id(self, account_bank_id):\n\n self._account_bank_id = account_bank_id",
"def bank_link_id(self, bank_link_id):\n\n self._bank_link_id = bank_link_id",
"def bank_connection_id(self, bank_connection_id):\n if bank_connection_id is None:\n raise ValueError(\"Inval... | [
"0.85761595",
"0.76104563",
"0.7233686",
"0.69656855",
"0.6965274",
"0.6584222",
"0.64605635",
"0.61643994",
"0.61526424",
"0.61526424",
"0.61526424",
"0.61526424",
"0.61526424",
"0.61526424",
"0.5989961",
"0.59329146",
"0.5888447",
"0.58465505",
"0.58465505",
"0.5741217",
"0... | 0.87485594 | 0 |
Sets the bank_name of this BankAccount. | def bank_name(self, bank_name):
self._bank_name = bank_name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def name_bank(self, new_bank_name: str):\n if self.is_bank_name_valid(new_bank_name):\n self.bank_name = new_bank_name\n else:\n raise ValueError(\"Bank name is not valid!\")",
"def bank_id(self, bank_id):\n\n self._bank_id = bank_id",
"def account_bank_id(self, accou... | [
"0.7720608",
"0.69549406",
"0.68231165",
"0.6589278",
"0.6535265",
"0.6535265",
"0.6467967",
"0.62740004",
"0.6060285",
"0.59841347",
"0.5965224",
"0.59646434",
"0.59646434",
"0.59447044",
"0.59406394",
"0.59212345",
"0.59212345",
"0.59212345",
"0.59212345",
"0.59212345",
"0.... | 0.8693754 | 0 |
Sets the name of this BankAccount. | def name(self, name):
self._name = name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def SetName(self, name):\n self.name = name",
"def bank_name(self, bank_name):\n\n self._bank_name = bank_name",
"def set_name(self, name):\n self._name = name",
"def set_name(self, name):\n self.name = name",
"def set_name(self, name):\n self.name = name",
"def set_nam... | [
"0.7643278",
"0.76228815",
"0.7620233",
"0.7609547",
"0.7609547",
"0.7609547",
"0.7609547",
"0.7609547",
"0.75583524",
"0.7482153",
"0.7482153",
"0.7475732",
"0.74252516",
"0.73911494",
"0.73911494",
"0.73849213",
"0.73849213",
"0.73787886",
"0.7317502",
"0.7301202",
"0.72500... | 0.0 | -1 |
Sets the currency_id of this BankAccount. | def currency_id(self, currency_id):
self._currency_id = currency_id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def card_currency(self, card_currency):\n\n self._card_currency = card_currency",
"def currency(self, currency):\n\n self._currency = currency",
"def currency(self, currency):\n\n self._currency = currency",
"def currency(self, currency):\n\n self._currency = currency",
"def cur... | [
"0.6789982",
"0.6657007",
"0.6657007",
"0.6657007",
"0.6657007",
"0.66185945",
"0.6618233",
"0.65618694",
"0.6548402",
"0.6548402",
"0.6548402",
"0.6548402",
"0.6548402",
"0.65144926",
"0.64059883",
"0.6260949",
"0.6260949",
"0.6260949",
"0.6260949",
"0.6260949",
"0.6260949",... | 0.8229745 | 1 |
Sets the currency_code of this BankAccount. | def currency_code(self, currency_code):
self._currency_code = currency_code | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def transaction_currency_code(self, transaction_currency_code):\n\n self._transaction_currency_code = transaction_currency_code",
"def card_currency(self, card_currency):\n\n self._card_currency = card_currency",
"def bank_transaction_code(self, bank_transaction_code):\n\n self._bank_trans... | [
"0.72288096",
"0.6596726",
"0.64978516",
"0.6352416",
"0.6352416",
"0.6352416",
"0.6352416",
"0.63117045",
"0.629458",
"0.61955637",
"0.6184762",
"0.6184762",
"0.6184762",
"0.6183992",
"0.60516715",
"0.60116154",
"0.59786963",
"0.59148085",
"0.5851118",
"0.5722165",
"0.561708... | 0.82565314 | 4 |
Returns true if both objects are equal | def __eq__(self, other):
if not isinstance(other, BankAccount):
return False
return self.__dict__ == other.__dict__ | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self,other):\n try: return self.object==other.object and isinstance(self,type(other))\n except: return False",
"def __eq__(self, other):\n if i... | [
"0.8088132",
"0.8088132",
"0.8054589",
"0.7982687",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
... | 0.0 | -1 |
Returns true if both objects are not equal | def __ne__(self, other):
return not self == other | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __ne__(self, other: object) -> bool:\n if self.__eq__(other):\n return False\n return True",
"def __ne__(self, other: object) -> bool:\n return not self.__eq__(other)",
"def __ne__(self, other) -> bool:\n return not self.__eq__(other)",
"def __eq__(self, other):\n ... | [
"0.845611",
"0.8391477",
"0.8144138",
"0.81410587",
"0.8132492",
"0.8093973",
"0.80920255",
"0.80920255",
"0.80920255",
"0.8085325",
"0.8085325",
"0.8076365",
"0.8076365",
"0.8065748"
] | 0.0 | -1 |
Create a bullet object, at the ship's current position. | def __init__(self, settings, screen, ship):
super().__init__()
self.screen = screen
self.settings = settings
self.ship = ship
# Load the bullet image, and get its rect.
self.image = pygame.image.load('Resources/UI/bullet1.png')
self.rect = self.im... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fire_bullet(ai_settings, screen, ship, bullets):\n new_bullet = Bullet(ai_settings, screen, ship)\n bullets.add(new_bullet)",
"def __init__(self,canvas=0,spritePath=bulletSpritePath,hitboxRadius=bulletHitboxRadius,xPos=0,yPos=0,entityThatCreatedMe=None):\n Entity.__init__(self,canvas,spritePath,... | [
"0.73586845",
"0.7345611",
"0.72411704",
"0.72100544",
"0.71051365",
"0.70906675",
"0.70333636",
"0.7021773",
"0.69993305",
"0.6995749",
"0.6953252",
"0.68985444",
"0.6826661",
"0.6810716",
"0.68016636",
"0.68016636",
"0.6794188",
"0.67631125",
"0.6733617",
"0.67141086",
"0.6... | 0.6809471 | 14 |
Create a bullet object, at the ship's current position. | def __init__(self, settings, screen, pos):
super().__init__()
self.screen = screen
self.settings = settings
# Load the bullet image, and get its rect.
self.image = pygame.image.load('Resources/UI/bullet2.png')
self.rect = self.image.get_rect()
sel... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fire_bullet(ai_settings, screen, ship, bullets):\n new_bullet = Bullet(ai_settings, screen, ship)\n bullets.add(new_bullet)",
"def __init__(self,canvas=0,spritePath=bulletSpritePath,hitboxRadius=bulletHitboxRadius,xPos=0,yPos=0,entityThatCreatedMe=None):\n Entity.__init__(self,canvas,spritePath,... | [
"0.73590076",
"0.73439646",
"0.7240352",
"0.72086555",
"0.71039873",
"0.7090023",
"0.703365",
"0.7021064",
"0.6999259",
"0.6994923",
"0.6952836",
"0.6898781",
"0.68250096",
"0.6809888",
"0.68092275",
"0.6801225",
"0.6801225",
"0.6792556",
"0.6762551",
"0.673309",
"0.67130476"... | 0.6251366 | 33 |
Returns a queryset for all devices of this class that belong to the given user. | def devices_for_user(self, user, confirmed=None):
devices = self.model.objects.filter(user=user)
if confirmed is not None:
devices = devices.filter(confirmed=bool(confirmed))
return devices | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def retrieve_user_devices(self, user_id):\n if self.database is None:\n raise Exception(\"No database.\")\n if user_id is None or len(user_id) == 0:\n raise Exception(\"Bad parameter.\")\n devices = self.database.retrieve_user_devices(user_id)\n if devices is not N... | [
"0.7426704",
"0.70703536",
"0.6745388",
"0.6709743",
"0.6606088",
"0.64538157",
"0.6346481",
"0.6333398",
"0.6319248",
"0.62833875",
"0.6259093",
"0.6248734",
"0.61839086",
"0.61656326",
"0.6078591",
"0.60602796",
"0.605198",
"0.6048005",
"0.60383916",
"0.6034938",
"0.6034938... | 0.75948817 | 0 |
Generates a challenge value that the user will need to produce a token. This method is permitted to have side effects, such as transmitting information to the user through some other channel (email or SMS, perhaps). And, of course, some devices may need to commit the challenge to the database. | def generate_challenge(self):
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_challenge(self):\n totp = self.totp_obj()\n token = format(totp.token(), '06d')\n message = settings.OTP_TWILIO_TOKEN_TEMPLATE.format(token=token)\n\n if settings.OTP_TWILIO_NO_DELIVERY:\n logger.info(message)\n else:\n self._deliver_token(messa... | [
"0.76210827",
"0.7384942",
"0.7228068",
"0.6863153",
"0.6795763",
"0.6706473",
"0.63787925",
"0.61515945",
"0.6132233",
"0.61092913",
"0.6060839",
"0.600915",
"0.6005161",
"0.5988815",
"0.59869313",
"0.5976093",
"0.5961075",
"0.59452605",
"0.5930759",
"0.5905588",
"0.5901082"... | 0.76744676 | 0 |
Returns 'cpu' or 'cuda' based on the device. | def get_device(self) -> str:
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def device() -> str:\n import torch\n\n if torch.cuda.is_available() and torch.cuda.device_count() > 0:\n if hasattr(Config().trainer,\n 'parallelized') and Config().trainer.parallelized:\n device = 'cuda'\n else:\n device = 'c... | [
"0.8067079",
"0.7917954",
"0.78129965",
"0.7779421",
"0.77591217",
"0.7382151",
"0.7312989",
"0.73088163",
"0.73088163",
"0.73088163",
"0.73088163",
"0.716866",
"0.71592695",
"0.71398836",
"0.71277714",
"0.7122792",
"0.7008257",
"0.6983328",
"0.6969115",
"0.69687873",
"0.6919... | 0.64525086 | 39 |
Compute the classifier accuracy trained on the outputs to predict the labels. A single output has a scalar format from the range <0,output_dim), A single label has a scalar format from the range <0,n_classes). | def _compute_classifier_acc(self, outputs: torch.Tensor, labels: torch.Tensor, output_dim: int) -> float:
acc = compute_nn_classifier_accuracy(outputs,
labels,
n_classes=self._num_classes,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def accuracy(outputs, labels):\n predicted = outputs.argmax(dim=1)\n correct = (predicted == labels).sum().item()\n return correct / labels.size(0)",
"def accuracy(outputs, labels):\n\n # reshape labels to give a flat vector of length batch_size*seq_len\n labels = labels.ravel()\n\n # since PAD... | [
"0.81931907",
"0.81465113",
"0.80907303",
"0.80473256",
"0.8045122",
"0.80298996",
"0.80298996",
"0.80142766",
"0.79513043",
"0.78830415",
"0.7639278",
"0.75438124",
"0.7520743",
"0.7491489",
"0.74834496",
"0.74675596",
"0.74417704",
"0.743137",
"0.7400949",
"0.73621196",
"0.... | 0.78595906 | 10 |
Correct Vcmax based on defined by PFTspecific upper and lower temperature params, see Clark et al. (mol CO2 m2 s1) | def correct_vcmax_for_temperature(self, Vcmax25, Tleaf):
num = self.Q10_func(Vcmax25, self.Q10_Vcmax, Tleaf)
den = (1.0 + math.exp(0.3 * (Tleaf - self.Tupper))) * \
(1.0 + math.exp(0.3 * (self.Tlower - Tleaf)))
return num / den | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def v_cmax(self, tl, ared):\n\t return ared*self.VCMAX0*exp(self.HAV/(R*self.TO)*(1. - self.TO/tl))/(1. + exp((self.SVC*tl - self.HDV)/(R*tl)))",
"def compute_vmax(particle, fieldset, time):\n if particle.active == 1:\n particle.vmax = fieldset.vscale*(particle.SCL**fieldset.d)",
"def get_max_cell... | [
"0.72130996",
"0.6881328",
"0.6812122",
"0.67136365",
"0.63841337",
"0.6383194",
"0.62809044",
"0.62629044",
"0.6258925",
"0.6205267",
"0.6161748",
"0.61336195",
"0.61061066",
"0.60839695",
"0.6054992",
"0.6025407",
"0.5984552",
"0.59812474",
"0.59707934",
"0.59521735",
"0.59... | 0.6719963 | 3 |
Returns true if both objects are equal | def __eq__(self, other):
if not isinstance(other, Antenna):
return False
return self.__dict__ == other.__dict__ | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self,other):\n try: return self.object==other.object and isinstance(self,type(other))\n except: return False",
"def __eq__(self, other):\n if i... | [
"0.8088132",
"0.8088132",
"0.8054589",
"0.7982687",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
... | 0.0 | -1 |
Returns true if both objects are not equal | def __ne__(self, other):
return not self == other | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __ne__(self, other: object) -> bool:\n if self.__eq__(other):\n return False\n return True",
"def __ne__(self, other: object) -> bool:\n return not self.__eq__(other)",
"def __ne__(self, other) -> bool:\n return not self.__eq__(other)",
"def __eq__(self, other):\n ... | [
"0.845611",
"0.8391477",
"0.8144138",
"0.81410587",
"0.8132492",
"0.8093973",
"0.80920255",
"0.80920255",
"0.80920255",
"0.8085325",
"0.8085325",
"0.8076365",
"0.8076365",
"0.8065748"
] | 0.0 | -1 |
Get a dictionary of singlequbit randomized benchmarking fidelities (for simultaneous gate operation across the chip, normalized to unity) from the specs, keyed by qubit index. | def f1Q_simultaneous_RBs(self) -> Dict[int, Optional[float]]:
return {qs.id: qs.f1Q_simultaneous_RB for qs in self.qubits_specs} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def T1s(self) -> Dict[int, Optional[float]]:\n return {qs.id: qs.T1 for qs in self.qubits_specs}",
"def f1QRBs(self) -> Dict[int, Optional[float]]:\n return {qs.id: qs.f1QRB for qs in self.qubits_specs}",
"def test_measure_deterministic_multi_qubit_without_sampling(self):\n shots = 100\n ... | [
"0.6405501",
"0.63267994",
"0.586585",
"0.5862669",
"0.5841792",
"0.5782346",
"0.5715171",
"0.5701122",
"0.5598223",
"0.5582311",
"0.5579969",
"0.5570852",
"0.5533324",
"0.550857",
"0.5499589",
"0.54724675",
"0.5440346",
"0.54012805",
"0.53740746",
"0.53307194",
"0.53010356",... | 0.6788763 | 0 |
Recreate the Specs from a dictionary representation. | def from_dict(d: Dict[str, Any]) -> "Specs":
return Specs(
qubits_specs=sorted(
[
QubitSpecs(
id=int(q),
fRO=qspecs.get("fRO"),
f1QRB=qspecs.get("f1QRB"),
f1QRB_std_err... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_dict(self, species_dict):\n try:\n self.label = species_dict['label']\n except KeyError:\n raise InputError('All species must have a label')\n self.run_time = datetime.timedelta(seconds=species_dict['run_time']) if 'run_time' in species_dict else None\n se... | [
"0.61800086",
"0.583812",
"0.58163005",
"0.5778212",
"0.5772694",
"0.57669944",
"0.5706261",
"0.5648898",
"0.56048036",
"0.56007177",
"0.5517956",
"0.5506859",
"0.5460887",
"0.5444614",
"0.54336846",
"0.53778005",
"0.5370809",
"0.5347907",
"0.5347901",
"0.5345304",
"0.5343918... | 0.66261363 | 0 |
initializes the account balance to 0. | def __init__(self):
self.account_balance = 0
self.amount = 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, initial_amount = 0):\n self.balance = initial_amount",
"def __init__(self):\n self.balance = 0",
"def __init__(self, initial_balance):\n self.balance = initial_balance\n self.fees = 0",
"def __init__(self, balance=0):\n self.balance = balance",
"def __i... | [
"0.77155954",
"0.7682677",
"0.7551734",
"0.7323435",
"0.67907226",
"0.6743896",
"0.6743896",
"0.6726501",
"0.6647526",
"0.6644126",
"0.6605843",
"0.65363574",
"0.65005654",
"0.64424235",
"0.64424235",
"0.64424235",
"0.61881495",
"0.61835986",
"0.6150073",
"0.61258584",
"0.606... | 0.7928584 | 0 |
Return the next item from the container. | def __next__(self):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_next_item(self):\n pass",
"def next(self):\n nxt = self.readentry()\n if nxt is None:\n raise StopIteration\n return nxt",
"def get_next_item(self):\n return self.ui.listItemList.model().get_next(self.selected_item)",
"def get_next(self):\n return ... | [
"0.84444296",
"0.7455769",
"0.74323374",
"0.74011606",
"0.74011606",
"0.7369738",
"0.7368069",
"0.7347361",
"0.72823435",
"0.7258089",
"0.7254842",
"0.72465545",
"0.7240386",
"0.72401816",
"0.7239885",
"0.7205326",
"0.717315",
"0.7170962",
"0.71504486",
"0.714327",
"0.714327"... | 0.0 | -1 |
Initializes a Person object. | def __init__(self, name, age):
self.name = name
self.age = age | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, name):\n # Person class has an attribute called name\n self.name = name",
"def test_init_basic(self):\n person = Person(\n self.initial_year, self.name, self.birth_date,\n retirement_date=self.retirement_date)\n self.assertEqual(person.name, se... | [
"0.6878999",
"0.66809994",
"0.64028704",
"0.6365746",
"0.62811184",
"0.62777156",
"0.6240137",
"0.6240034",
"0.6209613",
"0.6209613",
"0.6209613",
"0.6209613",
"0.6209613",
"0.6209613",
"0.6209613",
"0.6209613",
"0.6198115",
"0.6167236",
"0.6134421",
"0.6131545",
"0.61032367"... | 0.57260823 | 45 |
Returns True or False, depending on whether the root user for this instance has been enabled. | def root_user_status(self):
uri = "/instances/%s/root" % self.id
resp, body = self.manager.api.method_get(uri)
return body["rootEnabled"] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def enable_root_user(self, instance):\n return instance.enable_root_user()",
"def has_root():\n return bool(shell32.IsUserAnAdmin())",
"def user_is_root():\n return os.geteuid() == 0",
"def has_root_access(self) -> Optional[pulumi.Input[bool]]:\n return pulumi.get(self, \"has_root_access\... | [
"0.8131893",
"0.8048091",
"0.78824264",
"0.78400505",
"0.77383095",
"0.7678279",
"0.726169",
"0.71904343",
"0.71799356",
"0.7128314",
"0.70309466",
"0.7027943",
"0.69647485",
"0.69645506",
"0.6933054",
"0.68817663",
"0.68744314",
"0.68074656",
"0.6785048",
"0.6769912",
"0.674... | 0.75799143 | 6 |
Changes the size of the volume for this instance. | def resize_volume(self, size):
curr_size = self.volume.size
if size <= curr_size:
raise exc.InvalidVolumeResize("The new volume size must be larger "
"than the current volume size of '%s'." % curr_size)
body = {"volume": {"size": size}}
self.manager.action... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def resize(self, size):\n self.instance.resize_volume(size)\n self.size = size",
"def extend_volume(self, volume, new_size):\n spdk_name = self._get_spdk_volume_name(volume.name)\n params = {'name': spdk_name, 'size': new_size * units.Gi}\n self._rpc_call('bdev_lvol_resize', pa... | [
"0.8288842",
"0.7152017",
"0.7039675",
"0.7015468",
"0.68967843",
"0.6839727",
"0.6839727",
"0.6839727",
"0.6839727",
"0.6727076",
"0.6654916",
"0.664991",
"0.66362894",
"0.6555233",
"0.65343976",
"0.64699996",
"0.64603525",
"0.6446079",
"0.6431379",
"0.6431214",
"0.6424814",... | 0.7768492 | 1 |
Finds the user in the given instance with the specified name, and returns a CloudDatabaseUser object. If no match is found, a NoSuchUser exception is raised. | def get_user(self, instance, name):
return instance.get_user(name) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_user(self, name_or_id, instance, ignore_missing=True):\n instance = self._get_resource(_instance.Instance, instance)\n return self._find(\n _user.User,\n name_or_id,\n instance_id=instance.id,\n ignore_missing=ignore_missing,\n )",
"def ge... | [
"0.79625195",
"0.76373035",
"0.7330081",
"0.72199327",
"0.696431",
"0.68186736",
"0.6743377",
"0.6677676",
"0.66285974",
"0.65689415",
"0.65581423",
"0.65291554",
"0.6513396",
"0.65023434",
"0.6423479",
"0.6390939",
"0.6358115",
"0.6344449",
"0.63274324",
"0.63066614",
"0.629... | 0.73112166 | 3 |
Export Pytorch model to ONNX model and verify the outputs are same between Pytorch and ONNX. | def pytorch2onnx(model,
input_shape,
opset_version=11,
show=False,
output_file='tmp.onnx',
verify=False):
model.cpu().eval()
if isinstance(model.decode_head, nn.ModuleList):
num_classes = model.decode_head[-1].num_clas... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_export_pytorch_model(self):\n pytorch_model = PyTorchLinear()\n dummy_input = torch.empty(10, 10)\n\n with io.BytesIO() as f:\n onnx_converter._export_pytorch_model(f, pytorch_model, dummy_input)",
"def test_from_onnx(self):\n pytorch_model = PyTorchLinear()\n ... | [
"0.8001319",
"0.73981786",
"0.708819",
"0.68216825",
"0.6707142",
"0.66436833",
"0.65463984",
"0.6543401",
"0.64953166",
"0.63451",
"0.62029266",
"0.61725897",
"0.6159554",
"0.6062806",
"0.6057905",
"0.6022507",
"0.6010744",
"0.5993026",
"0.5977195",
"0.59687734",
"0.59529",
... | 0.69549173 | 3 |
Determine if the input value is numeric an int, float, decimal.Decimal, or a string such as '1', '1.23', etc. | def is_number(s: Any) -> bool:
try:
int(s)
return True
except ValueError:
pass
try:
float(s)
return True
except ValueError:
pass
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_numeric(value):\n return isinstance(value, int) or isinstance(value, float)",
"def could_be_number(val):\n if val == None:\n return False\n\n if isinstance(val, (float, int, long)):\n return True\n\n # allow coercion from str\n if isinstance(val, (str, ... | [
"0.8177763",
"0.7902721",
"0.78973424",
"0.78730375",
"0.775293",
"0.7660114",
"0.76314026",
"0.75975525",
"0.7587173",
"0.7545988",
"0.7531515",
"0.7501617",
"0.7480066",
"0.747651",
"0.74657536",
"0.74657536",
"0.74657536",
"0.7454203",
"0.74465585",
"0.74388295",
"0.743373... | 0.781281 | 4 |
Determine if the input string appears to represent a fraction. This does not include mixed numbers such as 1 1/3 | def is_fraction(s: Any) -> bool:
return bool(re.match(r"^-?\d+/\d+$", s)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def frac(num_str, obj_mode=False):\n if obj_mode == False:\n cast_frac = lambda inp: float(Fraction(inp))\n elif obj_mode == True:\n cast_frac = Fraction\n try:\n return cast_frac(num_str)\n except ValueError:\n if num_str == '':\n return cast_frac('0/1')\n ... | [
"0.7073657",
"0.66727126",
"0.65205353",
"0.6499013",
"0.647601",
"0.6416415",
"0.63426524",
"0.6293448",
"0.625244",
"0.6211022",
"0.6205079",
"0.61960167",
"0.61827934",
"0.6156284",
"0.61013836",
"0.60888964",
"0.6086599",
"0.60792184",
"0.6057164",
"0.60564476",
"0.604926... | 0.86758184 | 0 |
Take a quantity string and return a decimal. Handles one hundred, two hundred, three hundred twenty five, 1, 1 1/4, 1 and 1/4, 1.25, .25. Negative values should have the negative sign first, such as 1/4 or 1 1/4 | def quantity_to_decimal(quantity_string: str) -> Decimal:
# get actual fraction-like strings to be N/N with no spaces
quantity_string = quantity_string.strip()
quantity_string = re.sub(r"\b(\d+)\s+/\s+(\d+)\b", r"\1/\2", quantity_string)
if is_number(quantity_string):
return Decimal(quantity_s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_moneyline(string):\n if string.lower() in [\"ev\", \"even\", \"100\", \"+100\"]:\n return 1.0\n elif re.match(\"[+-][0-9]+?\", string):\n line = float(string[1:])\n if string[0] == '+':\n return line/100.0\n else:\n return 100.0/line\n elif re.ma... | [
"0.68759644",
"0.6698485",
"0.6554765",
"0.6272967",
"0.62640774",
"0.6253111",
"0.6222533",
"0.621012",
"0.62048554",
"0.61253256",
"0.6037588",
"0.60268945",
"0.60208285",
"0.5994501",
"0.5990835",
"0.59812343",
"0.5978315",
"0.5955434",
"0.5931994",
"0.59006685",
"0.587125... | 0.765134 | 0 |
Convert strings such as '1/4' to a Decimal | def _fraction_string_to_decimal(fraction: str) -> Decimal:
parts = fraction.split("/")
numerator = int(parts[0])
denominator = int(parts[1])
return Decimal(numerator / denominator) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert(srat):\n try:\n return float(srat)\n except ValueError:\n num, denom = srat.split('/')\n return float(num) / float(denom)",
"def _parseNumber(self, str):\r\n\t\tif (str.count(\".\") == 0):\r\n\t\t\treturn int(str)\r\n\t\tif (str.count(\".\") == 1):\r\n\t\t\treturn float(str... | [
"0.6712094",
"0.65168357",
"0.6514631",
"0.6488972",
"0.6453594",
"0.6352461",
"0.6313063",
"0.6297261",
"0.62813073",
"0.62050706",
"0.6168849",
"0.61630976",
"0.6130576",
"0.61172074",
"0.60611856",
"0.6048418",
"0.6031567",
"0.602669",
"0.60096455",
"0.6000484",
"0.5992137... | 0.71383834 | 0 |
checks whether this Employee object and the supplied other are identical | def equals(self, other):
# using and instead of && to make use of short circuiting
return self.employee_id == other.employee_id and \
self.gender == other.gender and \
self.sales == other.sales and \
self.bmi == other.bmi and \
self.salary ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other) -> bool:\n return self.Firstname == other.Firstname and self.LastName == other.LastName",
"def __eq__(self, other):\n return self.last_name == other.last_name and self.first_name == other.first_name",
"def __eq__(self, other) -> bool:\n return type(self) == type(oth... | [
"0.75566244",
"0.7387581",
"0.72227025",
"0.71725994",
"0.71301",
"0.71117663",
"0.71117663",
"0.71117663",
"0.70770377",
"0.7076466",
"0.7073752",
"0.7070425",
"0.70691836",
"0.7068052",
"0.702942",
"0.7027328",
"0.7017299",
"0.7017299",
"0.7016588",
"0.70160574",
"0.6998108... | 0.74171084 | 1 |
(Restaurant, Restaurant) > bool Return whether this restaurant has the same name and price_range as other. >>> r1 = Restaurant('Dumplings R Us', '$$', ['Chinese', 'Japanese']) >>> r2 = Restaurant('Dumplings R Us', '$$', ['Chinese', 'Japanese']) >>> r3 = Restaurant('Deep Fried Everything', '$', ['Canadian']) >>> r1 == r... | def __eq__(self, other):
return self.name == other.name and self.price_range == other.price_range | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other):\n if self is other:\n return True\n if type(self) == type(other):\n return self._name == other._name and self._calories == other._calories and \\\n self._carbohydrates == other._carbohydrates and self._fat == other._fat\\\n ... | [
"0.6902268",
"0.68999815",
"0.67332125",
"0.65908897",
"0.6482407",
"0.6423603",
"0.64177847",
"0.6410736",
"0.6371539",
"0.6337903",
"0.63209957",
"0.6319568",
"0.63061655",
"0.6294533",
"0.6286708",
"0.627964",
"0.6268629",
"0.6262128",
"0.6258317",
"0.62577486",
"0.6248587... | 0.75323975 | 0 |
Derivative of the demo univariate function. | def df(self, x):
return 2*math.exp(x*2) - math.exp(x) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _derivative_(self, x, diff_param=None):\n return 2*exp(-x**2)/sqrt(pi)",
"def Derivative(self, *args):\n return _Adaptor3d.Adaptor3d_InterFunc_Derivative(self, *args)",
"def deriv(func: Callable[[ndarrray], ndarray],\n input_: ndarray,\n delta: float = 0.001) -> ... | [
"0.7154575",
"0.7047326",
"0.6904753",
"0.6830699",
"0.67763203",
"0.67484254",
"0.6674235",
"0.667172",
"0.6661976",
"0.6639033",
"0.6565484",
"0.6530874",
"0.65278894",
"0.65199006",
"0.65096354",
"0.6505534",
"0.6505534",
"0.64882743",
"0.6472193",
"0.645865",
"0.645865",
... | 0.0 | -1 |
Derivative of the first demo multivariate function with respect to second variable. | def dfdy(self, X):
return (-2)*(X[1]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def secondderivative(func, x, samples):\n \n a = VERYSMALL\n \n fxplus2a = func(x + 2 * a, samples)\n fxplusa = func(x + a, samples)\n fx = func(x, samples)\n \n return (fxplus2a - 2 * fxplusa + fx) / (a ** 2)",
"def test_exp_2ndord_2vars():\n x, y = fwd.Variable(), fwd.Variable()\n f = fwd.exp(x/y... | [
"0.6998013",
"0.6945655",
"0.6819102",
"0.67878294",
"0.6755553",
"0.67505074",
"0.65766984",
"0.65667206",
"0.6565861",
"0.6561191",
"0.65507364",
"0.65169543",
"0.65002924",
"0.6492773",
"0.6470775",
"0.6459247",
"0.6410779",
"0.6396152",
"0.6389956",
"0.6365788",
"0.636432... | 0.5759675 | 88 |
Derivative of the second demo multivariate function with respect to first variable. | def dgdx(self, X):
return 2*(X[0]) - 2 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def secondderivative(func, x, samples):\n \n a = VERYSMALL\n \n fxplus2a = func(x + 2 * a, samples)\n fxplusa = func(x + a, samples)\n fx = func(x, samples)\n \n return (fxplus2a - 2 * fxplusa + fx) / (a ** 2)",
"def test_exp_2ndord_2vars():\n x, y = fwd.Variable(), fwd.Variable()\n f = fwd.exp(x/y... | [
"0.7090587",
"0.70327544",
"0.69019234",
"0.69009197",
"0.6882074",
"0.67597866",
"0.6719899",
"0.6595466",
"0.6590669",
"0.65454537",
"0.654265",
"0.6542233",
"0.6539736",
"0.65253234",
"0.6522854",
"0.64694166",
"0.64640486",
"0.64640486",
"0.64494026",
"0.64303935",
"0.640... | 0.0 | -1 |
Derivative of the second demo multivariate function with respect to second variable. | def dgdy(self, X):
return 3*X[1]**2 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def secondderivative(func, x, samples):\n \n a = VERYSMALL\n \n fxplus2a = func(x + 2 * a, samples)\n fxplusa = func(x + a, samples)\n fx = func(x, samples)\n \n return (fxplus2a - 2 * fxplusa + fx) / (a ** 2)",
"def test_exp_2ndord_2vars():\n x, y = fwd.Variable(), fwd.Variable()\n f = fwd.exp(x/y... | [
"0.7274507",
"0.7165489",
"0.7019225",
"0.6999153",
"0.69980603",
"0.6767395",
"0.6683145",
"0.6642778",
"0.66160053",
"0.6574214",
"0.6564908",
"0.6529273",
"0.6485721",
"0.64846903",
"0.6435201",
"0.64021164",
"0.6373839",
"0.633251",
"0.63178",
"0.63142693",
"0.63135934",
... | 0.6311451 | 21 |
Return a list of ``count``length slices from an integer iterable. | def slices(digits, count):
last = len(digits)-count+1
if count == 0:
raise ValueError('Zero-length slices are not allowed.')
elif last <= 0:
raise ValueError('Slice is longer than the string itself.')
else:
series = []
for start in range(last):
substring ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def slices(numstr, count):\n if count > len(numstr) or not count:\n raise ValueError(\"Slice can't be smaller than input!\")\n return [ map(int, list(numstr[i:i+count]))\n for i in xrange(len(numstr)-count+1) ]",
"def _get_slice(series, start, length):\n return [ int(s) for s in series[start:start+len... | [
"0.67554826",
"0.6530764",
"0.6426799",
"0.64160615",
"0.6366345",
"0.6290533",
"0.62764454",
"0.62764454",
"0.6210647",
"0.6190838",
"0.6190838",
"0.61892176",
"0.6128175",
"0.6124298",
"0.60630196",
"0.60578364",
"0.59810305",
"0.5885153",
"0.5731288",
"0.5730528",
"0.56893... | 0.6313807 | 5 |
Function for calculating the magnitude for the ``filter_name``. | def get_magnitude(
self, model_param: Dict[str, Union[float, List[float]]], synphot=None
) -> Tuple[Tuple[float, None], Tuple[float, None]]:
if "teff" in model_param and isinstance(model_param["teff"], list):
model_param = self.update_parameters(model_param)
spectrum = self.get... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate_magnitude(self, band, system='AB'):\n\n if system not in ('AB', 'Vega'):\n raise ValueError('`system` must be one of `AB` or `Vega`')\n\n f1 = self.calculate_flux(band)\n\n if f1 > 0:\n magnitude = -2.5 * log10(f1 / band.flux[system])\n\n if syste... | [
"0.6284845",
"0.62217325",
"0.59489876",
"0.59429955",
"0.5883451",
"0.5868979",
"0.58666056",
"0.58340514",
"0.5829398",
"0.5826518",
"0.5817128",
"0.5798922",
"0.57729346",
"0.5761314",
"0.5750273",
"0.573597",
"0.57326967",
"0.57184833",
"0.56658536",
"0.5661677",
"0.56269... | 0.5895239 | 4 |
Function for calculating two colors in the range of 10010000 K. | def get_color_color(
temperatures: np.ndarray,
radius: float,
filters_colors: Tuple[Tuple[str, str], Tuple[str, str]],
) -> box.ColorColorBox:
list_color_1 = []
list_color_2 = []
for item in temperatures:
model_param = {"teff": item, "radius": radius, "d... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def color_dist(c1, c2):\n return sum((a - b) ** 2 for a, b in zip(to_ycc(c1), to_ycc(c2)))",
"def calc_color_distance(rgb1, rgb2):\n\n color1_rgb = sRGBColor(rgb1[0], rgb1[1], rgb1[2])\n color2_rgb = sRGBColor(rgb2[0], rgb2[1], rgb2[2])\n\n color1_lab = convert_color(color1_rgb, LabColor)\n color2... | [
"0.68192273",
"0.6789395",
"0.6767154",
"0.67273617",
"0.6499797",
"0.64398926",
"0.64366484",
"0.64298755",
"0.6428867",
"0.6424603",
"0.63442063",
"0.6324817",
"0.63237154",
"0.63202584",
"0.6312862",
"0.6297631",
"0.6290631",
"0.6280015",
"0.6273409",
"0.62622875",
"0.6252... | 0.0 | -1 |
Align and crop a face image by landmarks | def align_crop(img, landmarks, standard_landmarks, crop_size=572, face_factor=0.45, align_type='similarity', order=3,
mode='edge'):
interpolation = {0: cv2.INTER_NEAREST,
1: cv2.INTER_LINEAR,
2: cv2.INTER_AREA,
3: cv2.INTER_CUBIC,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def imalign(src_file, dst_file, face_landmarks, output_size=1024, transform_size=1024, enable_padding=True, x_scale=1, y_scale=1, em_scale=0.1, alpha=False):\n lm = np.array(face_landmarks)\n lm_chin = lm[0 : 17] # left-right\n lm_eyebrow_left = lm[17 : 22] # left-right\n lm_eyebrow_right ... | [
"0.726591",
"0.7229944",
"0.71488667",
"0.66053444",
"0.65924925",
"0.65797514",
"0.64696044",
"0.6375372",
"0.63631606",
"0.63463944",
"0.63150406",
"0.62817866",
"0.6257367",
"0.62543607",
"0.62420964",
"0.6240839",
"0.61946523",
"0.61838573",
"0.61664724",
"0.616206",
"0.6... | 0.7401443 | 0 |
Parse conversion configuration from the provided YAML file. This function parses the conversion configuration contained in the YAML file provided as an argument. It ensures proper serialization of hls4ml objects and should be called on YAML files created by hls4ml. A minimal | def parse_yaml_config(config_file):
def construct_keras_model(loader, node):
from tensorflow.keras.models import load_model
model_str = loader.construct_scalar(node)
return load_model(model_str)
yaml.add_constructor('!keras_model', construct_keras_model, Loader=yaml.SafeLoader)
p... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse(self, config_file):\n\t\tself.options = yaml.load(open(config_file))",
"def get_cfg_from_yaml(self):\n try:\n with open(self.parsed_cfg_path, 'r') as cfg_yaml:\n self.from_yaml_cfg_dict = yaml.load(cfg_yaml)\n except Exception as exc:\n print(exc)\n ... | [
"0.6276491",
"0.6112377",
"0.5986719",
"0.5902252",
"0.5884811",
"0.58618176",
"0.5813338",
"0.56595254",
"0.5630324",
"0.5594361",
"0.55579704",
"0.5538933",
"0.54916924",
"0.5481259",
"0.54735905",
"0.546859",
"0.5458762",
"0.5452728",
"0.5391796",
"0.53752816",
"0.53727406... | 0.5929939 | 3 |
Return the vector of partial derivatives \partial C_x / \partial a for the output activations. y is the actual win/loss. | def cost_derivative(self, output_activations, y):
return (output_activations - y) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cost_derivative(self, output_activations, y):\r\n return (output_activations-y)",
"def cost_derivative(self, output_activations, y):\n return (output_activations-y)",
"def cost_derivative(self, output_activations, y):\n return (output_activations-y)",
"def cost_derivative(self, outpu... | [
"0.68356496",
"0.6744445",
"0.6744445",
"0.6744445",
"0.6744445",
"0.6668455",
"0.6634679",
"0.6509509",
"0.6384005",
"0.61824125",
"0.6129577",
"0.6041654",
"0.6014967",
"0.59947425",
"0.5987453",
"0.59800047",
"0.59151214",
"0.58971643",
"0.58891535",
"0.5853985",
"0.582582... | 0.6753196 | 1 |
Create an operation future from a gapic client. This interacts with the longrunning operations `service`_ (specific to a given API) via a gapic client. | def from_gapic(operation, operations_client, result_type, grpc_metadata=None, **kwargs):
refresh = functools.partial(
operations_client.get_operation, operation.name, metadata=grpc_metadata
)
cancel = functools.partial(
operations_client.cancel_operation, operation.name, metadata=grpc_metada... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_client(self) -> None:\n self._client = gapic.JobServiceClient(\n client_options=dict(api_endpoint=self._region + _UCAIP_ENDPOINT_SUFFIX))",
"def operations_client(self) -> operations_v1.OperationsAsyncClient:\n # Quick check: Only create a new client if we do not already have one.\n ... | [
"0.57153046",
"0.5562876",
"0.5562876",
"0.555662",
"0.55103457",
"0.534156",
"0.5295509",
"0.5292307",
"0.52681047",
"0.52581203",
"0.5254014",
"0.52445525",
"0.52170354",
"0.5177179",
"0.51706386",
"0.5121105",
"0.50933254",
"0.50844055",
"0.5078402",
"0.5067994",
"0.502592... | 0.69012654 | 0 |
load the yaml file to TaskGraph object Arguments | def load_taskgraph(filename):
with open(filename) as f:
yaml = ruamel.yaml.YAML(typ='safe')
yaml.constructor.yaml_constructors[
u'tag:yaml.org,2002:timestamp'] = \
yaml.constructor.yaml_constructors[u'tag:yaml.org,2002:str']
obj = yaml.load(f)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def readGraphFromYAMLFile(self, filename):\n self.G = nx.read_yaml(filename)\n # TODO: buiild up the indexes !!!",
"def load_multiple_yaml_file(self, args):\n sList = []\n for file in args:\n with open (file , \"r\") as stream:\n sList.append(stream.read())\n fString = ''\n ... | [
"0.6445745",
"0.62672144",
"0.61445665",
"0.61214024",
"0.60905254",
"0.59989923",
"0.58965605",
"0.5883612",
"0.58551216",
"0.5852209",
"0.5843519",
"0.58381903",
"0.5826303",
"0.5820304",
"0.57884884",
"0.5767811",
"0.57481486",
"0.56785256",
"0.5675653",
"0.56592107",
"0.5... | 0.6857499 | 0 |
In the constructor we instantiate two nn.Linear modules and assign them as member variables. | def __init__(self,feature,hidden_unit, D_in, D_out):
super(cnn_lstm, self).__init__()
self.model_ft = models.alexnet(pretrained=True)
# print (model_ft)
self.num_ftrs = self.model_ft.classifier[6].in_features
self.feature_model = list(self.model_ft.classifier.children())
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, *args):\n super(LinearND, self).__init__()\n self.fc = nn.Linear(*args)",
"def __init__(self, linear_args, activation_functions, softmax=False):\n super(NN, self).__init__()\n assert len(activation_functions) == len(linear_args) - 1\n k = len(linear_args)\n ... | [
"0.77401125",
"0.75483596",
"0.75074446",
"0.74346",
"0.7366003",
"0.7335429",
"0.73152226",
"0.7286699",
"0.7273464",
"0.72729063",
"0.72729063",
"0.7268201",
"0.72429734",
"0.72211164",
"0.72030157",
"0.7167753",
"0.7111596",
"0.7077496",
"0.7065618",
"0.7063983",
"0.705345... | 0.0 | -1 |
Decay learning rate by a factor of 0.1 every lr_decay_epoch epochs. | def exp_lr_scheduler(optimizer, epoch, init_lr, lr_decay_epoch):
lr = init_lr * (0.1**((epoch-1) // lr_decay_epoch))
if (epoch-1) % lr_decay_epoch == 0:
print('LR is set to {}'.format(lr))
# log_value('lr',lr,epoch)
for param_group in optimizer.param_groups:
param_group['lr'] = lr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def step_decay(epoch):\n # initial_lrate = 1.0 # no longer needed\n #drop = 0.5\n #epochs_drop = number_epoch_drop\n #lrate = init_lr * math.pow(drop,\n #math.floor((1+epoch)/epochs_drop))\n lr = learning_rate\n if epoch >= 60:\n lr *= 1e-1\n print('Learning rate: ', lr)\n return ... | [
"0.8267355",
"0.817801",
"0.7811282",
"0.7761358",
"0.77191705",
"0.7691683",
"0.7691683",
"0.7604844",
"0.7585767",
"0.75532204",
"0.75233716",
"0.74977565",
"0.7488197",
"0.74663943",
"0.7409523",
"0.7392131",
"0.7390558",
"0.7389717",
"0.73854584",
"0.7382199",
"0.7374641"... | 0.0 | -1 |
This function prints and plots the confusion matrix. Normalization can be applied by setting `normalize=True`. | def plot_confusion_matrix(cm, classes,
normalize=False,
title='Confusion matrix',
cmap=plt.cm.Blues):
if normalize:
cm = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis]
print("Normalized confusion matrix")
else:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_confusion_matrix(cm, classes=[0,1], normalize=False, title='Confusion matrix', print_matrix=False):\n\n if normalize:\n cm = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis]\n print(\"Normalized confusion matrix\")\n else:\n print('Confusion matrix, without normalization')\n\n... | [
"0.8194862",
"0.80949175",
"0.8029915",
"0.8019153",
"0.79941195",
"0.7991258",
"0.7980955",
"0.7976606",
"0.79610753",
"0.79590565",
"0.79378676",
"0.7934962",
"0.7934504",
"0.79313844",
"0.7926313",
"0.7924577",
"0.79241234",
"0.7923211",
"0.7923023",
"0.7921931",
"0.791787... | 0.78745896 | 38 |
Returns the max depth (number of edge types) in the batch | def get_max_A_depth(output_list):
A_matrix_size_per_gen = [np.shape(gen[0]) for gen in output_list
if gen is not None]
return max([A_shape[-3] for A_shape in A_matrix_size_per_gen], default=0) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _max_depth(self):\n max_depth = 0\n for node, data in self.traverse():\n max_depth = max(max_depth, data['level'])\n return max_depth",
"def get_max_depth_val():\n data = SUNRGBDTrainDataset(True)\n return max([data[0][i][-1].flatten().item() for i in range(len(data))])"... | [
"0.76936966",
"0.7605427",
"0.7585155",
"0.7497043",
"0.74924105",
"0.74078757",
"0.7355973",
"0.72077584",
"0.7180307",
"0.7129896",
"0.7109606",
"0.70448124",
"0.70025915",
"0.6977709",
"0.6965651",
"0.6960334",
"0.69345546",
"0.69150555",
"0.6885291",
"0.68641394",
"0.6822... | 0.67782664 | 24 |
Splits a sentence into a list of words. | def word_split(self, sentence):
return re.split(self.word_split_pattern, sentence) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def split_into_words(sentences):\n return list(sentences.split(\" \"))",
"def sentence_to_words(sentence: str) -> List[str]:\n return list(map(clean_word, sentence.split(\" \")))",
"def _split_into_words(sentences):\n return list(itertools.chain(*[_.split(\" \") for _ in sentences]))",
"def _split_int... | [
"0.839093",
"0.8328795",
"0.8278341",
"0.8278341",
"0.8247464",
"0.7886386",
"0.7748876",
"0.7702795",
"0.7640652",
"0.7610905",
"0.76034474",
"0.7584799",
"0.74990726",
"0.7388187",
"0.7298104",
"0.7248387",
"0.72372454",
"0.72277707",
"0.7168449",
"0.7161924",
"0.71543217",... | 0.854961 | 0 |
Tries making a sentence of no more than `max_chars` characters and optionally no less than `min_chars` characters, passing kwargs to `self.make_sentence`. | def make_short_sentence(self, max_chars, min_chars=0, **kwargs):
tries = kwargs.get("tries", DEFAULT_TRIES)
for _ in range(tries):
sentence = self.make_sentence(**kwargs)
if sentence and min_chars <= len(sentence) <= max_chars:
return sentence | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shortened_text(self, max_chars=50):\n if len(self.text) > max_chars:\n return self.text[:max_chars] + \"...\"\n else:\n return self.text",
"def sentence_actual(min_words=3, max_words=1000):\r\n for sentence in _Book.gen_random_sentences():\r\n words = _rewhite.sp... | [
"0.6095302",
"0.5819537",
"0.56781554",
"0.5637372",
"0.56108356",
"0.5603103",
"0.5558823",
"0.5543857",
"0.54824555",
"0.5467604",
"0.54280376",
"0.5425181",
"0.54055136",
"0.5369214",
"0.53447944",
"0.53248703",
"0.5298687",
"0.5253001",
"0.52371365",
"0.52371365",
"0.5210... | 0.8437237 | 0 |
Init a Text class based on an existing chain JSON string or object If corpus is None, overlap checking won't work. | def from_chain(cls, chain_json, corpus=None, parsed_sentences=None):
chain = Chain.from_json(chain_json)
return cls(
corpus or None,
parsed_sentences=parsed_sentences,
state_size=chain.state_size,
chain=chain,
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, text: Union[str, Text, None] = None):\n if isinstance(text, str):\n text = TNTParser().parse(text)\n if text is not None:\n self.text = text",
"def __init__(self, txt='', unicodeEncoding='utf-8'):\n # __document capture the document level structure\n ... | [
"0.69495267",
"0.60898894",
"0.6055206",
"0.604253",
"0.60330147",
"0.60256404",
"0.5980836",
"0.5953081",
"0.5942606",
"0.5942606",
"0.5863197",
"0.5858944",
"0.5816861",
"0.5816861",
"0.58047324",
"0.577506",
"0.5771009",
"0.5761173",
"0.5688844",
"0.5678",
"0.56764644",
... | 0.64903337 | 1 |
Reset this optimizer without losing the compiled loss and gradient functions. | def reset(self, tn=None, clear_info=True, loss_target=None):
if tn is not None:
self._set_tn(tn)
if clear_info:
self._reset_tracking_info(loss_target=loss_target) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset():\n\n global optimizer_data\n global optimizer_len\n\n optimizer_data = []\n optimizer_len = 0\n return",
"def reset_grad(self):\n self.optimizer.zero_grad()",
"def reset_grad(self):\n self.g_optimizer.zero_grad()\n self.d_optimizer.zero_grad()\n self.dr_op... | [
"0.7746544",
"0.7668442",
"0.76402324",
"0.76092446",
"0.75474644",
"0.75459784",
"0.75459784",
"0.75459784",
"0.7540876",
"0.75120944",
"0.7140316",
"0.7094543",
"0.7090118",
"0.7073485",
"0.7056893",
"0.7013742",
"0.7009912",
"0.7005744",
"0.6985951",
"0.69115394",
"0.69082... | 0.0 | -1 |
The value of the loss function at vector ``x``. | def vectorized_value(self, x):
self.vectorizer.vector[:] = x
arrays = self.vectorizer.unpack()
self.loss = self.handler.value(arrays).item()
self.losses.append(self.loss)
self._n += 1
self._maybe_update_pbar()
self._check_loss_target()
self._maybe_call_cal... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def loss(self, x):\n return self._svi.evaluate_loss(*x)",
"def loss(self, x, y):\n return x",
"def loss(self, x, s):\n return sum(cp.abs(x + s[self.w] - np.log(self.y)))",
"def get_value(self, x):\n return np.dot(self.w, x)",
"def compute_loss(self, x, label):\n # Forward... | [
"0.8424094",
"0.7410628",
"0.72768956",
"0.72642356",
"0.71729285",
"0.71583694",
"0.69923615",
"0.69820946",
"0.69820946",
"0.6934446",
"0.6931785",
"0.6860803",
"0.6849904",
"0.68063277",
"0.6734244",
"0.67270046",
"0.67184466",
"0.6687467",
"0.66776717",
"0.66444796",
"0.6... | 0.7342532 | 2 |
Converts a das data back into float format. | def from_uint16(traces, scalers):
mask = traces < 1
min_val, max_val = scalers
traces -= 1
traces = traces.astype(float) * max_val / (65535 - 1)
traces += min_val
return traces, mask | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_float_data(d, name):\n data = list(d[name])\n while '' in data:\n data.remove('')\n\n return list(map(float, data))",
"def to_float(data, **kwargs):\n return Component(\n \"ToFloat\",\n arguments={\n 'data': Component.of(data)\n },\n options={\n ... | [
"0.6600073",
"0.6448667",
"0.63835263",
"0.6343803",
"0.6319486",
"0.62636155",
"0.6189612",
"0.61531544",
"0.6141721",
"0.61352986",
"0.6130416",
"0.61013424",
"0.6058522",
"0.6038942",
"0.60367775",
"0.6000969",
"0.59840655",
"0.5979823",
"0.59585637",
"0.5956267",
"0.59328... | 0.0 | -1 |
Decays LR by 10 after 90, 180 and 270 epochs | def adjust_learning_rate(optimizer: torch.optim.SGD, epoch: int, args: Namespace):
lr = args.lr * (0.1 ** (epoch // 90)) * (0.1 ** (epoch // 180)) * (0.1 ** (epoch // 270))
# log to TensorBoard
if args.tensorboard:
log_value('learning_rate', lr, epoch)
for param_group in optimizer.param_groups:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lr_schedule(epoch):\r\n lr = 1e-3\r\n if epoch > 180:\r\n lr *= 0.5e-3\r\n elif epoch > 160:\r\n lr *= 1e-3\r\n elif epoch > 120:\r\n lr *= 1e-2\r\n elif epoch > 80:\r\n lr *= 1e-1\r\n print('Learning rate: ', lr)\r\n return lr",
"def lr_schedule(epoch):\n ... | [
"0.7870507",
"0.7816371",
"0.7816371",
"0.7816371",
"0.7816371",
"0.7736713",
"0.75606304",
"0.75248253",
"0.74722517",
"0.7454768",
"0.7450532",
"0.74315774",
"0.73081434",
"0.72106004",
"0.71888596",
"0.7175406",
"0.7078988",
"0.7072119",
"0.70515317",
"0.70453715",
"0.7044... | 0.0 | -1 |
Computes the precision for the specified values of k | def accuracy(output: torch.Tensor, target: torch.Tensor, topk: tuple = (1,)) -> list[torch.Tensor]:
maxk = max(topk)
batch_size = target.size(0)
_, pred = output.topk(maxk, 1, True, True)
pred = pred.t()
correct = pred.eq(target.view(1, -1).expand_as(pred))
res = []
for k in topk:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def precision(gt, pred, k):\n k = min(len(pred), k)\n den = min(len(gt), k)\n return sum([int(pred[i] in gt) for i in range(k)]) / den",
"def precision_at_k(r, k):\n assert k >= 1\n r = np.asarray(r)[:k] != 0\n if r.size != k:\n raise ValueError('Relevance score length < k')\... | [
"0.76427615",
"0.74189496",
"0.7418079",
"0.72710466",
"0.72456723",
"0.72446615",
"0.7237539",
"0.72213703",
"0.7210107",
"0.7058935",
"0.6852219",
"0.6786084",
"0.67836976",
"0.6768417",
"0.67273885",
"0.67181736",
"0.67181736",
"0.67181736",
"0.67181736",
"0.67181736",
"0.... | 0.0 | -1 |
Returns the last action. | def undo_act(self):
return self.history[self.position] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_last_action(self):\n return self.a_",
"def last_move(self):\n return self.last_action",
"def get_last_action_repeat(self):\n return self._action_list[-1]['repeat']",
"def get_action(self):\n return self.current_action",
"def get_previous_action(self) :\n return self.p... | [
"0.9066298",
"0.806668",
"0.79009575",
"0.76312876",
"0.74450755",
"0.74030536",
"0.73665595",
"0.7341361",
"0.723364",
"0.72315",
"0.7214738",
"0.7170566",
"0.7098485",
"0.70505255",
"0.70479053",
"0.69788265",
"0.69309396",
"0.69309396",
"0.69309396",
"0.69309396",
"0.69309... | 0.0 | -1 |
Returns the next action. | def redo_act(self):
return self.history[self.position + 1] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def action(self):\n next_action = self.strategy.get_next_move(self)\n return next_action",
"def get_next_action(self):\n\n u = self.plan.pop(0)\n return u",
"def get_next_action(self):\n chosen_action = None\n while chosen_action is None:\n choice = input('A... | [
"0.81929576",
"0.81275356",
"0.7947645",
"0.7455102",
"0.720421",
"0.7128966",
"0.7006066",
"0.70024776",
"0.693337",
"0.6893309",
"0.68680626",
"0.6865206",
"0.6849412",
"0.68324244",
"0.67408854",
"0.66489077",
"0.6647903",
"0.6627994",
"0.65668654",
"0.6510381",
"0.6510381... | 0.0 | -1 |
like str.join but for lists, automatically chain list of lists | def interleave(value, items):
if not items:
return
it = iter(items)
looping = False
while True:
try:
head = next(it)
except StopIteration:
break
if looping:
yield value
else:
looping = True
if isinstance(hea... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def join_list(items: Iterable[str]) -> str:\n\n return ITEM_SEPARATOR.join(items)",
"def join_recursive(lst, sep):\n msg = ''\n for i in lst:\n if isinstance(i, tuple) or isinstance(i, list):\n msg += join_recursive(i, sep)\n else:\n msg += (i + sep)\n return msg",... | [
"0.75198615",
"0.74211353",
"0.7389019",
"0.7297125",
"0.7196023",
"0.70937216",
"0.6973663",
"0.69703054",
"0.6932075",
"0.6922636",
"0.6877718",
"0.6778548",
"0.6766702",
"0.6741797",
"0.6733835",
"0.65953445",
"0.6549627",
"0.6549627",
"0.6549627",
"0.6549627",
"0.65237683... | 0.0 | -1 |
Returns the sum of the numbers from 0 to n (inclusive). If n is negative, returns None. | def total(n):
if n < 0:
return None
else:
result = 0
for i in range(n + 1):
result += i
return result | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sum(n):\n if n == 0:\n return 0\n return sum(n - 1) + n",
"def sum_of_nth( n ):\n if n > 0:\n return sum( range(n + 1) )\n else:\n return 0",
"def sum_of_n():\n try:\n input_value = int(input(\"Enter value for n: \"))\n except:\n return None\n \n s... | [
"0.7728651",
"0.7549618",
"0.7298949",
"0.7172998",
"0.7162448",
"0.70967263",
"0.7032798",
"0.6990254",
"0.69229853",
"0.6916972",
"0.6859973",
"0.6836657",
"0.6827941",
"0.68139833",
"0.672767",
"0.6696201",
"0.6694914",
"0.6536323",
"0.65196896",
"0.64874995",
"0.64776725"... | 0.78280175 | 1 |
Returns whether two numbers are prime relative to one another, meaning if the only common factor is "1" between the two numbers, function returns True | def is_relatively_prime(n, m):
result = True
larger = n
if m > n:
larger = m
for i in range(1, larger + 1):
if n % i == 0 and m % i == 0:
if i == 1:
result = True
else:
result = False
return result | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def relPrime(a, b):\n if gcd(a, b) == 1:\n return True\n else:\n return False",
"def coprime(a, b):\n return gcd(a, b) == 1",
"def relPrime (a, b):\n if a%b == 1:\n return True\n elif a%b == 0:\n return False\n else:\n r = a%b\n a = b\n b = r\n... | [
"0.8176672",
"0.75883496",
"0.75319326",
"0.7505304",
"0.72947055",
"0.7263977",
"0.70985687",
"0.70903563",
"0.70804167",
"0.7052747",
"0.6971458",
"0.6967196",
"0.69444907",
"0.6923393",
"0.6917334",
"0.69152874",
"0.6906821",
"0.6893945",
"0.68924296",
"0.6882768",
"0.6873... | 0.6867407 | 22 |
Returns the digit that most commonly occur in given integer | def mode_digit(n):
temp = dict()
result = 0
most = 0
n = abs(n)
while n != 0:
val = n % 10
if val in temp:
temp[val] += 1
else:
temp[val] = 1
n = n // 10
for k, v in temp.items():
if v >= most:
if v == most:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count_largest_group(n):\n group = collections.defaultdict(int)\n largest = 0\n\n for i in range(1, n + 1):\n num = i\n count = 0\n while num >= 10:\n count += num % 10\n num //= 10\n count += num\n group[count] += 1\n largest = max(larges... | [
"0.6303546",
"0.62543774",
"0.6246602",
"0.6242716",
"0.62082636",
"0.6179915",
"0.61003655",
"0.60774714",
"0.6059381",
"0.60159713",
"0.60123885",
"0.5958193",
"0.58911604",
"0.585496",
"0.58540314",
"0.5805185",
"0.574943",
"0.574943",
"0.57484955",
"0.5734084",
"0.5726823... | 0.7287928 | 0 |
generate random msg with varible lenght | def generate_rnd_msg() -> str:
char_num = random.randint(8,20)
i = 0
s = ""
for n in range(char_num):
if i == char_num:
break
rnd_char = random.randint(0, len(string.ascii_lowercase) - 1)
s += string.ascii_lowercase[rnd_char]
i += 1
return s | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def genMsg(self):\n return os.urandom(self.messageSize)",
"def some_payload(size=32, var=0):\n if var:\n size = random.randint(size-var, size+var)\n return ''.join(random.choice(string.ascii_uppercase) for _ in range(size))",
"def message_id(size):\n return os.urandom(size)",
"def get_... | [
"0.78360534",
"0.72770643",
"0.72565335",
"0.71919554",
"0.7153328",
"0.68699247",
"0.6868486",
"0.68300223",
"0.673388",
"0.6704045",
"0.67018807",
"0.6690742",
"0.6675773",
"0.66562545",
"0.6653962",
"0.6625286",
"0.6610047",
"0.65713227",
"0.65683055",
"0.65443546",
"0.654... | 0.7852546 | 0 |
Evaluate the model eagerly on the evaluation dataset. This method will compute the evaluation metrics specified in the configs on the entire evaluation dataset, then return the metrics. It will also log the metrics to TensorBoard. | def eager_eval_loop(
detection_model,
configs,
eval_dataset,
use_tpu=False,
postprocess_on_cpu=False,
global_step=None):
train_config = configs['train_config']
eval_input_config = configs['eval_input_config']
eval_config = configs['eval_config']
add_regularization_loss = train_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def evaluate(self) -> Dict[str, float]:\n eval_dataloader = self.get_eval_dataloader()\n\n output = self._prediction_loop(eval_dataloader, description=\"Evaluation\")\n return output.metrics",
"def evaluate(cfg: DictConfig):\n\n experiments = cfg.get('experiment_type', f'{cfg.model.name}_... | [
"0.7102267",
"0.68620574",
"0.67821705",
"0.67241156",
"0.6696348",
"0.6691182",
"0.6674414",
"0.6674196",
"0.66276413",
"0.6590031",
"0.6588168",
"0.65827966",
"0.6565333",
"0.65477735",
"0.65286255",
"0.6503664",
"0.6494033",
"0.6454866",
"0.6452057",
"0.64466405",
"0.64462... | 0.637657 | 26 |
Deletes a reward with the given reward_id. | def delete(request, reward_id):
# check if the reward_id passed in is invalid and raise a 404 if so.
# reward ids are integers
try:
reward_id = int(str(reward_id))
except ValueError:
raise Http404
account = request.session['account']
store = SESSION.get_store(reques... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def retrieveReward(self, rewardId):\n return self.get_json('/reward/%s' % str(rewardId))",
"def reward(self, history_id, reward):\n pass",
"def award_delete(request, award_id, person_id=None):\n award = get_object_or_404(Award, pk=award_id)\n badge_name = award.badge.name\n award.delete(... | [
"0.6410588",
"0.60932976",
"0.60260445",
"0.5929437",
"0.5707292",
"0.5610597",
"0.5568858",
"0.5547917",
"0.54966253",
"0.54309714",
"0.54212993",
"0.53692997",
"0.53522444",
"0.53504336",
"0.5343851",
"0.5297846",
"0.5279684",
"0.5270955",
"0.52592087",
"0.5185132",
"0.5181... | 0.75750613 | 0 |
Raise an exception if the specified file/s are not functional gifti. | def assertIsFuncGifti(*args):
for fname in args:
assert fname.endswith('.func.gii'), \
'file must be a functional gifti (func.gii): {}'.format(fname) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def assertIsSurfGifti(*args):\n for fname in args:\n assert fname.endswith('.surf.gii'), \\\n 'file must be a surface gifti (surf.gii): {}'.format(fname)",
"def test_invalidFile(self):\n self.assertRaises(cesmEnvLib.checkFile(\"blah\", \"write\"))",
"def file_exception_handler(fpath... | [
"0.6637329",
"0.59407943",
"0.5931642",
"0.58725005",
"0.58255327",
"0.58191395",
"0.5772434",
"0.5720803",
"0.57036084",
"0.57036084",
"0.5702096",
"0.56842667",
"0.5665184",
"0.56519955",
"0.5636446",
"0.5629092",
"0.5616985",
"0.561177",
"0.56089705",
"0.56048226",
"0.5590... | 0.66287357 | 1 |
Return the index of the given letter in an alphabet list. | def letter_to_index(letter):
return ord(letter.lower()) - CHAR_A | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def alphabet_position(letter):\n\n alphabet='abcdefghijklmnopqrstuvwxyz'\n ALPHABET='ABCDEFGHIJKLMNOPQRSTUVWXYZ'\n\n if letter.isupper() == True:\n for x in ALPHABET:\n if letter == x:\n position = ALPHABET.index(x)\n return position\n\n else:\n fo... | [
"0.78031665",
"0.77974206",
"0.76734906",
"0.7583449",
"0.7554691",
"0.7432476",
"0.7423165",
"0.7180686",
"0.7029244",
"0.6769329",
"0.6769329",
"0.6769329",
"0.6688472",
"0.6613892",
"0.6590025",
"0.658861",
"0.65874064",
"0.6517312",
"0.64405686",
"0.63059664",
"0.63059664... | 0.81031424 | 1 |
Print horizontal line in terminal. | def print_horizontal_line(length=None, symbol="="):
if length == None:
try:
_, length = get_terminal_size()
except:
length = 50
print(symbol * length) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def display_hline():\n for i in range(12):\n print(\"-\", end=\"\")\n print()",
"def print_line():\n print('+ - - - - + - - - - +'),",
"def single_line():\n print (\"-------------------------------------------------------------\")",
"def print_dotted_line(width=72):\n print('-' * width)... | [
"0.7489932",
"0.74544644",
"0.68511426",
"0.67388237",
"0.6733194",
"0.66523504",
"0.66264534",
"0.6619123",
"0.6595182",
"0.6454544",
"0.64418423",
"0.64250535",
"0.63298273",
"0.6321937",
"0.628159",
"0.62410754",
"0.61680657",
"0.61606765",
"0.61603504",
"0.6138188",
"0.61... | 0.77199095 | 0 |
Find the cell in open set with the smallest f score. | def node_with_min_fscore(open_set, f_cost): # open_set is a set (of cell) and f_cost is a dict (with cells as keys)
f_cost_open = dict([a for a in f_cost.items() if a[0] in open_set])
return min(f_cost_open, key=f_cost_open.get) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def minimum_f_cell(self):\n return sorted(self.open_cells,key = lambda cell: cell.f)[0]",
"def min_score(self):\n return min(self._extract_set('score') or [0])",
"def find_smallest(self):\n # add max value to covered rows and columns to ignore the covered cells\n maxval = self.C.max... | [
"0.7738727",
"0.67827576",
"0.6618954",
"0.65826356",
"0.6505747",
"0.64693487",
"0.64576846",
"0.64404434",
"0.6421414",
"0.6396712",
"0.6396712",
"0.63525033",
"0.63000214",
"0.6236328",
"0.61933583",
"0.6193137",
"0.6175177",
"0.61705387",
"0.6156253",
"0.6100206",
"0.6081... | 0.7625026 | 2 |
Convenience method that converts None entries of cuts list | def reformat_cuts(input_cuts):
output_cuts = []
for cut in input_cuts:
cut = list(cut)
if cut[1]==None:
cut[1]=float("-inf")
if cut[2]==None:
cut[2]=float("inf")
cut = tuple(cut)
output_cuts.append(cut)
return output_cuts | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_null(values: Iterable) -> list:\n\n return [x\n if x is not None\n else NULL\n for x in values]",
"def strip_null(arg,null=None):\n if null is None:\n null = NULL\n\n if type(arg) is types.ListType:\n return [i for i in arg if i ... | [
"0.6128967",
"0.5996578",
"0.5767134",
"0.5713516",
"0.5708201",
"0.564221",
"0.5564271",
"0.55511147",
"0.5550933",
"0.5540367",
"0.55326724",
"0.5485154",
"0.53882974",
"0.53234714",
"0.53099906",
"0.52810603",
"0.52799094",
"0.5256074",
"0.5252276",
"0.5232365",
"0.5225693... | 0.67457974 | 0 |
Callback for finding task specific learning rate | def __init__(self, min_lr=1e-5, max_lr=1, epochs=1, use_plotly=True):
super().__init__()
self.min_lr = min_lr
self.max_lr = max_lr
self.epochs = epochs
self.use_plotly = use_plotly
self.scheduler = None
self.gamma = 0
self.history = {} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_learning_rate():\n return 0.00001",
"def __call__(self, epoch):\n # Compute the new dynamic learning rate, log in onto TensorBoard and\n # return the result for the training process\n learning_rate = self.schedule(epoch)\n tf.summary.scalar('learning rate', data=learning_ra... | [
"0.6960934",
"0.6843069",
"0.67668796",
"0.663102",
"0.65240175",
"0.6493668",
"0.6484662",
"0.6461858",
"0.64162546",
"0.6374676",
"0.6357389",
"0.63514364",
"0.63490355",
"0.63194525",
"0.62696743",
"0.6234547",
"0.6220066",
"0.6220066",
"0.621396",
"0.6207748",
"0.6203574"... | 0.0 | -1 |
Test listing supplies authenticated as user | def test_listing_supplies_user(self):
request = self.factory.get(
'/api/supplies')
force_authenticate(request, user=self.testuser1)
response = SupplyListView.as_view()(request)
# normal user can browse the data
self.assertEqual(response.status_code, status.HTTP_200_OK... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_request_with_authenticated_user(self):\n self.client.force_authenticate(self.user)\n response = self.client.get(self.list_url)\n self.assertEqual(response.status_code, status.HTTP_200_OK)",
"def test_get_post_list_regular_user(self):\n url = reverse('post-list')\n ... | [
"0.8223138",
"0.8045665",
"0.783253",
"0.76140547",
"0.74250907",
"0.7412044",
"0.7402031",
"0.74005944",
"0.73971736",
"0.73767966",
"0.73697644",
"0.73501337",
"0.734557",
"0.7342337",
"0.7319705",
"0.7296174",
"0.7265814",
"0.72154063",
"0.7189685",
"0.7186148",
"0.7152279... | 0.7787935 | 3 |
Test listing supplies with no authentication | def test_listing_supplies_unauthenticated(self):
request = self.factory.get('/api/supplies')
response = SupplyListView.as_view()(request)
# no permission
self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_list_not_authenticated(self):\n response = self.client.get('/api/products/')\n expected = {'detail': 'Authentication credentials were not provided.'}\n self.assertEqual(response.status_code, 401)\n self.assertEqual(response.json(), expected)",
"def test_list_users_without_aut... | [
"0.78245306",
"0.77175856",
"0.7536064",
"0.73869556",
"0.73555213",
"0.73339677",
"0.73313177",
"0.7249594",
"0.71939224",
"0.7183721",
"0.71835554",
"0.71832544",
"0.7156579",
"0.71267843",
"0.7097886",
"0.7088167",
"0.7057511",
"0.70253474",
"0.70159745",
"0.70142674",
"0.... | 0.7507808 | 3 |
Create a 3D scatter plot. | def scatter3D(data, labels, centers=None, save_path=None):
fig = plt.figure(figsize=(25, 25))
ax = fig.add_subplot(111, projection='3d')
ax.set_proj_type('ortho')
ax.view_init(-22.5, -45)
# Draw points
ax.scatter(
data[:, 0], data[:, 1], data[:, 2],
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_3D_scatter_plot(x, y, z, labels_dict, file_title, plot_title):\n fig = plt.figure()\n ax = fig.add_subplot(projection='3d')\n ax.scatter(x, y, z,\n marker=\".\")\n\n if labels_dict:\n ax.set_xlabel(labels_dict[\"x\"])\n ax.set_ylabel(labels_dict[\"y\"])\n ... | [
"0.7635949",
"0.7585923",
"0.7524859",
"0.7411168",
"0.7389905",
"0.73628044",
"0.73240596",
"0.7289997",
"0.7072961",
"0.69969016",
"0.69541806",
"0.6943289",
"0.693428",
"0.6905351",
"0.6853237",
"0.6839082",
"0.67875725",
"0.6765641",
"0.67195946",
"0.66599864",
"0.6656628... | 0.7004175 | 9 |
Plot a confusion matrix using skplot. | def confusion_matrix(y_true, y_pred):
skplt.plot_confusion_matrix(y_true, y_pred, normalize=True)
plt.show() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_confusion_matrix(self):\r\n interp = ClassificationInterpretation.from_learner(self.learn)\r\n interp.plot_confusion_matrix()",
"def plot_confusion_matrix(name, trained_predictor, X_test, y_test):\n\n fig, ax = plt.subplots()\n fig.tight_layout()\n cm = confusion_matrix(y_test, tr... | [
"0.75599146",
"0.73580045",
"0.7341262",
"0.70718974",
"0.70618755",
"0.7024849",
"0.7010704",
"0.6994628",
"0.6984062",
"0.6974565",
"0.6945511",
"0.6926418",
"0.69062096",
"0.6880006",
"0.68752444",
"0.68589",
"0.6852855",
"0.6848795",
"0.68471",
"0.68376106",
"0.683245",
... | 0.7609457 | 0 |
Retrieves and parses the command line arguments created and defined using the argparse module. This function returns these arguments as an ArgumentParser object. | def get_input_args():
parser = argparse.ArgumentParser()
parser.add_argument("image_path", help= "Path to image", type=str)
parser.add_argument("checkpoint", help= "path to checkpoint", default="checkpoint.pth", type=str)
parser.add_argument("--top_k", help= "top k classes of image", default=5, type... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_arguments():\n\n args = Arguments()\n parser = argparse.ArgumentParser(\"Update river flow directions\")\n parser.add_argument('python_config_filename',\n metavar='python-config-filename',\n help='Full path to python configuration file',\n ... | [
"0.8138782",
"0.79517275",
"0.78769577",
"0.78217745",
"0.779941",
"0.779941",
"0.7774491",
"0.77692086",
"0.7760826",
"0.773166",
"0.7715235",
"0.77124196",
"0.7626294",
"0.7610812",
"0.75815564",
"0.7573426",
"0.7565669",
"0.7555788",
"0.7530112",
"0.7528781",
"0.7527054",
... | 0.0 | -1 |
Computes Hermite's polynom Hn between min and max with N points | def formHn(n,min,max,N):
pas = abs((max-min)/N)
x = min
result = np.array([])
for i in range(0,N):
result = np.append(result,H(n,x))
x += pas
return result | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hn(x, n):\n\n data = x\n for _ in xrange(n):\n data = h(data)\n return data",
"def heptagonal(n: int) -> int:\n return int(n * (5 * n - 3) / 2)",
"def H(n,x):\r\n H_values = [] #a list of sequential H values for different n's up to n=n.\r\n H_values.append(1) #appends H_0.\r\n ... | [
"0.71132356",
"0.69802856",
"0.696812",
"0.6884305",
"0.66561925",
"0.66005677",
"0.63991517",
"0.6263722",
"0.61933285",
"0.6161913",
"0.61318135",
"0.61293066",
"0.59849536",
"0.5968287",
"0.59290284",
"0.59086215",
"0.5907617",
"0.58984476",
"0.5894257",
"0.587678",
"0.584... | 0.77294046 | 0 |
Get the products assiociated with this user shop. | def shop_products(request):
shop = Shop.objects.get(user=request.user)
products = Products.objects.filter(shop_rel=shop)
paginator = pagination.PageNumberPagination()
paginator.page_size = 7
result_page = paginator.paginate_queryset(products, request=request)
serializer = ProductSerializer(resu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def products(self):\n return self._products",
"def products(self):\r\n return self._products",
"def get(self):\n return Products().get_all_products()",
"def products(self):\n return list(Product.select())",
"def list_products(self):\n return self._make_get_request(self._urls[... | [
"0.74293786",
"0.72564685",
"0.722878",
"0.7134896",
"0.71149504",
"0.7064715",
"0.70074445",
"0.69740665",
"0.6860416",
"0.6700805",
"0.67001706",
"0.6693325",
"0.6676763",
"0.6621401",
"0.65877783",
"0.6573072",
"0.65007657",
"0.64683115",
"0.6449971",
"0.64330256",
"0.6373... | 0.6211679 | 28 |
Convert the elapsed time into seconds | def sec(self):
# my clock uses seconds internally
return self.read() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_seconds(time):\n return 3600 * time",
"def to_seconds(self):\r\n return self.hours * 3600 + self.minutes * 60 + self.seconds",
"def elapsed_time_in_seconds(self):\n return self._elapsed_time_in_seconds",
"def t_sec(self):\n return self.t/self.parameters['time_conversion']",
"... | [
"0.771219",
"0.73355097",
"0.7316226",
"0.72687596",
"0.7256337",
"0.71504724",
"0.69973135",
"0.6895417",
"0.6860521",
"0.68201065",
"0.679488",
"0.67580366",
"0.6753473",
"0.6738132",
"0.6708478",
"0.66726875",
"0.66690636",
"0.6630715",
"0.6603114",
"0.66029364",
"0.659722... | 0.6505221 | 31 |
Generate a time stamp | def clock(self):
# use the monotonic system clock to get a time stamp
return time.clock_gettime(time.CLOCK_MONOTONIC) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _generate_timestamp():\n\t\treturn strftime(\"%Y%m%dT%H%M%S\")",
"def _create_time_stamp() -> str:\n\n return datetime.datetime.now().strftime(\"%Y%m%d\")",
"def time_stamper() :\n\treturn datetime.now().strftime(\"%Y-%m-%d-%H-%M-%S\")",
"def createTimeStamp_Time():\r\n\r\n return str(datetime.... | [
"0.84484076",
"0.81545067",
"0.80481887",
"0.8028092",
"0.79324174",
"0.7848481",
"0.77792066",
"0.7749148",
"0.7731803",
"0.7648559",
"0.76471174",
"0.7644689",
"0.76422656",
"0.75678486",
"0.75481355",
"0.74750304",
"0.74682057",
"0.7465322",
"0.7455983",
"0.74463737",
"0.7... | 0.0 | -1 |
Early stopping iterator. Keeps track of the best model state during training. Resets the model to its best state, when either the number of maximum epochs or the patience [number of epochs without improvement) is reached. Also includes a convenient way to reduce the learning rate. Takes as an additional input a PyTorch... | def early_stopping(
model,
objective,
interval=5,
patience=20,
start=0,
max_iter=1000,
maximize=True,
tolerance=1e-5,
switch_mode=True,
restore_best=True,
tracker=None,
scheduler=None,
lr_decay_steps=1,
):
training_status = model.training
def _objective():
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def train_with_early_stopping(self, train_iters, patience, verbose):\n if verbose:\n print('=== training ChebNet model ===')\n optimizer = optim.Adam(self.parameters(), lr=self.lr, weight_decay=self.weight_decay)\n\n labels = self.data.y\n train_mask, val_mask = self.data.tra... | [
"0.70969135",
"0.66711897",
"0.66637784",
"0.66478735",
"0.6583702",
"0.6560357",
"0.6560357",
"0.65172607",
"0.65171415",
"0.6463181",
"0.64101076",
"0.64014256",
"0.6388776",
"0.6334788",
"0.6323229",
"0.63058347",
"0.619649",
"0.6192976",
"0.6174986",
"0.615822",
"0.615527... | 0.6918384 | 1 |
Given multiple iterators, returns a generator that alternatively visit one element from each iterator at a time. | def alternate(*args):
for row in zip(*args):
yield from row | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def imerge_iterators(*iterators):\n \n # [next_value, index, iterator]\n ptr = defaultdict()\n for idx, itr in enumerate(iterators):\n try:\n ptr[idx] = [next(itr), idx, itr]\n except StopIteration:\n pass\n\n # get value function\n get_func = operator.itemgett... | [
"0.75546885",
"0.75123835",
"0.715824",
"0.7122773",
"0.69594467",
"0.67921436",
"0.67729753",
"0.6765857",
"0.6750847",
"0.6750847",
"0.6750847",
"0.6750847",
"0.67386055",
"0.67343456",
"0.67343456",
"0.67274785",
"0.6713396",
"0.66651595",
"0.66651595",
"0.66651595",
"0.66... | 0.6805151 | 5 |
Return an ASCIIonly JSON representation of a Python string | def py_encode_basestring_ascii(s):
if isinstance(s, str) and HAS_UTF8.search(s) is not None:
s = s.decode('utf-8')
def replace(match):
s = match.group(0)
try:
return ESCAPE_DCT[s]
except KeyError:
n = ord(s)
if n < 0x10000:
retu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def string2json(self, string):\n kwargs = {\n 'cls': BytesEncoder, # use the IPython bytes encoder\n 'indent': 1,\n 'sort_keys': True,\n 'separators': (',', ': '),\n }\n return cast_unicode(json.dumps(string, **kwargs), 'utf-8')",
"def convert_to_... | [
"0.8173381",
"0.7761752",
"0.73871756",
"0.7306732",
"0.7114988",
"0.6949071",
"0.6896345",
"0.68929964",
"0.6786643",
"0.67857534",
"0.6751209",
"0.66860336",
"0.66523707",
"0.66367877",
"0.6627448",
"0.66205585",
"0.6590046",
"0.6590046",
"0.6590046",
"0.6590046",
"0.659004... | 0.0 | -1 |
Computes the precision for the specified values of k | def accuracy(output, target, topk=(1,)):
with torch.no_grad():
maxk = max(topk)
batch_size = target.size(0)
_, pred = output.topk(maxk, 1, True, True)
pred = pred.t()
correct = pred.eq(target.view(1, -1).expand_as(pred))
res = []
for k in topk:
c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def precision(gt, pred, k):\n k = min(len(pred), k)\n den = min(len(gt), k)\n return sum([int(pred[i] in gt) for i in range(k)]) / den",
"def precision_at_k(r, k):\n assert k >= 1\n r = np.asarray(r)[:k] != 0\n if r.size != k:\n raise ValueError('Relevance score length < k')\... | [
"0.76427615",
"0.74189496",
"0.7418079",
"0.72710466",
"0.72456723",
"0.72446615",
"0.7237539",
"0.72213703",
"0.7210107",
"0.7058935",
"0.6852219",
"0.6786084",
"0.67836976",
"0.6768417",
"0.67273885",
"0.67181736",
"0.67181736",
"0.67181736",
"0.67181736",
"0.67181736",
"0.... | 0.0 | -1 |
get camera_location (x, y, z) you can write your own version of camera_location function to return the camera loation in the blender world coordinates system | def camera_location(azimuth, elevation, dist):
phi = float(elevation)
theta = float(azimuth)
dist = float(dist)
x = dist * math.cos(phi) * math.cos(theta)
y = dist * math.cos(phi) * math.sin(theta)
z = dist * math.sin(phi)
return x, y, z | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def camera_location(self) -> CameraLocationType:\n return self._location",
"def camera_position(self):\n return CameraPosition(\n scale_point(self.camera, self.camera.position, invert=True),\n scale_point(self.camera, self.camera.focal_point, invert=True),\n self.ca... | [
"0.6978486",
"0.6845743",
"0.65382594",
"0.6482532",
"0.6382791",
"0.6357661",
"0.6334138",
"0.628754",
"0.6276525",
"0.62225354",
"0.622146",
"0.62176895",
"0.61722606",
"0.615152",
"0.60883665",
"0.60853165",
"0.60726494",
"0.6057531",
"0.60207283",
"0.5974146",
"0.59305996... | 0.73757243 | 0 |
Make window with set elements, returns window object | def make_window():
sg.theme('DarkBlack1')
file_list_column = [
[
sg.Text("Select File"),
sg.In(size=(35, 1), key="-FILE-"),
sg.FileBrowse(button_text = 'File',file_types=(('Text Files', '*.txt'),)),
sg.FolderBrowse(button_text ='Folder', target = (ThisRow,... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Window(self, w):\r\n\r\n self.window = w\r\n return self",
"def newwin(self,name,sizeY,sizeX,offsetY,offsetX, border=False):\n\t\tself.windows[name]=Window(sizeY,sizeX,offsetY,offsetX,border)\n\t\treturn self.windows[name]",
"def create_window(session):\n def create_window():\n wind... | [
"0.66863805",
"0.65620005",
"0.6553244",
"0.6481401",
"0.64812434",
"0.6424367",
"0.6331128",
"0.63295686",
"0.6319351",
"0.63108695",
"0.6305862",
"0.6247642",
"0.6223596",
"0.6202475",
"0.619606",
"0.61541015",
"0.61454266",
"0.6143997",
"0.6137831",
"0.6136887",
"0.6086896... | 0.0 | -1 |
Randomly selects four colors color list | def color_picker(self):
num_to_select = 4
peg_color_list = [] #creates the list to store the peg object
#write a for loop to set a loop to select 4 colors from SOLUTION in mm_model
for i in range(num_to_select): #use i just to run the loop, variable is not used elsewhere
# print(i)
color = random.choic... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random_color():\n\n rgbl=[255,0,0]\n random.shuffle(rgbl)\n return tuple(rgbl)",
"def random_color():\n return random.choice(colors)",
"def _random_color(self):\n levels = range(0, 256)\n return tuple(random.choice(levels) for _ in range(3))",
"def random_color_gen():\n r = r... | [
"0.78718174",
"0.7705423",
"0.7641151",
"0.7612031",
"0.760041",
"0.7538865",
"0.75220114",
"0.74447376",
"0.7427404",
"0.74066377",
"0.7360473",
"0.7336653",
"0.72404",
"0.72404",
"0.72404",
"0.72396636",
"0.72254944",
"0.7223335",
"0.72187173",
"0.7195887",
"0.7179196",
"... | 0.0 | -1 |
Compute Median Absolute Deviation of features. | def get_features_mad(self):
mads = {}
for feature_name in self.feature_names:
med = np.median(self.train_data[feature_name].values)
# Compute the deviation from median for each feature value.
dev_from_med = abs(self.train_data[feature_name].values - med)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mad_std(x, axis=None):\r\n return 1.4826 * np.nanmedian(np.abs(x - np.nanmedian(x, axis)), axis)",
"def deviation(xs):\n\ta = avg(xs)\n\treturn sqrt(sum([(x - a) ** 2 for x in xs]) / (len(xs) - 1))",
"def stdDev(data):\r\n sum = 0\r\n ave = average(data)\r\n for i in data:\r\n sum += (i-... | [
"0.71527714",
"0.7113388",
"0.70079046",
"0.70061976",
"0.70061976",
"0.69930345",
"0.69928783",
"0.6978568",
"0.697292",
"0.6843644",
"0.68169683",
"0.68085957",
"0.6792761",
"0.6777352",
"0.6774723",
"0.67431194",
"0.6691886",
"0.6681689",
"0.66740364",
"0.6649821",
"0.6649... | 0.0 | -1 |
Plot boxplot for each feature. | def plot_feature_boxplots(self):
num_features = len(self.feature_names)
fig, ax = plt.subplots(nrows=1, ncols=num_features, figsize=(50, 2), tight_layout=True)
fig.suptitle('Boxplots of 19 features', fontsize=14)
for i in range(num_features):
ax[i].boxplot(self.train_data[s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def boxplot(data):\n sns.boxplot(data, width=0.5, palette=\"colorblind\")\n # add points on the plot\n sns.swarmplot(data, color='red', alpha=0.75)",
"def boxplot_2_features(df, x, y, ylim_i = 0, set_y_limit = False, order_boxplot = False, print_value = False, num_label = 1, save_plot = False, path_dir ... | [
"0.73225975",
"0.72694457",
"0.70212394",
"0.70091724",
"0.6988831",
"0.68876237",
"0.6881457",
"0.6821177",
"0.66874355",
"0.6681656",
"0.66667587",
"0.6620936",
"0.6585161",
"0.6497521",
"0.6493323",
"0.64753103",
"0.64355385",
"0.64240825",
"0.6423418",
"0.6365268",
"0.636... | 0.8290184 | 0 |
Applies a bidirectional GRU to sequence of embeddings x. The input minibatch x needs to be sorted by length. x should have dimensions [batch, time, dim]. | def forward(self, x, mask, lengths):
packed = pack_padded_sequence(x, lengths, batch_first=True)
output, final = self.rnn(packed)
output, _ = pad_packed_sequence(output, batch_first=True)
# output is of size (batch_length, seq_length, num_directions*hidden_size)
# we need to man... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gru_bid_encoder(inputs, sequence_length, hparams, train, name):\n\n with tf.variable_scope(name):\n cell_fw = tf.nn.rnn_cell.MultiRNNCell(\n [_dropout_gru_cell(hparams, train)\n for _ in range(hparams.num_hidden_layers)])\n\n cell_bw = tf.nn.rnn_cell.MultiRNNCell(\n ... | [
"0.5958678",
"0.55314916",
"0.5486782",
"0.53264564",
"0.5306856",
"0.53068465",
"0.53049946",
"0.530387",
"0.5303579",
"0.52948797",
"0.52849853",
"0.5242737",
"0.5242376",
"0.5241319",
"0.5209092",
"0.5202257",
"0.51923174",
"0.51715285",
"0.51625097",
"0.51385784",
"0.5137... | 0.0 | -1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.