repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
django-danceschool/django-danceschool | danceschool/core/models.py | Invoice.allocateFees | def allocateFees(self):
'''
Fees are allocated across invoice items based on their discounted
total price net of adjustments as a proportion of the overall
invoice's total price
'''
items = list(self.invoiceitem_set.all())
# Check that totals and adjusments match... | python | def allocateFees(self):
'''
Fees are allocated across invoice items based on their discounted
total price net of adjustments as a proportion of the overall
invoice's total price
'''
items = list(self.invoiceitem_set.all())
# Check that totals and adjusments match... | [
"def",
"allocateFees",
"(",
"self",
")",
":",
"items",
"=",
"list",
"(",
"self",
".",
"invoiceitem_set",
".",
"all",
"(",
")",
")",
"if",
"self",
".",
"total",
"!=",
"sum",
"(",
"[",
"x",
".",
"total",
"for",
"x",
"in",
"items",
"]",
")",
":",
... | Fees are allocated across invoice items based on their discounted
total price net of adjustments as a proportion of the overall
invoice's total price | [
"Fees",
"are",
"allocated",
"across",
"invoice",
"items",
"based",
"on",
"their",
"discounted",
"total",
"price",
"net",
"of",
"adjustments",
"as",
"a",
"proportion",
"of",
"the",
"overall",
"invoice",
"s",
"total",
"price"
] | bb08cbf39017a812a5a94bdb4ea34170bf1a30ba | https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/models.py#L2865-L2903 | train |
django-danceschool/django-danceschool | danceschool/discounts/models.py | DiscountCombo.applyAndAllocate | def applyAndAllocate(self,allocatedPrices,tieredTuples,payAtDoor=False):
'''
This method takes an initial allocation of prices across events, and
an identical length list of allocation tuples. It applies the rule
specified by this discount, allocates the discount across the listed
... | python | def applyAndAllocate(self,allocatedPrices,tieredTuples,payAtDoor=False):
'''
This method takes an initial allocation of prices across events, and
an identical length list of allocation tuples. It applies the rule
specified by this discount, allocates the discount across the listed
... | [
"def",
"applyAndAllocate",
"(",
"self",
",",
"allocatedPrices",
",",
"tieredTuples",
",",
"payAtDoor",
"=",
"False",
")",
":",
"initial_net_price",
"=",
"sum",
"(",
"[",
"x",
"for",
"x",
"in",
"allocatedPrices",
"]",
")",
"if",
"self",
".",
"discountType",
... | This method takes an initial allocation of prices across events, and
an identical length list of allocation tuples. It applies the rule
specified by this discount, allocates the discount across the listed
items, and returns both the price and the allocation | [
"This",
"method",
"takes",
"an",
"initial",
"allocation",
"of",
"prices",
"across",
"events",
"and",
"an",
"identical",
"length",
"list",
"of",
"allocation",
"tuples",
".",
"It",
"applies",
"the",
"rule",
"specified",
"by",
"this",
"discount",
"allocates",
"th... | bb08cbf39017a812a5a94bdb4ea34170bf1a30ba | https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/discounts/models.py#L146-L201 | train |
django-danceschool/django-danceschool | danceschool/discounts/models.py | DiscountCombo.getComponentList | def getComponentList(self):
'''
This function just returns a list with items that are supposed to
be present in the the list multiple times as multiple elements
of the list. It simplifies checking whether a discount's conditions
are satisfied.
'''
component_list... | python | def getComponentList(self):
'''
This function just returns a list with items that are supposed to
be present in the the list multiple times as multiple elements
of the list. It simplifies checking whether a discount's conditions
are satisfied.
'''
component_list... | [
"def",
"getComponentList",
"(",
"self",
")",
":",
"component_list",
"=",
"[",
"]",
"for",
"x",
"in",
"self",
".",
"discountcombocomponent_set",
".",
"all",
"(",
")",
":",
"for",
"y",
"in",
"range",
"(",
"0",
",",
"x",
".",
"quantity",
")",
":",
"comp... | This function just returns a list with items that are supposed to
be present in the the list multiple times as multiple elements
of the list. It simplifies checking whether a discount's conditions
are satisfied. | [
"This",
"function",
"just",
"returns",
"a",
"list",
"with",
"items",
"that",
"are",
"supposed",
"to",
"be",
"present",
"in",
"the",
"the",
"list",
"multiple",
"times",
"as",
"multiple",
"elements",
"of",
"the",
"list",
".",
"It",
"simplifies",
"checking",
... | bb08cbf39017a812a5a94bdb4ea34170bf1a30ba | https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/discounts/models.py#L215-L230 | train |
django-danceschool/django-danceschool | danceschool/discounts/models.py | DiscountCombo.save | def save(self, *args, **kwargs):
'''
Don't save any passed values related to a type of discount
that is not the specified type
'''
if self.discountType != self.DiscountType.flatPrice:
self.onlinePrice = None
self.doorPrice = None
if self.discount... | python | def save(self, *args, **kwargs):
'''
Don't save any passed values related to a type of discount
that is not the specified type
'''
if self.discountType != self.DiscountType.flatPrice:
self.onlinePrice = None
self.doorPrice = None
if self.discount... | [
"def",
"save",
"(",
"self",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"if",
"self",
".",
"discountType",
"!=",
"self",
".",
"DiscountType",
".",
"flatPrice",
":",
"self",
".",
"onlinePrice",
"=",
"None",
"self",
".",
"doorPrice",
"=",
"None",
... | Don't save any passed values related to a type of discount
that is not the specified type | [
"Don",
"t",
"save",
"any",
"passed",
"values",
"related",
"to",
"a",
"type",
"of",
"discount",
"that",
"is",
"not",
"the",
"specified",
"type"
] | bb08cbf39017a812a5a94bdb4ea34170bf1a30ba | https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/discounts/models.py#L232-L249 | train |
django-danceschool/django-danceschool | danceschool/vouchers/handlers.py | checkVoucherCode | def checkVoucherCode(sender,**kwargs):
'''
Check that the given voucher code is valid
'''
logger.debug('Signal to check RegistrationContactForm handled by vouchers app.')
formData = kwargs.get('formData',{})
request = kwargs.get('request',{})
registration = kwargs.get('registration'... | python | def checkVoucherCode(sender,**kwargs):
'''
Check that the given voucher code is valid
'''
logger.debug('Signal to check RegistrationContactForm handled by vouchers app.')
formData = kwargs.get('formData',{})
request = kwargs.get('request',{})
registration = kwargs.get('registration'... | [
"def",
"checkVoucherCode",
"(",
"sender",
",",
"**",
"kwargs",
")",
":",
"logger",
".",
"debug",
"(",
"'Signal to check RegistrationContactForm handled by vouchers app.'",
")",
"formData",
"=",
"kwargs",
".",
"get",
"(",
"'formData'",
",",
"{",
"}",
")",
"request"... | Check that the given voucher code is valid | [
"Check",
"that",
"the",
"given",
"voucher",
"code",
"is",
"valid"
] | bb08cbf39017a812a5a94bdb4ea34170bf1a30ba | https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/vouchers/handlers.py#L20-L71 | train |
django-danceschool/django-danceschool | danceschool/vouchers/handlers.py | applyVoucherCodeTemporarily | def applyVoucherCodeTemporarily(sender,**kwargs):
'''
When the core registration system creates a temporary registration with a voucher code,
the voucher app looks for vouchers that match that code and creates TemporaryVoucherUse
objects to keep track of the fact that the voucher may be used.
'... | python | def applyVoucherCodeTemporarily(sender,**kwargs):
'''
When the core registration system creates a temporary registration with a voucher code,
the voucher app looks for vouchers that match that code and creates TemporaryVoucherUse
objects to keep track of the fact that the voucher may be used.
'... | [
"def",
"applyVoucherCodeTemporarily",
"(",
"sender",
",",
"**",
"kwargs",
")",
":",
"logger",
".",
"debug",
"(",
"'Signal fired to apply temporary vouchers.'",
")",
"reg",
"=",
"kwargs",
".",
"pop",
"(",
"'registration'",
")",
"voucherId",
"=",
"reg",
".",
"data... | When the core registration system creates a temporary registration with a voucher code,
the voucher app looks for vouchers that match that code and creates TemporaryVoucherUse
objects to keep track of the fact that the voucher may be used. | [
"When",
"the",
"core",
"registration",
"system",
"creates",
"a",
"temporary",
"registration",
"with",
"a",
"voucher",
"code",
"the",
"voucher",
"app",
"looks",
"for",
"vouchers",
"that",
"match",
"that",
"code",
"and",
"creates",
"TemporaryVoucherUse",
"objects",
... | bb08cbf39017a812a5a94bdb4ea34170bf1a30ba | https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/vouchers/handlers.py#L75-L94 | train |
django-danceschool/django-danceschool | danceschool/vouchers/handlers.py | applyReferrerVouchersTemporarily | def applyReferrerVouchersTemporarily(sender,**kwargs):
'''
Unlike voucher codes which have to be manually supplied, referrer discounts are
automatically applied here, assuming that the referral program is enabled.
'''
# Only continue if the referral program is enabled
if not getConstant(... | python | def applyReferrerVouchersTemporarily(sender,**kwargs):
'''
Unlike voucher codes which have to be manually supplied, referrer discounts are
automatically applied here, assuming that the referral program is enabled.
'''
# Only continue if the referral program is enabled
if not getConstant(... | [
"def",
"applyReferrerVouchersTemporarily",
"(",
"sender",
",",
"**",
"kwargs",
")",
":",
"if",
"not",
"getConstant",
"(",
"'referrals__enableReferralProgram'",
")",
":",
"return",
"logger",
".",
"debug",
"(",
"'Signal fired to temporarily apply referrer vouchers.'",
")",
... | Unlike voucher codes which have to be manually supplied, referrer discounts are
automatically applied here, assuming that the referral program is enabled. | [
"Unlike",
"voucher",
"codes",
"which",
"have",
"to",
"be",
"manually",
"supplied",
"referrer",
"discounts",
"are",
"automatically",
"applied",
"here",
"assuming",
"that",
"the",
"referral",
"program",
"is",
"enabled",
"."
] | bb08cbf39017a812a5a94bdb4ea34170bf1a30ba | https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/vouchers/handlers.py#L98-L124 | train |
django-danceschool/django-danceschool | danceschool/vouchers/handlers.py | applyVoucherCodesFinal | def applyVoucherCodesFinal(sender,**kwargs):
'''
Once a registration has been completed, vouchers are used and referrers are awarded
'''
logger.debug('Signal fired to mark voucher codes as applied.')
finalReg = kwargs.pop('registration')
tr = finalReg.temporaryRegistration
tvus = ... | python | def applyVoucherCodesFinal(sender,**kwargs):
'''
Once a registration has been completed, vouchers are used and referrers are awarded
'''
logger.debug('Signal fired to mark voucher codes as applied.')
finalReg = kwargs.pop('registration')
tr = finalReg.temporaryRegistration
tvus = ... | [
"def",
"applyVoucherCodesFinal",
"(",
"sender",
",",
"**",
"kwargs",
")",
":",
"logger",
".",
"debug",
"(",
"'Signal fired to mark voucher codes as applied.'",
")",
"finalReg",
"=",
"kwargs",
".",
"pop",
"(",
"'registration'",
")",
"tr",
"=",
"finalReg",
".",
"t... | Once a registration has been completed, vouchers are used and referrers are awarded | [
"Once",
"a",
"registration",
"has",
"been",
"completed",
"vouchers",
"are",
"used",
"and",
"referrers",
"are",
"awarded"
] | bb08cbf39017a812a5a94bdb4ea34170bf1a30ba | https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/vouchers/handlers.py#L170-L185 | train |
django-danceschool/django-danceschool | danceschool/vouchers/handlers.py | provideCustomerReferralCode | def provideCustomerReferralCode(sender,**kwargs):
'''
If the vouchers app is installed and referrals are enabled, then the customer's profile page can show their voucher referral code.
'''
customer = kwargs.pop('customer')
if getConstant('vouchers__enableVouchers') and getConstant('referrals__e... | python | def provideCustomerReferralCode(sender,**kwargs):
'''
If the vouchers app is installed and referrals are enabled, then the customer's profile page can show their voucher referral code.
'''
customer = kwargs.pop('customer')
if getConstant('vouchers__enableVouchers') and getConstant('referrals__e... | [
"def",
"provideCustomerReferralCode",
"(",
"sender",
",",
"**",
"kwargs",
")",
":",
"customer",
"=",
"kwargs",
".",
"pop",
"(",
"'customer'",
")",
"if",
"getConstant",
"(",
"'vouchers__enableVouchers'",
")",
"and",
"getConstant",
"(",
"'referrals__enableReferralProg... | If the vouchers app is installed and referrals are enabled, then the customer's profile page can show their voucher referral code. | [
"If",
"the",
"vouchers",
"app",
"is",
"installed",
"and",
"referrals",
"are",
"enabled",
"then",
"the",
"customer",
"s",
"profile",
"page",
"can",
"show",
"their",
"voucher",
"referral",
"code",
"."
] | bb08cbf39017a812a5a94bdb4ea34170bf1a30ba | https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/vouchers/handlers.py#L189-L199 | train |
orcasgit/django-fernet-fields | fernet_fields/fields.py | get_prep_lookup | def get_prep_lookup(self):
"""Raise errors for unsupported lookups"""
raise FieldError("{} '{}' does not support lookups".format(
self.lhs.field.__class__.__name__, self.lookup_name)) | python | def get_prep_lookup(self):
"""Raise errors for unsupported lookups"""
raise FieldError("{} '{}' does not support lookups".format(
self.lhs.field.__class__.__name__, self.lookup_name)) | [
"def",
"get_prep_lookup",
"(",
"self",
")",
":",
"raise",
"FieldError",
"(",
"\"{} '{}' does not support lookups\"",
".",
"format",
"(",
"self",
".",
"lhs",
".",
"field",
".",
"__class__",
".",
"__name__",
",",
"self",
".",
"lookup_name",
")",
")"
] | Raise errors for unsupported lookups | [
"Raise",
"errors",
"for",
"unsupported",
"lookups"
] | 888777e5bdb93c72339663e7464f6ceaf4f5e7dd | https://github.com/orcasgit/django-fernet-fields/blob/888777e5bdb93c72339663e7464f6ceaf4f5e7dd/fernet_fields/fields.py#L93-L96 | train |
orcasgit/django-fernet-fields | fernet_fields/hkdf.py | derive_fernet_key | def derive_fernet_key(input_key):
"""Derive a 32-bit b64-encoded Fernet key from arbitrary input key."""
hkdf = HKDF(
algorithm=hashes.SHA256(),
length=32,
salt=salt,
info=info,
backend=backend,
)
return base64.urlsafe_b64encode(hkdf.derive(force_bytes(input_key))... | python | def derive_fernet_key(input_key):
"""Derive a 32-bit b64-encoded Fernet key from arbitrary input key."""
hkdf = HKDF(
algorithm=hashes.SHA256(),
length=32,
salt=salt,
info=info,
backend=backend,
)
return base64.urlsafe_b64encode(hkdf.derive(force_bytes(input_key))... | [
"def",
"derive_fernet_key",
"(",
"input_key",
")",
":",
"hkdf",
"=",
"HKDF",
"(",
"algorithm",
"=",
"hashes",
".",
"SHA256",
"(",
")",
",",
"length",
"=",
"32",
",",
"salt",
"=",
"salt",
",",
"info",
"=",
"info",
",",
"backend",
"=",
"backend",
",",
... | Derive a 32-bit b64-encoded Fernet key from arbitrary input key. | [
"Derive",
"a",
"32",
"-",
"bit",
"b64",
"-",
"encoded",
"Fernet",
"key",
"from",
"arbitrary",
"input",
"key",
"."
] | 888777e5bdb93c72339663e7464f6ceaf4f5e7dd | https://github.com/orcasgit/django-fernet-fields/blob/888777e5bdb93c72339663e7464f6ceaf4f5e7dd/fernet_fields/hkdf.py#L14-L23 | train |
xnd-project/gumath | python/gumath/__init__.py | reduce_cpu | def reduce_cpu(f, x, axes, dtype):
"""NumPy's reduce in terms of fold."""
axes = _get_axes(axes, x.ndim)
if not axes:
return x
permute = [n for n in range(x.ndim) if n not in axes]
permute = axes + permute
T = x.transpose(permute=permute)
N = len(axes)
t = T.type.at(N, dtype=d... | python | def reduce_cpu(f, x, axes, dtype):
"""NumPy's reduce in terms of fold."""
axes = _get_axes(axes, x.ndim)
if not axes:
return x
permute = [n for n in range(x.ndim) if n not in axes]
permute = axes + permute
T = x.transpose(permute=permute)
N = len(axes)
t = T.type.at(N, dtype=d... | [
"def",
"reduce_cpu",
"(",
"f",
",",
"x",
",",
"axes",
",",
"dtype",
")",
":",
"axes",
"=",
"_get_axes",
"(",
"axes",
",",
"x",
".",
"ndim",
")",
"if",
"not",
"axes",
":",
"return",
"x",
"permute",
"=",
"[",
"n",
"for",
"n",
"in",
"range",
"(",
... | NumPy's reduce in terms of fold. | [
"NumPy",
"s",
"reduce",
"in",
"terms",
"of",
"fold",
"."
] | a20ed5621db566ef805b8fb27ba4d8487f48c6b5 | https://github.com/xnd-project/gumath/blob/a20ed5621db566ef805b8fb27ba4d8487f48c6b5/python/gumath/__init__.py#L93-L118 | train |
xnd-project/gumath | python/gumath/__init__.py | reduce_cuda | def reduce_cuda(g, x, axes, dtype):
"""Reductions in CUDA use the thrust library for speed and have limited
functionality."""
if axes != 0:
raise NotImplementedError("'axes' keyword is not implemented for CUDA")
return g(x, dtype=dtype) | python | def reduce_cuda(g, x, axes, dtype):
"""Reductions in CUDA use the thrust library for speed and have limited
functionality."""
if axes != 0:
raise NotImplementedError("'axes' keyword is not implemented for CUDA")
return g(x, dtype=dtype) | [
"def",
"reduce_cuda",
"(",
"g",
",",
"x",
",",
"axes",
",",
"dtype",
")",
":",
"if",
"axes",
"!=",
"0",
":",
"raise",
"NotImplementedError",
"(",
"\"'axes' keyword is not implemented for CUDA\"",
")",
"return",
"g",
"(",
"x",
",",
"dtype",
"=",
"dtype",
")... | Reductions in CUDA use the thrust library for speed and have limited
functionality. | [
"Reductions",
"in",
"CUDA",
"use",
"the",
"thrust",
"library",
"for",
"speed",
"and",
"have",
"limited",
"functionality",
"."
] | a20ed5621db566ef805b8fb27ba4d8487f48c6b5 | https://github.com/xnd-project/gumath/blob/a20ed5621db566ef805b8fb27ba4d8487f48c6b5/python/gumath/__init__.py#L120-L126 | train |
xnd-project/gumath | python/gumath_aux.py | maxlevel | def maxlevel(lst):
"""Return maximum nesting depth"""
maxlev = 0
def f(lst, level):
nonlocal maxlev
if isinstance(lst, list):
level += 1
maxlev = max(level, maxlev)
for item in lst:
f(item, level)
f(lst, 0)
return maxlev | python | def maxlevel(lst):
"""Return maximum nesting depth"""
maxlev = 0
def f(lst, level):
nonlocal maxlev
if isinstance(lst, list):
level += 1
maxlev = max(level, maxlev)
for item in lst:
f(item, level)
f(lst, 0)
return maxlev | [
"def",
"maxlevel",
"(",
"lst",
")",
":",
"maxlev",
"=",
"0",
"def",
"f",
"(",
"lst",
",",
"level",
")",
":",
"nonlocal",
"maxlev",
"if",
"isinstance",
"(",
"lst",
",",
"list",
")",
":",
"level",
"+=",
"1",
"maxlev",
"=",
"max",
"(",
"level",
",",... | Return maximum nesting depth | [
"Return",
"maximum",
"nesting",
"depth"
] | a20ed5621db566ef805b8fb27ba4d8487f48c6b5 | https://github.com/xnd-project/gumath/blob/a20ed5621db566ef805b8fb27ba4d8487f48c6b5/python/gumath_aux.py#L101-L112 | train |
xnd-project/gumath | python/gumath_aux.py | getitem | def getitem(lst, indices):
"""Definition for multidimensional slicing and indexing on arbitrarily
shaped nested lists.
"""
if not indices:
return lst
i, indices = indices[0], indices[1:]
item = list.__getitem__(lst, i)
if isinstance(i, int):
return getitem(item, indices)... | python | def getitem(lst, indices):
"""Definition for multidimensional slicing and indexing on arbitrarily
shaped nested lists.
"""
if not indices:
return lst
i, indices = indices[0], indices[1:]
item = list.__getitem__(lst, i)
if isinstance(i, int):
return getitem(item, indices)... | [
"def",
"getitem",
"(",
"lst",
",",
"indices",
")",
":",
"if",
"not",
"indices",
":",
"return",
"lst",
"i",
",",
"indices",
"=",
"indices",
"[",
"0",
"]",
",",
"indices",
"[",
"1",
":",
"]",
"item",
"=",
"list",
".",
"__getitem__",
"(",
"lst",
","... | Definition for multidimensional slicing and indexing on arbitrarily
shaped nested lists. | [
"Definition",
"for",
"multidimensional",
"slicing",
"and",
"indexing",
"on",
"arbitrarily",
"shaped",
"nested",
"lists",
"."
] | a20ed5621db566ef805b8fb27ba4d8487f48c6b5 | https://github.com/xnd-project/gumath/blob/a20ed5621db566ef805b8fb27ba4d8487f48c6b5/python/gumath_aux.py#L114-L136 | train |
xnd-project/gumath | python/gumath_aux.py | genslices | def genslices(n):
"""Generate all possible slices for a single dimension."""
def range_with_none():
yield None
yield from range(-n, n+1)
for t in product(range_with_none(), range_with_none(), range_with_none()):
s = slice(*t)
if s.step != 0:
yield s | python | def genslices(n):
"""Generate all possible slices for a single dimension."""
def range_with_none():
yield None
yield from range(-n, n+1)
for t in product(range_with_none(), range_with_none(), range_with_none()):
s = slice(*t)
if s.step != 0:
yield s | [
"def",
"genslices",
"(",
"n",
")",
":",
"def",
"range_with_none",
"(",
")",
":",
"yield",
"None",
"yield",
"from",
"range",
"(",
"-",
"n",
",",
"n",
"+",
"1",
")",
"for",
"t",
"in",
"product",
"(",
"range_with_none",
"(",
")",
",",
"range_with_none",... | Generate all possible slices for a single dimension. | [
"Generate",
"all",
"possible",
"slices",
"for",
"a",
"single",
"dimension",
"."
] | a20ed5621db566ef805b8fb27ba4d8487f48c6b5 | https://github.com/xnd-project/gumath/blob/a20ed5621db566ef805b8fb27ba4d8487f48c6b5/python/gumath_aux.py#L276-L285 | train |
xnd-project/gumath | python/gumath_aux.py | genslices_ndim | def genslices_ndim(ndim, shape):
"""Generate all possible slice tuples for 'shape'."""
iterables = [genslices(shape[n]) for n in range(ndim)]
yield from product(*iterables) | python | def genslices_ndim(ndim, shape):
"""Generate all possible slice tuples for 'shape'."""
iterables = [genslices(shape[n]) for n in range(ndim)]
yield from product(*iterables) | [
"def",
"genslices_ndim",
"(",
"ndim",
",",
"shape",
")",
":",
"iterables",
"=",
"[",
"genslices",
"(",
"shape",
"[",
"n",
"]",
")",
"for",
"n",
"in",
"range",
"(",
"ndim",
")",
"]",
"yield",
"from",
"product",
"(",
"*",
"iterables",
")"
] | Generate all possible slice tuples for 'shape'. | [
"Generate",
"all",
"possible",
"slice",
"tuples",
"for",
"shape",
"."
] | a20ed5621db566ef805b8fb27ba4d8487f48c6b5 | https://github.com/xnd-project/gumath/blob/a20ed5621db566ef805b8fb27ba4d8487f48c6b5/python/gumath_aux.py#L287-L290 | train |
aarongarrett/inspyred | inspyred/ec/variators/mutators.py | mutator | def mutator(mutate):
"""Return an inspyred mutator function based on the given function.
This function generator takes a function that operates on only
one candidate to produce a single mutated candidate. The generator
handles the iteration over each candidate in the set to be mutated.
The gi... | python | def mutator(mutate):
"""Return an inspyred mutator function based on the given function.
This function generator takes a function that operates on only
one candidate to produce a single mutated candidate. The generator
handles the iteration over each candidate in the set to be mutated.
The gi... | [
"def",
"mutator",
"(",
"mutate",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"mutate",
")",
"def",
"inspyred_mutator",
"(",
"random",
",",
"candidates",
",",
"args",
")",
":",
"mutants",
"=",
"[",
"]",
"for",
"i",
",",
"cs",
"in",
"enumerate",
"("... | Return an inspyred mutator function based on the given function.
This function generator takes a function that operates on only
one candidate to produce a single mutated candidate. The generator
handles the iteration over each candidate in the set to be mutated.
The given function ``mutate`` must... | [
"Return",
"an",
"inspyred",
"mutator",
"function",
"based",
"on",
"the",
"given",
"function",
".",
"This",
"function",
"generator",
"takes",
"a",
"function",
"that",
"operates",
"on",
"only",
"one",
"candidate",
"to",
"produce",
"a",
"single",
"mutated",
"cand... | d5976ab503cc9d51c6f586cbb7bb601a38c01128 | https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/ec/variators/mutators.py#L33-L65 | train |
aarongarrett/inspyred | inspyred/ec/variators/mutators.py | bit_flip_mutation | def bit_flip_mutation(random, candidate, args):
"""Return the mutants produced by bit-flip mutation on the candidates.
This function performs bit-flip mutation. If a candidate solution contains
non-binary values, this function leaves it unchanged.
.. Arguments:
random -- the random number gener... | python | def bit_flip_mutation(random, candidate, args):
"""Return the mutants produced by bit-flip mutation on the candidates.
This function performs bit-flip mutation. If a candidate solution contains
non-binary values, this function leaves it unchanged.
.. Arguments:
random -- the random number gener... | [
"def",
"bit_flip_mutation",
"(",
"random",
",",
"candidate",
",",
"args",
")",
":",
"rate",
"=",
"args",
".",
"setdefault",
"(",
"'mutation_rate'",
",",
"0.1",
")",
"mutant",
"=",
"copy",
".",
"copy",
"(",
"candidate",
")",
"if",
"len",
"(",
"mutant",
... | Return the mutants produced by bit-flip mutation on the candidates.
This function performs bit-flip mutation. If a candidate solution contains
non-binary values, this function leaves it unchanged.
.. Arguments:
random -- the random number generator object
candidate -- the candidate solution
... | [
"Return",
"the",
"mutants",
"produced",
"by",
"bit",
"-",
"flip",
"mutation",
"on",
"the",
"candidates",
"."
] | d5976ab503cc9d51c6f586cbb7bb601a38c01128 | https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/ec/variators/mutators.py#L69-L93 | train |
aarongarrett/inspyred | inspyred/ec/variators/mutators.py | random_reset_mutation | def random_reset_mutation(random, candidate, args):
"""Return the mutants produced by randomly choosing new values.
This function performs random-reset mutation. It assumes that
candidate solutions are composed of discrete values. This function
makes use of the bounder function as specified in the EC'... | python | def random_reset_mutation(random, candidate, args):
"""Return the mutants produced by randomly choosing new values.
This function performs random-reset mutation. It assumes that
candidate solutions are composed of discrete values. This function
makes use of the bounder function as specified in the EC'... | [
"def",
"random_reset_mutation",
"(",
"random",
",",
"candidate",
",",
"args",
")",
":",
"bounder",
"=",
"args",
"[",
"'_ec'",
"]",
".",
"bounder",
"try",
":",
"values",
"=",
"bounder",
".",
"values",
"except",
"AttributeError",
":",
"values",
"=",
"None",
... | Return the mutants produced by randomly choosing new values.
This function performs random-reset mutation. It assumes that
candidate solutions are composed of discrete values. This function
makes use of the bounder function as specified in the EC's
``evolve`` method, and it assumes that the bounder c... | [
"Return",
"the",
"mutants",
"produced",
"by",
"randomly",
"choosing",
"new",
"values",
"."
] | d5976ab503cc9d51c6f586cbb7bb601a38c01128 | https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/ec/variators/mutators.py#L97-L137 | train |
aarongarrett/inspyred | inspyred/ec/variators/mutators.py | scramble_mutation | def scramble_mutation(random, candidate, args):
"""Return the mutants created by scramble mutation on the candidates.
This function performs scramble mutation. It randomly chooses two
locations along the candidate and scrambles the values within that
slice.
.. Arguments:
random -- the rand... | python | def scramble_mutation(random, candidate, args):
"""Return the mutants created by scramble mutation on the candidates.
This function performs scramble mutation. It randomly chooses two
locations along the candidate and scrambles the values within that
slice.
.. Arguments:
random -- the rand... | [
"def",
"scramble_mutation",
"(",
"random",
",",
"candidate",
",",
"args",
")",
":",
"rate",
"=",
"args",
".",
"setdefault",
"(",
"'mutation_rate'",
",",
"0.1",
")",
"if",
"random",
".",
"random",
"(",
")",
"<",
"rate",
":",
"size",
"=",
"len",
"(",
"... | Return the mutants created by scramble mutation on the candidates.
This function performs scramble mutation. It randomly chooses two
locations along the candidate and scrambles the values within that
slice.
.. Arguments:
random -- the random number generator object
candidate -- the cand... | [
"Return",
"the",
"mutants",
"created",
"by",
"scramble",
"mutation",
"on",
"the",
"candidates",
"."
] | d5976ab503cc9d51c6f586cbb7bb601a38c01128 | https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/ec/variators/mutators.py#L141-L171 | train |
aarongarrett/inspyred | inspyred/ec/variators/mutators.py | gaussian_mutation | def gaussian_mutation(random, candidate, args):
"""Return the mutants created by Gaussian mutation on the candidates.
This function performs Gaussian mutation. This function
makes use of the bounder function as specified in the EC's
``evolve`` method.
.. Arguments:
random -- the random n... | python | def gaussian_mutation(random, candidate, args):
"""Return the mutants created by Gaussian mutation on the candidates.
This function performs Gaussian mutation. This function
makes use of the bounder function as specified in the EC's
``evolve`` method.
.. Arguments:
random -- the random n... | [
"def",
"gaussian_mutation",
"(",
"random",
",",
"candidate",
",",
"args",
")",
":",
"mut_rate",
"=",
"args",
".",
"setdefault",
"(",
"'mutation_rate'",
",",
"0.1",
")",
"mean",
"=",
"args",
".",
"setdefault",
"(",
"'gaussian_mean'",
",",
"0.0",
")",
"stdev... | Return the mutants created by Gaussian mutation on the candidates.
This function performs Gaussian mutation. This function
makes use of the bounder function as specified in the EC's
``evolve`` method.
.. Arguments:
random -- the random number generator object
candidate -- the candidat... | [
"Return",
"the",
"mutants",
"created",
"by",
"Gaussian",
"mutation",
"on",
"the",
"candidates",
"."
] | d5976ab503cc9d51c6f586cbb7bb601a38c01128 | https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/ec/variators/mutators.py#L208-L239 | train |
aarongarrett/inspyred | inspyred/ec/variators/mutators.py | nonuniform_mutation | def nonuniform_mutation(random, candidate, args):
"""Return the mutants produced by nonuniform mutation on the candidates.
The function performs nonuniform mutation as specified in
(Michalewicz, "Genetic Algorithms + Data Structures = Evolution
Programs," Springer, 1996). This function also makes use o... | python | def nonuniform_mutation(random, candidate, args):
"""Return the mutants produced by nonuniform mutation on the candidates.
The function performs nonuniform mutation as specified in
(Michalewicz, "Genetic Algorithms + Data Structures = Evolution
Programs," Springer, 1996). This function also makes use o... | [
"def",
"nonuniform_mutation",
"(",
"random",
",",
"candidate",
",",
"args",
")",
":",
"bounder",
"=",
"args",
"[",
"'_ec'",
"]",
".",
"bounder",
"num_gens",
"=",
"args",
"[",
"'_ec'",
"]",
".",
"num_generations",
"max_gens",
"=",
"args",
"[",
"'max_generat... | Return the mutants produced by nonuniform mutation on the candidates.
The function performs nonuniform mutation as specified in
(Michalewicz, "Genetic Algorithms + Data Structures = Evolution
Programs," Springer, 1996). This function also makes use of the
bounder function as specified in the EC's ``ev... | [
"Return",
"the",
"mutants",
"produced",
"by",
"nonuniform",
"mutation",
"on",
"the",
"candidates",
"."
] | d5976ab503cc9d51c6f586cbb7bb601a38c01128 | https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/ec/variators/mutators.py#L243-L285 | train |
aarongarrett/inspyred | inspyred/ec/variators/crossovers.py | crossover | def crossover(cross):
"""Return an inspyred crossover function based on the given function.
This function generator takes a function that operates on only
two parent candidates to produce an iterable sequence of offspring
(typically two). The generator handles the pairing of selected
parents and co... | python | def crossover(cross):
"""Return an inspyred crossover function based on the given function.
This function generator takes a function that operates on only
two parent candidates to produce an iterable sequence of offspring
(typically two). The generator handles the pairing of selected
parents and co... | [
"def",
"crossover",
"(",
"cross",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"cross",
")",
"def",
"inspyred_crossover",
"(",
"random",
",",
"candidates",
",",
"args",
")",
":",
"if",
"len",
"(",
"candidates",
")",
"%",
"2",
"==",
"1",
":",
"candi... | Return an inspyred crossover function based on the given function.
This function generator takes a function that operates on only
two parent candidates to produce an iterable sequence of offspring
(typically two). The generator handles the pairing of selected
parents and collecting of all offspring.
... | [
"Return",
"an",
"inspyred",
"crossover",
"function",
"based",
"on",
"the",
"given",
"function",
"."
] | d5976ab503cc9d51c6f586cbb7bb601a38c01128 | https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/ec/variators/crossovers.py#L38-L83 | train |
aarongarrett/inspyred | inspyred/ec/variators/crossovers.py | n_point_crossover | def n_point_crossover(random, mom, dad, args):
"""Return the offspring of n-point crossover on the candidates.
This function performs n-point crossover (NPX). It selects *n*
random points without replacement at which to 'cut' the candidate
solutions and recombine them.
.. Arguments:
rando... | python | def n_point_crossover(random, mom, dad, args):
"""Return the offspring of n-point crossover on the candidates.
This function performs n-point crossover (NPX). It selects *n*
random points without replacement at which to 'cut' the candidate
solutions and recombine them.
.. Arguments:
rando... | [
"def",
"n_point_crossover",
"(",
"random",
",",
"mom",
",",
"dad",
",",
"args",
")",
":",
"crossover_rate",
"=",
"args",
".",
"setdefault",
"(",
"'crossover_rate'",
",",
"1.0",
")",
"num_crossover_points",
"=",
"args",
".",
"setdefault",
"(",
"'num_crossover_p... | Return the offspring of n-point crossover on the candidates.
This function performs n-point crossover (NPX). It selects *n*
random points without replacement at which to 'cut' the candidate
solutions and recombine them.
.. Arguments:
random -- the random number generator object
mom -- ... | [
"Return",
"the",
"offspring",
"of",
"n",
"-",
"point",
"crossover",
"on",
"the",
"candidates",
"."
] | d5976ab503cc9d51c6f586cbb7bb601a38c01128 | https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/ec/variators/crossovers.py#L87-L129 | train |
aarongarrett/inspyred | inspyred/ec/variators/crossovers.py | uniform_crossover | def uniform_crossover(random, mom, dad, args):
"""Return the offspring of uniform crossover on the candidates.
This function performs uniform crossover (UX). For each element
of the parents, a biased coin is flipped to determine whether
the first offspring gets the 'mom' or the 'dad' element. An
... | python | def uniform_crossover(random, mom, dad, args):
"""Return the offspring of uniform crossover on the candidates.
This function performs uniform crossover (UX). For each element
of the parents, a biased coin is flipped to determine whether
the first offspring gets the 'mom' or the 'dad' element. An
... | [
"def",
"uniform_crossover",
"(",
"random",
",",
"mom",
",",
"dad",
",",
"args",
")",
":",
"ux_bias",
"=",
"args",
".",
"setdefault",
"(",
"'ux_bias'",
",",
"0.5",
")",
"crossover_rate",
"=",
"args",
".",
"setdefault",
"(",
"'crossover_rate'",
",",
"1.0",
... | Return the offspring of uniform crossover on the candidates.
This function performs uniform crossover (UX). For each element
of the parents, a biased coin is flipped to determine whether
the first offspring gets the 'mom' or the 'dad' element. An
optional keyword argument in args, ``ux_bias``, deter... | [
"Return",
"the",
"offspring",
"of",
"uniform",
"crossover",
"on",
"the",
"candidates",
"."
] | d5976ab503cc9d51c6f586cbb7bb601a38c01128 | https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/ec/variators/crossovers.py#L133-L170 | train |
aarongarrett/inspyred | inspyred/ec/variators/crossovers.py | partially_matched_crossover | def partially_matched_crossover(random, mom, dad, args):
"""Return the offspring of partially matched crossover on the candidates.
This function performs partially matched crossover (PMX). This type of
crossover assumes that candidates are composed of discrete values that
are permutations of a given se... | python | def partially_matched_crossover(random, mom, dad, args):
"""Return the offspring of partially matched crossover on the candidates.
This function performs partially matched crossover (PMX). This type of
crossover assumes that candidates are composed of discrete values that
are permutations of a given se... | [
"def",
"partially_matched_crossover",
"(",
"random",
",",
"mom",
",",
"dad",
",",
"args",
")",
":",
"crossover_rate",
"=",
"args",
".",
"setdefault",
"(",
"'crossover_rate'",
",",
"1.0",
")",
"if",
"random",
".",
"random",
"(",
")",
"<",
"crossover_rate",
... | Return the offspring of partially matched crossover on the candidates.
This function performs partially matched crossover (PMX). This type of
crossover assumes that candidates are composed of discrete values that
are permutations of a given set (typically integers). It produces offspring
that are thems... | [
"Return",
"the",
"offspring",
"of",
"partially",
"matched",
"crossover",
"on",
"the",
"candidates",
"."
] | d5976ab503cc9d51c6f586cbb7bb601a38c01128 | https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/ec/variators/crossovers.py#L174-L212 | train |
aarongarrett/inspyred | inspyred/ec/variators/crossovers.py | arithmetic_crossover | def arithmetic_crossover(random, mom, dad, args):
"""Return the offspring of arithmetic crossover on the candidates.
This function performs arithmetic crossover (AX), which is similar to a
generalized weighted averaging of the candidate elements. The allele
of each parent is weighted by the *ax_alpha*... | python | def arithmetic_crossover(random, mom, dad, args):
"""Return the offspring of arithmetic crossover on the candidates.
This function performs arithmetic crossover (AX), which is similar to a
generalized weighted averaging of the candidate elements. The allele
of each parent is weighted by the *ax_alpha*... | [
"def",
"arithmetic_crossover",
"(",
"random",
",",
"mom",
",",
"dad",
",",
"args",
")",
":",
"ax_alpha",
"=",
"args",
".",
"setdefault",
"(",
"'ax_alpha'",
",",
"0.5",
")",
"ax_points",
"=",
"args",
".",
"setdefault",
"(",
"'ax_points'",
",",
"None",
")"... | Return the offspring of arithmetic crossover on the candidates.
This function performs arithmetic crossover (AX), which is similar to a
generalized weighted averaging of the candidate elements. The allele
of each parent is weighted by the *ax_alpha* keyword argument, and
the allele of the complement p... | [
"Return",
"the",
"offspring",
"of",
"arithmetic",
"crossover",
"on",
"the",
"candidates",
"."
] | d5976ab503cc9d51c6f586cbb7bb601a38c01128 | https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/ec/variators/crossovers.py#L216-L265 | train |
aarongarrett/inspyred | inspyred/ec/variators/crossovers.py | blend_crossover | def blend_crossover(random, mom, dad, args):
"""Return the offspring of blend crossover on the candidates.
This function performs blend crossover (BLX), which is similar to
arithmetic crossover with a bit of mutation. It creates offspring
whose values are chosen randomly from a range bounded by the
... | python | def blend_crossover(random, mom, dad, args):
"""Return the offspring of blend crossover on the candidates.
This function performs blend crossover (BLX), which is similar to
arithmetic crossover with a bit of mutation. It creates offspring
whose values are chosen randomly from a range bounded by the
... | [
"def",
"blend_crossover",
"(",
"random",
",",
"mom",
",",
"dad",
",",
"args",
")",
":",
"blx_alpha",
"=",
"args",
".",
"setdefault",
"(",
"'blx_alpha'",
",",
"0.1",
")",
"blx_points",
"=",
"args",
".",
"setdefault",
"(",
"'blx_points'",
",",
"None",
")",... | Return the offspring of blend crossover on the candidates.
This function performs blend crossover (BLX), which is similar to
arithmetic crossover with a bit of mutation. It creates offspring
whose values are chosen randomly from a range bounded by the
parent alleles but that is also extended by some a... | [
"Return",
"the",
"offspring",
"of",
"blend",
"crossover",
"on",
"the",
"candidates",
"."
] | d5976ab503cc9d51c6f586cbb7bb601a38c01128 | https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/ec/variators/crossovers.py#L269-L320 | train |
aarongarrett/inspyred | inspyred/ec/variators/crossovers.py | heuristic_crossover | def heuristic_crossover(random, candidates, args):
"""Return the offspring of heuristic crossover on the candidates.
It performs heuristic crossover (HX), which is similar to the
update rule used in particle swarm optimization. This function
also makes use of the bounder function as specified in the ... | python | def heuristic_crossover(random, candidates, args):
"""Return the offspring of heuristic crossover on the candidates.
It performs heuristic crossover (HX), which is similar to the
update rule used in particle swarm optimization. This function
also makes use of the bounder function as specified in the ... | [
"def",
"heuristic_crossover",
"(",
"random",
",",
"candidates",
",",
"args",
")",
":",
"crossover_rate",
"=",
"args",
".",
"setdefault",
"(",
"'crossover_rate'",
",",
"1.0",
")",
"bounder",
"=",
"args",
"[",
"'_ec'",
"]",
".",
"bounder",
"if",
"len",
"(",
... | Return the offspring of heuristic crossover on the candidates.
It performs heuristic crossover (HX), which is similar to the
update rule used in particle swarm optimization. This function
also makes use of the bounder function as specified in the EC's
``evolve`` method.
.. note::
Th... | [
"Return",
"the",
"offspring",
"of",
"heuristic",
"crossover",
"on",
"the",
"candidates",
"."
] | d5976ab503cc9d51c6f586cbb7bb601a38c01128 | https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/ec/variators/crossovers.py#L323-L379 | train |
aarongarrett/inspyred | docs/moonshot.py | gravitational_force | def gravitational_force(position_a, mass_a, position_b, mass_b):
"""Returns the gravitational force between the two bodies a and b."""
distance = distance_between(position_a, position_b)
# Calculate the direction and magnitude of the force.
angle = math.atan2(position_a[1] - position_b[1], position_a[0... | python | def gravitational_force(position_a, mass_a, position_b, mass_b):
"""Returns the gravitational force between the two bodies a and b."""
distance = distance_between(position_a, position_b)
# Calculate the direction and magnitude of the force.
angle = math.atan2(position_a[1] - position_b[1], position_a[0... | [
"def",
"gravitational_force",
"(",
"position_a",
",",
"mass_a",
",",
"position_b",
",",
"mass_b",
")",
":",
"distance",
"=",
"distance_between",
"(",
"position_a",
",",
"position_b",
")",
"angle",
"=",
"math",
".",
"atan2",
"(",
"position_a",
"[",
"1",
"]",
... | Returns the gravitational force between the two bodies a and b. | [
"Returns",
"the",
"gravitational",
"force",
"between",
"the",
"two",
"bodies",
"a",
"and",
"b",
"."
] | d5976ab503cc9d51c6f586cbb7bb601a38c01128 | https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/docs/moonshot.py#L37-L50 | train |
aarongarrett/inspyred | docs/moonshot.py | force_on_satellite | def force_on_satellite(position, mass):
"""Returns the total gravitational force acting on the body from the Earth and Moon."""
earth_grav_force = gravitational_force(position, mass, earth_position, earth_mass)
moon_grav_force = gravitational_force(position, mass, moon_position, moon_mass)
F_x = earth_g... | python | def force_on_satellite(position, mass):
"""Returns the total gravitational force acting on the body from the Earth and Moon."""
earth_grav_force = gravitational_force(position, mass, earth_position, earth_mass)
moon_grav_force = gravitational_force(position, mass, moon_position, moon_mass)
F_x = earth_g... | [
"def",
"force_on_satellite",
"(",
"position",
",",
"mass",
")",
":",
"earth_grav_force",
"=",
"gravitational_force",
"(",
"position",
",",
"mass",
",",
"earth_position",
",",
"earth_mass",
")",
"moon_grav_force",
"=",
"gravitational_force",
"(",
"position",
",",
"... | Returns the total gravitational force acting on the body from the Earth and Moon. | [
"Returns",
"the",
"total",
"gravitational",
"force",
"acting",
"on",
"the",
"body",
"from",
"the",
"Earth",
"and",
"Moon",
"."
] | d5976ab503cc9d51c6f586cbb7bb601a38c01128 | https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/docs/moonshot.py#L52-L58 | train |
aarongarrett/inspyred | docs/moonshot.py | acceleration_of_satellite | def acceleration_of_satellite(position, mass):
"""Returns the acceleration based on all forces acting upon the body."""
F_x, F_y = force_on_satellite(position, mass)
return F_x / mass, F_y / mass | python | def acceleration_of_satellite(position, mass):
"""Returns the acceleration based on all forces acting upon the body."""
F_x, F_y = force_on_satellite(position, mass)
return F_x / mass, F_y / mass | [
"def",
"acceleration_of_satellite",
"(",
"position",
",",
"mass",
")",
":",
"F_x",
",",
"F_y",
"=",
"force_on_satellite",
"(",
"position",
",",
"mass",
")",
"return",
"F_x",
"/",
"mass",
",",
"F_y",
"/",
"mass"
] | Returns the acceleration based on all forces acting upon the body. | [
"Returns",
"the",
"acceleration",
"based",
"on",
"all",
"forces",
"acting",
"upon",
"the",
"body",
"."
] | d5976ab503cc9d51c6f586cbb7bb601a38c01128 | https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/docs/moonshot.py#L60-L63 | train |
aarongarrett/inspyred | inspyred/ec/evaluators.py | evaluator | def evaluator(evaluate):
"""Return an inspyred evaluator function based on the given function.
This function generator takes a function that evaluates only one
candidate. The generator handles the iteration over each candidate
to be evaluated.
The given function ``evaluate`` must have the fol... | python | def evaluator(evaluate):
"""Return an inspyred evaluator function based on the given function.
This function generator takes a function that evaluates only one
candidate. The generator handles the iteration over each candidate
to be evaluated.
The given function ``evaluate`` must have the fol... | [
"def",
"evaluator",
"(",
"evaluate",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"evaluate",
")",
"def",
"inspyred_evaluator",
"(",
"candidates",
",",
"args",
")",
":",
"fitness",
"=",
"[",
"]",
"for",
"candidate",
"in",
"candidates",
":",
"fitness",
... | Return an inspyred evaluator function based on the given function.
This function generator takes a function that evaluates only one
candidate. The generator handles the iteration over each candidate
to be evaluated.
The given function ``evaluate`` must have the following signature::
... | [
"Return",
"an",
"inspyred",
"evaluator",
"function",
"based",
"on",
"the",
"given",
"function",
".",
"This",
"function",
"generator",
"takes",
"a",
"function",
"that",
"evaluates",
"only",
"one",
"candidate",
".",
"The",
"generator",
"handles",
"the",
"iteration... | d5976ab503cc9d51c6f586cbb7bb601a38c01128 | https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/ec/evaluators.py#L45-L77 | train |
aarongarrett/inspyred | inspyred/ec/evaluators.py | parallel_evaluation_pp | def parallel_evaluation_pp(candidates, args):
"""Evaluate the candidates in parallel using Parallel Python.
This function allows parallel evaluation of candidate solutions.
It uses the `Parallel Python <http://www.parallelpython.com>`_ (pp)
library to accomplish the parallelization. This library must ... | python | def parallel_evaluation_pp(candidates, args):
"""Evaluate the candidates in parallel using Parallel Python.
This function allows parallel evaluation of candidate solutions.
It uses the `Parallel Python <http://www.parallelpython.com>`_ (pp)
library to accomplish the parallelization. This library must ... | [
"def",
"parallel_evaluation_pp",
"(",
"candidates",
",",
"args",
")",
":",
"import",
"pp",
"logger",
"=",
"args",
"[",
"'_ec'",
"]",
".",
"logger",
"try",
":",
"evaluator",
"=",
"args",
"[",
"'pp_evaluator'",
"]",
"except",
"KeyError",
":",
"logger",
".",
... | Evaluate the candidates in parallel using Parallel Python.
This function allows parallel evaluation of candidate solutions.
It uses the `Parallel Python <http://www.parallelpython.com>`_ (pp)
library to accomplish the parallelization. This library must already
be installed in order to use this functi... | [
"Evaluate",
"the",
"candidates",
"in",
"parallel",
"using",
"Parallel",
"Python",
"."
] | d5976ab503cc9d51c6f586cbb7bb601a38c01128 | https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/ec/evaluators.py#L80-L162 | train |
aarongarrett/inspyred | inspyred/ec/evaluators.py | parallel_evaluation_mp | def parallel_evaluation_mp(candidates, args):
"""Evaluate the candidates in parallel using ``multiprocessing``.
This function allows parallel evaluation of candidate solutions.
It uses the standard multiprocessing library to accomplish the
parallelization. The function assigns the evaluation of each
... | python | def parallel_evaluation_mp(candidates, args):
"""Evaluate the candidates in parallel using ``multiprocessing``.
This function allows parallel evaluation of candidate solutions.
It uses the standard multiprocessing library to accomplish the
parallelization. The function assigns the evaluation of each
... | [
"def",
"parallel_evaluation_mp",
"(",
"candidates",
",",
"args",
")",
":",
"import",
"time",
"import",
"multiprocessing",
"logger",
"=",
"args",
"[",
"'_ec'",
"]",
".",
"logger",
"try",
":",
"evaluator",
"=",
"args",
"[",
"'mp_evaluator'",
"]",
"except",
"Ke... | Evaluate the candidates in parallel using ``multiprocessing``.
This function allows parallel evaluation of candidate solutions.
It uses the standard multiprocessing library to accomplish the
parallelization. The function assigns the evaluation of each
candidate to its own job, all of which are then di... | [
"Evaluate",
"the",
"candidates",
"in",
"parallel",
"using",
"multiprocessing",
"."
] | d5976ab503cc9d51c6f586cbb7bb601a38c01128 | https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/ec/evaluators.py#L165-L230 | train |
djsutho/django-debug-toolbar-request-history | ddt_request_history/panels/request_history.py | allow_ajax | def allow_ajax(request):
"""
Default function to determine whether to show the toolbar on a given page.
"""
if request.META.get('REMOTE_ADDR', None) not in settings.INTERNAL_IPS:
return False
if toolbar_version < LooseVersion('1.8') \
and request.get_full_path().startswith(DEBUG_... | python | def allow_ajax(request):
"""
Default function to determine whether to show the toolbar on a given page.
"""
if request.META.get('REMOTE_ADDR', None) not in settings.INTERNAL_IPS:
return False
if toolbar_version < LooseVersion('1.8') \
and request.get_full_path().startswith(DEBUG_... | [
"def",
"allow_ajax",
"(",
"request",
")",
":",
"if",
"request",
".",
"META",
".",
"get",
"(",
"'REMOTE_ADDR'",
",",
"None",
")",
"not",
"in",
"settings",
".",
"INTERNAL_IPS",
":",
"return",
"False",
"if",
"toolbar_version",
"<",
"LooseVersion",
"(",
"'1.8'... | Default function to determine whether to show the toolbar on a given page. | [
"Default",
"function",
"to",
"determine",
"whether",
"to",
"show",
"the",
"toolbar",
"on",
"a",
"given",
"page",
"."
] | b3da3e12762d68c23a307ffb279e6047f80ba695 | https://github.com/djsutho/django-debug-toolbar-request-history/blob/b3da3e12762d68c23a307ffb279e6047f80ba695/ddt_request_history/panels/request_history.py#L104-L114 | train |
djsutho/django-debug-toolbar-request-history | ddt_request_history/panels/request_history.py | RequestHistoryPanel.content | def content(self):
""" Content of the panel when it's displayed in full screen. """
toolbars = OrderedDict()
for id, toolbar in DebugToolbar._store.items():
content = {}
for panel in toolbar.panels:
panel_id = None
nav_title = ''
... | python | def content(self):
""" Content of the panel when it's displayed in full screen. """
toolbars = OrderedDict()
for id, toolbar in DebugToolbar._store.items():
content = {}
for panel in toolbar.panels:
panel_id = None
nav_title = ''
... | [
"def",
"content",
"(",
"self",
")",
":",
"toolbars",
"=",
"OrderedDict",
"(",
")",
"for",
"id",
",",
"toolbar",
"in",
"DebugToolbar",
".",
"_store",
".",
"items",
"(",
")",
":",
"content",
"=",
"{",
"}",
"for",
"panel",
"in",
"toolbar",
".",
"panels"... | Content of the panel when it's displayed in full screen. | [
"Content",
"of",
"the",
"panel",
"when",
"it",
"s",
"displayed",
"in",
"full",
"screen",
"."
] | b3da3e12762d68c23a307ffb279e6047f80ba695 | https://github.com/djsutho/django-debug-toolbar-request-history/blob/b3da3e12762d68c23a307ffb279e6047f80ba695/ddt_request_history/panels/request_history.py#L184-L215 | train |
AlexMathew/scrapple | scrapple/selectors/selector.py | Selector.extract_content | def extract_content(self, selector='', attr='', default='', connector='', *args, **kwargs):
"""
Method for performing the content extraction for the particular selector type. \
If the selector is "url", the URL of the current web page is returned.
Otherwise, the selector expression is used to extract content. ... | python | def extract_content(self, selector='', attr='', default='', connector='', *args, **kwargs):
"""
Method for performing the content extraction for the particular selector type. \
If the selector is "url", the URL of the current web page is returned.
Otherwise, the selector expression is used to extract content. ... | [
"def",
"extract_content",
"(",
"self",
",",
"selector",
"=",
"''",
",",
"attr",
"=",
"''",
",",
"default",
"=",
"''",
",",
"connector",
"=",
"''",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"try",
":",
"if",
"selector",
".",
"lower",
"(",
"... | Method for performing the content extraction for the particular selector type. \
If the selector is "url", the URL of the current web page is returned.
Otherwise, the selector expression is used to extract content. The particular \
attribute to be extracted ("text", "href", etc.) is specified in the method \
a... | [
"Method",
"for",
"performing",
"the",
"content",
"extraction",
"for",
"the",
"particular",
"selector",
"type",
".",
"\\"
] | eeb604601b155d6cc7e035855ff4d3f48f8bed74 | https://github.com/AlexMathew/scrapple/blob/eeb604601b155d6cc7e035855ff4d3f48f8bed74/scrapple/selectors/selector.py#L81-L119 | train |
AlexMathew/scrapple | scrapple/selectors/selector.py | Selector.extract_links | def extract_links(self, selector='', *args, **kwargs):
"""
Method for performing the link extraction for the crawler. \
The selector passed as the argument is a selector to point to the anchor tags \
that the crawler should pass through. A list of links is obtained, and the links \
are iterated through. The ... | python | def extract_links(self, selector='', *args, **kwargs):
"""
Method for performing the link extraction for the crawler. \
The selector passed as the argument is a selector to point to the anchor tags \
that the crawler should pass through. A list of links is obtained, and the links \
are iterated through. The ... | [
"def",
"extract_links",
"(",
"self",
",",
"selector",
"=",
"''",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"try",
":",
"links",
"=",
"self",
".",
"get_tree_tag",
"(",
"selector",
"=",
"selector",
")",
"for",
"link",
"in",
"links",
":",
"next_u... | Method for performing the link extraction for the crawler. \
The selector passed as the argument is a selector to point to the anchor tags \
that the crawler should pass through. A list of links is obtained, and the links \
are iterated through. The relative paths are converted into absolute paths and \
a ``Xp... | [
"Method",
"for",
"performing",
"the",
"link",
"extraction",
"for",
"the",
"crawler",
".",
"\\"
] | eeb604601b155d6cc7e035855ff4d3f48f8bed74 | https://github.com/AlexMathew/scrapple/blob/eeb604601b155d6cc7e035855ff4d3f48f8bed74/scrapple/selectors/selector.py#L122-L147 | train |
AlexMathew/scrapple | scrapple/selectors/selector.py | Selector.extract_tabular | def extract_tabular(self, header='', prefix='', suffix='', table_type='', *args, **kwargs):
"""
Method for performing the tabular data extraction. \
:param result: A dictionary containing the extracted data so far
:param table_type: Can be "rows" or "columns". This determines the type of table to be extracted.... | python | def extract_tabular(self, header='', prefix='', suffix='', table_type='', *args, **kwargs):
"""
Method for performing the tabular data extraction. \
:param result: A dictionary containing the extracted data so far
:param table_type: Can be "rows" or "columns". This determines the type of table to be extracted.... | [
"def",
"extract_tabular",
"(",
"self",
",",
"header",
"=",
"''",
",",
"prefix",
"=",
"''",
",",
"suffix",
"=",
"''",
",",
"table_type",
"=",
"''",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"if",
"type",
"(",
"header",
")",
"in",
"[",
"str"... | Method for performing the tabular data extraction. \
:param result: A dictionary containing the extracted data so far
:param table_type: Can be "rows" or "columns". This determines the type of table to be extracted. \
A row extraction is when there is a single row to be extracted and mapped to a set of headers. ... | [
"Method",
"for",
"performing",
"the",
"tabular",
"data",
"extraction",
".",
"\\"
] | eeb604601b155d6cc7e035855ff4d3f48f8bed74 | https://github.com/AlexMathew/scrapple/blob/eeb604601b155d6cc7e035855ff4d3f48f8bed74/scrapple/selectors/selector.py#L150-L187 | train |
AlexMathew/scrapple | scrapple/selectors/selector.py | Selector.extract_rows | def extract_rows(self, result={}, selector='', table_headers=[], attr='', connector='', default='', verbosity=0, *args, **kwargs):
"""
Row data extraction for extract_tabular
"""
result_list = []
try:
values = self.get_tree_tag(selector)
if len(table_headers) >= len(values):
from itertools import i... | python | def extract_rows(self, result={}, selector='', table_headers=[], attr='', connector='', default='', verbosity=0, *args, **kwargs):
"""
Row data extraction for extract_tabular
"""
result_list = []
try:
values = self.get_tree_tag(selector)
if len(table_headers) >= len(values):
from itertools import i... | [
"def",
"extract_rows",
"(",
"self",
",",
"result",
"=",
"{",
"}",
",",
"selector",
"=",
"''",
",",
"table_headers",
"=",
"[",
"]",
",",
"attr",
"=",
"''",
",",
"connector",
"=",
"''",
",",
"default",
"=",
"''",
",",
"verbosity",
"=",
"0",
",",
"*... | Row data extraction for extract_tabular | [
"Row",
"data",
"extraction",
"for",
"extract_tabular"
] | eeb604601b155d6cc7e035855ff4d3f48f8bed74 | https://github.com/AlexMathew/scrapple/blob/eeb604601b155d6cc7e035855ff4d3f48f8bed74/scrapple/selectors/selector.py#L190-L224 | train |
AlexMathew/scrapple | scrapple/selectors/selector.py | Selector.extract_columns | def extract_columns(self, result={}, selector='', table_headers=[], attr='', connector='', default='', verbosity=0, *args, **kwargs):
"""
Column data extraction for extract_tabular
"""
result_list = []
try:
if type(selector) in [str, unicode]:
selectors = [selector]
elif type(selector) == list:
... | python | def extract_columns(self, result={}, selector='', table_headers=[], attr='', connector='', default='', verbosity=0, *args, **kwargs):
"""
Column data extraction for extract_tabular
"""
result_list = []
try:
if type(selector) in [str, unicode]:
selectors = [selector]
elif type(selector) == list:
... | [
"def",
"extract_columns",
"(",
"self",
",",
"result",
"=",
"{",
"}",
",",
"selector",
"=",
"''",
",",
"table_headers",
"=",
"[",
"]",
",",
"attr",
"=",
"''",
",",
"connector",
"=",
"''",
",",
"default",
"=",
"''",
",",
"verbosity",
"=",
"0",
",",
... | Column data extraction for extract_tabular | [
"Column",
"data",
"extraction",
"for",
"extract_tabular"
] | eeb604601b155d6cc7e035855ff4d3f48f8bed74 | https://github.com/AlexMathew/scrapple/blob/eeb604601b155d6cc7e035855ff4d3f48f8bed74/scrapple/selectors/selector.py#L227-L271 | train |
AlexMathew/scrapple | scrapple/cmd.py | runCLI | def runCLI():
"""
The starting point for the execution of the Scrapple command line tool.
runCLI uses the docstring as the usage description for the scrapple command. \
The class for the required command is selected by a dynamic dispatch, and the \
command is executed through the execute_command() ... | python | def runCLI():
"""
The starting point for the execution of the Scrapple command line tool.
runCLI uses the docstring as the usage description for the scrapple command. \
The class for the required command is selected by a dynamic dispatch, and the \
command is executed through the execute_command() ... | [
"def",
"runCLI",
"(",
")",
":",
"args",
"=",
"docopt",
"(",
"__doc__",
",",
"version",
"=",
"'0.3.0'",
")",
"try",
":",
"check_arguments",
"(",
"args",
")",
"command_list",
"=",
"[",
"'genconfig'",
",",
"'run'",
",",
"'generate'",
"]",
"select",
"=",
"... | The starting point for the execution of the Scrapple command line tool.
runCLI uses the docstring as the usage description for the scrapple command. \
The class for the required command is selected by a dynamic dispatch, and the \
command is executed through the execute_command() method of the command clas... | [
"The",
"starting",
"point",
"for",
"the",
"execution",
"of",
"the",
"Scrapple",
"command",
"line",
"tool",
"."
] | eeb604601b155d6cc7e035855ff4d3f48f8bed74 | https://github.com/AlexMathew/scrapple/blob/eeb604601b155d6cc7e035855ff4d3f48f8bed74/scrapple/cmd.py#L49-L67 | train |
AlexMathew/scrapple | scrapple/utils/exceptions.py | check_arguments | def check_arguments(args):
"""
Validates the arguments passed through the CLI commands.
:param args: The arguments passed in the CLI, parsed by the docopt module
:return: None
"""
projectname_re = re.compile(r'[^a-zA-Z0-9_]')
if args['genconfig']:
if args['--type'] not in ['scraper', 'crawler']:
raise Inv... | python | def check_arguments(args):
"""
Validates the arguments passed through the CLI commands.
:param args: The arguments passed in the CLI, parsed by the docopt module
:return: None
"""
projectname_re = re.compile(r'[^a-zA-Z0-9_]')
if args['genconfig']:
if args['--type'] not in ['scraper', 'crawler']:
raise Inv... | [
"def",
"check_arguments",
"(",
"args",
")",
":",
"projectname_re",
"=",
"re",
".",
"compile",
"(",
"r'[^a-zA-Z0-9_]'",
")",
"if",
"args",
"[",
"'genconfig'",
"]",
":",
"if",
"args",
"[",
"'--type'",
"]",
"not",
"in",
"[",
"'scraper'",
",",
"'crawler'",
"... | Validates the arguments passed through the CLI commands.
:param args: The arguments passed in the CLI, parsed by the docopt module
:return: None | [
"Validates",
"the",
"arguments",
"passed",
"through",
"the",
"CLI",
"commands",
"."
] | eeb604601b155d6cc7e035855ff4d3f48f8bed74 | https://github.com/AlexMathew/scrapple/blob/eeb604601b155d6cc7e035855ff4d3f48f8bed74/scrapple/utils/exceptions.py#L36-L66 | train |
AlexMathew/scrapple | scrapple/utils/form.py | form_to_json | def form_to_json(form):
"""
Takes the form from the POST request in the web interface, and generates the JSON config\
file
:param form: The form from the POST request
:return: None
"""
config = dict()
if form['project_name'] == "":
raise Exception('Project name cannot be empty.')
if form['selector_type'] ... | python | def form_to_json(form):
"""
Takes the form from the POST request in the web interface, and generates the JSON config\
file
:param form: The form from the POST request
:return: None
"""
config = dict()
if form['project_name'] == "":
raise Exception('Project name cannot be empty.')
if form['selector_type'] ... | [
"def",
"form_to_json",
"(",
"form",
")",
":",
"config",
"=",
"dict",
"(",
")",
"if",
"form",
"[",
"'project_name'",
"]",
"==",
"\"\"",
":",
"raise",
"Exception",
"(",
"'Project name cannot be empty.'",
")",
"if",
"form",
"[",
"'selector_type'",
"]",
"not",
... | Takes the form from the POST request in the web interface, and generates the JSON config\
file
:param form: The form from the POST request
:return: None | [
"Takes",
"the",
"form",
"from",
"the",
"POST",
"request",
"in",
"the",
"web",
"interface",
"and",
"generates",
"the",
"JSON",
"config",
"\\",
"file"
] | eeb604601b155d6cc7e035855ff4d3f48f8bed74 | https://github.com/AlexMathew/scrapple/blob/eeb604601b155d6cc7e035855ff4d3f48f8bed74/scrapple/utils/form.py#L13-L48 | train |
AlexMathew/scrapple | scrapple/commands/run.py | RunCommand.execute_command | def execute_command(self):
"""
The run command implements the web content extractor corresponding to the given \
configuration file.
The execute_command() validates the input project name and opens the JSON \
configuration file. The run() method handles the execution of the ext... | python | def execute_command(self):
"""
The run command implements the web content extractor corresponding to the given \
configuration file.
The execute_command() validates the input project name and opens the JSON \
configuration file. The run() method handles the execution of the ext... | [
"def",
"execute_command",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"args",
"[",
"'--verbosity'",
"]",
"=",
"int",
"(",
"self",
".",
"args",
"[",
"'--verbosity'",
"]",
")",
"if",
"self",
".",
"args",
"[",
"'--verbosity'",
"]",
"not",
"in",
"[",... | The run command implements the web content extractor corresponding to the given \
configuration file.
The execute_command() validates the input project name and opens the JSON \
configuration file. The run() method handles the execution of the extractor run.
The extractor implementati... | [
"The",
"run",
"command",
"implements",
"the",
"web",
"content",
"extractor",
"corresponding",
"to",
"the",
"given",
"\\",
"configuration",
"file",
"."
] | eeb604601b155d6cc7e035855ff4d3f48f8bed74 | https://github.com/AlexMathew/scrapple/blob/eeb604601b155d6cc7e035855ff4d3f48f8bed74/scrapple/commands/run.py#L29-L74 | train |
AlexMathew/scrapple | scrapple/utils/config.py | traverse_next | def traverse_next(page, nextx, results, tabular_data_headers=[], verbosity=0):
"""
Recursive generator to traverse through the next attribute and \
crawl through the links to be followed.
:param page: The current page being parsed
:param next: The next attribute of the current scraping dict
:pa... | python | def traverse_next(page, nextx, results, tabular_data_headers=[], verbosity=0):
"""
Recursive generator to traverse through the next attribute and \
crawl through the links to be followed.
:param page: The current page being parsed
:param next: The next attribute of the current scraping dict
:pa... | [
"def",
"traverse_next",
"(",
"page",
",",
"nextx",
",",
"results",
",",
"tabular_data_headers",
"=",
"[",
"]",
",",
"verbosity",
"=",
"0",
")",
":",
"for",
"link",
"in",
"page",
".",
"extract_links",
"(",
"selector",
"=",
"nextx",
"[",
"'follow_link'",
"... | Recursive generator to traverse through the next attribute and \
crawl through the links to be followed.
:param page: The current page being parsed
:param next: The next attribute of the current scraping dict
:param results: The current extracted content, stored in a dict
:return: The extracted con... | [
"Recursive",
"generator",
"to",
"traverse",
"through",
"the",
"next",
"attribute",
"and",
"\\",
"crawl",
"through",
"the",
"links",
"to",
"be",
"followed",
"."
] | eeb604601b155d6cc7e035855ff4d3f48f8bed74 | https://github.com/AlexMathew/scrapple/blob/eeb604601b155d6cc7e035855ff4d3f48f8bed74/scrapple/utils/config.py#L20-L58 | train |
AlexMathew/scrapple | scrapple/utils/config.py | validate_config | def validate_config(config):
"""
Validates the extractor configuration file. Ensures that there are no duplicate field names, etc.
:param config: The configuration file that contains the specification of the extractor
:return: True if config is valid, else raises a exception that specifies the correcti... | python | def validate_config(config):
"""
Validates the extractor configuration file. Ensures that there are no duplicate field names, etc.
:param config: The configuration file that contains the specification of the extractor
:return: True if config is valid, else raises a exception that specifies the correcti... | [
"def",
"validate_config",
"(",
"config",
")",
":",
"fields",
"=",
"[",
"f",
"for",
"f",
"in",
"get_fields",
"(",
"config",
")",
"]",
"if",
"len",
"(",
"fields",
")",
"!=",
"len",
"(",
"set",
"(",
"fields",
")",
")",
":",
"raise",
"InvalidConfigExcept... | Validates the extractor configuration file. Ensures that there are no duplicate field names, etc.
:param config: The configuration file that contains the specification of the extractor
:return: True if config is valid, else raises a exception that specifies the correction to be made | [
"Validates",
"the",
"extractor",
"configuration",
"file",
".",
"Ensures",
"that",
"there",
"are",
"no",
"duplicate",
"field",
"names",
"etc",
"."
] | eeb604601b155d6cc7e035855ff4d3f48f8bed74 | https://github.com/AlexMathew/scrapple/blob/eeb604601b155d6cc7e035855ff4d3f48f8bed74/scrapple/utils/config.py#L61-L74 | train |
AlexMathew/scrapple | scrapple/utils/config.py | get_fields | def get_fields(config):
"""
Recursive generator that yields the field names in the config file
:param config: The configuration file that contains the specification of the extractor
:return: The field names in the config file, through a generator
"""
for data in config['scraping']['data']:
... | python | def get_fields(config):
"""
Recursive generator that yields the field names in the config file
:param config: The configuration file that contains the specification of the extractor
:return: The field names in the config file, through a generator
"""
for data in config['scraping']['data']:
... | [
"def",
"get_fields",
"(",
"config",
")",
":",
"for",
"data",
"in",
"config",
"[",
"'scraping'",
"]",
"[",
"'data'",
"]",
":",
"if",
"data",
"[",
"'field'",
"]",
"!=",
"''",
":",
"yield",
"data",
"[",
"'field'",
"]",
"if",
"'next'",
"in",
"config",
... | Recursive generator that yields the field names in the config file
:param config: The configuration file that contains the specification of the extractor
:return: The field names in the config file, through a generator | [
"Recursive",
"generator",
"that",
"yields",
"the",
"field",
"names",
"in",
"the",
"config",
"file"
] | eeb604601b155d6cc7e035855ff4d3f48f8bed74 | https://github.com/AlexMathew/scrapple/blob/eeb604601b155d6cc7e035855ff4d3f48f8bed74/scrapple/utils/config.py#L77-L91 | train |
AlexMathew/scrapple | scrapple/utils/config.py | extract_fieldnames | def extract_fieldnames(config):
"""
Function to return a list of unique field names from the config file
:param config: The configuration file that contains the specification of the extractor
:return: A list of field names from the config file
"""
fields = []
for x in get_fields(config):
... | python | def extract_fieldnames(config):
"""
Function to return a list of unique field names from the config file
:param config: The configuration file that contains the specification of the extractor
:return: A list of field names from the config file
"""
fields = []
for x in get_fields(config):
... | [
"def",
"extract_fieldnames",
"(",
"config",
")",
":",
"fields",
"=",
"[",
"]",
"for",
"x",
"in",
"get_fields",
"(",
"config",
")",
":",
"if",
"x",
"in",
"fields",
":",
"fields",
".",
"append",
"(",
"x",
"+",
"'_'",
"+",
"str",
"(",
"fields",
".",
... | Function to return a list of unique field names from the config file
:param config: The configuration file that contains the specification of the extractor
:return: A list of field names from the config file | [
"Function",
"to",
"return",
"a",
"list",
"of",
"unique",
"field",
"names",
"from",
"the",
"config",
"file"
] | eeb604601b155d6cc7e035855ff4d3f48f8bed74 | https://github.com/AlexMathew/scrapple/blob/eeb604601b155d6cc7e035855ff4d3f48f8bed74/scrapple/utils/config.py#L94-L108 | train |
CQCL/pytket | pytket/qiskit/tket_pass.py | TketPass.run | def run(self, dag:DAGCircuit) -> DAGCircuit:
"""
Run one pass of optimisation on the circuit and route for the given backend.
:param dag: The circuit to optimise and route
:return: The modified circuit
"""
circ = dagcircuit_to_tk(dag, _DROP_CONDS=self.DROP_CONDS,_BO... | python | def run(self, dag:DAGCircuit) -> DAGCircuit:
"""
Run one pass of optimisation on the circuit and route for the given backend.
:param dag: The circuit to optimise and route
:return: The modified circuit
"""
circ = dagcircuit_to_tk(dag, _DROP_CONDS=self.DROP_CONDS,_BO... | [
"def",
"run",
"(",
"self",
",",
"dag",
":",
"DAGCircuit",
")",
"->",
"DAGCircuit",
":",
"circ",
"=",
"dagcircuit_to_tk",
"(",
"dag",
",",
"_DROP_CONDS",
"=",
"self",
".",
"DROP_CONDS",
",",
"_BOX_UNKNOWN",
"=",
"self",
".",
"BOX_UNKNOWN",
")",
"circ",
",... | Run one pass of optimisation on the circuit and route for the given backend.
:param dag: The circuit to optimise and route
:return: The modified circuit | [
"Run",
"one",
"pass",
"of",
"optimisation",
"on",
"the",
"circuit",
"and",
"route",
"for",
"the",
"given",
"backend",
"."
] | ae68f7402dcb5fb45221832cc6185d267bdd7a71 | https://github.com/CQCL/pytket/blob/ae68f7402dcb5fb45221832cc6185d267bdd7a71/pytket/qiskit/tket_pass.py#L51-L68 | train |
CQCL/pytket | pytket/cirq/qubits.py | _sort_row_col | def _sort_row_col(qubits: Iterator[GridQubit]) -> List[GridQubit]:
"""Sort grid qubits first by row then by column"""
return sorted(qubits, key=lambda x: (x.row, x.col)) | python | def _sort_row_col(qubits: Iterator[GridQubit]) -> List[GridQubit]:
"""Sort grid qubits first by row then by column"""
return sorted(qubits, key=lambda x: (x.row, x.col)) | [
"def",
"_sort_row_col",
"(",
"qubits",
":",
"Iterator",
"[",
"GridQubit",
"]",
")",
"->",
"List",
"[",
"GridQubit",
"]",
":",
"return",
"sorted",
"(",
"qubits",
",",
"key",
"=",
"lambda",
"x",
":",
"(",
"x",
".",
"row",
",",
"x",
".",
"col",
")",
... | Sort grid qubits first by row then by column | [
"Sort",
"grid",
"qubits",
"first",
"by",
"row",
"then",
"by",
"column"
] | ae68f7402dcb5fb45221832cc6185d267bdd7a71 | https://github.com/CQCL/pytket/blob/ae68f7402dcb5fb45221832cc6185d267bdd7a71/pytket/cirq/qubits.py#L51-L54 | train |
CQCL/pytket | pytket/chemistry/aqua/qse.py | QSE.print_setting | def print_setting(self) -> str:
"""
Presents the QSE settings as a string.
:return: The formatted settings of the QSE instance
"""
ret = "\n"
ret += "==================== Setting of {} ============================\n".format(self.configuration['name'])
ret += "{}"... | python | def print_setting(self) -> str:
"""
Presents the QSE settings as a string.
:return: The formatted settings of the QSE instance
"""
ret = "\n"
ret += "==================== Setting of {} ============================\n".format(self.configuration['name'])
ret += "{}"... | [
"def",
"print_setting",
"(",
"self",
")",
"->",
"str",
":",
"ret",
"=",
"\"\\n\"",
"ret",
"+=",
"\"==================== Setting of {} ============================\\n\"",
".",
"format",
"(",
"self",
".",
"configuration",
"[",
"'name'",
"]",
")",
"ret",
"+=",
"\"{}\... | Presents the QSE settings as a string.
:return: The formatted settings of the QSE instance | [
"Presents",
"the",
"QSE",
"settings",
"as",
"a",
"string",
"."
] | ae68f7402dcb5fb45221832cc6185d267bdd7a71 | https://github.com/CQCL/pytket/blob/ae68f7402dcb5fb45221832cc6185d267bdd7a71/pytket/chemistry/aqua/qse.py#L117-L129 | train |
CQCL/pytket | pytket/chemistry/aqua/qse.py | QSE._energy_evaluation | def _energy_evaluation(self, operator):
"""
Evaluate the energy of the current input circuit with respect to the given operator.
:param operator: Hamiltonian of the system
:return: Energy of the Hamiltonian
"""
if self._quantum_state is not None:
input_circu... | python | def _energy_evaluation(self, operator):
"""
Evaluate the energy of the current input circuit with respect to the given operator.
:param operator: Hamiltonian of the system
:return: Energy of the Hamiltonian
"""
if self._quantum_state is not None:
input_circu... | [
"def",
"_energy_evaluation",
"(",
"self",
",",
"operator",
")",
":",
"if",
"self",
".",
"_quantum_state",
"is",
"not",
"None",
":",
"input_circuit",
"=",
"self",
".",
"_quantum_state",
"else",
":",
"input_circuit",
"=",
"[",
"self",
".",
"opt_circuit",
"]",
... | Evaluate the energy of the current input circuit with respect to the given operator.
:param operator: Hamiltonian of the system
:return: Energy of the Hamiltonian | [
"Evaluate",
"the",
"energy",
"of",
"the",
"current",
"input",
"circuit",
"with",
"respect",
"to",
"the",
"given",
"operator",
"."
] | ae68f7402dcb5fb45221832cc6185d267bdd7a71 | https://github.com/CQCL/pytket/blob/ae68f7402dcb5fb45221832cc6185d267bdd7a71/pytket/chemistry/aqua/qse.py#L131-L151 | train |
CQCL/pytket | pytket/chemistry/aqua/qse.py | QSE._run | def _run(self) -> dict:
"""
Runs the QSE algorithm to compute the eigenvalues of the Hamiltonian.
:return: Dictionary of results
"""
if not self._quantum_instance.is_statevector:
raise AquaError("Can only calculate state for QSE with statevector backends")
re... | python | def _run(self) -> dict:
"""
Runs the QSE algorithm to compute the eigenvalues of the Hamiltonian.
:return: Dictionary of results
"""
if not self._quantum_instance.is_statevector:
raise AquaError("Can only calculate state for QSE with statevector backends")
re... | [
"def",
"_run",
"(",
"self",
")",
"->",
"dict",
":",
"if",
"not",
"self",
".",
"_quantum_instance",
".",
"is_statevector",
":",
"raise",
"AquaError",
"(",
"\"Can only calculate state for QSE with statevector backends\"",
")",
"ret",
"=",
"self",
".",
"_quantum_instan... | Runs the QSE algorithm to compute the eigenvalues of the Hamiltonian.
:return: Dictionary of results | [
"Runs",
"the",
"QSE",
"algorithm",
"to",
"compute",
"the",
"eigenvalues",
"of",
"the",
"Hamiltonian",
"."
] | ae68f7402dcb5fb45221832cc6185d267bdd7a71 | https://github.com/CQCL/pytket/blob/ae68f7402dcb5fb45221832cc6185d267bdd7a71/pytket/chemistry/aqua/qse.py#L260-L274 | train |
bkabrda/flask-whooshee | flask_whooshee.py | WhoosheeQuery.whooshee_search | def whooshee_search(self, search_string, group=whoosh.qparser.OrGroup, whoosheer=None,
match_substrings=True, limit=None, order_by_relevance=10):
"""Do a fulltext search on the query.
Returns a query filtered with results of the fulltext search.
:param search_string: The... | python | def whooshee_search(self, search_string, group=whoosh.qparser.OrGroup, whoosheer=None,
match_substrings=True, limit=None, order_by_relevance=10):
"""Do a fulltext search on the query.
Returns a query filtered with results of the fulltext search.
:param search_string: The... | [
"def",
"whooshee_search",
"(",
"self",
",",
"search_string",
",",
"group",
"=",
"whoosh",
".",
"qparser",
".",
"OrGroup",
",",
"whoosheer",
"=",
"None",
",",
"match_substrings",
"=",
"True",
",",
"limit",
"=",
"None",
",",
"order_by_relevance",
"=",
"10",
... | Do a fulltext search on the query.
Returns a query filtered with results of the fulltext search.
:param search_string: The string to search for.
:param group: The whoosh group to use for searching.
Defaults to :class:`whoosh.qparser.OrGroup` which
sea... | [
"Do",
"a",
"fulltext",
"search",
"on",
"the",
"query",
".",
"Returns",
"a",
"query",
"filtered",
"with",
"results",
"of",
"the",
"fulltext",
"search",
"."
] | 773fc51ed53043bd5e92c65eadef5663845ae8c4 | https://github.com/bkabrda/flask-whooshee/blob/773fc51ed53043bd5e92c65eadef5663845ae8c4/flask_whooshee.py#L44-L123 | train |
bkabrda/flask-whooshee | flask_whooshee.py | AbstractWhoosheer.search | def search(cls, search_string, values_of='', group=whoosh.qparser.OrGroup, match_substrings=True, limit=None):
"""Searches the fields for given search_string.
Returns the found records if 'values_of' is left empty,
else the values of the given columns.
:param search_string: The string t... | python | def search(cls, search_string, values_of='', group=whoosh.qparser.OrGroup, match_substrings=True, limit=None):
"""Searches the fields for given search_string.
Returns the found records if 'values_of' is left empty,
else the values of the given columns.
:param search_string: The string t... | [
"def",
"search",
"(",
"cls",
",",
"search_string",
",",
"values_of",
"=",
"''",
",",
"group",
"=",
"whoosh",
".",
"qparser",
".",
"OrGroup",
",",
"match_substrings",
"=",
"True",
",",
"limit",
"=",
"None",
")",
":",
"index",
"=",
"Whooshee",
".",
"get_... | Searches the fields for given search_string.
Returns the found records if 'values_of' is left empty,
else the values of the given columns.
:param search_string: The string to search for.
:param values_of: If given, the method will not return the whole
records, ... | [
"Searches",
"the",
"fields",
"for",
"given",
"search_string",
".",
"Returns",
"the",
"found",
"records",
"if",
"values_of",
"is",
"left",
"empty",
"else",
"the",
"values",
"of",
"the",
"given",
"columns",
"."
] | 773fc51ed53043bd5e92c65eadef5663845ae8c4 | https://github.com/bkabrda/flask-whooshee/blob/773fc51ed53043bd5e92c65eadef5663845ae8c4/flask_whooshee.py#L138-L163 | train |
bkabrda/flask-whooshee | flask_whooshee.py | Whooshee.create_index | def create_index(cls, app, wh):
"""Creates and opens an index for the given whoosheer and app.
If the index already exists, it just opens it, otherwise it creates
it first.
:param app: The application instance.
:param wh: The whoosheer instance for which a index should be create... | python | def create_index(cls, app, wh):
"""Creates and opens an index for the given whoosheer and app.
If the index already exists, it just opens it, otherwise it creates
it first.
:param app: The application instance.
:param wh: The whoosheer instance for which a index should be create... | [
"def",
"create_index",
"(",
"cls",
",",
"app",
",",
"wh",
")",
":",
"if",
"app",
".",
"extensions",
"[",
"'whooshee'",
"]",
"[",
"'memory_storage'",
"]",
":",
"storage",
"=",
"RamStorage",
"(",
")",
"index",
"=",
"storage",
".",
"create_index",
"(",
"w... | Creates and opens an index for the given whoosheer and app.
If the index already exists, it just opens it, otherwise it creates
it first.
:param app: The application instance.
:param wh: The whoosheer instance for which a index should be created. | [
"Creates",
"and",
"opens",
"an",
"index",
"for",
"the",
"given",
"whoosheer",
"and",
"app",
".",
"If",
"the",
"index",
"already",
"exists",
"it",
"just",
"opens",
"it",
"otherwise",
"it",
"creates",
"it",
"first",
"."
] | 773fc51ed53043bd5e92c65eadef5663845ae8c4 | https://github.com/bkabrda/flask-whooshee/blob/773fc51ed53043bd5e92c65eadef5663845ae8c4/flask_whooshee.py#L375-L399 | train |
bkabrda/flask-whooshee | flask_whooshee.py | Whooshee.get_or_create_index | def get_or_create_index(cls, app, wh):
"""Gets a previously cached index or creates a new one for the
given app and whoosheer.
:param app: The application instance.
:param wh: The whoosheer instance for which the index should be
retrieved or created.
"""
... | python | def get_or_create_index(cls, app, wh):
"""Gets a previously cached index or creates a new one for the
given app and whoosheer.
:param app: The application instance.
:param wh: The whoosheer instance for which the index should be
retrieved or created.
"""
... | [
"def",
"get_or_create_index",
"(",
"cls",
",",
"app",
",",
"wh",
")",
":",
"if",
"wh",
"in",
"app",
".",
"extensions",
"[",
"'whooshee'",
"]",
"[",
"'whoosheers_indexes'",
"]",
":",
"return",
"app",
".",
"extensions",
"[",
"'whooshee'",
"]",
"[",
"'whoos... | Gets a previously cached index or creates a new one for the
given app and whoosheer.
:param app: The application instance.
:param wh: The whoosheer instance for which the index should be
retrieved or created. | [
"Gets",
"a",
"previously",
"cached",
"index",
"or",
"creates",
"a",
"new",
"one",
"for",
"the",
"given",
"app",
"and",
"whoosheer",
"."
] | 773fc51ed53043bd5e92c65eadef5663845ae8c4 | https://github.com/bkabrda/flask-whooshee/blob/773fc51ed53043bd5e92c65eadef5663845ae8c4/flask_whooshee.py#L410-L422 | train |
bkabrda/flask-whooshee | flask_whooshee.py | Whooshee.on_commit | def on_commit(self, changes):
"""Method that gets called when a model is changed. This serves
to do the actual index writing.
"""
if _get_config(self)['enable_indexing'] is False:
return None
for wh in self.whoosheers:
if not wh.auto_update:
... | python | def on_commit(self, changes):
"""Method that gets called when a model is changed. This serves
to do the actual index writing.
"""
if _get_config(self)['enable_indexing'] is False:
return None
for wh in self.whoosheers:
if not wh.auto_update:
... | [
"def",
"on_commit",
"(",
"self",
",",
"changes",
")",
":",
"if",
"_get_config",
"(",
"self",
")",
"[",
"'enable_indexing'",
"]",
"is",
"False",
":",
"return",
"None",
"for",
"wh",
"in",
"self",
".",
"whoosheers",
":",
"if",
"not",
"wh",
".",
"auto_upda... | Method that gets called when a model is changed. This serves
to do the actual index writing. | [
"Method",
"that",
"gets",
"called",
"when",
"a",
"model",
"is",
"changed",
".",
"This",
"serves",
"to",
"do",
"the",
"actual",
"index",
"writing",
"."
] | 773fc51ed53043bd5e92c65eadef5663845ae8c4 | https://github.com/bkabrda/flask-whooshee/blob/773fc51ed53043bd5e92c65eadef5663845ae8c4/flask_whooshee.py#L433-L454 | train |
bkabrda/flask-whooshee | flask_whooshee.py | Whooshee.reindex | def reindex(self):
"""Reindex all data
This method retrieves all the data from the registered models and
calls the ``update_<model>()`` function for every instance of such
model.
"""
for wh in self.whoosheers:
index = type(self).get_or_create_index(_get_app(s... | python | def reindex(self):
"""Reindex all data
This method retrieves all the data from the registered models and
calls the ``update_<model>()`` function for every instance of such
model.
"""
for wh in self.whoosheers:
index = type(self).get_or_create_index(_get_app(s... | [
"def",
"reindex",
"(",
"self",
")",
":",
"for",
"wh",
"in",
"self",
".",
"whoosheers",
":",
"index",
"=",
"type",
"(",
"self",
")",
".",
"get_or_create_index",
"(",
"_get_app",
"(",
"self",
")",
",",
"wh",
")",
"writer",
"=",
"index",
".",
"writer",
... | Reindex all data
This method retrieves all the data from the registered models and
calls the ``update_<model>()`` function for every instance of such
model. | [
"Reindex",
"all",
"data"
] | 773fc51ed53043bd5e92c65eadef5663845ae8c4 | https://github.com/bkabrda/flask-whooshee/blob/773fc51ed53043bd5e92c65eadef5663845ae8c4/flask_whooshee.py#L456-L470 | train |
spry-group/python-vultr | examples/basic_list.py | dump_info | def dump_info():
'''Shows various details about the account & servers'''
vultr = Vultr(API_KEY)
try:
logging.info('Listing account info:\n%s', dumps(
vultr.account.info(), indent=2
))
logging.info('Listing apps:\n%s', dumps(
vultr.app.list(), indent=2
... | python | def dump_info():
'''Shows various details about the account & servers'''
vultr = Vultr(API_KEY)
try:
logging.info('Listing account info:\n%s', dumps(
vultr.account.info(), indent=2
))
logging.info('Listing apps:\n%s', dumps(
vultr.app.list(), indent=2
... | [
"def",
"dump_info",
"(",
")",
":",
"vultr",
"=",
"Vultr",
"(",
"API_KEY",
")",
"try",
":",
"logging",
".",
"info",
"(",
"'Listing account info:\\n%s'",
",",
"dumps",
"(",
"vultr",
".",
"account",
".",
"info",
"(",
")",
",",
"indent",
"=",
"2",
")",
"... | Shows various details about the account & servers | [
"Shows",
"various",
"details",
"about",
"the",
"account",
"&",
"servers"
] | bad1448f1df7b5dba70fd3d11434f32580f0b850 | https://github.com/spry-group/python-vultr/blob/bad1448f1df7b5dba70fd3d11434f32580f0b850/examples/basic_list.py#L19-L72 | train |
spry-group/python-vultr | vultr/utils.py | update_params | def update_params(params, updates):
'''Merges updates into params'''
params = params.copy() if isinstance(params, dict) else dict()
params.update(updates)
return params | python | def update_params(params, updates):
'''Merges updates into params'''
params = params.copy() if isinstance(params, dict) else dict()
params.update(updates)
return params | [
"def",
"update_params",
"(",
"params",
",",
"updates",
")",
":",
"params",
"=",
"params",
".",
"copy",
"(",
")",
"if",
"isinstance",
"(",
"params",
",",
"dict",
")",
"else",
"dict",
"(",
")",
"params",
".",
"update",
"(",
"updates",
")",
"return",
"p... | Merges updates into params | [
"Merges",
"updates",
"into",
"params"
] | bad1448f1df7b5dba70fd3d11434f32580f0b850 | https://github.com/spry-group/python-vultr/blob/bad1448f1df7b5dba70fd3d11434f32580f0b850/vultr/utils.py#L94-L98 | train |
spry-group/python-vultr | vultr/utils.py | VultrBase._request_get_helper | def _request_get_helper(self, url, params=None):
'''API GET request helper'''
if not isinstance(params, dict):
params = dict()
if self.api_key:
params['api_key'] = self.api_key
return requests.get(url, params=params, timeout=60) | python | def _request_get_helper(self, url, params=None):
'''API GET request helper'''
if not isinstance(params, dict):
params = dict()
if self.api_key:
params['api_key'] = self.api_key
return requests.get(url, params=params, timeout=60) | [
"def",
"_request_get_helper",
"(",
"self",
",",
"url",
",",
"params",
"=",
"None",
")",
":",
"if",
"not",
"isinstance",
"(",
"params",
",",
"dict",
")",
":",
"params",
"=",
"dict",
"(",
")",
"if",
"self",
".",
"api_key",
":",
"params",
"[",
"'api_key... | API GET request helper | [
"API",
"GET",
"request",
"helper"
] | bad1448f1df7b5dba70fd3d11434f32580f0b850 | https://github.com/spry-group/python-vultr/blob/bad1448f1df7b5dba70fd3d11434f32580f0b850/vultr/utils.py#L26-L33 | train |
spry-group/python-vultr | vultr/utils.py | VultrBase._request_post_helper | def _request_post_helper(self, url, params=None):
'''API POST helper'''
if self.api_key:
query = {'api_key': self.api_key}
return requests.post(url, params=query, data=params, timeout=60) | python | def _request_post_helper(self, url, params=None):
'''API POST helper'''
if self.api_key:
query = {'api_key': self.api_key}
return requests.post(url, params=query, data=params, timeout=60) | [
"def",
"_request_post_helper",
"(",
"self",
",",
"url",
",",
"params",
"=",
"None",
")",
":",
"if",
"self",
".",
"api_key",
":",
"query",
"=",
"{",
"'api_key'",
":",
"self",
".",
"api_key",
"}",
"return",
"requests",
".",
"post",
"(",
"url",
",",
"pa... | API POST helper | [
"API",
"POST",
"helper"
] | bad1448f1df7b5dba70fd3d11434f32580f0b850 | https://github.com/spry-group/python-vultr/blob/bad1448f1df7b5dba70fd3d11434f32580f0b850/vultr/utils.py#L35-L39 | train |
spry-group/python-vultr | vultr/utils.py | VultrBase._request_helper | def _request_helper(self, url, params, method):
'''API request helper method'''
try:
if method == 'POST':
return self._request_post_helper(url, params)
elif method == 'GET':
return self._request_get_helper(url, params)
raise VultrError(... | python | def _request_helper(self, url, params, method):
'''API request helper method'''
try:
if method == 'POST':
return self._request_post_helper(url, params)
elif method == 'GET':
return self._request_get_helper(url, params)
raise VultrError(... | [
"def",
"_request_helper",
"(",
"self",
",",
"url",
",",
"params",
",",
"method",
")",
":",
"try",
":",
"if",
"method",
"==",
"'POST'",
":",
"return",
"self",
".",
"_request_post_helper",
"(",
"url",
",",
"params",
")",
"elif",
"method",
"==",
"'GET'",
... | API request helper method | [
"API",
"request",
"helper",
"method"
] | bad1448f1df7b5dba70fd3d11434f32580f0b850 | https://github.com/spry-group/python-vultr/blob/bad1448f1df7b5dba70fd3d11434f32580f0b850/vultr/utils.py#L41-L50 | train |
spry-group/python-vultr | examples/basic_haltRunning.py | halt_running | def halt_running():
'''Halts all running servers'''
vultr = Vultr(API_KEY)
try:
serverList = vultr.server.list()
#logging.info('Listing servers:\n%s', dumps(
#serverList, indent=2
#))
except VultrError as ex:
logging.error('VultrError: %s', ex)
f... | python | def halt_running():
'''Halts all running servers'''
vultr = Vultr(API_KEY)
try:
serverList = vultr.server.list()
#logging.info('Listing servers:\n%s', dumps(
#serverList, indent=2
#))
except VultrError as ex:
logging.error('VultrError: %s', ex)
f... | [
"def",
"halt_running",
"(",
")",
":",
"vultr",
"=",
"Vultr",
"(",
"API_KEY",
")",
"try",
":",
"serverList",
"=",
"vultr",
".",
"server",
".",
"list",
"(",
")",
"except",
"VultrError",
"as",
"ex",
":",
"logging",
".",
"error",
"(",
"'VultrError: %s'",
"... | Halts all running servers | [
"Halts",
"all",
"running",
"servers"
] | bad1448f1df7b5dba70fd3d11434f32580f0b850 | https://github.com/spry-group/python-vultr/blob/bad1448f1df7b5dba70fd3d11434f32580f0b850/examples/basic_haltRunning.py#L18-L33 | train |
inspirehep/refextract | refextract/references/tag.py | tag_arxiv | def tag_arxiv(line):
"""Tag arxiv report numbers
We handle arXiv in 2 ways:
* starting with arXiv:1022.1111
* this format exactly 9999.9999
We also format the output to the standard arxiv notation:
* arXiv:2007.12.1111
* arXiv:2007.12.1111v2
"""
def tagger(match):
groups = m... | python | def tag_arxiv(line):
"""Tag arxiv report numbers
We handle arXiv in 2 ways:
* starting with arXiv:1022.1111
* this format exactly 9999.9999
We also format the output to the standard arxiv notation:
* arXiv:2007.12.1111
* arXiv:2007.12.1111v2
"""
def tagger(match):
groups = m... | [
"def",
"tag_arxiv",
"(",
"line",
")",
":",
"def",
"tagger",
"(",
"match",
")",
":",
"groups",
"=",
"match",
".",
"groupdict",
"(",
")",
"if",
"match",
".",
"group",
"(",
"'suffix'",
")",
":",
"groups",
"[",
"'suffix'",
"]",
"=",
"' '",
"+",
"groups... | Tag arxiv report numbers
We handle arXiv in 2 ways:
* starting with arXiv:1022.1111
* this format exactly 9999.9999
We also format the output to the standard arxiv notation:
* arXiv:2007.12.1111
* arXiv:2007.12.1111v2 | [
"Tag",
"arxiv",
"report",
"numbers"
] | d70e3787be3c495a3a07d1517b53f81d51c788c7 | https://github.com/inspirehep/refextract/blob/d70e3787be3c495a3a07d1517b53f81d51c788c7/refextract/references/tag.py#L360-L384 | train |
inspirehep/refextract | refextract/references/tag.py | tag_arxiv_more | def tag_arxiv_more(line):
"""Tag old arxiv report numbers
Either formats:
* hep-th/1234567
* arXiv:1022111 [hep-ph] which transforms to hep-ph/1022111
"""
line = RE_ARXIV_CATCHUP.sub(ur"\g<suffix>/\g<year>\g<month>\g<num>", line)
for report_re, report_repl in RE_OLD_ARXIV:
report_n... | python | def tag_arxiv_more(line):
"""Tag old arxiv report numbers
Either formats:
* hep-th/1234567
* arXiv:1022111 [hep-ph] which transforms to hep-ph/1022111
"""
line = RE_ARXIV_CATCHUP.sub(ur"\g<suffix>/\g<year>\g<month>\g<num>", line)
for report_re, report_repl in RE_OLD_ARXIV:
report_n... | [
"def",
"tag_arxiv_more",
"(",
"line",
")",
":",
"line",
"=",
"RE_ARXIV_CATCHUP",
".",
"sub",
"(",
"ur\"\\g<suffix>/\\g<year>\\g<month>\\g<num>\"",
",",
"line",
")",
"for",
"report_re",
",",
"report_repl",
"in",
"RE_OLD_ARXIV",
":",
"report_number",
"=",
"report_repl... | Tag old arxiv report numbers
Either formats:
* hep-th/1234567
* arXiv:1022111 [hep-ph] which transforms to hep-ph/1022111 | [
"Tag",
"old",
"arxiv",
"report",
"numbers"
] | d70e3787be3c495a3a07d1517b53f81d51c788c7 | https://github.com/inspirehep/refextract/blob/d70e3787be3c495a3a07d1517b53f81d51c788c7/refextract/references/tag.py#L387-L402 | train |
inspirehep/refextract | refextract/references/tag.py | tag_pos_volume | def tag_pos_volume(line):
"""Tag POS volume number
POS is journal that has special volume numbers
e.g. PoS LAT2007 (2007) 369
"""
def tagger(match):
groups = match.groupdict()
try:
year = match.group('year')
except IndexError:
# Extract year from volu... | python | def tag_pos_volume(line):
"""Tag POS volume number
POS is journal that has special volume numbers
e.g. PoS LAT2007 (2007) 369
"""
def tagger(match):
groups = match.groupdict()
try:
year = match.group('year')
except IndexError:
# Extract year from volu... | [
"def",
"tag_pos_volume",
"(",
"line",
")",
":",
"def",
"tagger",
"(",
"match",
")",
":",
"groups",
"=",
"match",
".",
"groupdict",
"(",
")",
"try",
":",
"year",
"=",
"match",
".",
"group",
"(",
"'year'",
")",
"except",
"IndexError",
":",
"g",
"=",
... | Tag POS volume number
POS is journal that has special volume numbers
e.g. PoS LAT2007 (2007) 369 | [
"Tag",
"POS",
"volume",
"number"
] | d70e3787be3c495a3a07d1517b53f81d51c788c7 | https://github.com/inspirehep/refextract/blob/d70e3787be3c495a3a07d1517b53f81d51c788c7/refextract/references/tag.py#L405-L436 | train |
inspirehep/refextract | refextract/references/tag.py | find_numeration_more | def find_numeration_more(line):
"""Look for other numeration in line."""
# First, attempt to use marked-up titles
patterns = (
re_correct_numeration_2nd_try_ptn1,
re_correct_numeration_2nd_try_ptn2,
re_correct_numeration_2nd_try_ptn3,
re_correct_numeration_2nd_try_ptn4,
)... | python | def find_numeration_more(line):
"""Look for other numeration in line."""
# First, attempt to use marked-up titles
patterns = (
re_correct_numeration_2nd_try_ptn1,
re_correct_numeration_2nd_try_ptn2,
re_correct_numeration_2nd_try_ptn3,
re_correct_numeration_2nd_try_ptn4,
)... | [
"def",
"find_numeration_more",
"(",
"line",
")",
":",
"patterns",
"=",
"(",
"re_correct_numeration_2nd_try_ptn1",
",",
"re_correct_numeration_2nd_try_ptn2",
",",
"re_correct_numeration_2nd_try_ptn3",
",",
"re_correct_numeration_2nd_try_ptn4",
",",
")",
"for",
"pattern",
"in",... | Look for other numeration in line. | [
"Look",
"for",
"other",
"numeration",
"in",
"line",
"."
] | d70e3787be3c495a3a07d1517b53f81d51c788c7 | https://github.com/inspirehep/refextract/blob/d70e3787be3c495a3a07d1517b53f81d51c788c7/refextract/references/tag.py#L456-L481 | train |
inspirehep/refextract | refextract/references/tag.py | identify_ibids | def identify_ibids(line):
"""Find IBIDs within the line, record their position and length,
and replace them with underscores.
@param line: (string) the working reference line
@return: (tuple) containing 2 dictionaries and a string:
Dictionary: matched IBID text: (Key: position of IBI... | python | def identify_ibids(line):
"""Find IBIDs within the line, record their position and length,
and replace them with underscores.
@param line: (string) the working reference line
@return: (tuple) containing 2 dictionaries and a string:
Dictionary: matched IBID text: (Key: position of IBI... | [
"def",
"identify_ibids",
"(",
"line",
")",
":",
"ibid_match_txt",
"=",
"{",
"}",
"for",
"m_ibid",
"in",
"re_ibid",
".",
"finditer",
"(",
"line",
")",
":",
"ibid_match_txt",
"[",
"m_ibid",
".",
"start",
"(",
")",
"]",
"=",
"m_ibid",
".",
"group",
"(",
... | Find IBIDs within the line, record their position and length,
and replace them with underscores.
@param line: (string) the working reference line
@return: (tuple) containing 2 dictionaries and a string:
Dictionary: matched IBID text: (Key: position of IBID in
line;... | [
"Find",
"IBIDs",
"within",
"the",
"line",
"record",
"their",
"position",
"and",
"length",
"and",
"replace",
"them",
"with",
"underscores",
"."
] | d70e3787be3c495a3a07d1517b53f81d51c788c7 | https://github.com/inspirehep/refextract/blob/d70e3787be3c495a3a07d1517b53f81d51c788c7/refextract/references/tag.py#L1052-L1070 | train |
inspirehep/refextract | refextract/references/tag.py | find_numeration | def find_numeration(line):
"""Given a reference line, attempt to locate instances of citation
'numeration' in the line.
@param line: (string) the reference line.
@return: (string) the reference line after numeration has been checked
and possibly recognized/marked-up.
"""
pattern... | python | def find_numeration(line):
"""Given a reference line, attempt to locate instances of citation
'numeration' in the line.
@param line: (string) the reference line.
@return: (string) the reference line after numeration has been checked
and possibly recognized/marked-up.
"""
pattern... | [
"def",
"find_numeration",
"(",
"line",
")",
":",
"patterns",
"=",
"(",
"re_numeration_vol_page_yr",
",",
"re_numeration_vol_nucphys_page_yr",
",",
"re_numeration_nucphys_vol_page_yr",
",",
"re_numeration_vol_subvol_nucphys_yr_page",
",",
"re_numeration_vol_nucphys_yr_subvol_page",
... | Given a reference line, attempt to locate instances of citation
'numeration' in the line.
@param line: (string) the reference line.
@return: (string) the reference line after numeration has been checked
and possibly recognized/marked-up. | [
"Given",
"a",
"reference",
"line",
"attempt",
"to",
"locate",
"instances",
"of",
"citation",
"numeration",
"in",
"the",
"line",
"."
] | d70e3787be3c495a3a07d1517b53f81d51c788c7 | https://github.com/inspirehep/refextract/blob/d70e3787be3c495a3a07d1517b53f81d51c788c7/refextract/references/tag.py#L1083-L1127 | train |
inspirehep/refextract | refextract/references/engine.py | remove_reference_line_marker | def remove_reference_line_marker(line):
"""Trim a reference line's 'marker' from the beginning of the line.
@param line: (string) - the reference line.
@return: (tuple) containing two strings:
+ The reference line's marker (or if there was not one,
a 'space' charact... | python | def remove_reference_line_marker(line):
"""Trim a reference line's 'marker' from the beginning of the line.
@param line: (string) - the reference line.
@return: (tuple) containing two strings:
+ The reference line's marker (or if there was not one,
a 'space' charact... | [
"def",
"remove_reference_line_marker",
"(",
"line",
")",
":",
"marker_patterns",
"=",
"get_reference_line_numeration_marker_patterns",
"(",
")",
"line",
"=",
"line",
".",
"lstrip",
"(",
")",
"marker_match",
"=",
"regex_match_list",
"(",
"line",
",",
"marker_patterns",... | Trim a reference line's 'marker' from the beginning of the line.
@param line: (string) - the reference line.
@return: (tuple) containing two strings:
+ The reference line's marker (or if there was not one,
a 'space' character.
+ The reference line with ... | [
"Trim",
"a",
"reference",
"line",
"s",
"marker",
"from",
"the",
"beginning",
"of",
"the",
"line",
"."
] | d70e3787be3c495a3a07d1517b53f81d51c788c7 | https://github.com/inspirehep/refextract/blob/d70e3787be3c495a3a07d1517b53f81d51c788c7/refextract/references/engine.py#L92-L114 | train |
inspirehep/refextract | refextract/references/engine.py | roman2arabic | def roman2arabic(num):
"""Convert numbers from roman to arabic
This function expects a string like XXII
and outputs an integer
"""
t = 0
p = 0
for r in num:
n = 10 ** (205558 % ord(r) % 7) % 9995
t += n - 2 * p % n
p = n
return t | python | def roman2arabic(num):
"""Convert numbers from roman to arabic
This function expects a string like XXII
and outputs an integer
"""
t = 0
p = 0
for r in num:
n = 10 ** (205558 % ord(r) % 7) % 9995
t += n - 2 * p % n
p = n
return t | [
"def",
"roman2arabic",
"(",
"num",
")",
":",
"t",
"=",
"0",
"p",
"=",
"0",
"for",
"r",
"in",
"num",
":",
"n",
"=",
"10",
"**",
"(",
"205558",
"%",
"ord",
"(",
"r",
")",
"%",
"7",
")",
"%",
"9995",
"t",
"+=",
"n",
"-",
"2",
"*",
"p",
"%"... | Convert numbers from roman to arabic
This function expects a string like XXII
and outputs an integer | [
"Convert",
"numbers",
"from",
"roman",
"to",
"arabic"
] | d70e3787be3c495a3a07d1517b53f81d51c788c7 | https://github.com/inspirehep/refextract/blob/d70e3787be3c495a3a07d1517b53f81d51c788c7/refextract/references/engine.py#L117-L129 | train |
inspirehep/refextract | refextract/references/engine.py | format_report_number | def format_report_number(citation_elements):
"""Format report numbers that are missing a dash
e.g. CERN-LCHH2003-01 to CERN-LHCC-2003-01
"""
re_report = re.compile(ur'^(?P<name>[A-Z-]+)(?P<nums>[\d-]+)$', re.UNICODE)
for el in citation_elements:
if el['type'] == 'REPORTNUMBER':
... | python | def format_report_number(citation_elements):
"""Format report numbers that are missing a dash
e.g. CERN-LCHH2003-01 to CERN-LHCC-2003-01
"""
re_report = re.compile(ur'^(?P<name>[A-Z-]+)(?P<nums>[\d-]+)$', re.UNICODE)
for el in citation_elements:
if el['type'] == 'REPORTNUMBER':
... | [
"def",
"format_report_number",
"(",
"citation_elements",
")",
":",
"re_report",
"=",
"re",
".",
"compile",
"(",
"ur'^(?P<name>[A-Z-]+)(?P<nums>[\\d-]+)$'",
",",
"re",
".",
"UNICODE",
")",
"for",
"el",
"in",
"citation_elements",
":",
"if",
"el",
"[",
"'type'",
"]... | Format report numbers that are missing a dash
e.g. CERN-LCHH2003-01 to CERN-LHCC-2003-01 | [
"Format",
"report",
"numbers",
"that",
"are",
"missing",
"a",
"dash"
] | d70e3787be3c495a3a07d1517b53f81d51c788c7 | https://github.com/inspirehep/refextract/blob/d70e3787be3c495a3a07d1517b53f81d51c788c7/refextract/references/engine.py#L171-L184 | train |
inspirehep/refextract | refextract/references/engine.py | format_hep | def format_hep(citation_elements):
"""Format hep-th report numbers with a dash
e.g. replaces hep-th-9711200 with hep-th/9711200
"""
prefixes = ('astro-ph-', 'hep-th-', 'hep-ph-', 'hep-ex-', 'hep-lat-',
'math-ph-')
for el in citation_elements:
if el['type'] == 'REPORTNUMBER':... | python | def format_hep(citation_elements):
"""Format hep-th report numbers with a dash
e.g. replaces hep-th-9711200 with hep-th/9711200
"""
prefixes = ('astro-ph-', 'hep-th-', 'hep-ph-', 'hep-ex-', 'hep-lat-',
'math-ph-')
for el in citation_elements:
if el['type'] == 'REPORTNUMBER':... | [
"def",
"format_hep",
"(",
"citation_elements",
")",
":",
"prefixes",
"=",
"(",
"'astro-ph-'",
",",
"'hep-th-'",
",",
"'hep-ph-'",
",",
"'hep-ex-'",
",",
"'hep-lat-'",
",",
"'math-ph-'",
")",
"for",
"el",
"in",
"citation_elements",
":",
"if",
"el",
"[",
"'typ... | Format hep-th report numbers with a dash
e.g. replaces hep-th-9711200 with hep-th/9711200 | [
"Format",
"hep",
"-",
"th",
"report",
"numbers",
"with",
"a",
"dash"
] | d70e3787be3c495a3a07d1517b53f81d51c788c7 | https://github.com/inspirehep/refextract/blob/d70e3787be3c495a3a07d1517b53f81d51c788c7/refextract/references/engine.py#L187-L200 | train |
inspirehep/refextract | refextract/references/engine.py | look_for_books | def look_for_books(citation_elements, kbs):
"""Look for books in our kb
Create book tags by using the authors and the title to find books
in our knowledge base
"""
title = None
for el in citation_elements:
if el['type'] == 'QUOTED':
title = el
break
if title... | python | def look_for_books(citation_elements, kbs):
"""Look for books in our kb
Create book tags by using the authors and the title to find books
in our knowledge base
"""
title = None
for el in citation_elements:
if el['type'] == 'QUOTED':
title = el
break
if title... | [
"def",
"look_for_books",
"(",
"citation_elements",
",",
"kbs",
")",
":",
"title",
"=",
"None",
"for",
"el",
"in",
"citation_elements",
":",
"if",
"el",
"[",
"'type'",
"]",
"==",
"'QUOTED'",
":",
"title",
"=",
"el",
"break",
"if",
"title",
":",
"normalize... | Look for books in our kb
Create book tags by using the authors and the title to find books
in our knowledge base | [
"Look",
"for",
"books",
"in",
"our",
"kb"
] | d70e3787be3c495a3a07d1517b53f81d51c788c7 | https://github.com/inspirehep/refextract/blob/d70e3787be3c495a3a07d1517b53f81d51c788c7/refextract/references/engine.py#L215-L239 | train |
inspirehep/refextract | refextract/references/engine.py | split_volume_from_journal | def split_volume_from_journal(citation_elements):
"""Split volume from journal title
We need this because sometimes the volume is attached to the journal title
instead of the volume. In those cases we move it here from the title to the
volume
"""
for el in citation_elements:
if el['type... | python | def split_volume_from_journal(citation_elements):
"""Split volume from journal title
We need this because sometimes the volume is attached to the journal title
instead of the volume. In those cases we move it here from the title to the
volume
"""
for el in citation_elements:
if el['type... | [
"def",
"split_volume_from_journal",
"(",
"citation_elements",
")",
":",
"for",
"el",
"in",
"citation_elements",
":",
"if",
"el",
"[",
"'type'",
"]",
"==",
"'JOURNAL'",
"and",
"';'",
"in",
"el",
"[",
"'title'",
"]",
":",
"el",
"[",
"'title'",
"]",
",",
"s... | Split volume from journal title
We need this because sometimes the volume is attached to the journal title
instead of the volume. In those cases we move it here from the title to the
volume | [
"Split",
"volume",
"from",
"journal",
"title"
] | d70e3787be3c495a3a07d1517b53f81d51c788c7 | https://github.com/inspirehep/refextract/blob/d70e3787be3c495a3a07d1517b53f81d51c788c7/refextract/references/engine.py#L242-L253 | train |
inspirehep/refextract | refextract/references/engine.py | remove_b_for_nucl_phys | def remove_b_for_nucl_phys(citation_elements):
"""Removes b from the volume of some journals
Removes the B from the volume for Nucl.Phys.Proc.Suppl. because in INSPIRE
that journal is handled differently.
"""
for el in citation_elements:
if el['type'] == 'JOURNAL' and el['title'] == 'Nucl.P... | python | def remove_b_for_nucl_phys(citation_elements):
"""Removes b from the volume of some journals
Removes the B from the volume for Nucl.Phys.Proc.Suppl. because in INSPIRE
that journal is handled differently.
"""
for el in citation_elements:
if el['type'] == 'JOURNAL' and el['title'] == 'Nucl.P... | [
"def",
"remove_b_for_nucl_phys",
"(",
"citation_elements",
")",
":",
"for",
"el",
"in",
"citation_elements",
":",
"if",
"el",
"[",
"'type'",
"]",
"==",
"'JOURNAL'",
"and",
"el",
"[",
"'title'",
"]",
"==",
"'Nucl.Phys.Proc.Suppl.'",
"and",
"'volume'",
"in",
"el... | Removes b from the volume of some journals
Removes the B from the volume for Nucl.Phys.Proc.Suppl. because in INSPIRE
that journal is handled differently. | [
"Removes",
"b",
"from",
"the",
"volume",
"of",
"some",
"journals"
] | d70e3787be3c495a3a07d1517b53f81d51c788c7 | https://github.com/inspirehep/refextract/blob/d70e3787be3c495a3a07d1517b53f81d51c788c7/refextract/references/engine.py#L256-L267 | train |
inspirehep/refextract | refextract/references/engine.py | mangle_volume | def mangle_volume(citation_elements):
"""Make sure the volume letter is before the volume number
e.g. transforms 100B to B100
"""
volume_re = re.compile(ur"(\d+)([A-Z])", re.U | re.I)
for el in citation_elements:
if el['type'] == 'JOURNAL':
matches = volume_re.match(el['volume']... | python | def mangle_volume(citation_elements):
"""Make sure the volume letter is before the volume number
e.g. transforms 100B to B100
"""
volume_re = re.compile(ur"(\d+)([A-Z])", re.U | re.I)
for el in citation_elements:
if el['type'] == 'JOURNAL':
matches = volume_re.match(el['volume']... | [
"def",
"mangle_volume",
"(",
"citation_elements",
")",
":",
"volume_re",
"=",
"re",
".",
"compile",
"(",
"ur\"(\\d+)([A-Z])\"",
",",
"re",
".",
"U",
"|",
"re",
".",
"I",
")",
"for",
"el",
"in",
"citation_elements",
":",
"if",
"el",
"[",
"'type'",
"]",
... | Make sure the volume letter is before the volume number
e.g. transforms 100B to B100 | [
"Make",
"sure",
"the",
"volume",
"letter",
"is",
"before",
"the",
"volume",
"number"
] | d70e3787be3c495a3a07d1517b53f81d51c788c7 | https://github.com/inspirehep/refextract/blob/d70e3787be3c495a3a07d1517b53f81d51c788c7/refextract/references/engine.py#L270-L282 | train |
inspirehep/refextract | refextract/references/engine.py | split_citations | def split_citations(citation_elements):
"""Split a citation line in multiple citations
We handle the case where the author has put 2 citations in the same line
but split with ; or some other method.
"""
splitted_citations = []
new_elements = []
current_recid = None
current_doi = None
... | python | def split_citations(citation_elements):
"""Split a citation line in multiple citations
We handle the case where the author has put 2 citations in the same line
but split with ; or some other method.
"""
splitted_citations = []
new_elements = []
current_recid = None
current_doi = None
... | [
"def",
"split_citations",
"(",
"citation_elements",
")",
":",
"splitted_citations",
"=",
"[",
"]",
"new_elements",
"=",
"[",
"]",
"current_recid",
"=",
"None",
"current_doi",
"=",
"None",
"def",
"check_ibid",
"(",
"current_elements",
",",
"trigger_el",
")",
":",... | Split a citation line in multiple citations
We handle the case where the author has put 2 citations in the same line
but split with ; or some other method. | [
"Split",
"a",
"citation",
"line",
"in",
"multiple",
"citations"
] | d70e3787be3c495a3a07d1517b53f81d51c788c7 | https://github.com/inspirehep/refextract/blob/d70e3787be3c495a3a07d1517b53f81d51c788c7/refextract/references/engine.py#L307-L383 | train |
inspirehep/refextract | refextract/references/engine.py | look_for_hdl | def look_for_hdl(citation_elements):
"""Looks for handle identifiers in the misc txt of the citation elements
When finding an hdl, creates a new HDL element.
@param citation_elements: (list) elements to process
"""
for el in list(citation_elements):
matched_hdl = re_hdl.finditer(el['m... | python | def look_for_hdl(citation_elements):
"""Looks for handle identifiers in the misc txt of the citation elements
When finding an hdl, creates a new HDL element.
@param citation_elements: (list) elements to process
"""
for el in list(citation_elements):
matched_hdl = re_hdl.finditer(el['m... | [
"def",
"look_for_hdl",
"(",
"citation_elements",
")",
":",
"for",
"el",
"in",
"list",
"(",
"citation_elements",
")",
":",
"matched_hdl",
"=",
"re_hdl",
".",
"finditer",
"(",
"el",
"[",
"'misc_txt'",
"]",
")",
"for",
"match",
"in",
"reversed",
"(",
"list",
... | Looks for handle identifiers in the misc txt of the citation elements
When finding an hdl, creates a new HDL element.
@param citation_elements: (list) elements to process | [
"Looks",
"for",
"handle",
"identifiers",
"in",
"the",
"misc",
"txt",
"of",
"the",
"citation",
"elements"
] | d70e3787be3c495a3a07d1517b53f81d51c788c7 | https://github.com/inspirehep/refextract/blob/d70e3787be3c495a3a07d1517b53f81d51c788c7/refextract/references/engine.py#L596-L609 | train |
inspirehep/refextract | refextract/references/engine.py | look_for_hdl_urls | def look_for_hdl_urls(citation_elements):
"""Looks for handle identifiers that have already been identified as urls
When finding an hdl, creates a new HDL element.
@param citation_elements: (list) elements to process
"""
for el in citation_elements:
if el['type'] == 'URL':
... | python | def look_for_hdl_urls(citation_elements):
"""Looks for handle identifiers that have already been identified as urls
When finding an hdl, creates a new HDL element.
@param citation_elements: (list) elements to process
"""
for el in citation_elements:
if el['type'] == 'URL':
... | [
"def",
"look_for_hdl_urls",
"(",
"citation_elements",
")",
":",
"for",
"el",
"in",
"citation_elements",
":",
"if",
"el",
"[",
"'type'",
"]",
"==",
"'URL'",
":",
"match",
"=",
"re_hdl",
".",
"match",
"(",
"el",
"[",
"'url_string'",
"]",
")",
"if",
"match"... | Looks for handle identifiers that have already been identified as urls
When finding an hdl, creates a new HDL element.
@param citation_elements: (list) elements to process | [
"Looks",
"for",
"handle",
"identifiers",
"that",
"have",
"already",
"been",
"identified",
"as",
"urls"
] | d70e3787be3c495a3a07d1517b53f81d51c788c7 | https://github.com/inspirehep/refextract/blob/d70e3787be3c495a3a07d1517b53f81d51c788c7/refextract/references/engine.py#L612-L625 | train |
inspirehep/refextract | refextract/references/engine.py | parse_reference_line | def parse_reference_line(ref_line, kbs, bad_titles_count={}, linker_callback=None):
"""Parse one reference line
@input a string representing a single reference bullet
@output parsed references (a list of elements objects)
"""
# Strip the 'marker' (e.g. [1]) from this reference line:
line_marker... | python | def parse_reference_line(ref_line, kbs, bad_titles_count={}, linker_callback=None):
"""Parse one reference line
@input a string representing a single reference bullet
@output parsed references (a list of elements objects)
"""
# Strip the 'marker' (e.g. [1]) from this reference line:
line_marker... | [
"def",
"parse_reference_line",
"(",
"ref_line",
",",
"kbs",
",",
"bad_titles_count",
"=",
"{",
"}",
",",
"linker_callback",
"=",
"None",
")",
":",
"line_marker",
",",
"ref_line",
"=",
"remove_reference_line_marker",
"(",
"ref_line",
")",
"ref_line",
",",
"identi... | Parse one reference line
@input a string representing a single reference bullet
@output parsed references (a list of elements objects) | [
"Parse",
"one",
"reference",
"line"
] | d70e3787be3c495a3a07d1517b53f81d51c788c7 | https://github.com/inspirehep/refextract/blob/d70e3787be3c495a3a07d1517b53f81d51c788c7/refextract/references/engine.py#L639-L716 | train |
inspirehep/refextract | refextract/references/engine.py | search_for_book_in_misc | def search_for_book_in_misc(citation, kbs):
"""Searches for books in the misc_txt field if the citation is not recognized as anything like a journal, book, etc.
"""
citation_year = year_from_citation(citation)
for citation_element in citation:
LOGGER.debug(u"Searching for book title in: %s", cit... | python | def search_for_book_in_misc(citation, kbs):
"""Searches for books in the misc_txt field if the citation is not recognized as anything like a journal, book, etc.
"""
citation_year = year_from_citation(citation)
for citation_element in citation:
LOGGER.debug(u"Searching for book title in: %s", cit... | [
"def",
"search_for_book_in_misc",
"(",
"citation",
",",
"kbs",
")",
":",
"citation_year",
"=",
"year_from_citation",
"(",
"citation",
")",
"for",
"citation_element",
"in",
"citation",
":",
"LOGGER",
".",
"debug",
"(",
"u\"Searching for book title in: %s\"",
",",
"ci... | Searches for books in the misc_txt field if the citation is not recognized as anything like a journal, book, etc. | [
"Searches",
"for",
"books",
"in",
"the",
"misc_txt",
"field",
"if",
"the",
"citation",
"is",
"not",
"recognized",
"as",
"anything",
"like",
"a",
"journal",
"book",
"etc",
"."
] | d70e3787be3c495a3a07d1517b53f81d51c788c7 | https://github.com/inspirehep/refextract/blob/d70e3787be3c495a3a07d1517b53f81d51c788c7/refextract/references/engine.py#L736-L779 | train |
inspirehep/refextract | refextract/references/engine.py | map_tag_to_subfield | def map_tag_to_subfield(tag_type, line, cur_misc_txt, dest):
"""Create a new reference element"""
closing_tag = '</cds.%s>' % tag_type
# extract the institutional report-number from the line:
idx_closing_tag = line.find(closing_tag)
# Sanity check - did we find a closing tag?
if idx_closing_tag ... | python | def map_tag_to_subfield(tag_type, line, cur_misc_txt, dest):
"""Create a new reference element"""
closing_tag = '</cds.%s>' % tag_type
# extract the institutional report-number from the line:
idx_closing_tag = line.find(closing_tag)
# Sanity check - did we find a closing tag?
if idx_closing_tag ... | [
"def",
"map_tag_to_subfield",
"(",
"tag_type",
",",
"line",
",",
"cur_misc_txt",
",",
"dest",
")",
":",
"closing_tag",
"=",
"'</cds.%s>'",
"%",
"tag_type",
"idx_closing_tag",
"=",
"line",
".",
"find",
"(",
"closing_tag",
")",
"if",
"idx_closing_tag",
"==",
"-"... | Create a new reference element | [
"Create",
"a",
"new",
"reference",
"element"
] | d70e3787be3c495a3a07d1517b53f81d51c788c7 | https://github.com/inspirehep/refextract/blob/d70e3787be3c495a3a07d1517b53f81d51c788c7/refextract/references/engine.py#L1292-L1312 | train |
inspirehep/refextract | refextract/references/engine.py | remove_leading_garbage_lines_from_reference_section | def remove_leading_garbage_lines_from_reference_section(ref_sectn):
"""Sometimes, the first lines of the extracted references are completely
blank or email addresses. These must be removed as they are not
references.
@param ref_sectn: (list) of strings - the reference section lines
@retu... | python | def remove_leading_garbage_lines_from_reference_section(ref_sectn):
"""Sometimes, the first lines of the extracted references are completely
blank or email addresses. These must be removed as they are not
references.
@param ref_sectn: (list) of strings - the reference section lines
@retu... | [
"def",
"remove_leading_garbage_lines_from_reference_section",
"(",
"ref_sectn",
")",
":",
"p_email",
"=",
"re",
".",
"compile",
"(",
"ur'^\\s*e\\-?mail'",
",",
"re",
".",
"UNICODE",
")",
"while",
"ref_sectn",
"and",
"(",
"ref_sectn",
"[",
"0",
"]",
".",
"isspace... | Sometimes, the first lines of the extracted references are completely
blank or email addresses. These must be removed as they are not
references.
@param ref_sectn: (list) of strings - the reference section lines
@return: (list) of strings - the reference section without leading
blank... | [
"Sometimes",
"the",
"first",
"lines",
"of",
"the",
"extracted",
"references",
"are",
"completely",
"blank",
"or",
"email",
"addresses",
".",
"These",
"must",
"be",
"removed",
"as",
"they",
"are",
"not",
"references",
"."
] | d70e3787be3c495a3a07d1517b53f81d51c788c7 | https://github.com/inspirehep/refextract/blob/d70e3787be3c495a3a07d1517b53f81d51c788c7/refextract/references/engine.py#L1364-L1375 | train |
inspirehep/refextract | refextract/references/engine.py | get_plaintext_document_body | def get_plaintext_document_body(fpath, keep_layout=False):
"""Given a file-path to a full-text, return a list of unicode strings
whereby each string is a line of the fulltext.
In the case of a plain-text document, this simply means reading the
contents in from the file. In the case of a PDF how... | python | def get_plaintext_document_body(fpath, keep_layout=False):
"""Given a file-path to a full-text, return a list of unicode strings
whereby each string is a line of the fulltext.
In the case of a plain-text document, this simply means reading the
contents in from the file. In the case of a PDF how... | [
"def",
"get_plaintext_document_body",
"(",
"fpath",
",",
"keep_layout",
"=",
"False",
")",
":",
"textbody",
"=",
"[",
"]",
"mime_type",
"=",
"magic",
".",
"from_file",
"(",
"fpath",
",",
"mime",
"=",
"True",
")",
"if",
"mime_type",
"==",
"\"text/plain\"",
... | Given a file-path to a full-text, return a list of unicode strings
whereby each string is a line of the fulltext.
In the case of a plain-text document, this simply means reading the
contents in from the file. In the case of a PDF however,
this means converting the document to plaintext.
... | [
"Given",
"a",
"file",
"-",
"path",
"to",
"a",
"full",
"-",
"text",
"return",
"a",
"list",
"of",
"unicode",
"strings",
"whereby",
"each",
"string",
"is",
"a",
"line",
"of",
"the",
"fulltext",
".",
"In",
"the",
"case",
"of",
"a",
"plain",
"-",
"text",
... | d70e3787be3c495a3a07d1517b53f81d51c788c7 | https://github.com/inspirehep/refextract/blob/d70e3787be3c495a3a07d1517b53f81d51c788c7/refextract/references/engine.py#L1384-L1408 | train |
inspirehep/refextract | refextract/references/engine.py | parse_references | def parse_references(reference_lines,
recid=None,
override_kbs_files=None,
reference_format=u"{title} {volume} ({year}) {page}",
linker_callback=None):
"""Parse a list of references
Given a list of raw reference lines (list of ... | python | def parse_references(reference_lines,
recid=None,
override_kbs_files=None,
reference_format=u"{title} {volume} ({year}) {page}",
linker_callback=None):
"""Parse a list of references
Given a list of raw reference lines (list of ... | [
"def",
"parse_references",
"(",
"reference_lines",
",",
"recid",
"=",
"None",
",",
"override_kbs_files",
"=",
"None",
",",
"reference_format",
"=",
"u\"{title} {volume} ({year}) {page}\"",
",",
"linker_callback",
"=",
"None",
")",
":",
"kbs",
"=",
"get_kbs",
"(",
... | Parse a list of references
Given a list of raw reference lines (list of strings),
output a list of dictionaries containing the parsed references | [
"Parse",
"a",
"list",
"of",
"references"
] | d70e3787be3c495a3a07d1517b53f81d51c788c7 | https://github.com/inspirehep/refextract/blob/d70e3787be3c495a3a07d1517b53f81d51c788c7/refextract/references/engine.py#L1411-L1428 | train |
inspirehep/refextract | refextract/references/engine.py | build_stats | def build_stats(counts):
"""Return stats information from counts structure."""
stats = {
'status': 0,
'reportnum': counts['reportnum'],
'title': counts['title'],
'author': counts['auth_group'],
'url': counts['url'],
'doi': counts['doi'],
'misc': counts['mi... | python | def build_stats(counts):
"""Return stats information from counts structure."""
stats = {
'status': 0,
'reportnum': counts['reportnum'],
'title': counts['title'],
'author': counts['auth_group'],
'url': counts['url'],
'doi': counts['doi'],
'misc': counts['mi... | [
"def",
"build_stats",
"(",
"counts",
")",
":",
"stats",
"=",
"{",
"'status'",
":",
"0",
",",
"'reportnum'",
":",
"counts",
"[",
"'reportnum'",
"]",
",",
"'title'",
":",
"counts",
"[",
"'title'",
"]",
",",
"'author'",
":",
"counts",
"[",
"'auth_group'",
... | Return stats information from counts structure. | [
"Return",
"stats",
"information",
"from",
"counts",
"structure",
"."
] | d70e3787be3c495a3a07d1517b53f81d51c788c7 | https://github.com/inspirehep/refextract/blob/d70e3787be3c495a3a07d1517b53f81d51c788c7/refextract/references/engine.py#L1431-L1446 | train |
inspirehep/refextract | refextract/documents/pdf.py | replace_undesirable_characters | def replace_undesirable_characters(line):
"""
Replace certain bad characters in a text line.
@param line: (string) the text line in which bad characters are to
be replaced.
@return: (string) the text line after the bad characters have been
replaced.
"""
# T... | python | def replace_undesirable_characters(line):
"""
Replace certain bad characters in a text line.
@param line: (string) the text line in which bad characters are to
be replaced.
@return: (string) the text line after the bad characters have been
replaced.
"""
# T... | [
"def",
"replace_undesirable_characters",
"(",
"line",
")",
":",
"for",
"bad_string",
",",
"replacement",
"in",
"UNDESIRABLE_STRING_REPLACEMENTS",
":",
"line",
"=",
"line",
".",
"replace",
"(",
"bad_string",
",",
"replacement",
")",
"for",
"bad_char",
",",
"replace... | Replace certain bad characters in a text line.
@param line: (string) the text line in which bad characters are to
be replaced.
@return: (string) the text line after the bad characters have been
replaced. | [
"Replace",
"certain",
"bad",
"characters",
"in",
"a",
"text",
"line",
"."
] | d70e3787be3c495a3a07d1517b53f81d51c788c7 | https://github.com/inspirehep/refextract/blob/d70e3787be3c495a3a07d1517b53f81d51c788c7/refextract/documents/pdf.py#L434-L449 | train |
inspirehep/refextract | refextract/documents/pdf.py | convert_PDF_to_plaintext | def convert_PDF_to_plaintext(fpath, keep_layout=False):
""" Convert PDF to txt using pdftotext
Take the path to a PDF file and run pdftotext for this file, capturing
the output.
@param fpath: (string) path to the PDF file
@return: (list) of unicode strings (contents of the PDF file translated
i... | python | def convert_PDF_to_plaintext(fpath, keep_layout=False):
""" Convert PDF to txt using pdftotext
Take the path to a PDF file and run pdftotext for this file, capturing
the output.
@param fpath: (string) path to the PDF file
@return: (list) of unicode strings (contents of the PDF file translated
i... | [
"def",
"convert_PDF_to_plaintext",
"(",
"fpath",
",",
"keep_layout",
"=",
"False",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"CFG_PATH_PDFTOTEXT",
")",
":",
"raise",
"IOError",
"(",
"'Missing pdftotext executable'",
")",
"if",
"keep_layout",
... | Convert PDF to txt using pdftotext
Take the path to a PDF file and run pdftotext for this file, capturing
the output.
@param fpath: (string) path to the PDF file
@return: (list) of unicode strings (contents of the PDF file translated
into plaintext; each string is a line in the document.) | [
"Convert",
"PDF",
"to",
"txt",
"using",
"pdftotext"
] | d70e3787be3c495a3a07d1517b53f81d51c788c7 | https://github.com/inspirehep/refextract/blob/d70e3787be3c495a3a07d1517b53f81d51c788c7/refextract/documents/pdf.py#L452-L499 | train |
inspirehep/refextract | refextract/authors/regexs.py | get_author_affiliation_numeration_str | def get_author_affiliation_numeration_str(punct=None):
"""The numeration which can be applied to author names. Numeration
is sometimes found next to authors of papers.
@return: (string), which can be compiled into a regex; identifies
numeration next to an author name.
"""
# FIXME cater for star... | python | def get_author_affiliation_numeration_str(punct=None):
"""The numeration which can be applied to author names. Numeration
is sometimes found next to authors of papers.
@return: (string), which can be compiled into a regex; identifies
numeration next to an author name.
"""
# FIXME cater for star... | [
"def",
"get_author_affiliation_numeration_str",
"(",
"punct",
"=",
"None",
")",
":",
"re_number",
"=",
"r'(?:\\d\\d?)'",
"re_chained_numbers",
"=",
"r\"(?:(?:[,;]\\s*%s\\.?\\s*))*\"",
"%",
"re_number",
"if",
"punct",
"is",
"None",
":",
"re_punct",
"=",
"r\"(?:[\\{\\(\\[... | The numeration which can be applied to author names. Numeration
is sometimes found next to authors of papers.
@return: (string), which can be compiled into a regex; identifies
numeration next to an author name. | [
"The",
"numeration",
"which",
"can",
"be",
"applied",
"to",
"author",
"names",
".",
"Numeration",
"is",
"sometimes",
"found",
"next",
"to",
"authors",
"of",
"papers",
"."
] | d70e3787be3c495a3a07d1517b53f81d51c788c7 | https://github.com/inspirehep/refextract/blob/d70e3787be3c495a3a07d1517b53f81d51c788c7/refextract/authors/regexs.py#L36-L64 | train |
inspirehep/refextract | refextract/authors/regexs.py | make_auth_regex_str | def make_auth_regex_str(etal, initial_surname_author=None, surname_initial_author=None):
"""
Returns a regular expression to be used to identify groups of author names in a citation.
This method contains patterns for default authors, so no arguments are needed for the
most reliable form of m... | python | def make_auth_regex_str(etal, initial_surname_author=None, surname_initial_author=None):
"""
Returns a regular expression to be used to identify groups of author names in a citation.
This method contains patterns for default authors, so no arguments are needed for the
most reliable form of m... | [
"def",
"make_auth_regex_str",
"(",
"etal",
",",
"initial_surname_author",
"=",
"None",
",",
"surname_initial_author",
"=",
"None",
")",
":",
"if",
"not",
"initial_surname_author",
":",
"initial_surname_author",
"=",
"get_initial_surname_author_pattern",
"(",
")",
"if",
... | Returns a regular expression to be used to identify groups of author names in a citation.
This method contains patterns for default authors, so no arguments are needed for the
most reliable form of matching.
The returned author pattern is capable of:
1. Identifying single authors, with ... | [
"Returns",
"a",
"regular",
"expression",
"to",
"be",
"used",
"to",
"identify",
"groups",
"of",
"author",
"names",
"in",
"a",
"citation",
".",
"This",
"method",
"contains",
"patterns",
"for",
"default",
"authors",
"so",
"no",
"arguments",
"are",
"needed",
"fo... | d70e3787be3c495a3a07d1517b53f81d51c788c7 | https://github.com/inspirehep/refextract/blob/d70e3787be3c495a3a07d1517b53f81d51c788c7/refextract/authors/regexs.py#L192-L350 | train |
inspirehep/refextract | refextract/references/find.py | find_reference_section | def find_reference_section(docbody):
"""Search in document body for its reference section.
More precisely, find
the first line of the reference section. Effectively, the function starts
at the end of a document and works backwards, line-by-line, looking for
the title of a reference section. It stop... | python | def find_reference_section(docbody):
"""Search in document body for its reference section.
More precisely, find
the first line of the reference section. Effectively, the function starts
at the end of a document and works backwards, line-by-line, looking for
the title of a reference section. It stop... | [
"def",
"find_reference_section",
"(",
"docbody",
")",
":",
"ref_details",
"=",
"None",
"title_patterns",
"=",
"get_reference_section_title_patterns",
"(",
")",
"for",
"title_pattern",
"in",
"title_patterns",
":",
"for",
"reversed_index",
",",
"line",
"in",
"enumerate"... | Search in document body for its reference section.
More precisely, find
the first line of the reference section. Effectively, the function starts
at the end of a document and works backwards, line-by-line, looking for
the title of a reference section. It stops when (if) it finds something
that it c... | [
"Search",
"in",
"document",
"body",
"for",
"its",
"reference",
"section",
"."
] | d70e3787be3c495a3a07d1517b53f81d51c788c7 | https://github.com/inspirehep/refextract/blob/d70e3787be3c495a3a07d1517b53f81d51c788c7/refextract/references/find.py#L45-L97 | train |
inspirehep/refextract | refextract/references/find.py | find_numeration | def find_numeration(docbody, title):
"""Find numeration pattern
1st try to find numeration in the title
e.g.
References [4] Riotto...
2nd find the numeration alone in the line after the title
e.g.
References
1
Riotto
3rnd find the numeration in the following line
e.g.
... | python | def find_numeration(docbody, title):
"""Find numeration pattern
1st try to find numeration in the title
e.g.
References [4] Riotto...
2nd find the numeration alone in the line after the title
e.g.
References
1
Riotto
3rnd find the numeration in the following line
e.g.
... | [
"def",
"find_numeration",
"(",
"docbody",
",",
"title",
")",
":",
"ref_details",
",",
"found_title",
"=",
"find_numeration_in_title",
"(",
"docbody",
",",
"title",
")",
"if",
"not",
"ref_details",
":",
"ref_details",
",",
"found_title",
"=",
"find_numeration_in_bo... | Find numeration pattern
1st try to find numeration in the title
e.g.
References [4] Riotto...
2nd find the numeration alone in the line after the title
e.g.
References
1
Riotto
3rnd find the numeration in the following line
e.g.
References
[1] Riotto | [
"Find",
"numeration",
"pattern"
] | d70e3787be3c495a3a07d1517b53f81d51c788c7 | https://github.com/inspirehep/refextract/blob/d70e3787be3c495a3a07d1517b53f81d51c788c7/refextract/references/find.py#L181-L203 | train |
inspirehep/refextract | refextract/references/text.py | get_reference_lines | def get_reference_lines(docbody,
ref_sect_start_line,
ref_sect_end_line,
ref_sect_title,
ref_line_marker_ptn,
title_marker_same_line):
"""After the reference section of a document has been identif... | python | def get_reference_lines(docbody,
ref_sect_start_line,
ref_sect_end_line,
ref_sect_title,
ref_line_marker_ptn,
title_marker_same_line):
"""After the reference section of a document has been identif... | [
"def",
"get_reference_lines",
"(",
"docbody",
",",
"ref_sect_start_line",
",",
"ref_sect_end_line",
",",
"ref_sect_title",
",",
"ref_line_marker_ptn",
",",
"title_marker_same_line",
")",
":",
"start_idx",
"=",
"ref_sect_start_line",
"if",
"title_marker_same_line",
":",
"t... | After the reference section of a document has been identified, and the
first and last lines of the reference section have been recorded, this
function is called to take the reference lines out of the document body.
The document's reference lines are returned in a list of strings whereby
each... | [
"After",
"the",
"reference",
"section",
"of",
"a",
"document",
"has",
"been",
"identified",
"and",
"the",
"first",
"and",
"last",
"lines",
"of",
"the",
"reference",
"section",
"have",
"been",
"recorded",
"this",
"function",
"is",
"called",
"to",
"take",
"the... | d70e3787be3c495a3a07d1517b53f81d51c788c7 | https://github.com/inspirehep/refextract/blob/d70e3787be3c495a3a07d1517b53f81d51c788c7/refextract/references/text.py#L91-L142 | train |
inspirehep/refextract | refextract/references/text.py | match_pagination | def match_pagination(ref_line):
"""Remove footer pagination from references lines"""
pattern = ur'\(?\[?(\d{1,4})\]?\)?\.?\s*$'
re_footer = re.compile(pattern, re.UNICODE)
match = re_footer.match(ref_line)
if match:
return int(match.group(1))
return None | python | def match_pagination(ref_line):
"""Remove footer pagination from references lines"""
pattern = ur'\(?\[?(\d{1,4})\]?\)?\.?\s*$'
re_footer = re.compile(pattern, re.UNICODE)
match = re_footer.match(ref_line)
if match:
return int(match.group(1))
return None | [
"def",
"match_pagination",
"(",
"ref_line",
")",
":",
"pattern",
"=",
"ur'\\(?\\[?(\\d{1,4})\\]?\\)?\\.?\\s*$'",
"re_footer",
"=",
"re",
".",
"compile",
"(",
"pattern",
",",
"re",
".",
"UNICODE",
")",
"match",
"=",
"re_footer",
".",
"match",
"(",
"ref_line",
"... | Remove footer pagination from references lines | [
"Remove",
"footer",
"pagination",
"from",
"references",
"lines"
] | d70e3787be3c495a3a07d1517b53f81d51c788c7 | https://github.com/inspirehep/refextract/blob/d70e3787be3c495a3a07d1517b53f81d51c788c7/refextract/references/text.py#L145-L152 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.