partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | getObject | Returns an object for a specific date and
location. | flatlib/ephem/eph.py | def getObject(ID, jd, lat, lon):
""" Returns an object for a specific date and
location.
"""
if ID == const.SOUTH_NODE:
obj = swe.sweObject(const.NORTH_NODE, jd)
obj.update({
'id': const.SOUTH_NODE,
'lon': angle.norm(obj['lon'] + 180)
})
elif ID ... | def getObject(ID, jd, lat, lon):
""" Returns an object for a specific date and
location.
"""
if ID == const.SOUTH_NODE:
obj = swe.sweObject(const.NORTH_NODE, jd)
obj.update({
'id': const.SOUTH_NODE,
'lon': angle.norm(obj['lon'] + 180)
})
elif ID ... | [
"Returns",
"an",
"object",
"for",
"a",
"specific",
"date",
"and",
"location",
"."
] | flatangle/flatlib | python | https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/ephem/eph.py#L23-L51 | [
"def",
"getObject",
"(",
"ID",
",",
"jd",
",",
"lat",
",",
"lon",
")",
":",
"if",
"ID",
"==",
"const",
".",
"SOUTH_NODE",
":",
"obj",
"=",
"swe",
".",
"sweObject",
"(",
"const",
".",
"NORTH_NODE",
",",
"jd",
")",
"obj",
".",
"update",
"(",
"{",
... | 44e05b2991a296c678adbc17a1d51b6a21bc867c |
train | getHouses | Returns lists of houses and angles. | flatlib/ephem/eph.py | def getHouses(jd, lat, lon, hsys):
""" Returns lists of houses and angles. """
houses, angles = swe.sweHouses(jd, lat, lon, hsys)
for house in houses:
_signInfo(house)
for angle in angles:
_signInfo(angle)
return (houses, angles) | def getHouses(jd, lat, lon, hsys):
""" Returns lists of houses and angles. """
houses, angles = swe.sweHouses(jd, lat, lon, hsys)
for house in houses:
_signInfo(house)
for angle in angles:
_signInfo(angle)
return (houses, angles) | [
"Returns",
"lists",
"of",
"houses",
"and",
"angles",
"."
] | flatangle/flatlib | python | https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/ephem/eph.py#L56-L63 | [
"def",
"getHouses",
"(",
"jd",
",",
"lat",
",",
"lon",
",",
"hsys",
")",
":",
"houses",
",",
"angles",
"=",
"swe",
".",
"sweHouses",
"(",
"jd",
",",
"lat",
",",
"lon",
",",
"hsys",
")",
"for",
"house",
"in",
"houses",
":",
"_signInfo",
"(",
"hous... | 44e05b2991a296c678adbc17a1d51b6a21bc867c |
train | getFixedStar | Returns a fixed star. | flatlib/ephem/eph.py | def getFixedStar(ID, jd):
""" Returns a fixed star. """
star = swe.sweFixedStar(ID, jd)
_signInfo(star)
return star | def getFixedStar(ID, jd):
""" Returns a fixed star. """
star = swe.sweFixedStar(ID, jd)
_signInfo(star)
return star | [
"Returns",
"a",
"fixed",
"star",
"."
] | flatangle/flatlib | python | https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/ephem/eph.py#L68-L72 | [
"def",
"getFixedStar",
"(",
"ID",
",",
"jd",
")",
":",
"star",
"=",
"swe",
".",
"sweFixedStar",
"(",
"ID",
",",
"jd",
")",
"_signInfo",
"(",
"star",
")",
"return",
"star"
] | 44e05b2991a296c678adbc17a1d51b6a21bc867c |
train | nextSunrise | Returns the JD of the next sunrise. | flatlib/ephem/eph.py | def nextSunrise(jd, lat, lon):
""" Returns the JD of the next sunrise. """
return swe.sweNextTransit(const.SUN, jd, lat, lon, 'RISE') | def nextSunrise(jd, lat, lon):
""" Returns the JD of the next sunrise. """
return swe.sweNextTransit(const.SUN, jd, lat, lon, 'RISE') | [
"Returns",
"the",
"JD",
"of",
"the",
"next",
"sunrise",
"."
] | flatangle/flatlib | python | https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/ephem/eph.py#L88-L90 | [
"def",
"nextSunrise",
"(",
"jd",
",",
"lat",
",",
"lon",
")",
":",
"return",
"swe",
".",
"sweNextTransit",
"(",
"const",
".",
"SUN",
",",
"jd",
",",
"lat",
",",
"lon",
",",
"'RISE'",
")"
] | 44e05b2991a296c678adbc17a1d51b6a21bc867c |
train | nextSunset | Returns the JD of the next sunset. | flatlib/ephem/eph.py | def nextSunset(jd, lat, lon):
""" Returns the JD of the next sunset. """
return swe.sweNextTransit(const.SUN, jd, lat, lon, 'SET') | def nextSunset(jd, lat, lon):
""" Returns the JD of the next sunset. """
return swe.sweNextTransit(const.SUN, jd, lat, lon, 'SET') | [
"Returns",
"the",
"JD",
"of",
"the",
"next",
"sunset",
"."
] | flatangle/flatlib | python | https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/ephem/eph.py#L92-L94 | [
"def",
"nextSunset",
"(",
"jd",
",",
"lat",
",",
"lon",
")",
":",
"return",
"swe",
".",
"sweNextTransit",
"(",
"const",
".",
"SUN",
",",
"jd",
",",
"lat",
",",
"lon",
",",
"'SET'",
")"
] | 44e05b2991a296c678adbc17a1d51b6a21bc867c |
train | _signInfo | Appends the sign id and longitude to an object. | flatlib/ephem/eph.py | def _signInfo(obj):
""" Appends the sign id and longitude to an object. """
lon = obj['lon']
obj.update({
'sign': const.LIST_SIGNS[int(lon / 30)],
'signlon': lon % 30
}) | def _signInfo(obj):
""" Appends the sign id and longitude to an object. """
lon = obj['lon']
obj.update({
'sign': const.LIST_SIGNS[int(lon / 30)],
'signlon': lon % 30
}) | [
"Appends",
"the",
"sign",
"id",
"and",
"longitude",
"to",
"an",
"object",
"."
] | flatangle/flatlib | python | https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/ephem/eph.py#L114-L120 | [
"def",
"_signInfo",
"(",
"obj",
")",
":",
"lon",
"=",
"obj",
"[",
"'lon'",
"]",
"obj",
".",
"update",
"(",
"{",
"'sign'",
":",
"const",
".",
"LIST_SIGNS",
"[",
"int",
"(",
"lon",
"/",
"30",
")",
"]",
",",
"'signlon'",
":",
"lon",
"%",
"30",
"}"... | 44e05b2991a296c678adbc17a1d51b6a21bc867c |
train | pfLon | Returns the ecliptic longitude of Pars Fortuna.
It considers diurnal or nocturnal conditions. | flatlib/ephem/tools.py | def pfLon(jd, lat, lon):
""" Returns the ecliptic longitude of Pars Fortuna.
It considers diurnal or nocturnal conditions.
"""
sun = swe.sweObjectLon(const.SUN, jd)
moon = swe.sweObjectLon(const.MOON, jd)
asc = swe.sweHousesLon(jd, lat, lon,
const.HOUSES_DEFAULT)[... | def pfLon(jd, lat, lon):
""" Returns the ecliptic longitude of Pars Fortuna.
It considers diurnal or nocturnal conditions.
"""
sun = swe.sweObjectLon(const.SUN, jd)
moon = swe.sweObjectLon(const.MOON, jd)
asc = swe.sweHousesLon(jd, lat, lon,
const.HOUSES_DEFAULT)[... | [
"Returns",
"the",
"ecliptic",
"longitude",
"of",
"Pars",
"Fortuna",
".",
"It",
"considers",
"diurnal",
"or",
"nocturnal",
"conditions",
"."
] | flatangle/flatlib | python | https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/ephem/tools.py#L23-L36 | [
"def",
"pfLon",
"(",
"jd",
",",
"lat",
",",
"lon",
")",
":",
"sun",
"=",
"swe",
".",
"sweObjectLon",
"(",
"const",
".",
"SUN",
",",
"jd",
")",
"moon",
"=",
"swe",
".",
"sweObjectLon",
"(",
"const",
".",
"MOON",
",",
"jd",
")",
"asc",
"=",
"swe"... | 44e05b2991a296c678adbc17a1d51b6a21bc867c |
train | isDiurnal | Returns true if the sun is above the horizon
of a given date and location. | flatlib/ephem/tools.py | def isDiurnal(jd, lat, lon):
""" Returns true if the sun is above the horizon
of a given date and location.
"""
sun = swe.sweObject(const.SUN, jd)
mc = swe.sweHousesLon(jd, lat, lon,
const.HOUSES_DEFAULT)[1][1]
ra, decl = utils.eqCoords(sun['lon'], sun['lat'])
... | def isDiurnal(jd, lat, lon):
""" Returns true if the sun is above the horizon
of a given date and location.
"""
sun = swe.sweObject(const.SUN, jd)
mc = swe.sweHousesLon(jd, lat, lon,
const.HOUSES_DEFAULT)[1][1]
ra, decl = utils.eqCoords(sun['lon'], sun['lat'])
... | [
"Returns",
"true",
"if",
"the",
"sun",
"is",
"above",
"the",
"horizon",
"of",
"a",
"given",
"date",
"and",
"location",
"."
] | flatangle/flatlib | python | https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/ephem/tools.py#L41-L51 | [
"def",
"isDiurnal",
"(",
"jd",
",",
"lat",
",",
"lon",
")",
":",
"sun",
"=",
"swe",
".",
"sweObject",
"(",
"const",
".",
"SUN",
",",
"jd",
")",
"mc",
"=",
"swe",
".",
"sweHousesLon",
"(",
"jd",
",",
"lat",
",",
"lon",
",",
"const",
".",
"HOUSES... | 44e05b2991a296c678adbc17a1d51b6a21bc867c |
train | syzygyJD | Finds the latest new or full moon and
returns the julian date of that event. | flatlib/ephem/tools.py | def syzygyJD(jd):
""" Finds the latest new or full moon and
returns the julian date of that event.
"""
sun = swe.sweObjectLon(const.SUN, jd)
moon = swe.sweObjectLon(const.MOON, jd)
dist = angle.distance(sun, moon)
# Offset represents the Syzygy type.
# Zero is conjunction and... | def syzygyJD(jd):
""" Finds the latest new or full moon and
returns the julian date of that event.
"""
sun = swe.sweObjectLon(const.SUN, jd)
moon = swe.sweObjectLon(const.MOON, jd)
dist = angle.distance(sun, moon)
# Offset represents the Syzygy type.
# Zero is conjunction and... | [
"Finds",
"the",
"latest",
"new",
"or",
"full",
"moon",
"and",
"returns",
"the",
"julian",
"date",
"of",
"that",
"event",
"."
] | flatangle/flatlib | python | https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/ephem/tools.py#L56-L73 | [
"def",
"syzygyJD",
"(",
"jd",
")",
":",
"sun",
"=",
"swe",
".",
"sweObjectLon",
"(",
"const",
".",
"SUN",
",",
"jd",
")",
"moon",
"=",
"swe",
".",
"sweObjectLon",
"(",
"const",
".",
"MOON",
",",
"jd",
")",
"dist",
"=",
"angle",
".",
"distance",
"... | 44e05b2991a296c678adbc17a1d51b6a21bc867c |
train | solarReturnJD | Finds the julian date before or after
'jd' when the sun is at longitude 'lon'.
It searches forward by default. | flatlib/ephem/tools.py | def solarReturnJD(jd, lon, forward=True):
""" Finds the julian date before or after
'jd' when the sun is at longitude 'lon'.
It searches forward by default.
"""
sun = swe.sweObjectLon(const.SUN, jd)
if forward:
dist = angle.distance(sun, lon)
else:
dist = -angle.distan... | def solarReturnJD(jd, lon, forward=True):
""" Finds the julian date before or after
'jd' when the sun is at longitude 'lon'.
It searches forward by default.
"""
sun = swe.sweObjectLon(const.SUN, jd)
if forward:
dist = angle.distance(sun, lon)
else:
dist = -angle.distan... | [
"Finds",
"the",
"julian",
"date",
"before",
"or",
"after",
"jd",
"when",
"the",
"sun",
"is",
"at",
"longitude",
"lon",
".",
"It",
"searches",
"forward",
"by",
"default",
"."
] | flatangle/flatlib | python | https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/ephem/tools.py#L75-L91 | [
"def",
"solarReturnJD",
"(",
"jd",
",",
"lon",
",",
"forward",
"=",
"True",
")",
":",
"sun",
"=",
"swe",
".",
"sweObjectLon",
"(",
"const",
".",
"SUN",
",",
"jd",
")",
"if",
"forward",
":",
"dist",
"=",
"angle",
".",
"distance",
"(",
"sun",
",",
... | 44e05b2991a296c678adbc17a1d51b6a21bc867c |
train | nextStationJD | Finds the aproximate julian date of the
next station of a planet. | flatlib/ephem/tools.py | def nextStationJD(ID, jd):
""" Finds the aproximate julian date of the
next station of a planet.
"""
speed = swe.sweObject(ID, jd)['lonspeed']
for i in range(2000):
nextjd = jd + i / 2
nextspeed = swe.sweObject(ID, nextjd)['lonspeed']
if speed * nextspeed <= 0:
r... | def nextStationJD(ID, jd):
""" Finds the aproximate julian date of the
next station of a planet.
"""
speed = swe.sweObject(ID, jd)['lonspeed']
for i in range(2000):
nextjd = jd + i / 2
nextspeed = swe.sweObject(ID, nextjd)['lonspeed']
if speed * nextspeed <= 0:
r... | [
"Finds",
"the",
"aproximate",
"julian",
"date",
"of",
"the",
"next",
"station",
"of",
"a",
"planet",
"."
] | flatangle/flatlib | python | https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/ephem/tools.py#L96-L107 | [
"def",
"nextStationJD",
"(",
"ID",
",",
"jd",
")",
":",
"speed",
"=",
"swe",
".",
"sweObject",
"(",
"ID",
",",
"jd",
")",
"[",
"'lonspeed'",
"]",
"for",
"i",
"in",
"range",
"(",
"2000",
")",
":",
"nextjd",
"=",
"jd",
"+",
"i",
"/",
"2",
"nextsp... | 44e05b2991a296c678adbc17a1d51b6a21bc867c |
train | clean_caches | Removes all python cache files recursively on a path.
:param path: the path
:return: None | scripts/utils.py | def clean_caches(path):
"""
Removes all python cache files recursively on a path.
:param path: the path
:return: None
"""
for dirname, subdirlist, filelist in os.walk(path):
for f in filelist:
if f.endswith('pyc'):
try:
os.remove(os.path... | def clean_caches(path):
"""
Removes all python cache files recursively on a path.
:param path: the path
:return: None
"""
for dirname, subdirlist, filelist in os.walk(path):
for f in filelist:
if f.endswith('pyc'):
try:
os.remove(os.path... | [
"Removes",
"all",
"python",
"cache",
"files",
"recursively",
"on",
"a",
"path",
"."
] | flatangle/flatlib | python | https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/scripts/utils.py#L18-L36 | [
"def",
"clean_caches",
"(",
"path",
")",
":",
"for",
"dirname",
",",
"subdirlist",
",",
"filelist",
"in",
"os",
".",
"walk",
"(",
"path",
")",
":",
"for",
"f",
"in",
"filelist",
":",
"if",
"f",
".",
"endswith",
"(",
"'pyc'",
")",
":",
"try",
":",
... | 44e05b2991a296c678adbc17a1d51b6a21bc867c |
train | clean_py_files | Removes all .py files.
:param path: the path
:return: None | scripts/utils.py | def clean_py_files(path):
"""
Removes all .py files.
:param path: the path
:return: None
"""
for dirname, subdirlist, filelist in os.walk(path):
for f in filelist:
if f.endswith('py'):
os.remove(os.path.join(dirname, f)) | def clean_py_files(path):
"""
Removes all .py files.
:param path: the path
:return: None
"""
for dirname, subdirlist, filelist in os.walk(path):
for f in filelist:
if f.endswith('py'):
os.remove(os.path.join(dirname, f)) | [
"Removes",
"all",
".",
"py",
"files",
"."
] | flatangle/flatlib | python | https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/scripts/utils.py#L39-L51 | [
"def",
"clean_py_files",
"(",
"path",
")",
":",
"for",
"dirname",
",",
"subdirlist",
",",
"filelist",
"in",
"os",
".",
"walk",
"(",
"path",
")",
":",
"for",
"f",
"in",
"filelist",
":",
"if",
"f",
".",
"endswith",
"(",
"'py'",
")",
":",
"os",
".",
... | 44e05b2991a296c678adbc17a1d51b6a21bc867c |
train | toFloat | Converts angle representation to float.
Accepts angles and strings such as "12W30:00". | flatlib/geopos.py | def toFloat(value):
""" Converts angle representation to float.
Accepts angles and strings such as "12W30:00".
"""
if isinstance(value, str):
# Find lat/lon char in string and insert angle sign
value = value.upper()
for char in ['N', 'S', 'E', 'W']:
if char in v... | def toFloat(value):
""" Converts angle representation to float.
Accepts angles and strings such as "12W30:00".
"""
if isinstance(value, str):
# Find lat/lon char in string and insert angle sign
value = value.upper()
for char in ['N', 'S', 'E', 'W']:
if char in v... | [
"Converts",
"angle",
"representation",
"to",
"float",
".",
"Accepts",
"angles",
"and",
"strings",
"such",
"as",
"12W30",
":",
"00",
"."
] | flatangle/flatlib | python | https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/geopos.py#L29-L41 | [
"def",
"toFloat",
"(",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"str",
")",
":",
"# Find lat/lon char in string and insert angle sign",
"value",
"=",
"value",
".",
"upper",
"(",
")",
"for",
"char",
"in",
"[",
"'N'",
",",
"'S'",
",",
"'E'",... | 44e05b2991a296c678adbc17a1d51b6a21bc867c |
train | toString | Converts angle float to string.
Mode refers to LAT/LON. | flatlib/geopos.py | def toString(value, mode):
""" Converts angle float to string.
Mode refers to LAT/LON.
"""
string = angle.toString(value)
sign = string[0]
separator = CHAR[mode][sign]
string = string.replace(':', separator, 1)
return string[1:] | def toString(value, mode):
""" Converts angle float to string.
Mode refers to LAT/LON.
"""
string = angle.toString(value)
sign = string[0]
separator = CHAR[mode][sign]
string = string.replace(':', separator, 1)
return string[1:] | [
"Converts",
"angle",
"float",
"to",
"string",
".",
"Mode",
"refers",
"to",
"LAT",
"/",
"LON",
"."
] | flatangle/flatlib | python | https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/geopos.py#L47-L56 | [
"def",
"toString",
"(",
"value",
",",
"mode",
")",
":",
"string",
"=",
"angle",
".",
"toString",
"(",
"value",
")",
"sign",
"=",
"string",
"[",
"0",
"]",
"separator",
"=",
"CHAR",
"[",
"mode",
"]",
"[",
"sign",
"]",
"string",
"=",
"string",
".",
... | 44e05b2991a296c678adbc17a1d51b6a21bc867c |
train | GeoPos.strings | Return lat/lon as strings. | flatlib/geopos.py | def strings(self):
""" Return lat/lon as strings. """
return [
toString(self.lat, LAT),
toString(self.lon, LON)
] | def strings(self):
""" Return lat/lon as strings. """
return [
toString(self.lat, LAT),
toString(self.lon, LON)
] | [
"Return",
"lat",
"/",
"lon",
"as",
"strings",
"."
] | flatangle/flatlib | python | https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/geopos.py#L84-L89 | [
"def",
"strings",
"(",
"self",
")",
":",
"return",
"[",
"toString",
"(",
"self",
".",
"lat",
",",
"LAT",
")",
",",
"toString",
"(",
"self",
".",
"lon",
",",
"LON",
")",
"]"
] | 44e05b2991a296c678adbc17a1d51b6a21bc867c |
train | _orbList | Returns a list with the orb and angular
distances from obj1 to obj2, considering a
list of possible aspects. | flatlib/aspects.py | def _orbList(obj1, obj2, aspList):
""" Returns a list with the orb and angular
distances from obj1 to obj2, considering a
list of possible aspects.
"""
sep = angle.closestdistance(obj1.lon, obj2.lon)
absSep = abs(sep)
return [
{
'type': asp,
'orb': abs(a... | def _orbList(obj1, obj2, aspList):
""" Returns a list with the orb and angular
distances from obj1 to obj2, considering a
list of possible aspects.
"""
sep = angle.closestdistance(obj1.lon, obj2.lon)
absSep = abs(sep)
return [
{
'type': asp,
'orb': abs(a... | [
"Returns",
"a",
"list",
"with",
"the",
"orb",
"and",
"angular",
"distances",
"from",
"obj1",
"to",
"obj2",
"considering",
"a",
"list",
"of",
"possible",
"aspects",
"."
] | flatangle/flatlib | python | https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/aspects.py#L43-L57 | [
"def",
"_orbList",
"(",
"obj1",
",",
"obj2",
",",
"aspList",
")",
":",
"sep",
"=",
"angle",
".",
"closestdistance",
"(",
"obj1",
".",
"lon",
",",
"obj2",
".",
"lon",
")",
"absSep",
"=",
"abs",
"(",
"sep",
")",
"return",
"[",
"{",
"'type'",
":",
"... | 44e05b2991a296c678adbc17a1d51b6a21bc867c |
train | _aspectDict | Returns the properties of the aspect of
obj1 to obj2, considering a list of possible
aspects.
This function makes the following assumptions:
- Syzygy does not start aspects but receives
any aspect.
- Pars Fortuna and Moon Nodes only starts
conjunctions but receive any aspect.
... | flatlib/aspects.py | def _aspectDict(obj1, obj2, aspList):
""" Returns the properties of the aspect of
obj1 to obj2, considering a list of possible
aspects.
This function makes the following assumptions:
- Syzygy does not start aspects but receives
any aspect.
- Pars Fortuna and Moon Nodes only starts
... | def _aspectDict(obj1, obj2, aspList):
""" Returns the properties of the aspect of
obj1 to obj2, considering a list of possible
aspects.
This function makes the following assumptions:
- Syzygy does not start aspects but receives
any aspect.
- Pars Fortuna and Moon Nodes only starts
... | [
"Returns",
"the",
"properties",
"of",
"the",
"aspect",
"of",
"obj1",
"to",
"obj2",
"considering",
"a",
"list",
"of",
"possible",
"aspects",
".",
"This",
"function",
"makes",
"the",
"following",
"assumptions",
":",
"-",
"Syzygy",
"does",
"not",
"start",
"aspe... | flatangle/flatlib | python | https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/aspects.py#L59-L106 | [
"def",
"_aspectDict",
"(",
"obj1",
",",
"obj2",
",",
"aspList",
")",
":",
"# Ignore aspects from same and Syzygy",
"if",
"obj1",
"==",
"obj2",
"or",
"obj1",
".",
"id",
"==",
"const",
".",
"SYZYGY",
":",
"return",
"None",
"orbs",
"=",
"_orbList",
"(",
"obj1... | 44e05b2991a296c678adbc17a1d51b6a21bc867c |
train | _aspectProperties | Returns the properties of an aspect between
obj1 and obj2, given by 'aspDict'.
This function assumes obj1 to be the active object,
i.e., the one responsible for starting the aspect. | flatlib/aspects.py | def _aspectProperties(obj1, obj2, aspDict):
""" Returns the properties of an aspect between
obj1 and obj2, given by 'aspDict'.
This function assumes obj1 to be the active object,
i.e., the one responsible for starting the aspect.
"""
orb = aspDict['orb']
asp = aspDict['type']
... | def _aspectProperties(obj1, obj2, aspDict):
""" Returns the properties of an aspect between
obj1 and obj2, given by 'aspDict'.
This function assumes obj1 to be the active object,
i.e., the one responsible for starting the aspect.
"""
orb = aspDict['orb']
asp = aspDict['type']
... | [
"Returns",
"the",
"properties",
"of",
"an",
"aspect",
"between",
"obj1",
"and",
"obj2",
"given",
"by",
"aspDict",
".",
"This",
"function",
"assumes",
"obj1",
"to",
"be",
"the",
"active",
"object",
"i",
".",
"e",
".",
"the",
"one",
"responsible",
"for",
"... | flatangle/flatlib | python | https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/aspects.py#L108-L181 | [
"def",
"_aspectProperties",
"(",
"obj1",
",",
"obj2",
",",
"aspDict",
")",
":",
"orb",
"=",
"aspDict",
"[",
"'orb'",
"]",
"asp",
"=",
"aspDict",
"[",
"'type'",
"]",
"sep",
"=",
"aspDict",
"[",
"'separation'",
"]",
"# Properties",
"prop1",
"=",
"{",
"'i... | 44e05b2991a296c678adbc17a1d51b6a21bc867c |
train | _getActivePassive | Returns which is the active and the passive objects. | flatlib/aspects.py | def _getActivePassive(obj1, obj2):
""" Returns which is the active and the passive objects. """
speed1 = abs(obj1.lonspeed) if obj1.isPlanet() else -1.0
speed2 = abs(obj2.lonspeed) if obj2.isPlanet() else -1.0
if speed1 > speed2:
return {
'active': obj1,
'passive': obj2
... | def _getActivePassive(obj1, obj2):
""" Returns which is the active and the passive objects. """
speed1 = abs(obj1.lonspeed) if obj1.isPlanet() else -1.0
speed2 = abs(obj2.lonspeed) if obj2.isPlanet() else -1.0
if speed1 > speed2:
return {
'active': obj1,
'passive': obj2
... | [
"Returns",
"which",
"is",
"the",
"active",
"and",
"the",
"passive",
"objects",
"."
] | flatangle/flatlib | python | https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/aspects.py#L183-L196 | [
"def",
"_getActivePassive",
"(",
"obj1",
",",
"obj2",
")",
":",
"speed1",
"=",
"abs",
"(",
"obj1",
".",
"lonspeed",
")",
"if",
"obj1",
".",
"isPlanet",
"(",
")",
"else",
"-",
"1.0",
"speed2",
"=",
"abs",
"(",
"obj2",
".",
"lonspeed",
")",
"if",
"ob... | 44e05b2991a296c678adbc17a1d51b6a21bc867c |
train | aspectType | Returns the aspect type between objects considering
a list of possible aspect types. | flatlib/aspects.py | def aspectType(obj1, obj2, aspList):
""" Returns the aspect type between objects considering
a list of possible aspect types.
"""
ap = _getActivePassive(obj1, obj2)
aspDict = _aspectDict(ap['active'], ap['passive'], aspList)
return aspDict['type'] if aspDict else const.NO_ASPECT | def aspectType(obj1, obj2, aspList):
""" Returns the aspect type between objects considering
a list of possible aspect types.
"""
ap = _getActivePassive(obj1, obj2)
aspDict = _aspectDict(ap['active'], ap['passive'], aspList)
return aspDict['type'] if aspDict else const.NO_ASPECT | [
"Returns",
"the",
"aspect",
"type",
"between",
"objects",
"considering",
"a",
"list",
"of",
"possible",
"aspect",
"types",
"."
] | flatangle/flatlib | python | https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/aspects.py#L201-L208 | [
"def",
"aspectType",
"(",
"obj1",
",",
"obj2",
",",
"aspList",
")",
":",
"ap",
"=",
"_getActivePassive",
"(",
"obj1",
",",
"obj2",
")",
"aspDict",
"=",
"_aspectDict",
"(",
"ap",
"[",
"'active'",
"]",
",",
"ap",
"[",
"'passive'",
"]",
",",
"aspList",
... | 44e05b2991a296c678adbc17a1d51b6a21bc867c |
train | hasAspect | Returns if there is an aspect between objects
considering a list of possible aspect types. | flatlib/aspects.py | def hasAspect(obj1, obj2, aspList):
""" Returns if there is an aspect between objects
considering a list of possible aspect types.
"""
aspType = aspectType(obj1, obj2, aspList)
return aspType != const.NO_ASPECT | def hasAspect(obj1, obj2, aspList):
""" Returns if there is an aspect between objects
considering a list of possible aspect types.
"""
aspType = aspectType(obj1, obj2, aspList)
return aspType != const.NO_ASPECT | [
"Returns",
"if",
"there",
"is",
"an",
"aspect",
"between",
"objects",
"considering",
"a",
"list",
"of",
"possible",
"aspect",
"types",
"."
] | flatangle/flatlib | python | https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/aspects.py#L210-L216 | [
"def",
"hasAspect",
"(",
"obj1",
",",
"obj2",
",",
"aspList",
")",
":",
"aspType",
"=",
"aspectType",
"(",
"obj1",
",",
"obj2",
",",
"aspList",
")",
"return",
"aspType",
"!=",
"const",
".",
"NO_ASPECT"
] | 44e05b2991a296c678adbc17a1d51b6a21bc867c |
train | isAspecting | Returns if obj1 aspects obj2 within its orb,
considering a list of possible aspect types. | flatlib/aspects.py | def isAspecting(obj1, obj2, aspList):
""" Returns if obj1 aspects obj2 within its orb,
considering a list of possible aspect types.
"""
aspDict = _aspectDict(obj1, obj2, aspList)
if aspDict:
return aspDict['orb'] < obj1.orb()
return False | def isAspecting(obj1, obj2, aspList):
""" Returns if obj1 aspects obj2 within its orb,
considering a list of possible aspect types.
"""
aspDict = _aspectDict(obj1, obj2, aspList)
if aspDict:
return aspDict['orb'] < obj1.orb()
return False | [
"Returns",
"if",
"obj1",
"aspects",
"obj2",
"within",
"its",
"orb",
"considering",
"a",
"list",
"of",
"possible",
"aspect",
"types",
"."
] | flatangle/flatlib | python | https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/aspects.py#L218-L226 | [
"def",
"isAspecting",
"(",
"obj1",
",",
"obj2",
",",
"aspList",
")",
":",
"aspDict",
"=",
"_aspectDict",
"(",
"obj1",
",",
"obj2",
",",
"aspList",
")",
"if",
"aspDict",
":",
"return",
"aspDict",
"[",
"'orb'",
"]",
"<",
"obj1",
".",
"orb",
"(",
")",
... | 44e05b2991a296c678adbc17a1d51b6a21bc867c |
train | getAspect | Returns an Aspect object for the aspect between two
objects considering a list of possible aspect types. | flatlib/aspects.py | def getAspect(obj1, obj2, aspList):
""" Returns an Aspect object for the aspect between two
objects considering a list of possible aspect types.
"""
ap = _getActivePassive(obj1, obj2)
aspDict = _aspectDict(ap['active'], ap['passive'], aspList)
if not aspDict:
aspDict = {
... | def getAspect(obj1, obj2, aspList):
""" Returns an Aspect object for the aspect between two
objects considering a list of possible aspect types.
"""
ap = _getActivePassive(obj1, obj2)
aspDict = _aspectDict(ap['active'], ap['passive'], aspList)
if not aspDict:
aspDict = {
... | [
"Returns",
"an",
"Aspect",
"object",
"for",
"the",
"aspect",
"between",
"two",
"objects",
"considering",
"a",
"list",
"of",
"possible",
"aspect",
"types",
"."
] | flatangle/flatlib | python | https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/aspects.py#L228-L242 | [
"def",
"getAspect",
"(",
"obj1",
",",
"obj2",
",",
"aspList",
")",
":",
"ap",
"=",
"_getActivePassive",
"(",
"obj1",
",",
"obj2",
")",
"aspDict",
"=",
"_aspectDict",
"(",
"ap",
"[",
"'active'",
"]",
",",
"ap",
"[",
"'passive'",
"]",
",",
"aspList",
"... | 44e05b2991a296c678adbc17a1d51b6a21bc867c |
train | Aspect.movement | Returns the movement of this aspect.
The movement is the one of the active object, except
if the active is separating but within less than 1
degree. | flatlib/aspects.py | def movement(self):
""" Returns the movement of this aspect.
The movement is the one of the active object, except
if the active is separating but within less than 1
degree.
"""
mov = self.active.movement
if self.orb < 1 and mov == const.SEPARATIVE:
... | def movement(self):
""" Returns the movement of this aspect.
The movement is the one of the active object, except
if the active is separating but within less than 1
degree.
"""
mov = self.active.movement
if self.orb < 1 and mov == const.SEPARATIVE:
... | [
"Returns",
"the",
"movement",
"of",
"this",
"aspect",
".",
"The",
"movement",
"is",
"the",
"one",
"of",
"the",
"active",
"object",
"except",
"if",
"the",
"active",
"is",
"separating",
"but",
"within",
"less",
"than",
"1",
"degree",
"."
] | flatangle/flatlib | python | https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/aspects.py#L275-L285 | [
"def",
"movement",
"(",
"self",
")",
":",
"mov",
"=",
"self",
".",
"active",
".",
"movement",
"if",
"self",
".",
"orb",
"<",
"1",
"and",
"mov",
"==",
"const",
".",
"SEPARATIVE",
":",
"mov",
"=",
"const",
".",
"EXACT",
"return",
"mov"
] | 44e05b2991a296c678adbc17a1d51b6a21bc867c |
train | Aspect.getRole | Returns the role (active or passive) of an object
in this aspect. | flatlib/aspects.py | def getRole(self, ID):
""" Returns the role (active or passive) of an object
in this aspect.
"""
if self.active.id == ID:
return {
'role': 'active',
'inOrb': self.active.inOrb,
'movement': self.active.movement
... | def getRole(self, ID):
""" Returns the role (active or passive) of an object
in this aspect.
"""
if self.active.id == ID:
return {
'role': 'active',
'inOrb': self.active.inOrb,
'movement': self.active.movement
... | [
"Returns",
"the",
"role",
"(",
"active",
"or",
"passive",
")",
"of",
"an",
"object",
"in",
"this",
"aspect",
"."
] | flatangle/flatlib | python | https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/aspects.py#L298-L315 | [
"def",
"getRole",
"(",
"self",
",",
"ID",
")",
":",
"if",
"self",
".",
"active",
".",
"id",
"==",
"ID",
":",
"return",
"{",
"'role'",
":",
"'active'",
",",
"'inOrb'",
":",
"self",
".",
"active",
".",
"inOrb",
",",
"'movement'",
":",
"self",
".",
... | 44e05b2991a296c678adbc17a1d51b6a21bc867c |
train | setFaces | Sets the default faces variant | flatlib/dignities/essential.py | def setFaces(variant):
"""
Sets the default faces variant
"""
global FACES
if variant == CHALDEAN_FACES:
FACES = tables.CHALDEAN_FACES
else:
FACES = tables.TRIPLICITY_FACES | def setFaces(variant):
"""
Sets the default faces variant
"""
global FACES
if variant == CHALDEAN_FACES:
FACES = tables.CHALDEAN_FACES
else:
FACES = tables.TRIPLICITY_FACES | [
"Sets",
"the",
"default",
"faces",
"variant"
] | flatangle/flatlib | python | https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/dignities/essential.py#L33-L42 | [
"def",
"setFaces",
"(",
"variant",
")",
":",
"global",
"FACES",
"if",
"variant",
"==",
"CHALDEAN_FACES",
":",
"FACES",
"=",
"tables",
".",
"CHALDEAN_FACES",
"else",
":",
"FACES",
"=",
"tables",
".",
"TRIPLICITY_FACES"
] | 44e05b2991a296c678adbc17a1d51b6a21bc867c |
train | setTerms | Sets the default terms of the Dignities
table. | flatlib/dignities/essential.py | def setTerms(variant):
"""
Sets the default terms of the Dignities
table.
"""
global TERMS
if variant == EGYPTIAN_TERMS:
TERMS = tables.EGYPTIAN_TERMS
elif variant == TETRABIBLOS_TERMS:
TERMS = tables.TETRABIBLOS_TERMS
elif variant == LILLY_TERMS:
TERMS = tables.... | def setTerms(variant):
"""
Sets the default terms of the Dignities
table.
"""
global TERMS
if variant == EGYPTIAN_TERMS:
TERMS = tables.EGYPTIAN_TERMS
elif variant == TETRABIBLOS_TERMS:
TERMS = tables.TETRABIBLOS_TERMS
elif variant == LILLY_TERMS:
TERMS = tables.... | [
"Sets",
"the",
"default",
"terms",
"of",
"the",
"Dignities",
"table",
"."
] | flatangle/flatlib | python | https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/dignities/essential.py#L45-L57 | [
"def",
"setTerms",
"(",
"variant",
")",
":",
"global",
"TERMS",
"if",
"variant",
"==",
"EGYPTIAN_TERMS",
":",
"TERMS",
"=",
"tables",
".",
"EGYPTIAN_TERMS",
"elif",
"variant",
"==",
"TETRABIBLOS_TERMS",
":",
"TERMS",
"=",
"tables",
".",
"TETRABIBLOS_TERMS",
"e... | 44e05b2991a296c678adbc17a1d51b6a21bc867c |
train | term | Returns the term for a sign and longitude. | flatlib/dignities/essential.py | def term(sign, lon):
""" Returns the term for a sign and longitude. """
terms = TERMS[sign]
for (ID, a, b) in terms:
if (a <= lon < b):
return ID
return None | def term(sign, lon):
""" Returns the term for a sign and longitude. """
terms = TERMS[sign]
for (ID, a, b) in terms:
if (a <= lon < b):
return ID
return None | [
"Returns",
"the",
"term",
"for",
"a",
"sign",
"and",
"longitude",
"."
] | flatangle/flatlib | python | https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/dignities/essential.py#L98-L104 | [
"def",
"term",
"(",
"sign",
",",
"lon",
")",
":",
"terms",
"=",
"TERMS",
"[",
"sign",
"]",
"for",
"(",
"ID",
",",
"a",
",",
"b",
")",
"in",
"terms",
":",
"if",
"(",
"a",
"<=",
"lon",
"<",
"b",
")",
":",
"return",
"ID",
"return",
"None"
] | 44e05b2991a296c678adbc17a1d51b6a21bc867c |
train | face | Returns the face for a sign and longitude. | flatlib/dignities/essential.py | def face(sign, lon):
""" Returns the face for a sign and longitude. """
faces = FACES[sign]
if lon < 10:
return faces[0]
elif lon < 20:
return faces[1]
else:
return faces[2] | def face(sign, lon):
""" Returns the face for a sign and longitude. """
faces = FACES[sign]
if lon < 10:
return faces[0]
elif lon < 20:
return faces[1]
else:
return faces[2] | [
"Returns",
"the",
"face",
"for",
"a",
"sign",
"and",
"longitude",
"."
] | flatangle/flatlib | python | https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/dignities/essential.py#L106-L114 | [
"def",
"face",
"(",
"sign",
",",
"lon",
")",
":",
"faces",
"=",
"FACES",
"[",
"sign",
"]",
"if",
"lon",
"<",
"10",
":",
"return",
"faces",
"[",
"0",
"]",
"elif",
"lon",
"<",
"20",
":",
"return",
"faces",
"[",
"1",
"]",
"else",
":",
"return",
... | 44e05b2991a296c678adbc17a1d51b6a21bc867c |
train | getInfo | Returns the complete essential dignities
for a sign and longitude. | flatlib/dignities/essential.py | def getInfo(sign, lon):
""" Returns the complete essential dignities
for a sign and longitude.
"""
return {
'ruler': ruler(sign),
'exalt': exalt(sign),
'dayTrip': dayTrip(sign),
'nightTrip': nightTrip(sign),
'partTrip': partTrip(sign),
'term': term(sign, ... | def getInfo(sign, lon):
""" Returns the complete essential dignities
for a sign and longitude.
"""
return {
'ruler': ruler(sign),
'exalt': exalt(sign),
'dayTrip': dayTrip(sign),
'nightTrip': nightTrip(sign),
'partTrip': partTrip(sign),
'term': term(sign, ... | [
"Returns",
"the",
"complete",
"essential",
"dignities",
"for",
"a",
"sign",
"and",
"longitude",
"."
] | flatangle/flatlib | python | https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/dignities/essential.py#L119-L134 | [
"def",
"getInfo",
"(",
"sign",
",",
"lon",
")",
":",
"return",
"{",
"'ruler'",
":",
"ruler",
"(",
"sign",
")",
",",
"'exalt'",
":",
"exalt",
"(",
"sign",
")",
",",
"'dayTrip'",
":",
"dayTrip",
"(",
"sign",
")",
",",
"'nightTrip'",
":",
"nightTrip",
... | 44e05b2991a296c678adbc17a1d51b6a21bc867c |
train | isPeregrine | Returns if an object is peregrine
on a sign and longitude. | flatlib/dignities/essential.py | def isPeregrine(ID, sign, lon):
""" Returns if an object is peregrine
on a sign and longitude.
"""
info = getInfo(sign, lon)
for dign, objID in info.items():
if dign not in ['exile', 'fall'] and ID == objID:
return False
return True | def isPeregrine(ID, sign, lon):
""" Returns if an object is peregrine
on a sign and longitude.
"""
info = getInfo(sign, lon)
for dign, objID in info.items():
if dign not in ['exile', 'fall'] and ID == objID:
return False
return True | [
"Returns",
"if",
"an",
"object",
"is",
"peregrine",
"on",
"a",
"sign",
"and",
"longitude",
"."
] | flatangle/flatlib | python | https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/dignities/essential.py#L136-L145 | [
"def",
"isPeregrine",
"(",
"ID",
",",
"sign",
",",
"lon",
")",
":",
"info",
"=",
"getInfo",
"(",
"sign",
",",
"lon",
")",
"for",
"dign",
",",
"objID",
"in",
"info",
".",
"items",
"(",
")",
":",
"if",
"dign",
"not",
"in",
"[",
"'exile'",
",",
"'... | 44e05b2991a296c678adbc17a1d51b6a21bc867c |
train | score | Returns the score of an object on
a sign and longitude. | flatlib/dignities/essential.py | def score(ID, sign, lon):
""" Returns the score of an object on
a sign and longitude.
"""
info = getInfo(sign, lon)
dignities = [dign for (dign, objID) in info.items() if objID == ID]
return sum([SCORES[dign] for dign in dignities]) | def score(ID, sign, lon):
""" Returns the score of an object on
a sign and longitude.
"""
info = getInfo(sign, lon)
dignities = [dign for (dign, objID) in info.items() if objID == ID]
return sum([SCORES[dign] for dign in dignities]) | [
"Returns",
"the",
"score",
"of",
"an",
"object",
"on",
"a",
"sign",
"and",
"longitude",
"."
] | flatangle/flatlib | python | https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/dignities/essential.py#L162-L169 | [
"def",
"score",
"(",
"ID",
",",
"sign",
",",
"lon",
")",
":",
"info",
"=",
"getInfo",
"(",
"sign",
",",
"lon",
")",
"dignities",
"=",
"[",
"dign",
"for",
"(",
"dign",
",",
"objID",
")",
"in",
"info",
".",
"items",
"(",
")",
"if",
"objID",
"==",... | 44e05b2991a296c678adbc17a1d51b6a21bc867c |
train | almutem | Returns the almutem for a given
sign and longitude. | flatlib/dignities/essential.py | def almutem(sign, lon):
""" Returns the almutem for a given
sign and longitude.
"""
planets = const.LIST_SEVEN_PLANETS
res = [None, 0]
for ID in planets:
sc = score(ID, sign, lon)
if sc > res[1]:
res = [ID, sc]
return res[0] | def almutem(sign, lon):
""" Returns the almutem for a given
sign and longitude.
"""
planets = const.LIST_SEVEN_PLANETS
res = [None, 0]
for ID in planets:
sc = score(ID, sign, lon)
if sc > res[1]:
res = [ID, sc]
return res[0] | [
"Returns",
"the",
"almutem",
"for",
"a",
"given",
"sign",
"and",
"longitude",
"."
] | flatangle/flatlib | python | https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/dignities/essential.py#L171-L182 | [
"def",
"almutem",
"(",
"sign",
",",
"lon",
")",
":",
"planets",
"=",
"const",
".",
"LIST_SEVEN_PLANETS",
"res",
"=",
"[",
"None",
",",
"0",
"]",
"for",
"ID",
"in",
"planets",
":",
"sc",
"=",
"score",
"(",
"ID",
",",
"sign",
",",
"lon",
")",
"if",... | 44e05b2991a296c678adbc17a1d51b6a21bc867c |
train | EssentialInfo.getDignities | Returns the dignities belonging to this object. | flatlib/dignities/essential.py | def getDignities(self):
""" Returns the dignities belonging to this object. """
info = self.getInfo()
dignities = [dign for (dign, objID) in info.items()
if objID == self.obj.id]
return dignities | def getDignities(self):
""" Returns the dignities belonging to this object. """
info = self.getInfo()
dignities = [dign for (dign, objID) in info.items()
if objID == self.obj.id]
return dignities | [
"Returns",
"the",
"dignities",
"belonging",
"to",
"this",
"object",
"."
] | flatangle/flatlib | python | https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/dignities/essential.py#L208-L213 | [
"def",
"getDignities",
"(",
"self",
")",
":",
"info",
"=",
"self",
".",
"getInfo",
"(",
")",
"dignities",
"=",
"[",
"dign",
"for",
"(",
"dign",
",",
"objID",
")",
"in",
"info",
".",
"items",
"(",
")",
"if",
"objID",
"==",
"self",
".",
"obj",
".",... | 44e05b2991a296c678adbc17a1d51b6a21bc867c |
train | EssentialInfo.isPeregrine | Returns if this object is peregrine. | flatlib/dignities/essential.py | def isPeregrine(self):
""" Returns if this object is peregrine. """
return isPeregrine(self.obj.id,
self.obj.sign,
self.obj.signlon) | def isPeregrine(self):
""" Returns if this object is peregrine. """
return isPeregrine(self.obj.id,
self.obj.sign,
self.obj.signlon) | [
"Returns",
"if",
"this",
"object",
"is",
"peregrine",
"."
] | flatangle/flatlib | python | https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/dignities/essential.py#L215-L219 | [
"def",
"isPeregrine",
"(",
"self",
")",
":",
"return",
"isPeregrine",
"(",
"self",
".",
"obj",
".",
"id",
",",
"self",
".",
"obj",
".",
"sign",
",",
"self",
".",
"obj",
".",
"signlon",
")"
] | 44e05b2991a296c678adbc17a1d51b6a21bc867c |
train | _computeChart | Internal function to return a new chart for
a specific date using properties from old chart. | flatlib/predictives/returns.py | def _computeChart(chart, date):
""" Internal function to return a new chart for
a specific date using properties from old chart.
"""
pos = chart.pos
hsys = chart.hsys
IDs = [obj.id for obj in chart.objects]
return Chart(date, pos, IDs=IDs, hsys=hsys) | def _computeChart(chart, date):
""" Internal function to return a new chart for
a specific date using properties from old chart.
"""
pos = chart.pos
hsys = chart.hsys
IDs = [obj.id for obj in chart.objects]
return Chart(date, pos, IDs=IDs, hsys=hsys) | [
"Internal",
"function",
"to",
"return",
"a",
"new",
"chart",
"for",
"a",
"specific",
"date",
"using",
"properties",
"from",
"old",
"chart",
"."
] | flatangle/flatlib | python | https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/predictives/returns.py#L18-L26 | [
"def",
"_computeChart",
"(",
"chart",
",",
"date",
")",
":",
"pos",
"=",
"chart",
".",
"pos",
"hsys",
"=",
"chart",
".",
"hsys",
"IDs",
"=",
"[",
"obj",
".",
"id",
"for",
"obj",
"in",
"chart",
".",
"objects",
"]",
"return",
"Chart",
"(",
"date",
... | 44e05b2991a296c678adbc17a1d51b6a21bc867c |
train | nextSolarReturn | Returns the solar return of a Chart
after a specific date. | flatlib/predictives/returns.py | def nextSolarReturn(chart, date):
""" Returns the solar return of a Chart
after a specific date.
"""
sun = chart.getObject(const.SUN)
srDate = ephem.nextSolarReturn(date, sun.lon)
return _computeChart(chart, srDate) | def nextSolarReturn(chart, date):
""" Returns the solar return of a Chart
after a specific date.
"""
sun = chart.getObject(const.SUN)
srDate = ephem.nextSolarReturn(date, sun.lon)
return _computeChart(chart, srDate) | [
"Returns",
"the",
"solar",
"return",
"of",
"a",
"Chart",
"after",
"a",
"specific",
"date",
"."
] | flatangle/flatlib | python | https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/predictives/returns.py#L28-L35 | [
"def",
"nextSolarReturn",
"(",
"chart",
",",
"date",
")",
":",
"sun",
"=",
"chart",
".",
"getObject",
"(",
"const",
".",
"SUN",
")",
"srDate",
"=",
"ephem",
".",
"nextSolarReturn",
"(",
"date",
",",
"sun",
".",
"lon",
")",
"return",
"_computeChart",
"(... | 44e05b2991a296c678adbc17a1d51b6a21bc867c |
train | hourTable | Creates the planetary hour table for a date
and position.
The table includes both diurnal and nocturnal
hour sequences and each of the 24 entries (12 * 2)
are like (startJD, endJD, ruler). | flatlib/tools/planetarytime.py | def hourTable(date, pos):
""" Creates the planetary hour table for a date
and position.
The table includes both diurnal and nocturnal
hour sequences and each of the 24 entries (12 * 2)
are like (startJD, endJD, ruler).
"""
lastSunrise = ephem.lastSunrise(date, pos)
midd... | def hourTable(date, pos):
""" Creates the planetary hour table for a date
and position.
The table includes both diurnal and nocturnal
hour sequences and each of the 24 entries (12 * 2)
are like (startJD, endJD, ruler).
"""
lastSunrise = ephem.lastSunrise(date, pos)
midd... | [
"Creates",
"the",
"planetary",
"hour",
"table",
"for",
"a",
"date",
"and",
"position",
".",
"The",
"table",
"includes",
"both",
"diurnal",
"and",
"nocturnal",
"hour",
"sequences",
"and",
"each",
"of",
"the",
"24",
"entries",
"(",
"12",
"*",
"2",
")",
"ar... | flatangle/flatlib | python | https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/tools/planetarytime.py#L65-L96 | [
"def",
"hourTable",
"(",
"date",
",",
"pos",
")",
":",
"lastSunrise",
"=",
"ephem",
".",
"lastSunrise",
"(",
"date",
",",
"pos",
")",
"middleSunset",
"=",
"ephem",
".",
"nextSunset",
"(",
"lastSunrise",
",",
"pos",
")",
"nextSunrise",
"=",
"ephem",
".",
... | 44e05b2991a296c678adbc17a1d51b6a21bc867c |
train | getHourTable | Returns an HourTable object. | flatlib/tools/planetarytime.py | def getHourTable(date, pos):
""" Returns an HourTable object. """
table = hourTable(date, pos)
return HourTable(table, date) | def getHourTable(date, pos):
""" Returns an HourTable object. """
table = hourTable(date, pos)
return HourTable(table, date) | [
"Returns",
"an",
"HourTable",
"object",
"."
] | flatangle/flatlib | python | https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/tools/planetarytime.py#L98-L101 | [
"def",
"getHourTable",
"(",
"date",
",",
"pos",
")",
":",
"table",
"=",
"hourTable",
"(",
"date",
",",
"pos",
")",
"return",
"HourTable",
"(",
"table",
",",
"date",
")"
] | 44e05b2991a296c678adbc17a1d51b6a21bc867c |
train | HourTable.index | Returns the index of a date in the table. | flatlib/tools/planetarytime.py | def index(self, date):
""" Returns the index of a date in the table. """
for (i, (start, end, ruler)) in enumerate(self.table):
if start <= date.jd <= end:
return i
return None | def index(self, date):
""" Returns the index of a date in the table. """
for (i, (start, end, ruler)) in enumerate(self.table):
if start <= date.jd <= end:
return i
return None | [
"Returns",
"the",
"index",
"of",
"a",
"date",
"in",
"the",
"table",
"."
] | flatangle/flatlib | python | https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/tools/planetarytime.py#L119-L124 | [
"def",
"index",
"(",
"self",
",",
"date",
")",
":",
"for",
"(",
"i",
",",
"(",
"start",
",",
"end",
",",
"ruler",
")",
")",
"in",
"enumerate",
"(",
"self",
".",
"table",
")",
":",
"if",
"start",
"<=",
"date",
".",
"jd",
"<=",
"end",
":",
"ret... | 44e05b2991a296c678adbc17a1d51b6a21bc867c |
train | HourTable.indexInfo | Returns information about a specific
planetary time. | flatlib/tools/planetarytime.py | def indexInfo(self, index):
""" Returns information about a specific
planetary time.
"""
entry = self.table[index]
info = {
# Default is diurnal
'mode': 'Day',
'ruler': self.dayRuler(),
'dayRuler': self.dayRuler(),
... | def indexInfo(self, index):
""" Returns information about a specific
planetary time.
"""
entry = self.table[index]
info = {
# Default is diurnal
'mode': 'Day',
'ruler': self.dayRuler(),
'dayRuler': self.dayRuler(),
... | [
"Returns",
"information",
"about",
"a",
"specific",
"planetary",
"time",
"."
] | flatangle/flatlib | python | https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/tools/planetarytime.py#L157-L182 | [
"def",
"indexInfo",
"(",
"self",
",",
"index",
")",
":",
"entry",
"=",
"self",
".",
"table",
"[",
"index",
"]",
"info",
"=",
"{",
"# Default is diurnal",
"'mode'",
":",
"'Day'",
",",
"'ruler'",
":",
"self",
".",
"dayRuler",
"(",
")",
",",
"'dayRuler'",... | 44e05b2991a296c678adbc17a1d51b6a21bc867c |
train | compute | Returns a profection chart for a given
date. Receives argument 'fixedObjects' to
fix chart objects in their natal locations. | flatlib/predictives/profections.py | def compute(chart, date, fixedObjects=False):
""" Returns a profection chart for a given
date. Receives argument 'fixedObjects' to
fix chart objects in their natal locations.
"""
sun = chart.getObject(const.SUN)
prevSr = ephem.prevSolarReturn(date, sun.lon)
nextSr = ephem.nextSolar... | def compute(chart, date, fixedObjects=False):
""" Returns a profection chart for a given
date. Receives argument 'fixedObjects' to
fix chart objects in their natal locations.
"""
sun = chart.getObject(const.SUN)
prevSr = ephem.prevSolarReturn(date, sun.lon)
nextSr = ephem.nextSolar... | [
"Returns",
"a",
"profection",
"chart",
"for",
"a",
"given",
"date",
".",
"Receives",
"argument",
"fixedObjects",
"to",
"fix",
"chart",
"objects",
"in",
"their",
"natal",
"locations",
"."
] | flatangle/flatlib | python | https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/predictives/profections.py#L16-L44 | [
"def",
"compute",
"(",
"chart",
",",
"date",
",",
"fixedObjects",
"=",
"False",
")",
":",
"sun",
"=",
"chart",
".",
"getObject",
"(",
"const",
".",
"SUN",
")",
"prevSr",
"=",
"ephem",
".",
"prevSolarReturn",
"(",
"date",
",",
"sun",
".",
"lon",
")",
... | 44e05b2991a296c678adbc17a1d51b6a21bc867c |
train | _merge | Merges two list of objects removing
repetitions. | flatlib/protocols/behavior.py | def _merge(listA, listB):
""" Merges two list of objects removing
repetitions.
"""
listA = [x.id for x in listA]
listB = [x.id for x in listB]
listA.extend(listB)
set_ = set(listA)
return list(set_) | def _merge(listA, listB):
""" Merges two list of objects removing
repetitions.
"""
listA = [x.id for x in listA]
listB = [x.id for x in listB]
listA.extend(listB)
set_ = set(listA)
return list(set_) | [
"Merges",
"two",
"list",
"of",
"objects",
"removing",
"repetitions",
"."
] | flatangle/flatlib | python | https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/protocols/behavior.py#L16-L25 | [
"def",
"_merge",
"(",
"listA",
",",
"listB",
")",
":",
"listA",
"=",
"[",
"x",
".",
"id",
"for",
"x",
"in",
"listA",
"]",
"listB",
"=",
"[",
"x",
".",
"id",
"for",
"x",
"in",
"listB",
"]",
"listA",
".",
"extend",
"(",
"listB",
")",
"set_",
"=... | 44e05b2991a296c678adbc17a1d51b6a21bc867c |
train | compute | Computes the behavior. | flatlib/protocols/behavior.py | def compute(chart):
""" Computes the behavior. """
factors = []
# Planets in House1 or Conjunct Asc
house1 = chart.getHouse(const.HOUSE1)
planetsHouse1 = chart.objects.getObjectsInHouse(house1)
asc = chart.getAngle(const.ASC)
planetsConjAsc = chart.objects.getObjectsAspecting(asc, ... | def compute(chart):
""" Computes the behavior. """
factors = []
# Planets in House1 or Conjunct Asc
house1 = chart.getHouse(const.HOUSE1)
planetsHouse1 = chart.objects.getObjectsInHouse(house1)
asc = chart.getAngle(const.ASC)
planetsConjAsc = chart.objects.getObjectsAspecting(asc, ... | [
"Computes",
"the",
"behavior",
"."
] | flatangle/flatlib | python | https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/protocols/behavior.py#L28-L69 | [
"def",
"compute",
"(",
"chart",
")",
":",
"factors",
"=",
"[",
"]",
"# Planets in House1 or Conjunct Asc",
"house1",
"=",
"chart",
".",
"getHouse",
"(",
"const",
".",
"HOUSE1",
")",
"planetsHouse1",
"=",
"chart",
".",
"objects",
".",
"getObjectsInHouse",
"(",
... | 44e05b2991a296c678adbc17a1d51b6a21bc867c |
train | termLons | Returns a list with the absolute longitude
of all terms. | flatlib/dignities/tables.py | def termLons(TERMS):
""" Returns a list with the absolute longitude
of all terms.
"""
res = []
for i, sign in enumerate(SIGN_LIST):
termList = TERMS[sign]
res.extend([
ID,
sign,
start + 30 * i,
] for (ID, start, end) in termList)
... | def termLons(TERMS):
""" Returns a list with the absolute longitude
of all terms.
"""
res = []
for i, sign in enumerate(SIGN_LIST):
termList = TERMS[sign]
res.extend([
ID,
sign,
start + 30 * i,
] for (ID, start, end) in termList)
... | [
"Returns",
"a",
"list",
"with",
"the",
"absolute",
"longitude",
"of",
"all",
"terms",
"."
] | flatangle/flatlib | python | https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/dignities/tables.py#L482-L495 | [
"def",
"termLons",
"(",
"TERMS",
")",
":",
"res",
"=",
"[",
"]",
"for",
"i",
",",
"sign",
"in",
"enumerate",
"(",
"SIGN_LIST",
")",
":",
"termList",
"=",
"TERMS",
"[",
"sign",
"]",
"res",
".",
"extend",
"(",
"[",
"ID",
",",
"sign",
",",
"start",
... | 44e05b2991a296c678adbc17a1d51b6a21bc867c |
train | compute | Computes the Almutem table. | flatlib/protocols/almutem.py | def compute(chart):
""" Computes the Almutem table. """
almutems = {}
# Hylegic points
hylegic = [
chart.getObject(const.SUN),
chart.getObject(const.MOON),
chart.getAngle(const.ASC),
chart.getObject(const.PARS_FORTUNA),
chart.getObject(const.SYZYGY)
]
... | def compute(chart):
""" Computes the Almutem table. """
almutems = {}
# Hylegic points
hylegic = [
chart.getObject(const.SUN),
chart.getObject(const.MOON),
chart.getAngle(const.ASC),
chart.getObject(const.PARS_FORTUNA),
chart.getObject(const.SYZYGY)
]
... | [
"Computes",
"the",
"Almutem",
"table",
"."
] | flatangle/flatlib | python | https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/protocols/almutem.py#L58-L117 | [
"def",
"compute",
"(",
"chart",
")",
":",
"almutems",
"=",
"{",
"}",
"# Hylegic points",
"hylegic",
"=",
"[",
"chart",
".",
"getObject",
"(",
"const",
".",
"SUN",
")",
",",
"chart",
".",
"getObject",
"(",
"const",
".",
"MOON",
")",
",",
"chart",
".",... | 44e05b2991a296c678adbc17a1d51b6a21bc867c |
train | APIEndpoint.get | Gets the details for one or more resources by ID
Args:
cls - gophish.models.Model - The resource class
resource_id - str - The endpoint (URL path) for the resource
resource_action - str - An action to perform on the resource
resource_cls - cls - A class to use fo... | gophish/api/api.py | def get(self,
resource_id=None,
resource_action=None,
resource_cls=None,
single_resource=False):
""" Gets the details for one or more resources by ID
Args:
cls - gophish.models.Model - The resource class
resource_id - str - The end... | def get(self,
resource_id=None,
resource_action=None,
resource_cls=None,
single_resource=False):
""" Gets the details for one or more resources by ID
Args:
cls - gophish.models.Model - The resource class
resource_id - str - The end... | [
"Gets",
"the",
"details",
"for",
"one",
"or",
"more",
"resources",
"by",
"ID"
] | gophish/api-client-python | python | https://github.com/gophish/api-client-python/blob/28a7790f19e13c92ef0fb7bde8cd89389df5c155/gophish/api/api.py#L40-L79 | [
"def",
"get",
"(",
"self",
",",
"resource_id",
"=",
"None",
",",
"resource_action",
"=",
"None",
",",
"resource_cls",
"=",
"None",
",",
"single_resource",
"=",
"False",
")",
":",
"endpoint",
"=",
"self",
".",
"endpoint",
"if",
"not",
"resource_cls",
":",
... | 28a7790f19e13c92ef0fb7bde8cd89389df5c155 |
train | APIEndpoint.post | Creates a new instance of the resource.
Args:
resource - gophish.models.Model - The resource instance | gophish/api/api.py | def post(self, resource):
""" Creates a new instance of the resource.
Args:
resource - gophish.models.Model - The resource instance
"""
response = self.api.execute(
"POST", self.endpoint, json=(resource.as_dict()))
if not response.ok:
raise ... | def post(self, resource):
""" Creates a new instance of the resource.
Args:
resource - gophish.models.Model - The resource instance
"""
response = self.api.execute(
"POST", self.endpoint, json=(resource.as_dict()))
if not response.ok:
raise ... | [
"Creates",
"a",
"new",
"instance",
"of",
"the",
"resource",
"."
] | gophish/api-client-python | python | https://github.com/gophish/api-client-python/blob/28a7790f19e13c92ef0fb7bde8cd89389df5c155/gophish/api/api.py#L81-L94 | [
"def",
"post",
"(",
"self",
",",
"resource",
")",
":",
"response",
"=",
"self",
".",
"api",
".",
"execute",
"(",
"\"POST\"",
",",
"self",
".",
"endpoint",
",",
"json",
"=",
"(",
"resource",
".",
"as_dict",
"(",
")",
")",
")",
"if",
"not",
"response... | 28a7790f19e13c92ef0fb7bde8cd89389df5c155 |
train | APIEndpoint.put | Edits an existing resource
Args:
resource - gophish.models.Model - The resource instance | gophish/api/api.py | def put(self, resource):
""" Edits an existing resource
Args:
resource - gophish.models.Model - The resource instance
"""
endpoint = self.endpoint
if resource.id:
endpoint = self._build_url(endpoint, resource.id)
response = self.api.execute("PU... | def put(self, resource):
""" Edits an existing resource
Args:
resource - gophish.models.Model - The resource instance
"""
endpoint = self.endpoint
if resource.id:
endpoint = self._build_url(endpoint, resource.id)
response = self.api.execute("PU... | [
"Edits",
"an",
"existing",
"resource"
] | gophish/api-client-python | python | https://github.com/gophish/api-client-python/blob/28a7790f19e13c92ef0fb7bde8cd89389df5c155/gophish/api/api.py#L96-L113 | [
"def",
"put",
"(",
"self",
",",
"resource",
")",
":",
"endpoint",
"=",
"self",
".",
"endpoint",
"if",
"resource",
".",
"id",
":",
"endpoint",
"=",
"self",
".",
"_build_url",
"(",
"endpoint",
",",
"resource",
".",
"id",
")",
"response",
"=",
"self",
"... | 28a7790f19e13c92ef0fb7bde8cd89389df5c155 |
train | APIEndpoint.delete | Deletes an existing resource
Args:
resource_id - int - The resource ID to be deleted | gophish/api/api.py | def delete(self, resource_id):
""" Deletes an existing resource
Args:
resource_id - int - The resource ID to be deleted
"""
endpoint = '{}/{}'.format(self.endpoint, resource_id)
response = self.api.execute("DELETE", endpoint)
if not response.ok:
... | def delete(self, resource_id):
""" Deletes an existing resource
Args:
resource_id - int - The resource ID to be deleted
"""
endpoint = '{}/{}'.format(self.endpoint, resource_id)
response = self.api.execute("DELETE", endpoint)
if not response.ok:
... | [
"Deletes",
"an",
"existing",
"resource"
] | gophish/api-client-python | python | https://github.com/gophish/api-client-python/blob/28a7790f19e13c92ef0fb7bde8cd89389df5c155/gophish/api/api.py#L115-L129 | [
"def",
"delete",
"(",
"self",
",",
"resource_id",
")",
":",
"endpoint",
"=",
"'{}/{}'",
".",
"format",
"(",
"self",
".",
"endpoint",
",",
"resource_id",
")",
"response",
"=",
"self",
".",
"api",
".",
"execute",
"(",
"\"DELETE\"",
",",
"endpoint",
")",
... | 28a7790f19e13c92ef0fb7bde8cd89389df5c155 |
train | Model.as_dict | Returns a dict representation of the resource | gophish/models.py | def as_dict(self):
""" Returns a dict representation of the resource """
result = {}
for key in self._valid_properties:
val = getattr(self, key)
if isinstance(val, datetime):
val = val.isoformat()
# Parse custom classes
elif val and... | def as_dict(self):
""" Returns a dict representation of the resource """
result = {}
for key in self._valid_properties:
val = getattr(self, key)
if isinstance(val, datetime):
val = val.isoformat()
# Parse custom classes
elif val and... | [
"Returns",
"a",
"dict",
"representation",
"of",
"the",
"resource"
] | gophish/api-client-python | python | https://github.com/gophish/api-client-python/blob/28a7790f19e13c92ef0fb7bde8cd89389df5c155/gophish/models.py#L21-L46 | [
"def",
"as_dict",
"(",
"self",
")",
":",
"result",
"=",
"{",
"}",
"for",
"key",
"in",
"self",
".",
"_valid_properties",
":",
"val",
"=",
"getattr",
"(",
"self",
",",
"key",
")",
"if",
"isinstance",
"(",
"val",
",",
"datetime",
")",
":",
"val",
"=",... | 28a7790f19e13c92ef0fb7bde8cd89389df5c155 |
train | GophishClient.execute | Executes a request to a given endpoint, returning the result | gophish/client.py | def execute(self, method, path, **kwargs):
""" Executes a request to a given endpoint, returning the result """
url = "{}{}".format(self.host, path)
kwargs.update(self._client_kwargs)
response = requests.request(
method,
url,
headers={"Authorization":... | def execute(self, method, path, **kwargs):
""" Executes a request to a given endpoint, returning the result """
url = "{}{}".format(self.host, path)
kwargs.update(self._client_kwargs)
response = requests.request(
method,
url,
headers={"Authorization":... | [
"Executes",
"a",
"request",
"to",
"a",
"given",
"endpoint",
"returning",
"the",
"result"
] | gophish/api-client-python | python | https://github.com/gophish/api-client-python/blob/28a7790f19e13c92ef0fb7bde8cd89389df5c155/gophish/client.py#L16-L26 | [
"def",
"execute",
"(",
"self",
",",
"method",
",",
"path",
",",
"*",
"*",
"kwargs",
")",
":",
"url",
"=",
"\"{}{}\"",
".",
"format",
"(",
"self",
".",
"host",
",",
"path",
")",
"kwargs",
".",
"update",
"(",
"self",
".",
"_client_kwargs",
")",
"resp... | 28a7790f19e13c92ef0fb7bde8cd89389df5c155 |
train | API.complete | Complete an existing campaign (Stop processing events) | gophish/api/campaigns.py | def complete(self, campaign_id):
""" Complete an existing campaign (Stop processing events) """
return super(API, self).get(
resource_id=campaign_id, resource_action='complete') | def complete(self, campaign_id):
""" Complete an existing campaign (Stop processing events) """
return super(API, self).get(
resource_id=campaign_id, resource_action='complete') | [
"Complete",
"an",
"existing",
"campaign",
"(",
"Stop",
"processing",
"events",
")"
] | gophish/api-client-python | python | https://github.com/gophish/api-client-python/blob/28a7790f19e13c92ef0fb7bde8cd89389df5c155/gophish/api/campaigns.py#L32-L36 | [
"def",
"complete",
"(",
"self",
",",
"campaign_id",
")",
":",
"return",
"super",
"(",
"API",
",",
"self",
")",
".",
"get",
"(",
"resource_id",
"=",
"campaign_id",
",",
"resource_action",
"=",
"'complete'",
")"
] | 28a7790f19e13c92ef0fb7bde8cd89389df5c155 |
train | API.summary | Returns the campaign summary | gophish/api/campaigns.py | def summary(self, campaign_id=None):
""" Returns the campaign summary """
resource_cls = CampaignSummary
single_resource = False
if not campaign_id:
resource_cls = CampaignSummaries
single_resource = True
return super(API, self).get(
resource... | def summary(self, campaign_id=None):
""" Returns the campaign summary """
resource_cls = CampaignSummary
single_resource = False
if not campaign_id:
resource_cls = CampaignSummaries
single_resource = True
return super(API, self).get(
resource... | [
"Returns",
"the",
"campaign",
"summary"
] | gophish/api-client-python | python | https://github.com/gophish/api-client-python/blob/28a7790f19e13c92ef0fb7bde8cd89389df5c155/gophish/api/campaigns.py#L38-L51 | [
"def",
"summary",
"(",
"self",
",",
"campaign_id",
"=",
"None",
")",
":",
"resource_cls",
"=",
"CampaignSummary",
"single_resource",
"=",
"False",
"if",
"not",
"campaign_id",
":",
"resource_cls",
"=",
"CampaignSummaries",
"single_resource",
"=",
"True",
"return",
... | 28a7790f19e13c92ef0fb7bde8cd89389df5c155 |
train | API.results | Returns just the results for a given campaign | gophish/api/campaigns.py | def results(self, campaign_id):
""" Returns just the results for a given campaign """
return super(API, self).get(
resource_id=campaign_id,
resource_action='results',
resource_cls=CampaignResults) | def results(self, campaign_id):
""" Returns just the results for a given campaign """
return super(API, self).get(
resource_id=campaign_id,
resource_action='results',
resource_cls=CampaignResults) | [
"Returns",
"just",
"the",
"results",
"for",
"a",
"given",
"campaign"
] | gophish/api-client-python | python | https://github.com/gophish/api-client-python/blob/28a7790f19e13c92ef0fb7bde8cd89389df5c155/gophish/api/campaigns.py#L53-L58 | [
"def",
"results",
"(",
"self",
",",
"campaign_id",
")",
":",
"return",
"super",
"(",
"API",
",",
"self",
")",
".",
"get",
"(",
"resource_id",
"=",
"campaign_id",
",",
"resource_action",
"=",
"'results'",
",",
"resource_cls",
"=",
"CampaignResults",
")"
] | 28a7790f19e13c92ef0fb7bde8cd89389df5c155 |
train | Database.set_path | Set the path of the database.
Create the file if it does not exist. | jsondb/db.py | def set_path(self, file_path):
"""
Set the path of the database.
Create the file if it does not exist.
"""
if not file_path:
self.read_data = self.memory_read
self.write_data = self.memory_write
elif not is_valid(file_path):
self.write_... | def set_path(self, file_path):
"""
Set the path of the database.
Create the file if it does not exist.
"""
if not file_path:
self.read_data = self.memory_read
self.write_data = self.memory_write
elif not is_valid(file_path):
self.write_... | [
"Set",
"the",
"path",
"of",
"the",
"database",
".",
"Create",
"the",
"file",
"if",
"it",
"does",
"not",
"exist",
"."
] | gunthercox/jsondb | python | https://github.com/gunthercox/jsondb/blob/d0d2c7e5fdb8c3c46c0373d59c130641349b1bc9/jsondb/db.py#L38-L49 | [
"def",
"set_path",
"(",
"self",
",",
"file_path",
")",
":",
"if",
"not",
"file_path",
":",
"self",
".",
"read_data",
"=",
"self",
".",
"memory_read",
"self",
".",
"write_data",
"=",
"self",
".",
"memory_write",
"elif",
"not",
"is_valid",
"(",
"file_path",
... | d0d2c7e5fdb8c3c46c0373d59c130641349b1bc9 |
train | Database.delete | Removes the specified key from the database. | jsondb/db.py | def delete(self, key):
"""
Removes the specified key from the database.
"""
obj = self._get_content()
obj.pop(key, None)
self.write_data(self.path, obj) | def delete(self, key):
"""
Removes the specified key from the database.
"""
obj = self._get_content()
obj.pop(key, None)
self.write_data(self.path, obj) | [
"Removes",
"the",
"specified",
"key",
"from",
"the",
"database",
"."
] | gunthercox/jsondb | python | https://github.com/gunthercox/jsondb/blob/d0d2c7e5fdb8c3c46c0373d59c130641349b1bc9/jsondb/db.py#L68-L75 | [
"def",
"delete",
"(",
"self",
",",
"key",
")",
":",
"obj",
"=",
"self",
".",
"_get_content",
"(",
")",
"obj",
".",
"pop",
"(",
"key",
",",
"None",
")",
"self",
".",
"write_data",
"(",
"self",
".",
"path",
",",
"obj",
")"
] | d0d2c7e5fdb8c3c46c0373d59c130641349b1bc9 |
train | Database.data | If a key is passed in, a corresponding value will be returned.
If a key-value pair is passed in then the corresponding key in
the database will be set to the specified value.
A dictionary can be passed in as well.
If a key does not exist and a value is provided then an entry
will... | jsondb/db.py | def data(self, **kwargs):
"""
If a key is passed in, a corresponding value will be returned.
If a key-value pair is passed in then the corresponding key in
the database will be set to the specified value.
A dictionary can be passed in as well.
If a key does not exist and ... | def data(self, **kwargs):
"""
If a key is passed in, a corresponding value will be returned.
If a key-value pair is passed in then the corresponding key in
the database will be set to the specified value.
A dictionary can be passed in as well.
If a key does not exist and ... | [
"If",
"a",
"key",
"is",
"passed",
"in",
"a",
"corresponding",
"value",
"will",
"be",
"returned",
".",
"If",
"a",
"key",
"-",
"value",
"pair",
"is",
"passed",
"in",
"then",
"the",
"corresponding",
"key",
"in",
"the",
"database",
"will",
"be",
"set",
"to... | gunthercox/jsondb | python | https://github.com/gunthercox/jsondb/blob/d0d2c7e5fdb8c3c46c0373d59c130641349b1bc9/jsondb/db.py#L77-L109 | [
"def",
"data",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"key",
"=",
"kwargs",
".",
"pop",
"(",
"'key'",
",",
"None",
")",
"value",
"=",
"kwargs",
".",
"pop",
"(",
"'value'",
",",
"None",
")",
"dictionary",
"=",
"kwargs",
".",
"pop",
"(",
... | d0d2c7e5fdb8c3c46c0373d59c130641349b1bc9 |
train | Database.filter | Takes a dictionary of filter parameters.
Return a list of objects based on a list of parameters. | jsondb/db.py | def filter(self, filter_arguments):
"""
Takes a dictionary of filter parameters.
Return a list of objects based on a list of parameters.
"""
results = self._get_content()
# Filter based on a dictionary of search parameters
if isinstance(filter_arguments, dict):
... | def filter(self, filter_arguments):
"""
Takes a dictionary of filter parameters.
Return a list of objects based on a list of parameters.
"""
results = self._get_content()
# Filter based on a dictionary of search parameters
if isinstance(filter_arguments, dict):
... | [
"Takes",
"a",
"dictionary",
"of",
"filter",
"parameters",
".",
"Return",
"a",
"list",
"of",
"objects",
"based",
"on",
"a",
"list",
"of",
"parameters",
"."
] | gunthercox/jsondb | python | https://github.com/gunthercox/jsondb/blob/d0d2c7e5fdb8c3c46c0373d59c130641349b1bc9/jsondb/db.py#L125-L149 | [
"def",
"filter",
"(",
"self",
",",
"filter_arguments",
")",
":",
"results",
"=",
"self",
".",
"_get_content",
"(",
")",
"# Filter based on a dictionary of search parameters",
"if",
"isinstance",
"(",
"filter_arguments",
",",
"dict",
")",
":",
"for",
"item",
",",
... | d0d2c7e5fdb8c3c46c0373d59c130641349b1bc9 |
train | Database.drop | Remove the database by deleting the JSON file. | jsondb/db.py | def drop(self):
"""
Remove the database by deleting the JSON file.
"""
import os
if self.path:
if os.path.exists(self.path):
os.remove(self.path)
else:
# Clear the in-memory data if there is no file path
self._data = {} | def drop(self):
"""
Remove the database by deleting the JSON file.
"""
import os
if self.path:
if os.path.exists(self.path):
os.remove(self.path)
else:
# Clear the in-memory data if there is no file path
self._data = {} | [
"Remove",
"the",
"database",
"by",
"deleting",
"the",
"JSON",
"file",
"."
] | gunthercox/jsondb | python | https://github.com/gunthercox/jsondb/blob/d0d2c7e5fdb8c3c46c0373d59c130641349b1bc9/jsondb/db.py#L151-L162 | [
"def",
"drop",
"(",
"self",
")",
":",
"import",
"os",
"if",
"self",
".",
"path",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"path",
")",
":",
"os",
".",
"remove",
"(",
"self",
".",
"path",
")",
"else",
":",
"# Clear the in-mem... | d0d2c7e5fdb8c3c46c0373d59c130641349b1bc9 |
train | read_data | Reads a file and returns a json encoded representation of the file. | jsondb/file_writer.py | def read_data(file_path):
"""
Reads a file and returns a json encoded representation of the file.
"""
if not is_valid(file_path):
write_data(file_path, {})
db = open_file_for_reading(file_path)
content = db.read()
obj = decode(content)
db.close()
return obj | def read_data(file_path):
"""
Reads a file and returns a json encoded representation of the file.
"""
if not is_valid(file_path):
write_data(file_path, {})
db = open_file_for_reading(file_path)
content = db.read()
obj = decode(content)
db.close()
return obj | [
"Reads",
"a",
"file",
"and",
"returns",
"a",
"json",
"encoded",
"representation",
"of",
"the",
"file",
"."
] | gunthercox/jsondb | python | https://github.com/gunthercox/jsondb/blob/d0d2c7e5fdb8c3c46c0373d59c130641349b1bc9/jsondb/file_writer.py#L4-L19 | [
"def",
"read_data",
"(",
"file_path",
")",
":",
"if",
"not",
"is_valid",
"(",
"file_path",
")",
":",
"write_data",
"(",
"file_path",
",",
"{",
"}",
")",
"db",
"=",
"open_file_for_reading",
"(",
"file_path",
")",
"content",
"=",
"db",
".",
"read",
"(",
... | d0d2c7e5fdb8c3c46c0373d59c130641349b1bc9 |
train | write_data | Writes to a file and returns the updated file content. | jsondb/file_writer.py | def write_data(path, obj):
"""
Writes to a file and returns the updated file content.
"""
with open_file_for_writing(path) as db:
db.write(encode(obj))
return obj | def write_data(path, obj):
"""
Writes to a file and returns the updated file content.
"""
with open_file_for_writing(path) as db:
db.write(encode(obj))
return obj | [
"Writes",
"to",
"a",
"file",
"and",
"returns",
"the",
"updated",
"file",
"content",
"."
] | gunthercox/jsondb | python | https://github.com/gunthercox/jsondb/blob/d0d2c7e5fdb8c3c46c0373d59c130641349b1bc9/jsondb/file_writer.py#L21-L28 | [
"def",
"write_data",
"(",
"path",
",",
"obj",
")",
":",
"with",
"open_file_for_writing",
"(",
"path",
")",
"as",
"db",
":",
"db",
".",
"write",
"(",
"encode",
"(",
"obj",
")",
")",
"return",
"obj"
] | d0d2c7e5fdb8c3c46c0373d59c130641349b1bc9 |
train | is_valid | Check to see if a file exists or is empty. | jsondb/file_writer.py | def is_valid(file_path):
"""
Check to see if a file exists or is empty.
"""
from os import path, stat
can_open = False
try:
with open(file_path) as fp:
can_open = True
except IOError:
return False
is_file = path.isfile(file_path)
return path.exists(fil... | def is_valid(file_path):
"""
Check to see if a file exists or is empty.
"""
from os import path, stat
can_open = False
try:
with open(file_path) as fp:
can_open = True
except IOError:
return False
is_file = path.isfile(file_path)
return path.exists(fil... | [
"Check",
"to",
"see",
"if",
"a",
"file",
"exists",
"or",
"is",
"empty",
"."
] | gunthercox/jsondb | python | https://github.com/gunthercox/jsondb/blob/d0d2c7e5fdb8c3c46c0373d59c130641349b1bc9/jsondb/file_writer.py#L30-L46 | [
"def",
"is_valid",
"(",
"file_path",
")",
":",
"from",
"os",
"import",
"path",
",",
"stat",
"can_open",
"=",
"False",
"try",
":",
"with",
"open",
"(",
"file_path",
")",
"as",
"fp",
":",
"can_open",
"=",
"True",
"except",
"IOError",
":",
"return",
"Fals... | d0d2c7e5fdb8c3c46c0373d59c130641349b1bc9 |
train | _refine | Canonically refine a mesh by inserting nodes at all edge midpoints
and make four triangular elements where there was one.
This is a very crude refinement; don't use for actual applications. | meshzoo/helpers.py | def _refine(node_coords, cells_nodes, edge_nodes, cells_edges):
"""Canonically refine a mesh by inserting nodes at all edge midpoints
and make four triangular elements where there was one.
This is a very crude refinement; don't use for actual applications.
"""
num_nodes = len(node_coords)
num_ne... | def _refine(node_coords, cells_nodes, edge_nodes, cells_edges):
"""Canonically refine a mesh by inserting nodes at all edge midpoints
and make four triangular elements where there was one.
This is a very crude refinement; don't use for actual applications.
"""
num_nodes = len(node_coords)
num_ne... | [
"Canonically",
"refine",
"a",
"mesh",
"by",
"inserting",
"nodes",
"at",
"all",
"edge",
"midpoints",
"and",
"make",
"four",
"triangular",
"elements",
"where",
"there",
"was",
"one",
".",
"This",
"is",
"a",
"very",
"crude",
"refinement",
";",
"don",
"t",
"us... | nschloe/meshzoo | python | https://github.com/nschloe/meshzoo/blob/623b84c8b985dcc8e5ccc6250d1dbb989736dcef/meshzoo/helpers.py#L7-L124 | [
"def",
"_refine",
"(",
"node_coords",
",",
"cells_nodes",
",",
"edge_nodes",
",",
"cells_edges",
")",
":",
"num_nodes",
"=",
"len",
"(",
"node_coords",
")",
"num_new_nodes",
"=",
"len",
"(",
"edge_nodes",
")",
"# new_nodes = numpy.empty(num_new_nodes, dtype=numpy.dtyp... | 623b84c8b985dcc8e5ccc6250d1dbb989736dcef |
train | create_edges | Setup edge-node and edge-cell relations. Adapted from voropy. | meshzoo/helpers.py | def create_edges(cells_nodes):
"""Setup edge-node and edge-cell relations. Adapted from voropy.
"""
# Create the idx_hierarchy (nodes->edges->cells), i.e., the value of
# `self.idx_hierarchy[0, 2, 27]` is the index of the node of cell 27, edge
# 2, node 0. The shape of `self.idx_hierarchy` is `(2, 3... | def create_edges(cells_nodes):
"""Setup edge-node and edge-cell relations. Adapted from voropy.
"""
# Create the idx_hierarchy (nodes->edges->cells), i.e., the value of
# `self.idx_hierarchy[0, 2, 27]` is the index of the node of cell 27, edge
# 2, node 0. The shape of `self.idx_hierarchy` is `(2, 3... | [
"Setup",
"edge",
"-",
"node",
"and",
"edge",
"-",
"cell",
"relations",
".",
"Adapted",
"from",
"voropy",
"."
] | nschloe/meshzoo | python | https://github.com/nschloe/meshzoo/blob/623b84c8b985dcc8e5ccc6250d1dbb989736dcef/meshzoo/helpers.py#L127-L158 | [
"def",
"create_edges",
"(",
"cells_nodes",
")",
":",
"# Create the idx_hierarchy (nodes->edges->cells), i.e., the value of",
"# `self.idx_hierarchy[0, 2, 27]` is the index of the node of cell 27, edge",
"# 2, node 0. The shape of `self.idx_hierarchy` is `(2, 3, n)`, where `n` is",
"# the number of... | 623b84c8b985dcc8e5ccc6250d1dbb989736dcef |
train | plot2d | Plot a 2D mesh using matplotlib. | meshzoo/helpers.py | def plot2d(points, cells, mesh_color="k", show_axes=False):
"""Plot a 2D mesh using matplotlib.
"""
import matplotlib.pyplot as plt
from matplotlib.collections import LineCollection
fig = plt.figure()
ax = fig.gca()
plt.axis("equal")
if not show_axes:
ax.set_axis_off()
xmin... | def plot2d(points, cells, mesh_color="k", show_axes=False):
"""Plot a 2D mesh using matplotlib.
"""
import matplotlib.pyplot as plt
from matplotlib.collections import LineCollection
fig = plt.figure()
ax = fig.gca()
plt.axis("equal")
if not show_axes:
ax.set_axis_off()
xmin... | [
"Plot",
"a",
"2D",
"mesh",
"using",
"matplotlib",
"."
] | nschloe/meshzoo | python | https://github.com/nschloe/meshzoo/blob/623b84c8b985dcc8e5ccc6250d1dbb989736dcef/meshzoo/helpers.py#L169-L203 | [
"def",
"plot2d",
"(",
"points",
",",
"cells",
",",
"mesh_color",
"=",
"\"k\"",
",",
"show_axes",
"=",
"False",
")",
":",
"import",
"matplotlib",
".",
"pyplot",
"as",
"plt",
"from",
"matplotlib",
".",
"collections",
"import",
"LineCollection",
"fig",
"=",
"... | 623b84c8b985dcc8e5ccc6250d1dbb989736dcef |
train | BlockingWorkerPool.put | Perform a job by a member in the pool and return the result. | samples/blockingworker.py | def put(self, job, result):
"Perform a job by a member in the pool and return the result."
self.job.put(job)
r = result.get()
return r | def put(self, job, result):
"Perform a job by a member in the pool and return the result."
self.job.put(job)
r = result.get()
return r | [
"Perform",
"a",
"job",
"by",
"a",
"member",
"in",
"the",
"pool",
"and",
"return",
"the",
"result",
"."
] | shazow/workerpool | python | https://github.com/shazow/workerpool/blob/2c5b29ec64ffbc94fc3623a4531eaf7c7c1a9ab5/samples/blockingworker.py#L16-L20 | [
"def",
"put",
"(",
"self",
",",
"job",
",",
"result",
")",
":",
"self",
".",
"job",
".",
"put",
"(",
"job",
")",
"r",
"=",
"result",
".",
"get",
"(",
")",
"return",
"r"
] | 2c5b29ec64ffbc94fc3623a4531eaf7c7c1a9ab5 |
train | BlockingWorkerPool.contract | Perform a contract on a number of jobs and block until a result is
retrieved for each job. | samples/blockingworker.py | def contract(self, jobs, result):
"""
Perform a contract on a number of jobs and block until a result is
retrieved for each job.
"""
for j in jobs:
WorkerPool.put(self, j)
r = []
for i in xrange(len(jobs)):
r.append(result.get())
... | def contract(self, jobs, result):
"""
Perform a contract on a number of jobs and block until a result is
retrieved for each job.
"""
for j in jobs:
WorkerPool.put(self, j)
r = []
for i in xrange(len(jobs)):
r.append(result.get())
... | [
"Perform",
"a",
"contract",
"on",
"a",
"number",
"of",
"jobs",
"and",
"block",
"until",
"a",
"result",
"is",
"retrieved",
"for",
"each",
"job",
"."
] | shazow/workerpool | python | https://github.com/shazow/workerpool/blob/2c5b29ec64ffbc94fc3623a4531eaf7c7c1a9ab5/samples/blockingworker.py#L22-L34 | [
"def",
"contract",
"(",
"self",
",",
"jobs",
",",
"result",
")",
":",
"for",
"j",
"in",
"jobs",
":",
"WorkerPool",
".",
"put",
"(",
"self",
",",
"j",
")",
"r",
"=",
"[",
"]",
"for",
"i",
"in",
"xrange",
"(",
"len",
"(",
"jobs",
")",
")",
":",... | 2c5b29ec64ffbc94fc3623a4531eaf7c7c1a9ab5 |
train | cube | Canonical tetrahedrization of the cube.
Input:
Edge lenghts of the cube
Number of nodes along the edges. | meshzoo/cube.py | def cube(
xmin=0.0, xmax=1.0, ymin=0.0, ymax=1.0, zmin=0.0, zmax=1.0, nx=11, ny=11, nz=11
):
"""Canonical tetrahedrization of the cube.
Input:
Edge lenghts of the cube
Number of nodes along the edges.
"""
# Generate suitable ranges for parametrization
x_range = numpy.linspace(xmin, xmax,... | def cube(
xmin=0.0, xmax=1.0, ymin=0.0, ymax=1.0, zmin=0.0, zmax=1.0, nx=11, ny=11, nz=11
):
"""Canonical tetrahedrization of the cube.
Input:
Edge lenghts of the cube
Number of nodes along the edges.
"""
# Generate suitable ranges for parametrization
x_range = numpy.linspace(xmin, xmax,... | [
"Canonical",
"tetrahedrization",
"of",
"the",
"cube",
".",
"Input",
":",
"Edge",
"lenghts",
"of",
"the",
"cube",
"Number",
"of",
"nodes",
"along",
"the",
"edges",
"."
] | nschloe/meshzoo | python | https://github.com/nschloe/meshzoo/blob/623b84c8b985dcc8e5ccc6250d1dbb989736dcef/meshzoo/cube.py#L6-L294 | [
"def",
"cube",
"(",
"xmin",
"=",
"0.0",
",",
"xmax",
"=",
"1.0",
",",
"ymin",
"=",
"0.0",
",",
"ymax",
"=",
"1.0",
",",
"zmin",
"=",
"0.0",
",",
"zmax",
"=",
"1.0",
",",
"nx",
"=",
"11",
",",
"ny",
"=",
"11",
",",
"nz",
"=",
"11",
")",
":... | 623b84c8b985dcc8e5ccc6250d1dbb989736dcef |
train | WorkerPool.grow | Add another worker to the pool. | workerpool/pools.py | def grow(self):
"Add another worker to the pool."
t = self.worker_factory(self)
t.start()
self._size += 1 | def grow(self):
"Add another worker to the pool."
t = self.worker_factory(self)
t.start()
self._size += 1 | [
"Add",
"another",
"worker",
"to",
"the",
"pool",
"."
] | shazow/workerpool | python | https://github.com/shazow/workerpool/blob/2c5b29ec64ffbc94fc3623a4531eaf7c7c1a9ab5/workerpool/pools.py#L66-L70 | [
"def",
"grow",
"(",
"self",
")",
":",
"t",
"=",
"self",
".",
"worker_factory",
"(",
"self",
")",
"t",
".",
"start",
"(",
")",
"self",
".",
"_size",
"+=",
"1"
] | 2c5b29ec64ffbc94fc3623a4531eaf7c7c1a9ab5 |
train | WorkerPool.shrink | Get rid of one worker from the pool. Raises IndexError if empty. | workerpool/pools.py | def shrink(self):
"Get rid of one worker from the pool. Raises IndexError if empty."
if self._size <= 0:
raise IndexError("pool is already empty")
self._size -= 1
self.put(SuicideJob()) | def shrink(self):
"Get rid of one worker from the pool. Raises IndexError if empty."
if self._size <= 0:
raise IndexError("pool is already empty")
self._size -= 1
self.put(SuicideJob()) | [
"Get",
"rid",
"of",
"one",
"worker",
"from",
"the",
"pool",
".",
"Raises",
"IndexError",
"if",
"empty",
"."
] | shazow/workerpool | python | https://github.com/shazow/workerpool/blob/2c5b29ec64ffbc94fc3623a4531eaf7c7c1a9ab5/workerpool/pools.py#L72-L77 | [
"def",
"shrink",
"(",
"self",
")",
":",
"if",
"self",
".",
"_size",
"<=",
"0",
":",
"raise",
"IndexError",
"(",
"\"pool is already empty\"",
")",
"self",
".",
"_size",
"-=",
"1",
"self",
".",
"put",
"(",
"SuicideJob",
"(",
")",
")"
] | 2c5b29ec64ffbc94fc3623a4531eaf7c7c1a9ab5 |
train | WorkerPool.map | Perform a map operation distributed among the workers. Will | workerpool/pools.py | def map(self, fn, *seq):
"Perform a map operation distributed among the workers. Will "
"block until done."
results = Queue()
args = zip(*seq)
for seq in args:
j = SimpleJob(results, fn, seq)
self.put(j)
# Aggregate results
r = []
... | def map(self, fn, *seq):
"Perform a map operation distributed among the workers. Will "
"block until done."
results = Queue()
args = zip(*seq)
for seq in args:
j = SimpleJob(results, fn, seq)
self.put(j)
# Aggregate results
r = []
... | [
"Perform",
"a",
"map",
"operation",
"distributed",
"among",
"the",
"workers",
".",
"Will"
] | shazow/workerpool | python | https://github.com/shazow/workerpool/blob/2c5b29ec64ffbc94fc3623a4531eaf7c7c1a9ab5/workerpool/pools.py#L89-L103 | [
"def",
"map",
"(",
"self",
",",
"fn",
",",
"*",
"seq",
")",
":",
"\"block until done.\"",
"results",
"=",
"Queue",
"(",
")",
"args",
"=",
"zip",
"(",
"*",
"seq",
")",
"for",
"seq",
"in",
"args",
":",
"j",
"=",
"SimpleJob",
"(",
"results",
",",
"f... | 2c5b29ec64ffbc94fc3623a4531eaf7c7c1a9ab5 |
train | moebius | Creates a simplistic triangular mesh on a slightly Möbius strip. The
Möbius strip here deviates slightly from the ordinary geometry in that it
is constructed in such a way that the two halves can be exchanged as to
allow better comparison with the pseudo-Möbius geometry.
The mode is either `'classical'... | meshzoo/moebius.py | def moebius(
num_twists=1, # How many twists are there in the 'paper'?
nl=60, # Number of nodes along the length of the strip
nw=11, # Number of nodes along the width of the strip (>= 2)
mode="classical",
):
"""Creates a simplistic triangular mesh on a slightly Möbius strip. The
Möbius strip ... | def moebius(
num_twists=1, # How many twists are there in the 'paper'?
nl=60, # Number of nodes along the length of the strip
nw=11, # Number of nodes along the width of the strip (>= 2)
mode="classical",
):
"""Creates a simplistic triangular mesh on a slightly Möbius strip. The
Möbius strip ... | [
"Creates",
"a",
"simplistic",
"triangular",
"mesh",
"on",
"a",
"slightly",
"Möbius",
"strip",
".",
"The",
"Möbius",
"strip",
"here",
"deviates",
"slightly",
"from",
"the",
"ordinary",
"geometry",
"in",
"that",
"it",
"is",
"constructed",
"in",
"such",
"a",
"w... | nschloe/meshzoo | python | https://github.com/nschloe/meshzoo/blob/623b84c8b985dcc8e5ccc6250d1dbb989736dcef/meshzoo/moebius.py#L7-L83 | [
"def",
"moebius",
"(",
"num_twists",
"=",
"1",
",",
"# How many twists are there in the 'paper'?",
"nl",
"=",
"60",
",",
"# Number of nodes along the length of the strip",
"nw",
"=",
"11",
",",
"# Number of nodes along the width of the strip (>= 2)",
"mode",
"=",
"\"classical... | 623b84c8b985dcc8e5ccc6250d1dbb989736dcef |
train | Worker.run | Get jobs from the queue and perform them as they arrive. | workerpool/workers.py | def run(self):
"Get jobs from the queue and perform them as they arrive."
while 1:
# Sleep until there is a job to perform.
job = self.jobs.get()
# Yawn. Time to get some work done.
try:
job.run()
self.jobs.task_done()
... | def run(self):
"Get jobs from the queue and perform them as they arrive."
while 1:
# Sleep until there is a job to perform.
job = self.jobs.get()
# Yawn. Time to get some work done.
try:
job.run()
self.jobs.task_done()
... | [
"Get",
"jobs",
"from",
"the",
"queue",
"and",
"perform",
"them",
"as",
"they",
"arrive",
"."
] | shazow/workerpool | python | https://github.com/shazow/workerpool/blob/2c5b29ec64ffbc94fc3623a4531eaf7c7c1a9ab5/workerpool/workers.py#L28-L40 | [
"def",
"run",
"(",
"self",
")",
":",
"while",
"1",
":",
"# Sleep until there is a job to perform.",
"job",
"=",
"self",
".",
"jobs",
".",
"get",
"(",
")",
"# Yawn. Time to get some work done.",
"try",
":",
"job",
".",
"run",
"(",
")",
"self",
".",
"jobs",
... | 2c5b29ec64ffbc94fc3623a4531eaf7c7c1a9ab5 |
train | display | Open a web browser pointing to geojson.io with the specified content.
If the content is large, an anonymous gist will be created on github and
the URL will instruct geojson.io to download the gist data and then
display. If the content is small, this step is not needed as the data can
be included in the... | geojsonio/geojsonio.py | def display(contents, domain=DEFAULT_DOMAIN, force_gist=False):
"""
Open a web browser pointing to geojson.io with the specified content.
If the content is large, an anonymous gist will be created on github and
the URL will instruct geojson.io to download the gist data and then
display. If the cont... | def display(contents, domain=DEFAULT_DOMAIN, force_gist=False):
"""
Open a web browser pointing to geojson.io with the specified content.
If the content is large, an anonymous gist will be created on github and
the URL will instruct geojson.io to download the gist data and then
display. If the cont... | [
"Open",
"a",
"web",
"browser",
"pointing",
"to",
"geojson",
".",
"io",
"with",
"the",
"specified",
"content",
"."
] | jwass/geojsonio.py | python | https://github.com/jwass/geojsonio.py/blob/8229a48238f128837e6dce49f18310df84968825/geojsonio/geojsonio.py#L18-L38 | [
"def",
"display",
"(",
"contents",
",",
"domain",
"=",
"DEFAULT_DOMAIN",
",",
"force_gist",
"=",
"False",
")",
":",
"url",
"=",
"make_url",
"(",
"contents",
",",
"domain",
",",
"force_gist",
")",
"webbrowser",
".",
"open",
"(",
"url",
")",
"return",
"url... | 8229a48238f128837e6dce49f18310df84968825 |
train | embed | Embed geojson.io in an iframe in Jupyter/IPython notebook.
Parameters
----------
contents - see make_url()
width - string, default '100%' - width of the iframe
height - string / int, default 512 - height of the iframe
kwargs - additional arguments are passed to `make_url()` | geojsonio/geojsonio.py | def embed(contents='', width='100%', height=512, *args, **kwargs):
"""
Embed geojson.io in an iframe in Jupyter/IPython notebook.
Parameters
----------
contents - see make_url()
width - string, default '100%' - width of the iframe
height - string / int, default 512 - height of the iframe
... | def embed(contents='', width='100%', height=512, *args, **kwargs):
"""
Embed geojson.io in an iframe in Jupyter/IPython notebook.
Parameters
----------
contents - see make_url()
width - string, default '100%' - width of the iframe
height - string / int, default 512 - height of the iframe
... | [
"Embed",
"geojson",
".",
"io",
"in",
"an",
"iframe",
"in",
"Jupyter",
"/",
"IPython",
"notebook",
"."
] | jwass/geojsonio.py | python | https://github.com/jwass/geojsonio.py/blob/8229a48238f128837e6dce49f18310df84968825/geojsonio/geojsonio.py#L43-L60 | [
"def",
"embed",
"(",
"contents",
"=",
"''",
",",
"width",
"=",
"'100%'",
",",
"height",
"=",
"512",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"from",
"IPython",
".",
"display",
"import",
"HTML",
"url",
"=",
"make_url",
"(",
"contents",
"... | 8229a48238f128837e6dce49f18310df84968825 |
train | make_url | Returns the URL to open given the domain and contents.
If the file contents are large, an anonymous gist will be created.
Parameters
----------
contents
* string - assumed to be GeoJSON
* an object that implements __geo_interface__
A FeatureCollection will be constructed wi... | geojsonio/geojsonio.py | def make_url(contents, domain=DEFAULT_DOMAIN, force_gist=False,
size_for_gist=MAX_URL_LEN):
"""
Returns the URL to open given the domain and contents.
If the file contents are large, an anonymous gist will be created.
Parameters
----------
contents
* string - assumed to be... | def make_url(contents, domain=DEFAULT_DOMAIN, force_gist=False,
size_for_gist=MAX_URL_LEN):
"""
Returns the URL to open given the domain and contents.
If the file contents are large, an anonymous gist will be created.
Parameters
----------
contents
* string - assumed to be... | [
"Returns",
"the",
"URL",
"to",
"open",
"given",
"the",
"domain",
"and",
"contents",
"."
] | jwass/geojsonio.py | python | https://github.com/jwass/geojsonio.py/blob/8229a48238f128837e6dce49f18310df84968825/geojsonio/geojsonio.py#L63-L96 | [
"def",
"make_url",
"(",
"contents",
",",
"domain",
"=",
"DEFAULT_DOMAIN",
",",
"force_gist",
"=",
"False",
",",
"size_for_gist",
"=",
"MAX_URL_LEN",
")",
":",
"contents",
"=",
"make_geojson",
"(",
"contents",
")",
"if",
"len",
"(",
"contents",
")",
"<=",
"... | 8229a48238f128837e6dce49f18310df84968825 |
train | make_geojson | Return a GeoJSON string from a variety of inputs.
See the documentation for make_url for the possible contents
input.
Returns
-------
GeoJSON string | geojsonio/geojsonio.py | def make_geojson(contents):
"""
Return a GeoJSON string from a variety of inputs.
See the documentation for make_url for the possible contents
input.
Returns
-------
GeoJSON string
"""
if isinstance(contents, six.string_types):
return contents
if hasattr(contents, '__g... | def make_geojson(contents):
"""
Return a GeoJSON string from a variety of inputs.
See the documentation for make_url for the possible contents
input.
Returns
-------
GeoJSON string
"""
if isinstance(contents, six.string_types):
return contents
if hasattr(contents, '__g... | [
"Return",
"a",
"GeoJSON",
"string",
"from",
"a",
"variety",
"of",
"inputs",
".",
"See",
"the",
"documentation",
"for",
"make_url",
"for",
"the",
"possible",
"contents",
"input",
"."
] | jwass/geojsonio.py | python | https://github.com/jwass/geojsonio.py/blob/8229a48238f128837e6dce49f18310df84968825/geojsonio/geojsonio.py#L99-L128 | [
"def",
"make_geojson",
"(",
"contents",
")",
":",
"if",
"isinstance",
"(",
"contents",
",",
"six",
".",
"string_types",
")",
":",
"return",
"contents",
"if",
"hasattr",
"(",
"contents",
",",
"'__geo_interface__'",
")",
":",
"features",
"=",
"[",
"_geo_to_fea... | 8229a48238f128837e6dce49f18310df84968825 |
train | data_url | Return the URL for embedding the GeoJSON data in the URL hash
Parameters
----------
contents - string of GeoJSON
domain - string, default http://geojson.io | geojsonio/geojsonio.py | def data_url(contents, domain=DEFAULT_DOMAIN):
"""
Return the URL for embedding the GeoJSON data in the URL hash
Parameters
----------
contents - string of GeoJSON
domain - string, default http://geojson.io
"""
url = (domain + '#data=data:application/json,' +
urllib.parse.qu... | def data_url(contents, domain=DEFAULT_DOMAIN):
"""
Return the URL for embedding the GeoJSON data in the URL hash
Parameters
----------
contents - string of GeoJSON
domain - string, default http://geojson.io
"""
url = (domain + '#data=data:application/json,' +
urllib.parse.qu... | [
"Return",
"the",
"URL",
"for",
"embedding",
"the",
"GeoJSON",
"data",
"in",
"the",
"URL",
"hash"
] | jwass/geojsonio.py | python | https://github.com/jwass/geojsonio.py/blob/8229a48238f128837e6dce49f18310df84968825/geojsonio/geojsonio.py#L149-L161 | [
"def",
"data_url",
"(",
"contents",
",",
"domain",
"=",
"DEFAULT_DOMAIN",
")",
":",
"url",
"=",
"(",
"domain",
"+",
"'#data=data:application/json,'",
"+",
"urllib",
".",
"parse",
".",
"quote",
"(",
"contents",
")",
")",
"return",
"url"
] | 8229a48238f128837e6dce49f18310df84968825 |
train | _make_gist | Create and return an anonymous gist with a single file and specified
contents | geojsonio/geojsonio.py | def _make_gist(contents, description='', filename='data.geojson'):
"""
Create and return an anonymous gist with a single file and specified
contents
"""
ghapi = github3.GitHub()
files = {filename: {'content': contents}}
gist = ghapi.create_gist(description, files)
return gist | def _make_gist(contents, description='', filename='data.geojson'):
"""
Create and return an anonymous gist with a single file and specified
contents
"""
ghapi = github3.GitHub()
files = {filename: {'content': contents}}
gist = ghapi.create_gist(description, files)
return gist | [
"Create",
"and",
"return",
"an",
"anonymous",
"gist",
"with",
"a",
"single",
"file",
"and",
"specified",
"contents"
] | jwass/geojsonio.py | python | https://github.com/jwass/geojsonio.py/blob/8229a48238f128837e6dce49f18310df84968825/geojsonio/geojsonio.py#L164-L174 | [
"def",
"_make_gist",
"(",
"contents",
",",
"description",
"=",
"''",
",",
"filename",
"=",
"'data.geojson'",
")",
":",
"ghapi",
"=",
"github3",
".",
"GitHub",
"(",
")",
"files",
"=",
"{",
"filename",
":",
"{",
"'content'",
":",
"contents",
"}",
"}",
"g... | 8229a48238f128837e6dce49f18310df84968825 |
train | clenshaw | Clenshaw's algorithm for evaluating
S(t) = \\sum a_k P_k(alpha, beta)(t)
where P_k(alpha, beta) is the kth orthogonal polynomial defined by the
recurrence coefficients alpha, beta.
See <https://en.wikipedia.org/wiki/Clenshaw_algorithm> for details. | orthopy/line_segment/tools.py | def clenshaw(a, alpha, beta, t):
"""Clenshaw's algorithm for evaluating
S(t) = \\sum a_k P_k(alpha, beta)(t)
where P_k(alpha, beta) is the kth orthogonal polynomial defined by the
recurrence coefficients alpha, beta.
See <https://en.wikipedia.org/wiki/Clenshaw_algorithm> for details.
"""
... | def clenshaw(a, alpha, beta, t):
"""Clenshaw's algorithm for evaluating
S(t) = \\sum a_k P_k(alpha, beta)(t)
where P_k(alpha, beta) is the kth orthogonal polynomial defined by the
recurrence coefficients alpha, beta.
See <https://en.wikipedia.org/wiki/Clenshaw_algorithm> for details.
"""
... | [
"Clenshaw",
"s",
"algorithm",
"for",
"evaluating"
] | nschloe/orthopy | python | https://github.com/nschloe/orthopy/blob/64713d0533b0af042810a7535fff411b8e0aea9e/orthopy/line_segment/tools.py#L8-L39 | [
"def",
"clenshaw",
"(",
"a",
",",
"alpha",
",",
"beta",
",",
"t",
")",
":",
"n",
"=",
"len",
"(",
"alpha",
")",
"assert",
"len",
"(",
"beta",
")",
"==",
"n",
"assert",
"len",
"(",
"a",
")",
"==",
"n",
"+",
"1",
"try",
":",
"b",
"=",
"numpy"... | 64713d0533b0af042810a7535fff411b8e0aea9e |
train | tree | Recurrence coefficients for generalized Laguerre polynomials. Set
alpha=0 (default) to get classical Laguerre. | orthopy/e1r/orth.py | def tree(X, n, alpha=0, symbolic=False):
"""Recurrence coefficients for generalized Laguerre polynomials. Set
alpha=0 (default) to get classical Laguerre.
"""
args = recurrence_coefficients(n, alpha=alpha, symbolic=symbolic)
return line_tree(X, *args) | def tree(X, n, alpha=0, symbolic=False):
"""Recurrence coefficients for generalized Laguerre polynomials. Set
alpha=0 (default) to get classical Laguerre.
"""
args = recurrence_coefficients(n, alpha=alpha, symbolic=symbolic)
return line_tree(X, *args) | [
"Recurrence",
"coefficients",
"for",
"generalized",
"Laguerre",
"polynomials",
".",
"Set",
"alpha",
"=",
"0",
"(",
"default",
")",
"to",
"get",
"classical",
"Laguerre",
"."
] | nschloe/orthopy | python | https://github.com/nschloe/orthopy/blob/64713d0533b0af042810a7535fff411b8e0aea9e/orthopy/e1r/orth.py#L12-L17 | [
"def",
"tree",
"(",
"X",
",",
"n",
",",
"alpha",
"=",
"0",
",",
"symbolic",
"=",
"False",
")",
":",
"args",
"=",
"recurrence_coefficients",
"(",
"n",
",",
"alpha",
"=",
"alpha",
",",
"symbolic",
"=",
"symbolic",
")",
"return",
"line_tree",
"(",
"X",
... | 64713d0533b0af042810a7535fff411b8e0aea9e |
train | recurrence_coefficients | Recurrence coefficients for generalized Laguerre polynomials.
vals_k = vals_{k-1} * (t*a_k - b_k) - vals{k-2} * c_k | orthopy/e1r/orth.py | def recurrence_coefficients(n, alpha, standardization="normal", symbolic=False):
"""Recurrence coefficients for generalized Laguerre polynomials.
vals_k = vals_{k-1} * (t*a_k - b_k) - vals{k-2} * c_k
"""
S = sympy.S if symbolic else lambda x: x
sqrt = sympy.sqrt if symbolic else numpy.sqrt
... | def recurrence_coefficients(n, alpha, standardization="normal", symbolic=False):
"""Recurrence coefficients for generalized Laguerre polynomials.
vals_k = vals_{k-1} * (t*a_k - b_k) - vals{k-2} * c_k
"""
S = sympy.S if symbolic else lambda x: x
sqrt = sympy.sqrt if symbolic else numpy.sqrt
... | [
"Recurrence",
"coefficients",
"for",
"generalized",
"Laguerre",
"polynomials",
"."
] | nschloe/orthopy | python | https://github.com/nschloe/orthopy/blob/64713d0533b0af042810a7535fff411b8e0aea9e/orthopy/e1r/orth.py#L20-L53 | [
"def",
"recurrence_coefficients",
"(",
"n",
",",
"alpha",
",",
"standardization",
"=",
"\"normal\"",
",",
"symbolic",
"=",
"False",
")",
":",
"S",
"=",
"sympy",
".",
"S",
"if",
"symbolic",
"else",
"lambda",
"x",
":",
"x",
"sqrt",
"=",
"sympy",
".",
"sq... | 64713d0533b0af042810a7535fff411b8e0aea9e |
train | jacobi | Generate the recurrence coefficients a_k, b_k, c_k in
P_{k+1}(x) = (a_k x - b_k)*P_{k}(x) - c_k P_{k-1}(x)
for the Jacobi polynomials which are orthogonal on [-1, 1]
with respect to the weight w(x)=[(1-x)^alpha]*[(1+x)^beta]; see
<https://en.wikipedia.org/wiki/Jacobi_polynomials#Recurrence_relations>. | orthopy/line_segment/recurrence_coefficients.py | def jacobi(n, alpha, beta, standardization, symbolic=False):
"""Generate the recurrence coefficients a_k, b_k, c_k in
P_{k+1}(x) = (a_k x - b_k)*P_{k}(x) - c_k P_{k-1}(x)
for the Jacobi polynomials which are orthogonal on [-1, 1]
with respect to the weight w(x)=[(1-x)^alpha]*[(1+x)^beta]; see
<htt... | def jacobi(n, alpha, beta, standardization, symbolic=False):
"""Generate the recurrence coefficients a_k, b_k, c_k in
P_{k+1}(x) = (a_k x - b_k)*P_{k}(x) - c_k P_{k-1}(x)
for the Jacobi polynomials which are orthogonal on [-1, 1]
with respect to the weight w(x)=[(1-x)^alpha]*[(1+x)^beta]; see
<htt... | [
"Generate",
"the",
"recurrence",
"coefficients",
"a_k",
"b_k",
"c_k",
"in"
] | nschloe/orthopy | python | https://github.com/nschloe/orthopy/blob/64713d0533b0af042810a7535fff411b8e0aea9e/orthopy/line_segment/recurrence_coefficients.py#L28-L211 | [
"def",
"jacobi",
"(",
"n",
",",
"alpha",
",",
"beta",
",",
"standardization",
",",
"symbolic",
"=",
"False",
")",
":",
"gamma",
"=",
"sympy",
".",
"gamma",
"if",
"symbolic",
"else",
"lambda",
"x",
":",
"scipy",
".",
"special",
".",
"gamma",
"(",
"flo... | 64713d0533b0af042810a7535fff411b8e0aea9e |
train | plot | Plot function over a disk. | orthopy/disk/tools.py | def plot(f, lcar=1.0e-1):
"""Plot function over a disk.
"""
import matplotlib
import matplotlib.pyplot as plt
import pygmsh
geom = pygmsh.built_in.Geometry()
geom.add_circle([0.0, 0.0, 0.0], 1.0, lcar, num_sections=4, compound=True)
points, cells, _, _, _ = pygmsh.generate_mesh(geom, ve... | def plot(f, lcar=1.0e-1):
"""Plot function over a disk.
"""
import matplotlib
import matplotlib.pyplot as plt
import pygmsh
geom = pygmsh.built_in.Geometry()
geom.add_circle([0.0, 0.0, 0.0], 1.0, lcar, num_sections=4, compound=True)
points, cells, _, _, _ = pygmsh.generate_mesh(geom, ve... | [
"Plot",
"function",
"over",
"a",
"disk",
"."
] | nschloe/orthopy | python | https://github.com/nschloe/orthopy/blob/64713d0533b0af042810a7535fff411b8e0aea9e/orthopy/disk/tools.py#L13-L45 | [
"def",
"plot",
"(",
"f",
",",
"lcar",
"=",
"1.0e-1",
")",
":",
"import",
"matplotlib",
"import",
"matplotlib",
".",
"pyplot",
"as",
"plt",
"import",
"pygmsh",
"geom",
"=",
"pygmsh",
".",
"built_in",
".",
"Geometry",
"(",
")",
"geom",
".",
"add_circle",
... | 64713d0533b0af042810a7535fff411b8e0aea9e |
train | tree | Evaluates the entire tree of orthogonal polynomials for the n-cube
The computation is organized such that tree returns a list of arrays, L={0,
..., dim}, where each level corresponds to the polynomial degree L.
Further, each level is organized like a discrete (dim-1)-dimensional
simplex. Let's demonstr... | orthopy/ncube/orth.py | def tree(X, n, symbolic=False):
"""Evaluates the entire tree of orthogonal polynomials for the n-cube
The computation is organized such that tree returns a list of arrays, L={0,
..., dim}, where each level corresponds to the polynomial degree L.
Further, each level is organized like a discrete (dim-1)-... | def tree(X, n, symbolic=False):
"""Evaluates the entire tree of orthogonal polynomials for the n-cube
The computation is organized such that tree returns a list of arrays, L={0,
..., dim}, where each level corresponds to the polynomial degree L.
Further, each level is organized like a discrete (dim-1)-... | [
"Evaluates",
"the",
"entire",
"tree",
"of",
"orthogonal",
"polynomials",
"for",
"the",
"n",
"-",
"cube"
] | nschloe/orthopy | python | https://github.com/nschloe/orthopy/blob/64713d0533b0af042810a7535fff411b8e0aea9e/orthopy/ncube/orth.py#L11-L76 | [
"def",
"tree",
"(",
"X",
",",
"n",
",",
"symbolic",
"=",
"False",
")",
":",
"p0",
",",
"a",
",",
"b",
",",
"c",
"=",
"legendre",
"(",
"n",
"+",
"1",
",",
"\"normal\"",
",",
"symbolic",
"=",
"symbolic",
")",
"dim",
"=",
"X",
".",
"shape",
"[",... | 64713d0533b0af042810a7535fff411b8e0aea9e |
train | line_evaluate | Evaluate the orthogonal polynomial defined by its recurrence coefficients
a, b, and c at the point(s) t. | orthopy/tools.py | def line_evaluate(t, p0, a, b, c):
"""Evaluate the orthogonal polynomial defined by its recurrence coefficients
a, b, and c at the point(s) t.
"""
vals1 = numpy.zeros_like(t, dtype=int)
# The order is important here; see
# <https://github.com/sympy/sympy/issues/13637>.
vals2 = numpy.ones_lik... | def line_evaluate(t, p0, a, b, c):
"""Evaluate the orthogonal polynomial defined by its recurrence coefficients
a, b, and c at the point(s) t.
"""
vals1 = numpy.zeros_like(t, dtype=int)
# The order is important here; see
# <https://github.com/sympy/sympy/issues/13637>.
vals2 = numpy.ones_lik... | [
"Evaluate",
"the",
"orthogonal",
"polynomial",
"defined",
"by",
"its",
"recurrence",
"coefficients",
"a",
"b",
"and",
"c",
"at",
"the",
"point",
"(",
"s",
")",
"t",
"."
] | nschloe/orthopy | python | https://github.com/nschloe/orthopy/blob/64713d0533b0af042810a7535fff411b8e0aea9e/orthopy/tools.py#L21-L33 | [
"def",
"line_evaluate",
"(",
"t",
",",
"p0",
",",
"a",
",",
"b",
",",
"c",
")",
":",
"vals1",
"=",
"numpy",
".",
"zeros_like",
"(",
"t",
",",
"dtype",
"=",
"int",
")",
"# The order is important here; see",
"# <https://github.com/sympy/sympy/issues/13637>.",
"v... | 64713d0533b0af042810a7535fff411b8e0aea9e |
train | plot | Plot function over a triangle. | orthopy/triangle/tools.py | def plot(corners, f, n=100):
"""Plot function over a triangle.
"""
import matplotlib.tri
import matplotlib.pyplot as plt
# discretization points
def partition(boxes, balls):
# <https://stackoverflow.com/a/36748940/353337>
def rec(boxes, balls, parent=tuple()):
if box... | def plot(corners, f, n=100):
"""Plot function over a triangle.
"""
import matplotlib.tri
import matplotlib.pyplot as plt
# discretization points
def partition(boxes, balls):
# <https://stackoverflow.com/a/36748940/353337>
def rec(boxes, balls, parent=tuple()):
if box... | [
"Plot",
"function",
"over",
"a",
"triangle",
"."
] | nschloe/orthopy | python | https://github.com/nschloe/orthopy/blob/64713d0533b0af042810a7535fff411b8e0aea9e/orthopy/triangle/tools.py#L16-L63 | [
"def",
"plot",
"(",
"corners",
",",
"f",
",",
"n",
"=",
"100",
")",
":",
"import",
"matplotlib",
".",
"tri",
"import",
"matplotlib",
".",
"pyplot",
"as",
"plt",
"# discretization points",
"def",
"partition",
"(",
"boxes",
",",
"balls",
")",
":",
"# <http... | 64713d0533b0af042810a7535fff411b8e0aea9e |
train | _iget | Case-insensitive search for `key` within keys of `lookup_dict`. | le_utils/constants/languages.py | def _iget(key, lookup_dict):
"""
Case-insensitive search for `key` within keys of `lookup_dict`.
"""
for k, v in lookup_dict.items():
if k.lower() == key.lower():
return v
return None | def _iget(key, lookup_dict):
"""
Case-insensitive search for `key` within keys of `lookup_dict`.
"""
for k, v in lookup_dict.items():
if k.lower() == key.lower():
return v
return None | [
"Case",
"-",
"insensitive",
"search",
"for",
"key",
"within",
"keys",
"of",
"lookup_dict",
"."
] | learningequality/le-utils | python | https://github.com/learningequality/le-utils/blob/07a776e3d5c288818764a25170de2e9ec5850c0d/le_utils/constants/languages.py#L83-L90 | [
"def",
"_iget",
"(",
"key",
",",
"lookup_dict",
")",
":",
"for",
"k",
",",
"v",
"in",
"lookup_dict",
".",
"items",
"(",
")",
":",
"if",
"k",
".",
"lower",
"(",
")",
"==",
"key",
".",
"lower",
"(",
")",
":",
"return",
"v",
"return",
"None"
] | 07a776e3d5c288818764a25170de2e9ec5850c0d |
train | getlang_by_name | Try to lookup a Language object by name, e.g. 'English', in internal language list.
Returns None if lookup by language name fails in resources/languagelookup.json. | le_utils/constants/languages.py | def getlang_by_name(name):
"""
Try to lookup a Language object by name, e.g. 'English', in internal language list.
Returns None if lookup by language name fails in resources/languagelookup.json.
"""
direct_match = _iget(name, _LANGUAGE_NAME_LOOKUP)
if direct_match:
return direct_match
... | def getlang_by_name(name):
"""
Try to lookup a Language object by name, e.g. 'English', in internal language list.
Returns None if lookup by language name fails in resources/languagelookup.json.
"""
direct_match = _iget(name, _LANGUAGE_NAME_LOOKUP)
if direct_match:
return direct_match
... | [
"Try",
"to",
"lookup",
"a",
"Language",
"object",
"by",
"name",
"e",
".",
"g",
".",
"English",
"in",
"internal",
"language",
"list",
".",
"Returns",
"None",
"if",
"lookup",
"by",
"language",
"name",
"fails",
"in",
"resources",
"/",
"languagelookup",
".",
... | learningequality/le-utils | python | https://github.com/learningequality/le-utils/blob/07a776e3d5c288818764a25170de2e9ec5850c0d/le_utils/constants/languages.py#L146-L157 | [
"def",
"getlang_by_name",
"(",
"name",
")",
":",
"direct_match",
"=",
"_iget",
"(",
"name",
",",
"_LANGUAGE_NAME_LOOKUP",
")",
"if",
"direct_match",
":",
"return",
"direct_match",
"else",
":",
"simple_name",
"=",
"name",
".",
"split",
"(",
"','",
")",
"[",
... | 07a776e3d5c288818764a25170de2e9ec5850c0d |
train | getlang_by_native_name | Try to lookup a Language object by native_name, e.g. 'English', in internal language list.
Returns None if lookup by language name fails in resources/languagelookup.json. | le_utils/constants/languages.py | def getlang_by_native_name(native_name):
"""
Try to lookup a Language object by native_name, e.g. 'English', in internal language list.
Returns None if lookup by language name fails in resources/languagelookup.json.
"""
direct_match = _iget(native_name, _LANGUAGE_NATIVE_NAME_LOOKUP)
if direct_ma... | def getlang_by_native_name(native_name):
"""
Try to lookup a Language object by native_name, e.g. 'English', in internal language list.
Returns None if lookup by language name fails in resources/languagelookup.json.
"""
direct_match = _iget(native_name, _LANGUAGE_NATIVE_NAME_LOOKUP)
if direct_ma... | [
"Try",
"to",
"lookup",
"a",
"Language",
"object",
"by",
"native_name",
"e",
".",
"g",
".",
"English",
"in",
"internal",
"language",
"list",
".",
"Returns",
"None",
"if",
"lookup",
"by",
"language",
"name",
"fails",
"in",
"resources",
"/",
"languagelookup",
... | learningequality/le-utils | python | https://github.com/learningequality/le-utils/blob/07a776e3d5c288818764a25170de2e9ec5850c0d/le_utils/constants/languages.py#L185-L196 | [
"def",
"getlang_by_native_name",
"(",
"native_name",
")",
":",
"direct_match",
"=",
"_iget",
"(",
"native_name",
",",
"_LANGUAGE_NATIVE_NAME_LOOKUP",
")",
"if",
"direct_match",
":",
"return",
"direct_match",
"else",
":",
"simple_native_name",
"=",
"native_name",
".",
... | 07a776e3d5c288818764a25170de2e9ec5850c0d |
train | getlang_by_alpha2 | Lookup a Language object for language code `code` based on these strategies:
- Special case rules for Hebrew and Chinese Hans/Hant scripts
- Using `alpha_2` lookup in `pycountry.languages` followed by lookup for a
language with the same `name` in the internal representaion
Returns `None` if no m... | le_utils/constants/languages.py | def getlang_by_alpha2(code):
"""
Lookup a Language object for language code `code` based on these strategies:
- Special case rules for Hebrew and Chinese Hans/Hant scripts
- Using `alpha_2` lookup in `pycountry.languages` followed by lookup for a
language with the same `name` in the internal... | def getlang_by_alpha2(code):
"""
Lookup a Language object for language code `code` based on these strategies:
- Special case rules for Hebrew and Chinese Hans/Hant scripts
- Using `alpha_2` lookup in `pycountry.languages` followed by lookup for a
language with the same `name` in the internal... | [
"Lookup",
"a",
"Language",
"object",
"for",
"language",
"code",
"code",
"based",
"on",
"these",
"strategies",
":",
"-",
"Special",
"case",
"rules",
"for",
"Hebrew",
"and",
"Chinese",
"Hans",
"/",
"Hant",
"scripts",
"-",
"Using",
"alpha_2",
"lookup",
"in",
... | learningequality/le-utils | python | https://github.com/learningequality/le-utils/blob/07a776e3d5c288818764a25170de2e9ec5850c0d/le_utils/constants/languages.py#L200-L231 | [
"def",
"getlang_by_alpha2",
"(",
"code",
")",
":",
"# Handle special cases for language codes returned by YouTube API",
"if",
"code",
"==",
"'iw'",
":",
"# handle old Hebrew code 'iw' and return modern code 'he'",
"return",
"getlang",
"(",
"'he'",
")",
"elif",
"'zh-Hans'",
"i... | 07a776e3d5c288818764a25170de2e9ec5850c0d |
train | write | Write a function `f` defined in terms of spherical coordinates to a file. | orthopy/sphere/tools.py | def write(filename, f):
"""Write a function `f` defined in terms of spherical coordinates to a file.
"""
import meshio
import meshzoo
points, cells = meshzoo.iso_sphere(5)
# get spherical coordinates from points
polar = numpy.arccos(points[:, 2])
azimuthal = numpy.arctan2(points[:, 1], ... | def write(filename, f):
"""Write a function `f` defined in terms of spherical coordinates to a file.
"""
import meshio
import meshzoo
points, cells = meshzoo.iso_sphere(5)
# get spherical coordinates from points
polar = numpy.arccos(points[:, 2])
azimuthal = numpy.arctan2(points[:, 1], ... | [
"Write",
"a",
"function",
"f",
"defined",
"in",
"terms",
"of",
"spherical",
"coordinates",
"to",
"a",
"file",
"."
] | nschloe/orthopy | python | https://github.com/nschloe/orthopy/blob/64713d0533b0af042810a7535fff411b8e0aea9e/orthopy/sphere/tools.py#L6-L18 | [
"def",
"write",
"(",
"filename",
",",
"f",
")",
":",
"import",
"meshio",
"import",
"meshzoo",
"points",
",",
"cells",
"=",
"meshzoo",
".",
"iso_sphere",
"(",
"5",
")",
"# get spherical coordinates from points",
"polar",
"=",
"numpy",
".",
"arccos",
"(",
"poi... | 64713d0533b0af042810a7535fff411b8e0aea9e |
train | tree_sph | Evaluate all spherical harmonics of degree at most `n` at angles `polar`,
`azimuthal`. | orthopy/sphere/orth.py | def tree_sph(polar, azimuthal, n, standardization, symbolic=False):
"""Evaluate all spherical harmonics of degree at most `n` at angles `polar`,
`azimuthal`.
"""
cos = numpy.vectorize(sympy.cos) if symbolic else numpy.cos
# Conventions from
# <https://en.wikipedia.org/wiki/Spherical_harmonics#O... | def tree_sph(polar, azimuthal, n, standardization, symbolic=False):
"""Evaluate all spherical harmonics of degree at most `n` at angles `polar`,
`azimuthal`.
"""
cos = numpy.vectorize(sympy.cos) if symbolic else numpy.cos
# Conventions from
# <https://en.wikipedia.org/wiki/Spherical_harmonics#O... | [
"Evaluate",
"all",
"spherical",
"harmonics",
"of",
"degree",
"at",
"most",
"n",
"at",
"angles",
"polar",
"azimuthal",
"."
] | nschloe/orthopy | python | https://github.com/nschloe/orthopy/blob/64713d0533b0af042810a7535fff411b8e0aea9e/orthopy/sphere/orth.py#L9-L33 | [
"def",
"tree_sph",
"(",
"polar",
",",
"azimuthal",
",",
"n",
",",
"standardization",
",",
"symbolic",
"=",
"False",
")",
":",
"cos",
"=",
"numpy",
".",
"vectorize",
"(",
"sympy",
".",
"cos",
")",
"if",
"symbolic",
"else",
"numpy",
".",
"cos",
"# Conven... | 64713d0533b0af042810a7535fff411b8e0aea9e |
train | tree_alp | Evaluates the entire tree of associated Legendre polynomials up to depth
n.
There are many recurrence relations that can be used to construct the
associated Legendre polynomials. However, only few are numerically stable.
Many implementations (including this one) use the classical Legendre
recurrence... | orthopy/line_segment/orth.py | def tree_alp(
x, n, standardization, phi=None, with_condon_shortley_phase=True, symbolic=False
):
"""Evaluates the entire tree of associated Legendre polynomials up to depth
n.
There are many recurrence relations that can be used to construct the
associated Legendre polynomials. However, only few ar... | def tree_alp(
x, n, standardization, phi=None, with_condon_shortley_phase=True, symbolic=False
):
"""Evaluates the entire tree of associated Legendre polynomials up to depth
n.
There are many recurrence relations that can be used to construct the
associated Legendre polynomials. However, only few ar... | [
"Evaluates",
"the",
"entire",
"tree",
"of",
"associated",
"Legendre",
"polynomials",
"up",
"to",
"depth",
"n",
".",
"There",
"are",
"many",
"recurrence",
"relations",
"that",
"can",
"be",
"used",
"to",
"construct",
"the",
"associated",
"Legendre",
"polynomials",... | nschloe/orthopy | python | https://github.com/nschloe/orthopy/blob/64713d0533b0af042810a7535fff411b8e0aea9e/orthopy/line_segment/orth.py#L186-L260 | [
"def",
"tree_alp",
"(",
"x",
",",
"n",
",",
"standardization",
",",
"phi",
"=",
"None",
",",
"with_condon_shortley_phase",
"=",
"True",
",",
"symbolic",
"=",
"False",
")",
":",
"# assert numpy.all(numpy.abs(x) <= 1.0)",
"d",
"=",
"{",
"\"natural\"",
":",
"(",
... | 64713d0533b0af042810a7535fff411b8e0aea9e |
train | tree | Evaluates the entire tree of orthogonal polynomials on the unit disk.
The return value is a list of arrays, where `out[k]` hosts the `2*k+1`
values of the `k`th level of the tree
(0, 0)
(0, 1) (1, 1)
(0, 2) (1, 2) (2, 2)
... ... ... | orthopy/disk/orth.py | def tree(X, n, symbolic=False):
"""Evaluates the entire tree of orthogonal polynomials on the unit disk.
The return value is a list of arrays, where `out[k]` hosts the `2*k+1`
values of the `k`th level of the tree
(0, 0)
(0, 1) (1, 1)
(0, 2) (1, 2) (2, 2)
... .... | def tree(X, n, symbolic=False):
"""Evaluates the entire tree of orthogonal polynomials on the unit disk.
The return value is a list of arrays, where `out[k]` hosts the `2*k+1`
values of the `k`th level of the tree
(0, 0)
(0, 1) (1, 1)
(0, 2) (1, 2) (2, 2)
... .... | [
"Evaluates",
"the",
"entire",
"tree",
"of",
"orthogonal",
"polynomials",
"on",
"the",
"unit",
"disk",
"."
] | nschloe/orthopy | python | https://github.com/nschloe/orthopy/blob/64713d0533b0af042810a7535fff411b8e0aea9e/orthopy/disk/orth.py#L9-L89 | [
"def",
"tree",
"(",
"X",
",",
"n",
",",
"symbolic",
"=",
"False",
")",
":",
"frac",
"=",
"sympy",
".",
"Rational",
"if",
"symbolic",
"else",
"lambda",
"x",
",",
"y",
":",
"x",
"/",
"y",
"sqrt",
"=",
"sympy",
".",
"sqrt",
"if",
"symbolic",
"else",... | 64713d0533b0af042810a7535fff411b8e0aea9e |
train | tree | Evaluates the entire tree of orthogonal triangle polynomials.
The return value is a list of arrays, where `out[k]` hosts the `2*k+1`
values of the `k`th level of the tree
(0, 0)
(0, 1) (1, 1)
(0, 2) (1, 2) (2, 2)
... ... ...
For reference, see
Abedal... | orthopy/triangle/orth.py | def tree(bary, n, standardization, symbolic=False):
"""Evaluates the entire tree of orthogonal triangle polynomials.
The return value is a list of arrays, where `out[k]` hosts the `2*k+1`
values of the `k`th level of the tree
(0, 0)
(0, 1) (1, 1)
(0, 2) (1, 2) (2, 2)
... | def tree(bary, n, standardization, symbolic=False):
"""Evaluates the entire tree of orthogonal triangle polynomials.
The return value is a list of arrays, where `out[k]` hosts the `2*k+1`
values of the `k`th level of the tree
(0, 0)
(0, 1) (1, 1)
(0, 2) (1, 2) (2, 2)
... | [
"Evaluates",
"the",
"entire",
"tree",
"of",
"orthogonal",
"triangle",
"polynomials",
"."
] | nschloe/orthopy | python | https://github.com/nschloe/orthopy/blob/64713d0533b0af042810a7535fff411b8e0aea9e/orthopy/triangle/orth.py#L9-L126 | [
"def",
"tree",
"(",
"bary",
",",
"n",
",",
"standardization",
",",
"symbolic",
"=",
"False",
")",
":",
"S",
"=",
"numpy",
".",
"vectorize",
"(",
"sympy",
".",
"S",
")",
"if",
"symbolic",
"else",
"lambda",
"x",
":",
"x",
"sqrt",
"=",
"numpy",
".",
... | 64713d0533b0af042810a7535fff411b8e0aea9e |
train | check_if_this_file_exist | Check if this file exist and if it's a directory
This function will check if the given filename
actually exists and if it's not a Directory
Arguments:
filename {string} -- filename
Return:
True : if it's not a directory and if this file exist
False : If it's not a file and if... | pyexifinfo/pyexifinfo.py | def check_if_this_file_exist(filename):
"""Check if this file exist and if it's a directory
This function will check if the given filename
actually exists and if it's not a Directory
Arguments:
filename {string} -- filename
Return:
True : if it's not a directory and if this file ... | def check_if_this_file_exist(filename):
"""Check if this file exist and if it's a directory
This function will check if the given filename
actually exists and if it's not a Directory
Arguments:
filename {string} -- filename
Return:
True : if it's not a directory and if this file ... | [
"Check",
"if",
"this",
"file",
"exist",
"and",
"if",
"it",
"s",
"a",
"directory"
] | guinslym/pyexifinfo | python | https://github.com/guinslym/pyexifinfo/blob/56e5b44e77ee17b018a530ec858f19a9c6c07018/pyexifinfo/pyexifinfo.py#L17-L41 | [
"def",
"check_if_this_file_exist",
"(",
"filename",
")",
":",
"#get the absolute path",
"filename",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"filename",
")",
"#Boolean",
"this_file_exist",
"=",
"os",
".",
"path",
".",
"exists",
"(",
"filename",
")",
"a_dir... | 56e5b44e77ee17b018a530ec858f19a9c6c07018 |
train | command_line | Handle the command line call
keyword arguments:
cmd = a list
return
0 if error
or a string for the command line output | pyexifinfo/pyexifinfo.py | def command_line(cmd):
"""Handle the command line call
keyword arguments:
cmd = a list
return
0 if error
or a string for the command line output
"""
try:
s = subprocess.Popen(cmd, stdout=subprocess.PIPE)
s = s.stdout.read()
return s.strip()
except subproce... | def command_line(cmd):
"""Handle the command line call
keyword arguments:
cmd = a list
return
0 if error
or a string for the command line output
"""
try:
s = subprocess.Popen(cmd, stdout=subprocess.PIPE)
s = s.stdout.read()
return s.strip()
except subproce... | [
"Handle",
"the",
"command",
"line",
"call"
] | guinslym/pyexifinfo | python | https://github.com/guinslym/pyexifinfo/blob/56e5b44e77ee17b018a530ec858f19a9c6c07018/pyexifinfo/pyexifinfo.py#L45-L62 | [
"def",
"command_line",
"(",
"cmd",
")",
":",
"try",
":",
"s",
"=",
"subprocess",
".",
"Popen",
"(",
"cmd",
",",
"stdout",
"=",
"subprocess",
".",
"PIPE",
")",
"s",
"=",
"s",
".",
"stdout",
".",
"read",
"(",
")",
"return",
"s",
".",
"strip",
"(",
... | 56e5b44e77ee17b018a530ec858f19a9c6c07018 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.