repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
skyfielders/python-skyfield | skyfield/timelib.py | Timescale.tai | def tai(self, year=None, month=1, day=1, hour=0, minute=0, second=0.0,
jd=None):
"""Build a `Time` from a TAI calendar date.
Supply the International Atomic Time (TAI) as a proleptic
Gregorian calendar date:
>>> t = ts.tai(2014, 1, 18, 1, 35, 37.5)
>>> t.tai
... | python | def tai(self, year=None, month=1, day=1, hour=0, minute=0, second=0.0,
jd=None):
"""Build a `Time` from a TAI calendar date.
Supply the International Atomic Time (TAI) as a proleptic
Gregorian calendar date:
>>> t = ts.tai(2014, 1, 18, 1, 35, 37.5)
>>> t.tai
... | [
"def",
"tai",
"(",
"self",
",",
"year",
"=",
"None",
",",
"month",
"=",
"1",
",",
"day",
"=",
"1",
",",
"hour",
"=",
"0",
",",
"minute",
"=",
"0",
",",
"second",
"=",
"0.0",
",",
"jd",
"=",
"None",
")",
":",
"if",
"jd",
"is",
"not",
"None",... | Build a `Time` from a TAI calendar date.
Supply the International Atomic Time (TAI) as a proleptic
Gregorian calendar date:
>>> t = ts.tai(2014, 1, 18, 1, 35, 37.5)
>>> t.tai
2456675.56640625
>>> t.tai_calendar()
(2014, 1, 18, 1, 35, 37.5) | [
"Build",
"a",
"Time",
"from",
"a",
"TAI",
"calendar",
"date",
"."
] | 51d9e042e06457f6b1f2415296d50a38cb3a300f | https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/timelib.py#L129-L150 | train |
skyfielders/python-skyfield | skyfield/timelib.py | Timescale.tai_jd | def tai_jd(self, jd):
"""Build a `Time` from a TAI Julian date.
Supply the International Atomic Time (TAI) as a Julian date:
>>> t = ts.tai_jd(2456675.56640625)
>>> t.tai
2456675.56640625
>>> t.tai_calendar()
(2014, 1, 18, 1, 35, 37.5)
"""
tai =... | python | def tai_jd(self, jd):
"""Build a `Time` from a TAI Julian date.
Supply the International Atomic Time (TAI) as a Julian date:
>>> t = ts.tai_jd(2456675.56640625)
>>> t.tai
2456675.56640625
>>> t.tai_calendar()
(2014, 1, 18, 1, 35, 37.5)
"""
tai =... | [
"def",
"tai_jd",
"(",
"self",
",",
"jd",
")",
":",
"tai",
"=",
"_to_array",
"(",
"jd",
")",
"t",
"=",
"Time",
"(",
"self",
",",
"tai",
"+",
"tt_minus_tai",
")",
"t",
".",
"tai",
"=",
"tai",
"return",
"t"
] | Build a `Time` from a TAI Julian date.
Supply the International Atomic Time (TAI) as a Julian date:
>>> t = ts.tai_jd(2456675.56640625)
>>> t.tai
2456675.56640625
>>> t.tai_calendar()
(2014, 1, 18, 1, 35, 37.5) | [
"Build",
"a",
"Time",
"from",
"a",
"TAI",
"Julian",
"date",
"."
] | 51d9e042e06457f6b1f2415296d50a38cb3a300f | https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/timelib.py#L152-L167 | train |
skyfielders/python-skyfield | skyfield/timelib.py | Timescale.tt | def tt(self, year=None, month=1, day=1, hour=0, minute=0, second=0.0,
jd=None):
"""Build a `Time` from a TT calendar date.
Supply the Terrestrial Time (TT) as a proleptic Gregorian
calendar date:
>>> t = ts.tt(2014, 1, 18, 1, 35, 37.5)
>>> t.tt
2456675.566406... | python | def tt(self, year=None, month=1, day=1, hour=0, minute=0, second=0.0,
jd=None):
"""Build a `Time` from a TT calendar date.
Supply the Terrestrial Time (TT) as a proleptic Gregorian
calendar date:
>>> t = ts.tt(2014, 1, 18, 1, 35, 37.5)
>>> t.tt
2456675.566406... | [
"def",
"tt",
"(",
"self",
",",
"year",
"=",
"None",
",",
"month",
"=",
"1",
",",
"day",
"=",
"1",
",",
"hour",
"=",
"0",
",",
"minute",
"=",
"0",
",",
"second",
"=",
"0.0",
",",
"jd",
"=",
"None",
")",
":",
"if",
"jd",
"is",
"not",
"None",
... | Build a `Time` from a TT calendar date.
Supply the Terrestrial Time (TT) as a proleptic Gregorian
calendar date:
>>> t = ts.tt(2014, 1, 18, 1, 35, 37.5)
>>> t.tt
2456675.56640625
>>> t.tt_calendar()
(2014, 1, 18, 1, 35, 37.5) | [
"Build",
"a",
"Time",
"from",
"a",
"TT",
"calendar",
"date",
"."
] | 51d9e042e06457f6b1f2415296d50a38cb3a300f | https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/timelib.py#L169-L191 | train |
skyfielders/python-skyfield | skyfield/timelib.py | Timescale.tdb | def tdb(self, year=None, month=1, day=1, hour=0, minute=0, second=0.0,
jd=None):
"""Build a `Time` from a TDB calendar date.
Supply the Barycentric Dynamical Time (TDB) as a proleptic
Gregorian calendar date:
>>> t = ts.tdb(2014, 1, 18, 1, 35, 37.5)
>>> t.tdb
... | python | def tdb(self, year=None, month=1, day=1, hour=0, minute=0, second=0.0,
jd=None):
"""Build a `Time` from a TDB calendar date.
Supply the Barycentric Dynamical Time (TDB) as a proleptic
Gregorian calendar date:
>>> t = ts.tdb(2014, 1, 18, 1, 35, 37.5)
>>> t.tdb
... | [
"def",
"tdb",
"(",
"self",
",",
"year",
"=",
"None",
",",
"month",
"=",
"1",
",",
"day",
"=",
"1",
",",
"hour",
"=",
"0",
",",
"minute",
"=",
"0",
",",
"second",
"=",
"0.0",
",",
"jd",
"=",
"None",
")",
":",
"if",
"jd",
"is",
"not",
"None",... | Build a `Time` from a TDB calendar date.
Supply the Barycentric Dynamical Time (TDB) as a proleptic
Gregorian calendar date:
>>> t = ts.tdb(2014, 1, 18, 1, 35, 37.5)
>>> t.tdb
2456675.56640625 | [
"Build",
"a",
"Time",
"from",
"a",
"TDB",
"calendar",
"date",
"."
] | 51d9e042e06457f6b1f2415296d50a38cb3a300f | https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/timelib.py#L208-L231 | train |
skyfielders/python-skyfield | skyfield/timelib.py | Timescale.tdb_jd | def tdb_jd(self, jd):
"""Build a `Time` from a TDB Julian date.
Supply the Barycentric Dynamical Time (TDB) as a Julian date:
>>> t = ts.tdb_jd(2456675.56640625)
>>> t.tdb
2456675.56640625
"""
tdb = _to_array(jd)
tt = tdb - tdb_minus_tt(tdb) / DAY_S
... | python | def tdb_jd(self, jd):
"""Build a `Time` from a TDB Julian date.
Supply the Barycentric Dynamical Time (TDB) as a Julian date:
>>> t = ts.tdb_jd(2456675.56640625)
>>> t.tdb
2456675.56640625
"""
tdb = _to_array(jd)
tt = tdb - tdb_minus_tt(tdb) / DAY_S
... | [
"def",
"tdb_jd",
"(",
"self",
",",
"jd",
")",
":",
"tdb",
"=",
"_to_array",
"(",
"jd",
")",
"tt",
"=",
"tdb",
"-",
"tdb_minus_tt",
"(",
"tdb",
")",
"/",
"DAY_S",
"t",
"=",
"Time",
"(",
"self",
",",
"tt",
")",
"t",
".",
"tdb",
"=",
"tdb",
"ret... | Build a `Time` from a TDB Julian date.
Supply the Barycentric Dynamical Time (TDB) as a Julian date:
>>> t = ts.tdb_jd(2456675.56640625)
>>> t.tdb
2456675.56640625 | [
"Build",
"a",
"Time",
"from",
"a",
"TDB",
"Julian",
"date",
"."
] | 51d9e042e06457f6b1f2415296d50a38cb3a300f | https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/timelib.py#L233-L247 | train |
skyfielders/python-skyfield | skyfield/timelib.py | Timescale.ut1 | def ut1(self, year=None, month=1, day=1, hour=0, minute=0, second=0.0,
jd=None):
"""Build a `Time` from a UT1 calendar date.
Supply the Universal Time (UT1) as a proleptic Gregorian
calendar date:
>>> t = ts.ut1(2014, 1, 18, 1, 35, 37.5)
>>> t.ut1
2456675.56... | python | def ut1(self, year=None, month=1, day=1, hour=0, minute=0, second=0.0,
jd=None):
"""Build a `Time` from a UT1 calendar date.
Supply the Universal Time (UT1) as a proleptic Gregorian
calendar date:
>>> t = ts.ut1(2014, 1, 18, 1, 35, 37.5)
>>> t.ut1
2456675.56... | [
"def",
"ut1",
"(",
"self",
",",
"year",
"=",
"None",
",",
"month",
"=",
"1",
",",
"day",
"=",
"1",
",",
"hour",
"=",
"0",
",",
"minute",
"=",
"0",
",",
"second",
"=",
"0.0",
",",
"jd",
"=",
"None",
")",
":",
"if",
"jd",
"is",
"not",
"None",... | Build a `Time` from a UT1 calendar date.
Supply the Universal Time (UT1) as a proleptic Gregorian
calendar date:
>>> t = ts.ut1(2014, 1, 18, 1, 35, 37.5)
>>> t.ut1
2456675.56640625 | [
"Build",
"a",
"Time",
"from",
"a",
"UT1",
"calendar",
"date",
"."
] | 51d9e042e06457f6b1f2415296d50a38cb3a300f | https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/timelib.py#L249-L268 | train |
skyfielders/python-skyfield | skyfield/timelib.py | Timescale.ut1_jd | def ut1_jd(self, jd):
"""Build a `Time` from UT1 a Julian date.
Supply the Universal Time (UT1) as a Julian date:
>>> t = ts.ut1_jd(2456675.56640625)
>>> t.ut1
2456675.56640625
"""
ut1 = _to_array(jd)
# Estimate TT = UT1, to get a rough Delta T estimat... | python | def ut1_jd(self, jd):
"""Build a `Time` from UT1 a Julian date.
Supply the Universal Time (UT1) as a Julian date:
>>> t = ts.ut1_jd(2456675.56640625)
>>> t.ut1
2456675.56640625
"""
ut1 = _to_array(jd)
# Estimate TT = UT1, to get a rough Delta T estimat... | [
"def",
"ut1_jd",
"(",
"self",
",",
"jd",
")",
":",
"ut1",
"=",
"_to_array",
"(",
"jd",
")",
"tt_approx",
"=",
"ut1",
"delta_t_approx",
"=",
"interpolate_delta_t",
"(",
"self",
".",
"delta_t_table",
",",
"tt_approx",
")",
"tt_approx",
"=",
"ut1",
"+",
"de... | Build a `Time` from UT1 a Julian date.
Supply the Universal Time (UT1) as a Julian date:
>>> t = ts.ut1_jd(2456675.56640625)
>>> t.ut1
2456675.56640625 | [
"Build",
"a",
"Time",
"from",
"UT1",
"a",
"Julian",
"date",
"."
] | 51d9e042e06457f6b1f2415296d50a38cb3a300f | https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/timelib.py#L270-L298 | train |
skyfielders/python-skyfield | skyfield/timelib.py | Time.astimezone_and_leap_second | def astimezone_and_leap_second(self, tz):
"""Convert to a Python ``datetime`` and leap second in a timezone.
Convert this time to a Python ``datetime`` and a leap second::
dt, leap_second = t.astimezone_and_leap_second(tz)
The argument ``tz`` should be a timezone from the third-pa... | python | def astimezone_and_leap_second(self, tz):
"""Convert to a Python ``datetime`` and leap second in a timezone.
Convert this time to a Python ``datetime`` and a leap second::
dt, leap_second = t.astimezone_and_leap_second(tz)
The argument ``tz`` should be a timezone from the third-pa... | [
"def",
"astimezone_and_leap_second",
"(",
"self",
",",
"tz",
")",
":",
"dt",
",",
"leap_second",
"=",
"self",
".",
"utc_datetime_and_leap_second",
"(",
")",
"normalize",
"=",
"getattr",
"(",
"tz",
",",
"'normalize'",
",",
"None",
")",
"if",
"self",
".",
"s... | Convert to a Python ``datetime`` and leap second in a timezone.
Convert this time to a Python ``datetime`` and a leap second::
dt, leap_second = t.astimezone_and_leap_second(tz)
The argument ``tz`` should be a timezone from the third-party
``pytz`` package, which must be installed... | [
"Convert",
"to",
"a",
"Python",
"datetime",
"and",
"leap",
"second",
"in",
"a",
"timezone",
"."
] | 51d9e042e06457f6b1f2415296d50a38cb3a300f | https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/timelib.py#L365-L399 | train |
skyfielders/python-skyfield | skyfield/timelib.py | Time.utc_datetime_and_leap_second | def utc_datetime_and_leap_second(self):
"""Convert to a Python ``datetime`` in UTC, plus a leap second value.
Convert this time to a `datetime`_ object and a leap second::
dt, leap_second = t.utc_datetime_and_leap_second()
If the third-party `pytz`_ package is available, then its
... | python | def utc_datetime_and_leap_second(self):
"""Convert to a Python ``datetime`` in UTC, plus a leap second value.
Convert this time to a `datetime`_ object and a leap second::
dt, leap_second = t.utc_datetime_and_leap_second()
If the third-party `pytz`_ package is available, then its
... | [
"def",
"utc_datetime_and_leap_second",
"(",
"self",
")",
":",
"year",
",",
"month",
",",
"day",
",",
"hour",
",",
"minute",
",",
"second",
"=",
"self",
".",
"_utc_tuple",
"(",
"_half_millisecond",
")",
"second",
",",
"fraction",
"=",
"divmod",
"(",
"second... | Convert to a Python ``datetime`` in UTC, plus a leap second value.
Convert this time to a `datetime`_ object and a leap second::
dt, leap_second = t.utc_datetime_and_leap_second()
If the third-party `pytz`_ package is available, then its
``utc`` timezone will be used as the timezo... | [
"Convert",
"to",
"a",
"Python",
"datetime",
"in",
"UTC",
"plus",
"a",
"leap",
"second",
"value",
"."
] | 51d9e042e06457f6b1f2415296d50a38cb3a300f | https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/timelib.py#L425-L462 | train |
skyfielders/python-skyfield | skyfield/timelib.py | Time.utc_strftime | def utc_strftime(self, format):
"""Format the UTC time using a Python date formatting string.
This internally calls the Python ``strftime()`` routine from the
Standard Library ``time()`` module, for which you can find a
quick reference at ``http://strftime.org/``. If this object is
... | python | def utc_strftime(self, format):
"""Format the UTC time using a Python date formatting string.
This internally calls the Python ``strftime()`` routine from the
Standard Library ``time()`` module, for which you can find a
quick reference at ``http://strftime.org/``. If this object is
... | [
"def",
"utc_strftime",
"(",
"self",
",",
"format",
")",
":",
"tup",
"=",
"self",
".",
"_utc_tuple",
"(",
"_half_second",
")",
"year",
",",
"month",
",",
"day",
",",
"hour",
",",
"minute",
",",
"second",
"=",
"tup",
"second",
"=",
"second",
".",
"asty... | Format the UTC time using a Python date formatting string.
This internally calls the Python ``strftime()`` routine from the
Standard Library ``time()`` module, for which you can find a
quick reference at ``http://strftime.org/``. If this object is
an array of times, then a sequence of ... | [
"Format",
"the",
"UTC",
"time",
"using",
"a",
"Python",
"date",
"formatting",
"string",
"."
] | 51d9e042e06457f6b1f2415296d50a38cb3a300f | https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/timelib.py#L520-L538 | train |
skyfielders/python-skyfield | skyfield/timelib.py | Time._utc_year | def _utc_year(self):
"""Return a fractional UTC year, for convenience when plotting.
An experiment, probably superseded by the ``J`` attribute below.
"""
d = self._utc_float() - 1721059.5
#d += offset
C = 365 * 100 + 24
d -= 365
d += d // C - d // (4 * C... | python | def _utc_year(self):
"""Return a fractional UTC year, for convenience when plotting.
An experiment, probably superseded by the ``J`` attribute below.
"""
d = self._utc_float() - 1721059.5
#d += offset
C = 365 * 100 + 24
d -= 365
d += d // C - d // (4 * C... | [
"def",
"_utc_year",
"(",
"self",
")",
":",
"d",
"=",
"self",
".",
"_utc_float",
"(",
")",
"-",
"1721059.5",
"C",
"=",
"365",
"*",
"100",
"+",
"24",
"d",
"-=",
"365",
"d",
"+=",
"d",
"//",
"C",
"-",
"d",
"//",
"(",
"4",
"*",
"C",
")",
"d",
... | Return a fractional UTC year, for convenience when plotting.
An experiment, probably superseded by the ``J`` attribute below. | [
"Return",
"a",
"fractional",
"UTC",
"year",
"for",
"convenience",
"when",
"plotting",
"."
] | 51d9e042e06457f6b1f2415296d50a38cb3a300f | https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/timelib.py#L540-L557 | train |
skyfielders/python-skyfield | skyfield/timelib.py | Time._utc_float | def _utc_float(self):
"""Return UTC as a floating point Julian date."""
tai = self.tai
leap_dates = self.ts.leap_dates
leap_offsets = self.ts.leap_offsets
leap_reverse_dates = leap_dates + leap_offsets / DAY_S
i = searchsorted(leap_reverse_dates, tai, 'right')
ret... | python | def _utc_float(self):
"""Return UTC as a floating point Julian date."""
tai = self.tai
leap_dates = self.ts.leap_dates
leap_offsets = self.ts.leap_offsets
leap_reverse_dates = leap_dates + leap_offsets / DAY_S
i = searchsorted(leap_reverse_dates, tai, 'right')
ret... | [
"def",
"_utc_float",
"(",
"self",
")",
":",
"tai",
"=",
"self",
".",
"tai",
"leap_dates",
"=",
"self",
".",
"ts",
".",
"leap_dates",
"leap_offsets",
"=",
"self",
".",
"ts",
".",
"leap_offsets",
"leap_reverse_dates",
"=",
"leap_dates",
"+",
"leap_offsets",
... | Return UTC as a floating point Julian date. | [
"Return",
"UTC",
"as",
"a",
"floating",
"point",
"Julian",
"date",
"."
] | 51d9e042e06457f6b1f2415296d50a38cb3a300f | https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/timelib.py#L586-L593 | train |
skyfielders/python-skyfield | skyfield/earthlib.py | terra | def terra(latitude, longitude, elevation, gast):
"""Compute the position and velocity of a terrestrial observer.
`latitude` - Latitude in radians.
`longitude` - Longitude in radians.
`elevation` - Elevation above sea level in au.
`gast` - Hours of Greenwich Apparent Sidereal Time (can be an array).... | python | def terra(latitude, longitude, elevation, gast):
"""Compute the position and velocity of a terrestrial observer.
`latitude` - Latitude in radians.
`longitude` - Longitude in radians.
`elevation` - Elevation above sea level in au.
`gast` - Hours of Greenwich Apparent Sidereal Time (can be an array).... | [
"def",
"terra",
"(",
"latitude",
",",
"longitude",
",",
"elevation",
",",
"gast",
")",
":",
"zero",
"=",
"zeros_like",
"(",
"gast",
")",
"sinphi",
"=",
"sin",
"(",
"latitude",
")",
"cosphi",
"=",
"cos",
"(",
"latitude",
")",
"c",
"=",
"1.0",
"/",
"... | Compute the position and velocity of a terrestrial observer.
`latitude` - Latitude in radians.
`longitude` - Longitude in radians.
`elevation` - Elevation above sea level in au.
`gast` - Hours of Greenwich Apparent Sidereal Time (can be an array).
The return value is a tuple of two 3-vectors `(pos... | [
"Compute",
"the",
"position",
"and",
"velocity",
"of",
"a",
"terrestrial",
"observer",
"."
] | 51d9e042e06457f6b1f2415296d50a38cb3a300f | https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/earthlib.py#L15-L55 | train |
skyfielders/python-skyfield | skyfield/earthlib.py | compute_limb_angle | def compute_limb_angle(position_au, observer_au):
"""Determine the angle of an object above or below the Earth's limb.
Given an object's GCRS `position_au` [x,y,z] vector and the position
of an `observer_au` as a vector in the same coordinate system,
return a tuple that provides `(limb_ang, nadir_ang)`... | python | def compute_limb_angle(position_au, observer_au):
"""Determine the angle of an object above or below the Earth's limb.
Given an object's GCRS `position_au` [x,y,z] vector and the position
of an `observer_au` as a vector in the same coordinate system,
return a tuple that provides `(limb_ang, nadir_ang)`... | [
"def",
"compute_limb_angle",
"(",
"position_au",
",",
"observer_au",
")",
":",
"disobj",
"=",
"sqrt",
"(",
"dots",
"(",
"position_au",
",",
"position_au",
")",
")",
"disobs",
"=",
"sqrt",
"(",
"dots",
"(",
"observer_au",
",",
"observer_au",
")",
")",
"apra... | Determine the angle of an object above or below the Earth's limb.
Given an object's GCRS `position_au` [x,y,z] vector and the position
of an `observer_au` as a vector in the same coordinate system,
return a tuple that provides `(limb_ang, nadir_ang)`:
limb_angle
Angle of observed object above ... | [
"Determine",
"the",
"angle",
"of",
"an",
"object",
"above",
"or",
"below",
"the",
"Earth",
"s",
"limb",
"."
] | 51d9e042e06457f6b1f2415296d50a38cb3a300f | https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/earthlib.py#L85-L127 | train |
skyfielders/python-skyfield | skyfield/earthlib.py | sidereal_time | def sidereal_time(t):
"""Compute Greenwich sidereal time at the given ``Time``."""
# Compute the Earth Rotation Angle. Time argument is UT1.
theta = earth_rotation_angle(t.ut1)
# The equinox method. See Circular 179, Section 2.6.2.
# Precession-in-RA terms in mean sidereal time taken from third... | python | def sidereal_time(t):
"""Compute Greenwich sidereal time at the given ``Time``."""
# Compute the Earth Rotation Angle. Time argument is UT1.
theta = earth_rotation_angle(t.ut1)
# The equinox method. See Circular 179, Section 2.6.2.
# Precession-in-RA terms in mean sidereal time taken from third... | [
"def",
"sidereal_time",
"(",
"t",
")",
":",
"theta",
"=",
"earth_rotation_angle",
"(",
"t",
".",
"ut1",
")",
"t",
"=",
"(",
"t",
".",
"tdb",
"-",
"T0",
")",
"/",
"36525.0",
"st",
"=",
"(",
"0.014506",
"+",
"(",
"(",
"(",
"(",
"-",
"0.0000000368",... | Compute Greenwich sidereal time at the given ``Time``. | [
"Compute",
"Greenwich",
"sidereal",
"time",
"at",
"the",
"given",
"Time",
"."
] | 51d9e042e06457f6b1f2415296d50a38cb3a300f | https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/earthlib.py#L130-L151 | train |
skyfielders/python-skyfield | skyfield/earthlib.py | refraction | def refraction(alt_degrees, temperature_C, pressure_mbar):
"""Given an observed altitude, return how much the image is refracted.
Zero refraction is returned both for objects very near the zenith,
as well as for objects more than one degree below the horizon.
"""
r = 0.016667 / tan((alt_degrees + ... | python | def refraction(alt_degrees, temperature_C, pressure_mbar):
"""Given an observed altitude, return how much the image is refracted.
Zero refraction is returned both for objects very near the zenith,
as well as for objects more than one degree below the horizon.
"""
r = 0.016667 / tan((alt_degrees + ... | [
"def",
"refraction",
"(",
"alt_degrees",
",",
"temperature_C",
",",
"pressure_mbar",
")",
":",
"r",
"=",
"0.016667",
"/",
"tan",
"(",
"(",
"alt_degrees",
"+",
"7.31",
"/",
"(",
"alt_degrees",
"+",
"4.4",
")",
")",
"*",
"DEG2RAD",
")",
"d",
"=",
"r",
... | Given an observed altitude, return how much the image is refracted.
Zero refraction is returned both for objects very near the zenith,
as well as for objects more than one degree below the horizon. | [
"Given",
"an",
"observed",
"altitude",
"return",
"how",
"much",
"the",
"image",
"is",
"refracted",
"."
] | 51d9e042e06457f6b1f2415296d50a38cb3a300f | https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/earthlib.py#L166-L175 | train |
skyfielders/python-skyfield | skyfield/earthlib.py | refract | def refract(alt_degrees, temperature_C, pressure_mbar):
"""Given an unrefracted `alt` determine where it will appear in the sky."""
alt = alt_degrees
while True:
alt1 = alt
alt = alt_degrees + refraction(alt, temperature_C, pressure_mbar)
converged = abs(alt - alt1) <= 3.0e-5
... | python | def refract(alt_degrees, temperature_C, pressure_mbar):
"""Given an unrefracted `alt` determine where it will appear in the sky."""
alt = alt_degrees
while True:
alt1 = alt
alt = alt_degrees + refraction(alt, temperature_C, pressure_mbar)
converged = abs(alt - alt1) <= 3.0e-5
... | [
"def",
"refract",
"(",
"alt_degrees",
",",
"temperature_C",
",",
"pressure_mbar",
")",
":",
"alt",
"=",
"alt_degrees",
"while",
"True",
":",
"alt1",
"=",
"alt",
"alt",
"=",
"alt_degrees",
"+",
"refraction",
"(",
"alt",
",",
"temperature_C",
",",
"pressure_mb... | Given an unrefracted `alt` determine where it will appear in the sky. | [
"Given",
"an",
"unrefracted",
"alt",
"determine",
"where",
"it",
"will",
"appear",
"in",
"the",
"sky",
"."
] | 51d9e042e06457f6b1f2415296d50a38cb3a300f | https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/earthlib.py#L178-L187 | train |
skyfielders/python-skyfield | skyfield/precessionlib.py | compute_precession | def compute_precession(jd_tdb):
"""Return the rotation matrices for precessing to an array of epochs.
`jd_tdb` - array of TDB Julian dates
The array returned has the shape `(3, 3, n)` where `n` is the number
of dates that have been provided as input.
"""
eps0 = 84381.406
# 't' is time in... | python | def compute_precession(jd_tdb):
"""Return the rotation matrices for precessing to an array of epochs.
`jd_tdb` - array of TDB Julian dates
The array returned has the shape `(3, 3, n)` where `n` is the number
of dates that have been provided as input.
"""
eps0 = 84381.406
# 't' is time in... | [
"def",
"compute_precession",
"(",
"jd_tdb",
")",
":",
"eps0",
"=",
"84381.406",
"t",
"=",
"(",
"jd_tdb",
"-",
"T0",
")",
"/",
"36525.0",
"psia",
"=",
"(",
"(",
"(",
"(",
"-",
"0.0000000951",
"*",
"t",
"+",
"0.000132851",
")",
"*",
"t",
"-",
"0.0011... | Return the rotation matrices for precessing to an array of epochs.
`jd_tdb` - array of TDB Julian dates
The array returned has the shape `(3, 3, n)` where `n` is the number
of dates that have been provided as input. | [
"Return",
"the",
"rotation",
"matrices",
"for",
"precessing",
"to",
"an",
"array",
"of",
"epochs",
"."
] | 51d9e042e06457f6b1f2415296d50a38cb3a300f | https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/precessionlib.py#L5-L69 | train |
skyfielders/python-skyfield | skyfield/nutationlib.py | compute_nutation | def compute_nutation(t):
"""Generate the nutation rotations for Time `t`.
If the Julian date is scalar, a simple ``(3, 3)`` matrix is
returned; if the date is an array of length ``n``, then an array of
matrices is returned with dimensions ``(3, 3, n)``.
"""
oblm, oblt, eqeq, psi, eps = t._eart... | python | def compute_nutation(t):
"""Generate the nutation rotations for Time `t`.
If the Julian date is scalar, a simple ``(3, 3)`` matrix is
returned; if the date is an array of length ``n``, then an array of
matrices is returned with dimensions ``(3, 3, n)``.
"""
oblm, oblt, eqeq, psi, eps = t._eart... | [
"def",
"compute_nutation",
"(",
"t",
")",
":",
"oblm",
",",
"oblt",
",",
"eqeq",
",",
"psi",
",",
"eps",
"=",
"t",
".",
"_earth_tilt",
"cobm",
"=",
"cos",
"(",
"oblm",
"*",
"DEG2RAD",
")",
"sobm",
"=",
"sin",
"(",
"oblm",
"*",
"DEG2RAD",
")",
"co... | Generate the nutation rotations for Time `t`.
If the Julian date is scalar, a simple ``(3, 3)`` matrix is
returned; if the date is an array of length ``n``, then an array of
matrices is returned with dimensions ``(3, 3, n)``. | [
"Generate",
"the",
"nutation",
"rotations",
"for",
"Time",
"t",
"."
] | 51d9e042e06457f6b1f2415296d50a38cb3a300f | https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/nutationlib.py#L19-L44 | train |
skyfielders/python-skyfield | skyfield/nutationlib.py | earth_tilt | def earth_tilt(t):
"""Return a tuple of information about the earth's axis and position.
`t` - A Time object.
The returned tuple contains five items:
``mean_ob`` - Mean obliquity of the ecliptic in degrees.
``true_ob`` - True obliquity of the ecliptic in degrees.
``eq_eq`` - Equation of the e... | python | def earth_tilt(t):
"""Return a tuple of information about the earth's axis and position.
`t` - A Time object.
The returned tuple contains five items:
``mean_ob`` - Mean obliquity of the ecliptic in degrees.
``true_ob`` - True obliquity of the ecliptic in degrees.
``eq_eq`` - Equation of the e... | [
"def",
"earth_tilt",
"(",
"t",
")",
":",
"dp",
",",
"de",
"=",
"t",
".",
"_nutation_angles",
"c_terms",
"=",
"equation_of_the_equinoxes_complimentary_terms",
"(",
"t",
".",
"tt",
")",
"/",
"ASEC2RAD",
"d_psi",
"=",
"dp",
"*",
"1e-7",
"+",
"t",
".",
"psi_... | Return a tuple of information about the earth's axis and position.
`t` - A Time object.
The returned tuple contains five items:
``mean_ob`` - Mean obliquity of the ecliptic in degrees.
``true_ob`` - True obliquity of the ecliptic in degrees.
``eq_eq`` - Equation of the equinoxes in seconds of tim... | [
"Return",
"a",
"tuple",
"of",
"information",
"about",
"the",
"earth",
"s",
"axis",
"and",
"position",
"."
] | 51d9e042e06457f6b1f2415296d50a38cb3a300f | https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/nutationlib.py#L46-L75 | train |
skyfielders/python-skyfield | skyfield/nutationlib.py | mean_obliquity | def mean_obliquity(jd_tdb):
"""Return the mean obliquity of the ecliptic in arcseconds.
`jd_tt` - TDB time as a Julian date float, or NumPy array of floats
"""
# Compute time in Julian centuries from epoch J2000.0.
t = (jd_tdb - T0) / 36525.0
# Compute the mean obliquity in arcseconds. Use ... | python | def mean_obliquity(jd_tdb):
"""Return the mean obliquity of the ecliptic in arcseconds.
`jd_tt` - TDB time as a Julian date float, or NumPy array of floats
"""
# Compute time in Julian centuries from epoch J2000.0.
t = (jd_tdb - T0) / 36525.0
# Compute the mean obliquity in arcseconds. Use ... | [
"def",
"mean_obliquity",
"(",
"jd_tdb",
")",
":",
"t",
"=",
"(",
"jd_tdb",
"-",
"T0",
")",
"/",
"36525.0",
"epsilon",
"=",
"(",
"(",
"(",
"(",
"-",
"0.0000000434",
"*",
"t",
"-",
"0.000000576",
")",
"*",
"t",
"+",
"0.00200340",
")",
"*",
"t",
"-"... | Return the mean obliquity of the ecliptic in arcseconds.
`jd_tt` - TDB time as a Julian date float, or NumPy array of floats | [
"Return",
"the",
"mean",
"obliquity",
"of",
"the",
"ecliptic",
"in",
"arcseconds",
"."
] | 51d9e042e06457f6b1f2415296d50a38cb3a300f | https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/nutationlib.py#L79-L99 | train |
skyfielders/python-skyfield | skyfield/nutationlib.py | equation_of_the_equinoxes_complimentary_terms | def equation_of_the_equinoxes_complimentary_terms(jd_tt):
"""Compute the complementary terms of the equation of the equinoxes.
`jd_tt` - Terrestrial Time: Julian date float, or NumPy array of floats
"""
# Interval between fundamental epoch J2000.0 and current date.
t = (jd_tt - T0) / 36525.0
... | python | def equation_of_the_equinoxes_complimentary_terms(jd_tt):
"""Compute the complementary terms of the equation of the equinoxes.
`jd_tt` - Terrestrial Time: Julian date float, or NumPy array of floats
"""
# Interval between fundamental epoch J2000.0 and current date.
t = (jd_tt - T0) / 36525.0
... | [
"def",
"equation_of_the_equinoxes_complimentary_terms",
"(",
"jd_tt",
")",
":",
"t",
"=",
"(",
"jd_tt",
"-",
"T0",
")",
"/",
"36525.0",
"shape",
"=",
"getattr",
"(",
"jd_tt",
",",
"'shape'",
",",
"(",
")",
")",
"fa",
"=",
"zeros",
"(",
"(",
"14",
",",
... | Compute the complementary terms of the equation of the equinoxes.
`jd_tt` - Terrestrial Time: Julian date float, or NumPy array of floats | [
"Compute",
"the",
"complementary",
"terms",
"of",
"the",
"equation",
"of",
"the",
"equinoxes",
"."
] | 51d9e042e06457f6b1f2415296d50a38cb3a300f | https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/nutationlib.py#L101-L189 | train |
skyfielders/python-skyfield | skyfield/nutationlib.py | iau2000a | def iau2000a(jd_tt):
"""Compute Earth nutation based on the IAU 2000A nutation model.
`jd_tt` - Terrestrial Time: Julian date float, or NumPy array of floats
Returns a tuple ``(delta_psi, delta_epsilon)`` measured in tenths of
a micro-arcsecond. Each value is either a float, or a NumPy array
with... | python | def iau2000a(jd_tt):
"""Compute Earth nutation based on the IAU 2000A nutation model.
`jd_tt` - Terrestrial Time: Julian date float, or NumPy array of floats
Returns a tuple ``(delta_psi, delta_epsilon)`` measured in tenths of
a micro-arcsecond. Each value is either a float, or a NumPy array
with... | [
"def",
"iau2000a",
"(",
"jd_tt",
")",
":",
"t",
"=",
"(",
"jd_tt",
"-",
"T0",
")",
"/",
"36525.0",
"a",
"=",
"fundamental_arguments",
"(",
"t",
")",
"arg",
"=",
"nals_t",
".",
"dot",
"(",
"a",
")",
"fmod",
"(",
"arg",
",",
"tau",
",",
"out",
"=... | Compute Earth nutation based on the IAU 2000A nutation model.
`jd_tt` - Terrestrial Time: Julian date float, or NumPy array of floats
Returns a tuple ``(delta_psi, delta_epsilon)`` measured in tenths of
a micro-arcsecond. Each value is either a float, or a NumPy array
with the same dimensions as the ... | [
"Compute",
"Earth",
"nutation",
"based",
"on",
"the",
"IAU",
"2000A",
"nutation",
"model",
"."
] | 51d9e042e06457f6b1f2415296d50a38cb3a300f | https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/nutationlib.py#L222-L271 | train |
skyfielders/python-skyfield | skyfield/nutationlib.py | iau2000b | def iau2000b(jd_tt):
"""Compute Earth nutation based on the faster IAU 2000B nutation model.
`jd_tt` - Terrestrial Time: Julian date float, or NumPy array of floats
Returns a tuple ``(delta_psi, delta_epsilon)`` measured in tenths of
a micro-arcsecond. Each is either a float, or a NumPy array with
... | python | def iau2000b(jd_tt):
"""Compute Earth nutation based on the faster IAU 2000B nutation model.
`jd_tt` - Terrestrial Time: Julian date float, or NumPy array of floats
Returns a tuple ``(delta_psi, delta_epsilon)`` measured in tenths of
a micro-arcsecond. Each is either a float, or a NumPy array with
... | [
"def",
"iau2000b",
"(",
"jd_tt",
")",
":",
"dpplan",
"=",
"-",
"0.000135",
"*",
"1e7",
"deplan",
"=",
"0.000388",
"*",
"1e7",
"t",
"=",
"(",
"jd_tt",
"-",
"T0",
")",
"/",
"36525.0",
"el",
"=",
"fmod",
"(",
"485868.249036",
"+",
"t",
"*",
"171791592... | Compute Earth nutation based on the faster IAU 2000B nutation model.
`jd_tt` - Terrestrial Time: Julian date float, or NumPy array of floats
Returns a tuple ``(delta_psi, delta_epsilon)`` measured in tenths of
a micro-arcsecond. Each is either a float, or a NumPy array with
the same dimensions as the... | [
"Compute",
"Earth",
"nutation",
"based",
"on",
"the",
"faster",
"IAU",
"2000B",
"nutation",
"model",
"."
] | 51d9e042e06457f6b1f2415296d50a38cb3a300f | https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/nutationlib.py#L273-L325 | train |
skyfielders/python-skyfield | skyfield/data/hipparcos.py | load_dataframe | def load_dataframe(fobj, compression='gzip'):
"""Given an open file for `hip_main.dat.gz`, return a parsed dataframe.
If your copy of ``hip_main.dat`` has already been unzipped, pass the
optional argument ``compression=None``.
"""
try:
from pandas import read_fwf
except ImportError:
... | python | def load_dataframe(fobj, compression='gzip'):
"""Given an open file for `hip_main.dat.gz`, return a parsed dataframe.
If your copy of ``hip_main.dat`` has already been unzipped, pass the
optional argument ``compression=None``.
"""
try:
from pandas import read_fwf
except ImportError:
... | [
"def",
"load_dataframe",
"(",
"fobj",
",",
"compression",
"=",
"'gzip'",
")",
":",
"try",
":",
"from",
"pandas",
"import",
"read_fwf",
"except",
"ImportError",
":",
"raise",
"ImportError",
"(",
"PANDAS_MESSAGE",
")",
"names",
",",
"colspecs",
"=",
"zip",
"("... | Given an open file for `hip_main.dat.gz`, return a parsed dataframe.
If your copy of ``hip_main.dat`` has already been unzipped, pass the
optional argument ``compression=None``. | [
"Given",
"an",
"open",
"file",
"for",
"hip_main",
".",
"dat",
".",
"gz",
"return",
"a",
"parsed",
"dataframe",
"."
] | 51d9e042e06457f6b1f2415296d50a38cb3a300f | https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/data/hipparcos.py#L44-L71 | train |
skyfielders/python-skyfield | skyfield/toposlib.py | Topos._altaz_rotation | def _altaz_rotation(self, t):
"""Compute the rotation from the ICRF into the alt-az system."""
R_lon = rot_z(- self.longitude.radians - t.gast * tau / 24.0)
return einsum('ij...,jk...,kl...->il...', self.R_lat, R_lon, t.M) | python | def _altaz_rotation(self, t):
"""Compute the rotation from the ICRF into the alt-az system."""
R_lon = rot_z(- self.longitude.radians - t.gast * tau / 24.0)
return einsum('ij...,jk...,kl...->il...', self.R_lat, R_lon, t.M) | [
"def",
"_altaz_rotation",
"(",
"self",
",",
"t",
")",
":",
"R_lon",
"=",
"rot_z",
"(",
"-",
"self",
".",
"longitude",
".",
"radians",
"-",
"t",
".",
"gast",
"*",
"tau",
"/",
"24.0",
")",
"return",
"einsum",
"(",
"'ij...,jk...,kl...->il...'",
",",
"self... | Compute the rotation from the ICRF into the alt-az system. | [
"Compute",
"the",
"rotation",
"from",
"the",
"ICRF",
"into",
"the",
"alt",
"-",
"az",
"system",
"."
] | 51d9e042e06457f6b1f2415296d50a38cb3a300f | https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/toposlib.py#L70-L73 | train |
skyfielders/python-skyfield | skyfield/toposlib.py | Topos._at | def _at(self, t):
"""Compute the GCRS position and velocity of this Topos at time `t`."""
pos, vel = terra(self.latitude.radians, self.longitude.radians,
self.elevation.au, t.gast)
pos = einsum('ij...,j...->i...', t.MT, pos)
vel = einsum('ij...,j...->i...', t.MT,... | python | def _at(self, t):
"""Compute the GCRS position and velocity of this Topos at time `t`."""
pos, vel = terra(self.latitude.radians, self.longitude.radians,
self.elevation.au, t.gast)
pos = einsum('ij...,j...->i...', t.MT, pos)
vel = einsum('ij...,j...->i...', t.MT,... | [
"def",
"_at",
"(",
"self",
",",
"t",
")",
":",
"pos",
",",
"vel",
"=",
"terra",
"(",
"self",
".",
"latitude",
".",
"radians",
",",
"self",
".",
"longitude",
".",
"radians",
",",
"self",
".",
"elevation",
".",
"au",
",",
"t",
".",
"gast",
")",
"... | Compute the GCRS position and velocity of this Topos at time `t`. | [
"Compute",
"the",
"GCRS",
"position",
"and",
"velocity",
"of",
"this",
"Topos",
"at",
"time",
"t",
"."
] | 51d9e042e06457f6b1f2415296d50a38cb3a300f | https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/toposlib.py#L75-L89 | train |
skyfielders/python-skyfield | skyfield/elementslib.py | osculating_elements_of | def osculating_elements_of(position, reference_frame=None):
"""Produce the osculating orbital elements for a position.
The ``position`` should be an :class:`~skyfield.positionlib.ICRF`
instance like that returned by the ``at()`` method of any Solar
System body, specifying a position, a velocity, and a ... | python | def osculating_elements_of(position, reference_frame=None):
"""Produce the osculating orbital elements for a position.
The ``position`` should be an :class:`~skyfield.positionlib.ICRF`
instance like that returned by the ``at()`` method of any Solar
System body, specifying a position, a velocity, and a ... | [
"def",
"osculating_elements_of",
"(",
"position",
",",
"reference_frame",
"=",
"None",
")",
":",
"mu",
"=",
"GM_dict",
".",
"get",
"(",
"position",
".",
"center",
",",
"0",
")",
"+",
"GM_dict",
".",
"get",
"(",
"position",
".",
"target",
",",
"0",
")",... | Produce the osculating orbital elements for a position.
The ``position`` should be an :class:`~skyfield.positionlib.ICRF`
instance like that returned by the ``at()`` method of any Solar
System body, specifying a position, a velocity, and a time. An
instance of :class:`~skyfield.elementslib.OsculatingE... | [
"Produce",
"the",
"osculating",
"orbital",
"elements",
"for",
"a",
"position",
"."
] | 51d9e042e06457f6b1f2415296d50a38cb3a300f | https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/elementslib.py#L12-L34 | train |
skyfielders/python-skyfield | skyfield/sgp4lib.py | theta_GMST1982 | def theta_GMST1982(jd_ut1):
"""Return the angle of Greenwich Mean Standard Time 1982 given the JD.
This angle defines the difference between the idiosyncratic True
Equator Mean Equinox (TEME) frame of reference used by SGP4 and the
more standard Pseudo Earth Fixed (PEF) frame of reference.
From AI... | python | def theta_GMST1982(jd_ut1):
"""Return the angle of Greenwich Mean Standard Time 1982 given the JD.
This angle defines the difference between the idiosyncratic True
Equator Mean Equinox (TEME) frame of reference used by SGP4 and the
more standard Pseudo Earth Fixed (PEF) frame of reference.
From AI... | [
"def",
"theta_GMST1982",
"(",
"jd_ut1",
")",
":",
"t",
"=",
"(",
"jd_ut1",
"-",
"T0",
")",
"/",
"36525.0",
"g",
"=",
"67310.54841",
"+",
"(",
"8640184.812866",
"+",
"(",
"0.093104",
"+",
"(",
"-",
"6.2e-6",
")",
"*",
"t",
")",
"*",
"t",
")",
"*",... | Return the angle of Greenwich Mean Standard Time 1982 given the JD.
This angle defines the difference between the idiosyncratic True
Equator Mean Equinox (TEME) frame of reference used by SGP4 and the
more standard Pseudo Earth Fixed (PEF) frame of reference.
From AIAA 2006-6753 Appendix C. | [
"Return",
"the",
"angle",
"of",
"Greenwich",
"Mean",
"Standard",
"Time",
"1982",
"given",
"the",
"JD",
"."
] | 51d9e042e06457f6b1f2415296d50a38cb3a300f | https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/sgp4lib.py#L160-L175 | train |
skyfielders/python-skyfield | skyfield/sgp4lib.py | TEME_to_ITRF | def TEME_to_ITRF(jd_ut1, rTEME, vTEME, xp=0.0, yp=0.0):
"""Convert TEME position and velocity into standard ITRS coordinates.
This converts a position and velocity vector in the idiosyncratic
True Equator Mean Equinox (TEME) frame of reference used by the SGP4
theory into vectors into the more standard... | python | def TEME_to_ITRF(jd_ut1, rTEME, vTEME, xp=0.0, yp=0.0):
"""Convert TEME position and velocity into standard ITRS coordinates.
This converts a position and velocity vector in the idiosyncratic
True Equator Mean Equinox (TEME) frame of reference used by the SGP4
theory into vectors into the more standard... | [
"def",
"TEME_to_ITRF",
"(",
"jd_ut1",
",",
"rTEME",
",",
"vTEME",
",",
"xp",
"=",
"0.0",
",",
"yp",
"=",
"0.0",
")",
":",
"theta",
",",
"theta_dot",
"=",
"theta_GMST1982",
"(",
"jd_ut1",
")",
"zero",
"=",
"theta_dot",
"*",
"0.0",
"angular_velocity",
"=... | Convert TEME position and velocity into standard ITRS coordinates.
This converts a position and velocity vector in the idiosyncratic
True Equator Mean Equinox (TEME) frame of reference used by the SGP4
theory into vectors into the more standard ITRS frame of reference.
The velocity should be provided i... | [
"Convert",
"TEME",
"position",
"and",
"velocity",
"into",
"standard",
"ITRS",
"coordinates",
"."
] | 51d9e042e06457f6b1f2415296d50a38cb3a300f | https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/sgp4lib.py#L177-L208 | train |
skyfielders/python-skyfield | skyfield/sgp4lib.py | EarthSatellite.ITRF_position_velocity_error | def ITRF_position_velocity_error(self, t):
"""Return the ITRF position, velocity, and error at time `t`.
The position is an x,y,z vector measured in au, the velocity is
an x,y,z vector measured in au/day, and the error is a vector of
possible error messages for the time or vector of tim... | python | def ITRF_position_velocity_error(self, t):
"""Return the ITRF position, velocity, and error at time `t`.
The position is an x,y,z vector measured in au, the velocity is
an x,y,z vector measured in au/day, and the error is a vector of
possible error messages for the time or vector of tim... | [
"def",
"ITRF_position_velocity_error",
"(",
"self",
",",
"t",
")",
":",
"rTEME",
",",
"vTEME",
",",
"error",
"=",
"self",
".",
"_position_and_velocity_TEME_km",
"(",
"t",
")",
"rTEME",
"/=",
"AU_KM",
"vTEME",
"/=",
"AU_KM",
"vTEME",
"*=",
"DAY_S",
"rITRF",
... | Return the ITRF position, velocity, and error at time `t`.
The position is an x,y,z vector measured in au, the velocity is
an x,y,z vector measured in au/day, and the error is a vector of
possible error messages for the time or vector of times `t`. | [
"Return",
"the",
"ITRF",
"position",
"velocity",
"and",
"error",
"at",
"time",
"t",
"."
] | 51d9e042e06457f6b1f2415296d50a38cb3a300f | https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/sgp4lib.py#L136-L149 | train |
skyfielders/python-skyfield | skyfield/sgp4lib.py | EarthSatellite._at | def _at(self, t):
"""Compute this satellite's GCRS position and velocity at time `t`."""
rITRF, vITRF, error = self.ITRF_position_velocity_error(t)
rGCRS, vGCRS = ITRF_to_GCRS2(t, rITRF, vITRF)
return rGCRS, vGCRS, rGCRS, error | python | def _at(self, t):
"""Compute this satellite's GCRS position and velocity at time `t`."""
rITRF, vITRF, error = self.ITRF_position_velocity_error(t)
rGCRS, vGCRS = ITRF_to_GCRS2(t, rITRF, vITRF)
return rGCRS, vGCRS, rGCRS, error | [
"def",
"_at",
"(",
"self",
",",
"t",
")",
":",
"rITRF",
",",
"vITRF",
",",
"error",
"=",
"self",
".",
"ITRF_position_velocity_error",
"(",
"t",
")",
"rGCRS",
",",
"vGCRS",
"=",
"ITRF_to_GCRS2",
"(",
"t",
",",
"rITRF",
",",
"vITRF",
")",
"return",
"rG... | Compute this satellite's GCRS position and velocity at time `t`. | [
"Compute",
"this",
"satellite",
"s",
"GCRS",
"position",
"and",
"velocity",
"at",
"time",
"t",
"."
] | 51d9e042e06457f6b1f2415296d50a38cb3a300f | https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/sgp4lib.py#L151-L155 | train |
skyfielders/python-skyfield | skyfield/data/earth_orientation.py | morrison_and_stephenson_2004_table | def morrison_and_stephenson_2004_table():
"""Table of smoothed Delta T values from Morrison and Stephenson, 2004."""
import pandas as pd
f = load.open('http://eclipse.gsfc.nasa.gov/SEcat5/deltat.html')
tables = pd.read_html(f.read())
df = tables[0]
return pd.DataFrame({'year': df[0], 'delta_t': ... | python | def morrison_and_stephenson_2004_table():
"""Table of smoothed Delta T values from Morrison and Stephenson, 2004."""
import pandas as pd
f = load.open('http://eclipse.gsfc.nasa.gov/SEcat5/deltat.html')
tables = pd.read_html(f.read())
df = tables[0]
return pd.DataFrame({'year': df[0], 'delta_t': ... | [
"def",
"morrison_and_stephenson_2004_table",
"(",
")",
":",
"import",
"pandas",
"as",
"pd",
"f",
"=",
"load",
".",
"open",
"(",
"'http://eclipse.gsfc.nasa.gov/SEcat5/deltat.html'",
")",
"tables",
"=",
"pd",
".",
"read_html",
"(",
"f",
".",
"read",
"(",
")",
")... | Table of smoothed Delta T values from Morrison and Stephenson, 2004. | [
"Table",
"of",
"smoothed",
"Delta",
"T",
"values",
"from",
"Morrison",
"and",
"Stephenson",
"2004",
"."
] | 51d9e042e06457f6b1f2415296d50a38cb3a300f | https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/data/earth_orientation.py#L8-L14 | train |
skyfielders/python-skyfield | skyfield/functions.py | angle_between | def angle_between(u_vec, v_vec):
"""Given 2 vectors in `v` and `u`, return the angle separating them.
This works whether `v` and `u` each have the shape ``(3,)``, or
whether they are each whole arrays of corresponding x, y, and z
coordinates and have shape ``(3, N)``. The returned angle will be
bet... | python | def angle_between(u_vec, v_vec):
"""Given 2 vectors in `v` and `u`, return the angle separating them.
This works whether `v` and `u` each have the shape ``(3,)``, or
whether they are each whole arrays of corresponding x, y, and z
coordinates and have shape ``(3, N)``. The returned angle will be
bet... | [
"def",
"angle_between",
"(",
"u_vec",
",",
"v_vec",
")",
":",
"u",
"=",
"length_of",
"(",
"u_vec",
")",
"v",
"=",
"length_of",
"(",
"v_vec",
")",
"num",
"=",
"v",
"*",
"u_vec",
"-",
"u",
"*",
"v_vec",
"denom",
"=",
"v",
"*",
"u_vec",
"+",
"u",
... | Given 2 vectors in `v` and `u`, return the angle separating them.
This works whether `v` and `u` each have the shape ``(3,)``, or
whether they are each whole arrays of corresponding x, y, and z
coordinates and have shape ``(3, N)``. The returned angle will be
between 0 and 180 degrees.
This formul... | [
"Given",
"2",
"vectors",
"in",
"v",
"and",
"u",
"return",
"the",
"angle",
"separating",
"them",
"."
] | 51d9e042e06457f6b1f2415296d50a38cb3a300f | https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/functions.py#L26-L42 | train |
skyfielders/python-skyfield | skyfield/starlib.py | Star._compute_vectors | def _compute_vectors(self):
"""Compute the star's position as an ICRF position and velocity."""
# Use 1 gigaparsec for stars whose parallax is zero.
parallax = self.parallax_mas
if parallax <= 0.0:
parallax = 1.0e-6
# Convert right ascension, declination, and paral... | python | def _compute_vectors(self):
"""Compute the star's position as an ICRF position and velocity."""
# Use 1 gigaparsec for stars whose parallax is zero.
parallax = self.parallax_mas
if parallax <= 0.0:
parallax = 1.0e-6
# Convert right ascension, declination, and paral... | [
"def",
"_compute_vectors",
"(",
"self",
")",
":",
"parallax",
"=",
"self",
".",
"parallax_mas",
"if",
"parallax",
"<=",
"0.0",
":",
"parallax",
"=",
"1.0e-6",
"dist",
"=",
"1.0",
"/",
"sin",
"(",
"parallax",
"*",
"1.0e-3",
"*",
"ASEC2RAD",
")",
"r",
"=... | Compute the star's position as an ICRF position and velocity. | [
"Compute",
"the",
"star",
"s",
"position",
"as",
"an",
"ICRF",
"position",
"and",
"velocity",
"."
] | 51d9e042e06457f6b1f2415296d50a38cb3a300f | https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/starlib.py#L126-L170 | train |
skyfielders/python-skyfield | skyfield/units.py | _to_array | def _to_array(value):
"""As a convenience, turn Python lists and tuples into NumPy arrays."""
if isinstance(value, (tuple, list)):
return array(value)
elif isinstance(value, (float, int)):
return np.float64(value)
else:
return value | python | def _to_array(value):
"""As a convenience, turn Python lists and tuples into NumPy arrays."""
if isinstance(value, (tuple, list)):
return array(value)
elif isinstance(value, (float, int)):
return np.float64(value)
else:
return value | [
"def",
"_to_array",
"(",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"(",
"tuple",
",",
"list",
")",
")",
":",
"return",
"array",
"(",
"value",
")",
"elif",
"isinstance",
"(",
"value",
",",
"(",
"float",
",",
"int",
")",
")",
":",
"... | As a convenience, turn Python lists and tuples into NumPy arrays. | [
"As",
"a",
"convenience",
"turn",
"Python",
"lists",
"and",
"tuples",
"into",
"NumPy",
"arrays",
"."
] | 51d9e042e06457f6b1f2415296d50a38cb3a300f | https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/units.py#L12-L19 | train |
skyfielders/python-skyfield | skyfield/units.py | _sexagesimalize_to_float | def _sexagesimalize_to_float(value):
"""Decompose `value` into units, minutes, and seconds.
Note that this routine is not appropriate for displaying a value,
because rounding to the smallest digit of display is necessary
before showing a value to the user. Use `_sexagesimalize_to_int()`
for data b... | python | def _sexagesimalize_to_float(value):
"""Decompose `value` into units, minutes, and seconds.
Note that this routine is not appropriate for displaying a value,
because rounding to the smallest digit of display is necessary
before showing a value to the user. Use `_sexagesimalize_to_int()`
for data b... | [
"def",
"_sexagesimalize_to_float",
"(",
"value",
")",
":",
"sign",
"=",
"np",
".",
"sign",
"(",
"value",
")",
"n",
"=",
"abs",
"(",
"value",
")",
"minutes",
",",
"seconds",
"=",
"divmod",
"(",
"n",
"*",
"3600.0",
",",
"60.0",
")",
"units",
",",
"mi... | Decompose `value` into units, minutes, and seconds.
Note that this routine is not appropriate for displaying a value,
because rounding to the smallest digit of display is necessary
before showing a value to the user. Use `_sexagesimalize_to_int()`
for data being displayed to the user.
This routin... | [
"Decompose",
"value",
"into",
"units",
"minutes",
"and",
"seconds",
"."
] | 51d9e042e06457f6b1f2415296d50a38cb3a300f | https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/units.py#L310-L332 | train |
skyfielders/python-skyfield | skyfield/units.py | _sexagesimalize_to_int | def _sexagesimalize_to_int(value, places=0):
"""Decompose `value` into units, minutes, seconds, and second fractions.
This routine prepares a value for sexagesimal display, with its
seconds fraction expressed as an integer with `places` digits. The
result is a tuple of five integers:
``(sign [eit... | python | def _sexagesimalize_to_int(value, places=0):
"""Decompose `value` into units, minutes, seconds, and second fractions.
This routine prepares a value for sexagesimal display, with its
seconds fraction expressed as an integer with `places` digits. The
result is a tuple of five integers:
``(sign [eit... | [
"def",
"_sexagesimalize_to_int",
"(",
"value",
",",
"places",
"=",
"0",
")",
":",
"sign",
"=",
"int",
"(",
"np",
".",
"sign",
"(",
"value",
")",
")",
"value",
"=",
"abs",
"(",
"value",
")",
"power",
"=",
"10",
"**",
"places",
"n",
"=",
"int",
"("... | Decompose `value` into units, minutes, seconds, and second fractions.
This routine prepares a value for sexagesimal display, with its
seconds fraction expressed as an integer with `places` digits. The
result is a tuple of five integers:
``(sign [either +1 or -1], units, minutes, seconds, second_fract... | [
"Decompose",
"value",
"into",
"units",
"minutes",
"seconds",
"and",
"second",
"fractions",
"."
] | 51d9e042e06457f6b1f2415296d50a38cb3a300f | https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/units.py#L334-L356 | train |
skyfielders/python-skyfield | skyfield/units.py | _hstr | def _hstr(hours, places=2):
"""Convert floating point `hours` into a sexagesimal string.
>>> _hstr(12.125)
'12h 07m 30.00s'
>>> _hstr(12.125, places=4)
'12h 07m 30.0000s'
>>> _hstr(float('nan'))
'nan'
"""
if isnan(hours):
return 'nan'
sgn, h, m, s, etc = _sexagesimalize... | python | def _hstr(hours, places=2):
"""Convert floating point `hours` into a sexagesimal string.
>>> _hstr(12.125)
'12h 07m 30.00s'
>>> _hstr(12.125, places=4)
'12h 07m 30.0000s'
>>> _hstr(float('nan'))
'nan'
"""
if isnan(hours):
return 'nan'
sgn, h, m, s, etc = _sexagesimalize... | [
"def",
"_hstr",
"(",
"hours",
",",
"places",
"=",
"2",
")",
":",
"if",
"isnan",
"(",
"hours",
")",
":",
"return",
"'nan'",
"sgn",
",",
"h",
",",
"m",
",",
"s",
",",
"etc",
"=",
"_sexagesimalize_to_int",
"(",
"hours",
",",
"places",
")",
"sign",
"... | Convert floating point `hours` into a sexagesimal string.
>>> _hstr(12.125)
'12h 07m 30.00s'
>>> _hstr(12.125, places=4)
'12h 07m 30.0000s'
>>> _hstr(float('nan'))
'nan' | [
"Convert",
"floating",
"point",
"hours",
"into",
"a",
"sexagesimal",
"string",
"."
] | 51d9e042e06457f6b1f2415296d50a38cb3a300f | https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/units.py#L358-L373 | train |
skyfielders/python-skyfield | skyfield/units.py | _dstr | def _dstr(degrees, places=1, signed=False):
r"""Convert floating point `degrees` into a sexagesimal string.
>>> _dstr(181.875)
'181deg 52\' 30.0"'
>>> _dstr(181.875, places=3)
'181deg 52\' 30.000"'
>>> _dstr(181.875, signed=True)
'+181deg 52\' 30.0"'
>>> _dstr(float('nan'))
'nan'
... | python | def _dstr(degrees, places=1, signed=False):
r"""Convert floating point `degrees` into a sexagesimal string.
>>> _dstr(181.875)
'181deg 52\' 30.0"'
>>> _dstr(181.875, places=3)
'181deg 52\' 30.000"'
>>> _dstr(181.875, signed=True)
'+181deg 52\' 30.0"'
>>> _dstr(float('nan'))
'nan'
... | [
"def",
"_dstr",
"(",
"degrees",
",",
"places",
"=",
"1",
",",
"signed",
"=",
"False",
")",
":",
"r",
"if",
"isnan",
"(",
"degrees",
")",
":",
"return",
"'nan'",
"sgn",
",",
"d",
",",
"m",
",",
"s",
",",
"etc",
"=",
"_sexagesimalize_to_int",
"(",
... | r"""Convert floating point `degrees` into a sexagesimal string.
>>> _dstr(181.875)
'181deg 52\' 30.0"'
>>> _dstr(181.875, places=3)
'181deg 52\' 30.000"'
>>> _dstr(181.875, signed=True)
'+181deg 52\' 30.0"'
>>> _dstr(float('nan'))
'nan' | [
"r",
"Convert",
"floating",
"point",
"degrees",
"into",
"a",
"sexagesimal",
"string",
"."
] | 51d9e042e06457f6b1f2415296d50a38cb3a300f | https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/units.py#L375-L392 | train |
skyfielders/python-skyfield | skyfield/units.py | _interpret_angle | def _interpret_angle(name, angle_object, angle_float, unit='degrees'):
"""Return an angle in radians from one of two arguments.
It is common for Skyfield routines to accept both an argument like
`alt` that takes an Angle object as well as an `alt_degrees` that
can be given a bare float or a sexagesimal... | python | def _interpret_angle(name, angle_object, angle_float, unit='degrees'):
"""Return an angle in radians from one of two arguments.
It is common for Skyfield routines to accept both an argument like
`alt` that takes an Angle object as well as an `alt_degrees` that
can be given a bare float or a sexagesimal... | [
"def",
"_interpret_angle",
"(",
"name",
",",
"angle_object",
",",
"angle_float",
",",
"unit",
"=",
"'degrees'",
")",
":",
"if",
"angle_object",
"is",
"not",
"None",
":",
"if",
"isinstance",
"(",
"angle_object",
",",
"Angle",
")",
":",
"return",
"angle_object... | Return an angle in radians from one of two arguments.
It is common for Skyfield routines to accept both an argument like
`alt` that takes an Angle object as well as an `alt_degrees` that
can be given a bare float or a sexagesimal tuple. A pair of such
arguments can be passed to this routine for interp... | [
"Return",
"an",
"angle",
"in",
"radians",
"from",
"one",
"of",
"two",
"arguments",
"."
] | 51d9e042e06457f6b1f2415296d50a38cb3a300f | https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/units.py#L423-L439 | train |
skyfielders/python-skyfield | skyfield/units.py | _interpret_ltude | def _interpret_ltude(value, name, psuffix, nsuffix):
"""Interpret a string, float, or tuple as a latitude or longitude angle.
`value` - The string to interpret.
`name` - 'latitude' or 'longitude', for use in exception messages.
`positive` - The string that indicates a positive angle ('N' or 'E').
`... | python | def _interpret_ltude(value, name, psuffix, nsuffix):
"""Interpret a string, float, or tuple as a latitude or longitude angle.
`value` - The string to interpret.
`name` - 'latitude' or 'longitude', for use in exception messages.
`positive` - The string that indicates a positive angle ('N' or 'E').
`... | [
"def",
"_interpret_ltude",
"(",
"value",
",",
"name",
",",
"psuffix",
",",
"nsuffix",
")",
":",
"if",
"not",
"isinstance",
"(",
"value",
",",
"str",
")",
":",
"return",
"Angle",
"(",
"degrees",
"=",
"_unsexagesimalize",
"(",
"value",
")",
")",
"value",
... | Interpret a string, float, or tuple as a latitude or longitude angle.
`value` - The string to interpret.
`name` - 'latitude' or 'longitude', for use in exception messages.
`positive` - The string that indicates a positive angle ('N' or 'E').
`negative` - The string that indicates a negative angle ('S' ... | [
"Interpret",
"a",
"string",
"float",
"or",
"tuple",
"as",
"a",
"latitude",
"or",
"longitude",
"angle",
"."
] | 51d9e042e06457f6b1f2415296d50a38cb3a300f | https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/units.py#L441-L469 | train |
skyfielders/python-skyfield | skyfield/units.py | Distance.to | def to(self, unit):
"""Convert this distance to the given AstroPy unit."""
from astropy.units import au
return (self.au * au).to(unit) | python | def to(self, unit):
"""Convert this distance to the given AstroPy unit."""
from astropy.units import au
return (self.au * au).to(unit) | [
"def",
"to",
"(",
"self",
",",
"unit",
")",
":",
"from",
"astropy",
".",
"units",
"import",
"au",
"return",
"(",
"self",
".",
"au",
"*",
"au",
")",
".",
"to",
"(",
"unit",
")"
] | Convert this distance to the given AstroPy unit. | [
"Convert",
"this",
"distance",
"to",
"the",
"given",
"AstroPy",
"unit",
"."
] | 51d9e042e06457f6b1f2415296d50a38cb3a300f | https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/units.py#L76-L79 | train |
skyfielders/python-skyfield | skyfield/units.py | Velocity.to | def to(self, unit):
"""Convert this velocity to the given AstroPy unit."""
from astropy.units import au, d
return (self.au_per_d * au / d).to(unit) | python | def to(self, unit):
"""Convert this velocity to the given AstroPy unit."""
from astropy.units import au, d
return (self.au_per_d * au / d).to(unit) | [
"def",
"to",
"(",
"self",
",",
"unit",
")",
":",
"from",
"astropy",
".",
"units",
"import",
"au",
",",
"d",
"return",
"(",
"self",
".",
"au_per_d",
"*",
"au",
"/",
"d",
")",
".",
"to",
"(",
"unit",
")"
] | Convert this velocity to the given AstroPy unit. | [
"Convert",
"this",
"velocity",
"to",
"the",
"given",
"AstroPy",
"unit",
"."
] | 51d9e042e06457f6b1f2415296d50a38cb3a300f | https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/units.py#L123-L126 | train |
skyfielders/python-skyfield | skyfield/units.py | Angle.hstr | def hstr(self, places=2, warn=True):
"""Convert to a string like ``12h 07m 30.00s``."""
if warn and self.preference != 'hours':
raise WrongUnitError('hstr')
if self.radians.size == 0:
return '<Angle []>'
hours = self._hours
shape = getattr(hours, 'shape', ... | python | def hstr(self, places=2, warn=True):
"""Convert to a string like ``12h 07m 30.00s``."""
if warn and self.preference != 'hours':
raise WrongUnitError('hstr')
if self.radians.size == 0:
return '<Angle []>'
hours = self._hours
shape = getattr(hours, 'shape', ... | [
"def",
"hstr",
"(",
"self",
",",
"places",
"=",
"2",
",",
"warn",
"=",
"True",
")",
":",
"if",
"warn",
"and",
"self",
".",
"preference",
"!=",
"'hours'",
":",
"raise",
"WrongUnitError",
"(",
"'hstr'",
")",
"if",
"self",
".",
"radians",
".",
"size",
... | Convert to a string like ``12h 07m 30.00s``. | [
"Convert",
"to",
"a",
"string",
"like",
"12h",
"07m",
"30",
".",
"00s",
"."
] | 51d9e042e06457f6b1f2415296d50a38cb3a300f | https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/units.py#L232-L246 | train |
skyfielders/python-skyfield | skyfield/units.py | Angle.dstr | def dstr(self, places=1, warn=True):
"""Convert to a string like ``181deg 52\' 30.0"``."""
if warn and self.preference != 'degrees':
raise WrongUnitError('dstr')
if self.radians.size == 0:
return '<Angle []>'
degrees = self._degrees
signed = self.signed
... | python | def dstr(self, places=1, warn=True):
"""Convert to a string like ``181deg 52\' 30.0"``."""
if warn and self.preference != 'degrees':
raise WrongUnitError('dstr')
if self.radians.size == 0:
return '<Angle []>'
degrees = self._degrees
signed = self.signed
... | [
"def",
"dstr",
"(",
"self",
",",
"places",
"=",
"1",
",",
"warn",
"=",
"True",
")",
":",
"if",
"warn",
"and",
"self",
".",
"preference",
"!=",
"'degrees'",
":",
"raise",
"WrongUnitError",
"(",
"'dstr'",
")",
"if",
"self",
".",
"radians",
".",
"size",... | Convert to a string like ``181deg 52\' 30.0"``. | [
"Convert",
"to",
"a",
"string",
"like",
"181deg",
"52",
"\\",
"30",
".",
"0",
"."
] | 51d9e042e06457f6b1f2415296d50a38cb3a300f | https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/units.py#L270-L285 | train |
skyfielders/python-skyfield | skyfield/units.py | Angle.to | def to(self, unit):
"""Convert this angle to the given AstroPy unit."""
from astropy.units import rad
return (self.radians * rad).to(unit)
# Or should this do:
from astropy.coordinates import Angle
from astropy.units import rad
return Angle(self.radians, rad).to(... | python | def to(self, unit):
"""Convert this angle to the given AstroPy unit."""
from astropy.units import rad
return (self.radians * rad).to(unit)
# Or should this do:
from astropy.coordinates import Angle
from astropy.units import rad
return Angle(self.radians, rad).to(... | [
"def",
"to",
"(",
"self",
",",
"unit",
")",
":",
"from",
"astropy",
".",
"units",
"import",
"rad",
"return",
"(",
"self",
".",
"radians",
"*",
"rad",
")",
".",
"to",
"(",
"unit",
")",
"from",
"astropy",
".",
"coordinates",
"import",
"Angle",
"from",
... | Convert this angle to the given AstroPy unit. | [
"Convert",
"this",
"angle",
"to",
"the",
"given",
"AstroPy",
"unit",
"."
] | 51d9e042e06457f6b1f2415296d50a38cb3a300f | https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/units.py#L287-L295 | train |
skyfielders/python-skyfield | skyfield/positionlib.py | ICRF.separation_from | def separation_from(self, another_icrf):
"""Return the angle between this position and another.
>>> print(ICRF([1,0,0]).separation_from(ICRF([1,1,0])))
45deg 00' 00.0"
You can also compute separations across an array of positions.
>>> directions = ICRF([[1,0,-1,0], [0,1,0,-1],... | python | def separation_from(self, another_icrf):
"""Return the angle between this position and another.
>>> print(ICRF([1,0,0]).separation_from(ICRF([1,1,0])))
45deg 00' 00.0"
You can also compute separations across an array of positions.
>>> directions = ICRF([[1,0,-1,0], [0,1,0,-1],... | [
"def",
"separation_from",
"(",
"self",
",",
"another_icrf",
")",
":",
"p1",
"=",
"self",
".",
"position",
".",
"au",
"p2",
"=",
"another_icrf",
".",
"position",
".",
"au",
"u1",
"=",
"p1",
"/",
"length_of",
"(",
"p1",
")",
"u2",
"=",
"p2",
"/",
"le... | Return the angle between this position and another.
>>> print(ICRF([1,0,0]).separation_from(ICRF([1,1,0])))
45deg 00' 00.0"
You can also compute separations across an array of positions.
>>> directions = ICRF([[1,0,-1,0], [0,1,0,-1], [0,0,0,0]])
>>> directions.separation_from(... | [
"Return",
"the",
"angle",
"between",
"this",
"position",
"and",
"another",
"."
] | 51d9e042e06457f6b1f2415296d50a38cb3a300f | https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/positionlib.py#L134-L157 | train |
skyfielders/python-skyfield | skyfield/positionlib.py | ICRF.to_skycoord | def to_skycoord(self, unit=None):
"""Convert this distance to an AstroPy ``SkyCoord`` object."""
from astropy.coordinates import SkyCoord
from astropy.units import au
x, y, z = self.position.au
return SkyCoord(representation='cartesian', x=x, y=y, z=z, unit=au) | python | def to_skycoord(self, unit=None):
"""Convert this distance to an AstroPy ``SkyCoord`` object."""
from astropy.coordinates import SkyCoord
from astropy.units import au
x, y, z = self.position.au
return SkyCoord(representation='cartesian', x=x, y=y, z=z, unit=au) | [
"def",
"to_skycoord",
"(",
"self",
",",
"unit",
"=",
"None",
")",
":",
"from",
"astropy",
".",
"coordinates",
"import",
"SkyCoord",
"from",
"astropy",
".",
"units",
"import",
"au",
"x",
",",
"y",
",",
"z",
"=",
"self",
".",
"position",
".",
"au",
"re... | Convert this distance to an AstroPy ``SkyCoord`` object. | [
"Convert",
"this",
"distance",
"to",
"an",
"AstroPy",
"SkyCoord",
"object",
"."
] | 51d9e042e06457f6b1f2415296d50a38cb3a300f | https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/positionlib.py#L262-L267 | train |
skyfielders/python-skyfield | skyfield/positionlib.py | ICRF.from_altaz | def from_altaz(self, alt=None, az=None, alt_degrees=None, az_degrees=None,
distance=Distance(au=0.1)):
"""Generate an Apparent position from an altitude and azimuth.
The altitude and azimuth can each be provided as an `Angle`
object, or else as a number of degrees provided as... | python | def from_altaz(self, alt=None, az=None, alt_degrees=None, az_degrees=None,
distance=Distance(au=0.1)):
"""Generate an Apparent position from an altitude and azimuth.
The altitude and azimuth can each be provided as an `Angle`
object, or else as a number of degrees provided as... | [
"def",
"from_altaz",
"(",
"self",
",",
"alt",
"=",
"None",
",",
"az",
"=",
"None",
",",
"alt_degrees",
"=",
"None",
",",
"az_degrees",
"=",
"None",
",",
"distance",
"=",
"Distance",
"(",
"au",
"=",
"0.1",
")",
")",
":",
"R",
"=",
"self",
".",
"ob... | Generate an Apparent position from an altitude and azimuth.
The altitude and azimuth can each be provided as an `Angle`
object, or else as a number of degrees provided as either a
float or a tuple of degrees, arcminutes, and arcseconds::
alt=Angle(...), az=Angle(...)
al... | [
"Generate",
"an",
"Apparent",
"position",
"from",
"an",
"altitude",
"and",
"azimuth",
"."
] | 51d9e042e06457f6b1f2415296d50a38cb3a300f | https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/positionlib.py#L277-L304 | train |
skyfielders/python-skyfield | skyfield/positionlib.py | Barycentric.observe | def observe(self, body):
"""Compute the `Astrometric` position of a body from this location.
To compute the body's astrometric position, it is first asked
for its position at the time `t` of this position itself. The
distance to the body is then divided by the speed of light to
... | python | def observe(self, body):
"""Compute the `Astrometric` position of a body from this location.
To compute the body's astrometric position, it is first asked
for its position at the time `t` of this position itself. The
distance to the body is then divided by the speed of light to
... | [
"def",
"observe",
"(",
"self",
",",
"body",
")",
":",
"p",
",",
"v",
",",
"t",
",",
"light_time",
"=",
"body",
".",
"_observe_from_bcrs",
"(",
"self",
")",
"astrometric",
"=",
"Astrometric",
"(",
"p",
",",
"v",
",",
"t",
",",
"observer_data",
"=",
... | Compute the `Astrometric` position of a body from this location.
To compute the body's astrometric position, it is first asked
for its position at the time `t` of this position itself. The
distance to the body is then divided by the speed of light to
find how long it takes its light to... | [
"Compute",
"the",
"Astrometric",
"position",
"of",
"a",
"body",
"from",
"this",
"location",
"."
] | 51d9e042e06457f6b1f2415296d50a38cb3a300f | https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/positionlib.py#L349-L367 | train |
skyfielders/python-skyfield | skyfield/positionlib.py | Geocentric.subpoint | def subpoint(self):
"""Return the latitude and longitude directly beneath this position.
Returns a :class:`~skyfield.toposlib.Topos` whose ``longitude``
and ``latitude`` are those of the point on the Earth's surface
directly beneath this position, and whose ``elevation`` is the
... | python | def subpoint(self):
"""Return the latitude and longitude directly beneath this position.
Returns a :class:`~skyfield.toposlib.Topos` whose ``longitude``
and ``latitude`` are those of the point on the Earth's surface
directly beneath this position, and whose ``elevation`` is the
... | [
"def",
"subpoint",
"(",
"self",
")",
":",
"if",
"self",
".",
"center",
"!=",
"399",
":",
"raise",
"ValueError",
"(",
"\"you can only ask for the geographic subpoint\"",
"\" of a position measured from Earth's center\"",
")",
"t",
"=",
"self",
".",
"t",
"xyz_au",
"="... | Return the latitude and longitude directly beneath this position.
Returns a :class:`~skyfield.toposlib.Topos` whose ``longitude``
and ``latitude`` are those of the point on the Earth's surface
directly beneath this position, and whose ``elevation`` is the
height of this position above t... | [
"Return",
"the",
"latitude",
"and",
"longitude",
"directly",
"beneath",
"this",
"position",
"."
] | 51d9e042e06457f6b1f2415296d50a38cb3a300f | https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/positionlib.py#L454-L478 | train |
skyfielders/python-skyfield | skyfield/charting.py | _plot_stars | def _plot_stars(catalog, observer, project, ax, mag1, mag2, margin=1.25):
"""Experiment in progress, hence the underscore; expect changes."""
art = []
# from astropy import wcs
# w = wcs.WCS(naxis=2)
# w.wcs.crpix = [-234.75, 8.3393]
# w.wcs.cdelt = np.array([-0.066667, 0.066667])
# w.wcs.... | python | def _plot_stars(catalog, observer, project, ax, mag1, mag2, margin=1.25):
"""Experiment in progress, hence the underscore; expect changes."""
art = []
# from astropy import wcs
# w = wcs.WCS(naxis=2)
# w.wcs.crpix = [-234.75, 8.3393]
# w.wcs.cdelt = np.array([-0.066667, 0.066667])
# w.wcs.... | [
"def",
"_plot_stars",
"(",
"catalog",
",",
"observer",
",",
"project",
",",
"ax",
",",
"mag1",
",",
"mag2",
",",
"margin",
"=",
"1.25",
")",
":",
"art",
"=",
"[",
"]",
"xmin",
",",
"xmax",
"=",
"ax",
".",
"get_xlim",
"(",
")",
"ymin",
",",
"ymax"... | Experiment in progress, hence the underscore; expect changes. | [
"Experiment",
"in",
"progress",
"hence",
"the",
"underscore",
";",
"expect",
"changes",
"."
] | 51d9e042e06457f6b1f2415296d50a38cb3a300f | https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/charting.py#L9-L82 | train |
skyfielders/python-skyfield | skyfield/almanac.py | phase_angle | def phase_angle(ephemeris, body, t):
"""Compute the phase angle of a body viewed from Earth.
The ``body`` should be an integer or string that can be looked up in
the given ``ephemeris``, which will also be asked to provide
positions for the Earth and Sun. The return value will be an
:class:`~skyfi... | python | def phase_angle(ephemeris, body, t):
"""Compute the phase angle of a body viewed from Earth.
The ``body`` should be an integer or string that can be looked up in
the given ``ephemeris``, which will also be asked to provide
positions for the Earth and Sun. The return value will be an
:class:`~skyfi... | [
"def",
"phase_angle",
"(",
"ephemeris",
",",
"body",
",",
"t",
")",
":",
"earth",
"=",
"ephemeris",
"[",
"'earth'",
"]",
"sun",
"=",
"ephemeris",
"[",
"'sun'",
"]",
"body",
"=",
"ephemeris",
"[",
"body",
"]",
"pe",
"=",
"earth",
".",
"at",
"(",
"t"... | Compute the phase angle of a body viewed from Earth.
The ``body`` should be an integer or string that can be looked up in
the given ``ephemeris``, which will also be asked to provide
positions for the Earth and Sun. The return value will be an
:class:`~skyfield.units.Angle` object. | [
"Compute",
"the",
"phase",
"angle",
"of",
"a",
"body",
"viewed",
"from",
"Earth",
"."
] | 51d9e042e06457f6b1f2415296d50a38cb3a300f | https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/almanac.py#L11-L27 | train |
skyfielders/python-skyfield | skyfield/almanac.py | fraction_illuminated | def fraction_illuminated(ephemeris, body, t):
"""Compute the illuminated fraction of a body viewed from Earth.
The ``body`` should be an integer or string that can be looked up in
the given ``ephemeris``, which will also be asked to provide
positions for the Earth and Sun. The return value will be a
... | python | def fraction_illuminated(ephemeris, body, t):
"""Compute the illuminated fraction of a body viewed from Earth.
The ``body`` should be an integer or string that can be looked up in
the given ``ephemeris``, which will also be asked to provide
positions for the Earth and Sun. The return value will be a
... | [
"def",
"fraction_illuminated",
"(",
"ephemeris",
",",
"body",
",",
"t",
")",
":",
"a",
"=",
"phase_angle",
"(",
"ephemeris",
",",
"body",
",",
"t",
")",
".",
"radians",
"return",
"0.5",
"*",
"(",
"1.0",
"+",
"cos",
"(",
"a",
")",
")"
] | Compute the illuminated fraction of a body viewed from Earth.
The ``body`` should be an integer or string that can be looked up in
the given ``ephemeris``, which will also be asked to provide
positions for the Earth and Sun. The return value will be a
floating point number between zero and one. This ... | [
"Compute",
"the",
"illuminated",
"fraction",
"of",
"a",
"body",
"viewed",
"from",
"Earth",
"."
] | 51d9e042e06457f6b1f2415296d50a38cb3a300f | https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/almanac.py#L29-L40 | train |
skyfielders/python-skyfield | skyfield/almanac.py | find_discrete | def find_discrete(start_time, end_time, f, epsilon=EPSILON, num=12):
"""Find the times when a function changes value.
Searches between ``start_time`` and ``end_time``, which should both
be :class:`~skyfield.timelib.Time` objects, for the occasions where
the function ``f`` changes from one value to anot... | python | def find_discrete(start_time, end_time, f, epsilon=EPSILON, num=12):
"""Find the times when a function changes value.
Searches between ``start_time`` and ``end_time``, which should both
be :class:`~skyfield.timelib.Time` objects, for the occasions where
the function ``f`` changes from one value to anot... | [
"def",
"find_discrete",
"(",
"start_time",
",",
"end_time",
",",
"f",
",",
"epsilon",
"=",
"EPSILON",
",",
"num",
"=",
"12",
")",
":",
"ts",
"=",
"start_time",
".",
"ts",
"jd0",
"=",
"start_time",
".",
"tt",
"jd1",
"=",
"end_time",
".",
"tt",
"if",
... | Find the times when a function changes value.
Searches between ``start_time`` and ``end_time``, which should both
be :class:`~skyfield.timelib.Time` objects, for the occasions where
the function ``f`` changes from one value to another. Use this to
search for events like sunrise or moon phases.
A ... | [
"Find",
"the",
"times",
"when",
"a",
"function",
"changes",
"value",
"."
] | 51d9e042e06457f6b1f2415296d50a38cb3a300f | https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/almanac.py#L44-L101 | train |
skyfielders/python-skyfield | skyfield/almanac.py | seasons | def seasons(ephemeris):
"""Build a function of time that returns the quarter of the year.
The function that this returns will expect a single argument that is
a :class:`~skyfield.timelib.Time` and will return 0 through 3 for
the seasons Spring, Summer, Autumn, and Winter.
"""
earth = ephemeris... | python | def seasons(ephemeris):
"""Build a function of time that returns the quarter of the year.
The function that this returns will expect a single argument that is
a :class:`~skyfield.timelib.Time` and will return 0 through 3 for
the seasons Spring, Summer, Autumn, and Winter.
"""
earth = ephemeris... | [
"def",
"seasons",
"(",
"ephemeris",
")",
":",
"earth",
"=",
"ephemeris",
"[",
"'earth'",
"]",
"sun",
"=",
"ephemeris",
"[",
"'sun'",
"]",
"def",
"season_at",
"(",
"t",
")",
":",
"t",
".",
"_nutation_angles",
"=",
"iau2000b",
"(",
"t",
".",
"tt",
")",... | Build a function of time that returns the quarter of the year.
The function that this returns will expect a single argument that is
a :class:`~skyfield.timelib.Time` and will return 0 through 3 for
the seasons Spring, Summer, Autumn, and Winter. | [
"Build",
"a",
"function",
"of",
"time",
"that",
"returns",
"the",
"quarter",
"of",
"the",
"year",
"."
] | 51d9e042e06457f6b1f2415296d50a38cb3a300f | https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/almanac.py#L161-L180 | train |
skyfielders/python-skyfield | skyfield/almanac.py | sunrise_sunset | def sunrise_sunset(ephemeris, topos):
"""Build a function of time that returns whether the sun is up.
The function that this returns will expect a single argument that is
a :class:`~skyfield.timelib.Time` and will return ``True`` if the
sun is up, else ``False``.
"""
sun = ephemeris['sun']
... | python | def sunrise_sunset(ephemeris, topos):
"""Build a function of time that returns whether the sun is up.
The function that this returns will expect a single argument that is
a :class:`~skyfield.timelib.Time` and will return ``True`` if the
sun is up, else ``False``.
"""
sun = ephemeris['sun']
... | [
"def",
"sunrise_sunset",
"(",
"ephemeris",
",",
"topos",
")",
":",
"sun",
"=",
"ephemeris",
"[",
"'sun'",
"]",
"topos_at",
"=",
"(",
"ephemeris",
"[",
"'earth'",
"]",
"+",
"topos",
")",
".",
"at",
"def",
"is_sun_up_at",
"(",
"t",
")",
":",
"t",
".",
... | Build a function of time that returns whether the sun is up.
The function that this returns will expect a single argument that is
a :class:`~skyfield.timelib.Time` and will return ``True`` if the
sun is up, else ``False``. | [
"Build",
"a",
"function",
"of",
"time",
"that",
"returns",
"whether",
"the",
"sun",
"is",
"up",
"."
] | 51d9e042e06457f6b1f2415296d50a38cb3a300f | https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/almanac.py#L182-L200 | train |
skyfielders/python-skyfield | skyfield/almanac.py | moon_phases | def moon_phases(ephemeris):
"""Build a function of time that returns the moon phase 0 through 3.
The function that this returns will expect a single argument that is
a :class:`~skyfield.timelib.Time` and will return the phase of the
moon as an integer. See the accompanying array ``MOON_PHASES`` if
... | python | def moon_phases(ephemeris):
"""Build a function of time that returns the moon phase 0 through 3.
The function that this returns will expect a single argument that is
a :class:`~skyfield.timelib.Time` and will return the phase of the
moon as an integer. See the accompanying array ``MOON_PHASES`` if
... | [
"def",
"moon_phases",
"(",
"ephemeris",
")",
":",
"earth",
"=",
"ephemeris",
"[",
"'earth'",
"]",
"moon",
"=",
"ephemeris",
"[",
"'moon'",
"]",
"sun",
"=",
"ephemeris",
"[",
"'sun'",
"]",
"def",
"moon_phase_at",
"(",
"t",
")",
":",
"t",
".",
"_nutation... | Build a function of time that returns the moon phase 0 through 3.
The function that this returns will expect a single argument that is
a :class:`~skyfield.timelib.Time` and will return the phase of the
moon as an integer. See the accompanying array ``MOON_PHASES`` if
you want to give string names to e... | [
"Build",
"a",
"function",
"of",
"time",
"that",
"returns",
"the",
"moon",
"phase",
"0",
"through",
"3",
"."
] | 51d9e042e06457f6b1f2415296d50a38cb3a300f | https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/almanac.py#L209-L231 | train |
skyfielders/python-skyfield | skyfield/projections.py | _derive_stereographic | def _derive_stereographic():
"""Compute the formulae to cut-and-paste into the routine below."""
from sympy import symbols, atan2, acos, rot_axis1, rot_axis3, Matrix
x_c, y_c, z_c, x, y, z = symbols('x_c y_c z_c x y z')
# The angles we'll need to rotate through.
around_z = atan2(x_c, y_c)
aroun... | python | def _derive_stereographic():
"""Compute the formulae to cut-and-paste into the routine below."""
from sympy import symbols, atan2, acos, rot_axis1, rot_axis3, Matrix
x_c, y_c, z_c, x, y, z = symbols('x_c y_c z_c x y z')
# The angles we'll need to rotate through.
around_z = atan2(x_c, y_c)
aroun... | [
"def",
"_derive_stereographic",
"(",
")",
":",
"from",
"sympy",
"import",
"symbols",
",",
"atan2",
",",
"acos",
",",
"rot_axis1",
",",
"rot_axis3",
",",
"Matrix",
"x_c",
",",
"y_c",
",",
"z_c",
",",
"x",
",",
"y",
",",
"z",
"=",
"symbols",
"(",
"'x_c... | Compute the formulae to cut-and-paste into the routine below. | [
"Compute",
"the",
"formulae",
"to",
"cut",
"-",
"and",
"-",
"paste",
"into",
"the",
"routine",
"below",
"."
] | 51d9e042e06457f6b1f2415296d50a38cb3a300f | https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/projections.py#L5-L23 | train |
reiinakano/scikit-plot | scikitplot/classifiers.py | classifier_factory | def classifier_factory(clf):
"""Embeds scikit-plot instance methods in an sklearn classifier.
Args:
clf: Scikit-learn classifier instance
Returns:
The same scikit-learn classifier instance passed in **clf**
with embedded scikit-plot instance methods.
Raises:
ValueError... | python | def classifier_factory(clf):
"""Embeds scikit-plot instance methods in an sklearn classifier.
Args:
clf: Scikit-learn classifier instance
Returns:
The same scikit-learn classifier instance passed in **clf**
with embedded scikit-plot instance methods.
Raises:
ValueError... | [
"def",
"classifier_factory",
"(",
"clf",
")",
":",
"required_methods",
"=",
"[",
"'fit'",
",",
"'score'",
",",
"'predict'",
"]",
"for",
"method",
"in",
"required_methods",
":",
"if",
"not",
"hasattr",
"(",
"clf",
",",
"method",
")",
":",
"raise",
"TypeErro... | Embeds scikit-plot instance methods in an sklearn classifier.
Args:
clf: Scikit-learn classifier instance
Returns:
The same scikit-learn classifier instance passed in **clf**
with embedded scikit-plot instance methods.
Raises:
ValueError: If **clf** does not contain the in... | [
"Embeds",
"scikit",
"-",
"plot",
"instance",
"methods",
"in",
"an",
"sklearn",
"classifier",
"."
] | 2dd3e6a76df77edcbd724c4db25575f70abb57cb | https://github.com/reiinakano/scikit-plot/blob/2dd3e6a76df77edcbd724c4db25575f70abb57cb/scikitplot/classifiers.py#L24-L67 | train |
reiinakano/scikit-plot | scikitplot/classifiers.py | plot_confusion_matrix_with_cv | def plot_confusion_matrix_with_cv(clf, X, y, labels=None, true_labels=None,
pred_labels=None, title=None,
normalize=False, hide_zeros=False,
x_tick_rotation=0, do_cv=True, cv=None,
shu... | python | def plot_confusion_matrix_with_cv(clf, X, y, labels=None, true_labels=None,
pred_labels=None, title=None,
normalize=False, hide_zeros=False,
x_tick_rotation=0, do_cv=True, cv=None,
shu... | [
"def",
"plot_confusion_matrix_with_cv",
"(",
"clf",
",",
"X",
",",
"y",
",",
"labels",
"=",
"None",
",",
"true_labels",
"=",
"None",
",",
"pred_labels",
"=",
"None",
",",
"title",
"=",
"None",
",",
"normalize",
"=",
"False",
",",
"hide_zeros",
"=",
"Fals... | Generates the confusion matrix for a given classifier and dataset.
Args:
clf: Classifier instance that implements ``fit`` and ``predict``
methods.
X (array-like, shape (n_samples, n_features)):
Training vector, where n_samples is the number of samples and
n_feat... | [
"Generates",
"the",
"confusion",
"matrix",
"for",
"a",
"given",
"classifier",
"and",
"dataset",
"."
] | 2dd3e6a76df77edcbd724c4db25575f70abb57cb | https://github.com/reiinakano/scikit-plot/blob/2dd3e6a76df77edcbd724c4db25575f70abb57cb/scikitplot/classifiers.py#L70-L219 | train |
reiinakano/scikit-plot | scikitplot/classifiers.py | plot_ks_statistic_with_cv | def plot_ks_statistic_with_cv(clf, X, y, title='KS Statistic Plot',
do_cv=True, cv=None, shuffle=True,
random_state=None, ax=None, figsize=None,
title_fontsize="large", text_fontsize="medium"):
"""Generates the KS Statistic pl... | python | def plot_ks_statistic_with_cv(clf, X, y, title='KS Statistic Plot',
do_cv=True, cv=None, shuffle=True,
random_state=None, ax=None, figsize=None,
title_fontsize="large", text_fontsize="medium"):
"""Generates the KS Statistic pl... | [
"def",
"plot_ks_statistic_with_cv",
"(",
"clf",
",",
"X",
",",
"y",
",",
"title",
"=",
"'KS Statistic Plot'",
",",
"do_cv",
"=",
"True",
",",
"cv",
"=",
"None",
",",
"shuffle",
"=",
"True",
",",
"random_state",
"=",
"None",
",",
"ax",
"=",
"None",
",",... | Generates the KS Statistic plot for a given classifier and dataset.
Args:
clf: Classifier instance that implements "fit" and "predict_proba"
methods.
X (array-like, shape (n_samples, n_features)):
Training vector, where n_samples is the number of samples and
n_f... | [
"Generates",
"the",
"KS",
"Statistic",
"plot",
"for",
"a",
"given",
"classifier",
"and",
"dataset",
"."
] | 2dd3e6a76df77edcbd724c4db25575f70abb57cb | https://github.com/reiinakano/scikit-plot/blob/2dd3e6a76df77edcbd724c4db25575f70abb57cb/scikitplot/classifiers.py#L352-L467 | train |
reiinakano/scikit-plot | scikitplot/plotters.py | plot_confusion_matrix | def plot_confusion_matrix(y_true, y_pred, labels=None, true_labels=None,
pred_labels=None, title=None, normalize=False,
hide_zeros=False, x_tick_rotation=0, ax=None,
figsize=None, cmap='Blues', title_fontsize="large",
... | python | def plot_confusion_matrix(y_true, y_pred, labels=None, true_labels=None,
pred_labels=None, title=None, normalize=False,
hide_zeros=False, x_tick_rotation=0, ax=None,
figsize=None, cmap='Blues', title_fontsize="large",
... | [
"def",
"plot_confusion_matrix",
"(",
"y_true",
",",
"y_pred",
",",
"labels",
"=",
"None",
",",
"true_labels",
"=",
"None",
",",
"pred_labels",
"=",
"None",
",",
"title",
"=",
"None",
",",
"normalize",
"=",
"False",
",",
"hide_zeros",
"=",
"False",
",",
"... | Generates confusion matrix plot from predictions and true labels
Args:
y_true (array-like, shape (n_samples)):
Ground truth (correct) target values.
y_pred (array-like, shape (n_samples)):
Estimated targets as returned by a classifier.
labels (array-like, shape (n_... | [
"Generates",
"confusion",
"matrix",
"plot",
"from",
"predictions",
"and",
"true",
"labels"
] | 2dd3e6a76df77edcbd724c4db25575f70abb57cb | https://github.com/reiinakano/scikit-plot/blob/2dd3e6a76df77edcbd724c4db25575f70abb57cb/scikitplot/plotters.py#L42-L181 | train |
reiinakano/scikit-plot | scikitplot/plotters.py | plot_feature_importances | def plot_feature_importances(clf, title='Feature Importance',
feature_names=None, max_num_features=20,
order='descending', x_tick_rotation=0, ax=None,
figsize=None, title_fontsize="large",
text_fontsize="... | python | def plot_feature_importances(clf, title='Feature Importance',
feature_names=None, max_num_features=20,
order='descending', x_tick_rotation=0, ax=None,
figsize=None, title_fontsize="large",
text_fontsize="... | [
"def",
"plot_feature_importances",
"(",
"clf",
",",
"title",
"=",
"'Feature Importance'",
",",
"feature_names",
"=",
"None",
",",
"max_num_features",
"=",
"20",
",",
"order",
"=",
"'descending'",
",",
"x_tick_rotation",
"=",
"0",
",",
"ax",
"=",
"None",
",",
... | Generates a plot of a classifier's feature importances.
Args:
clf: Classifier instance that implements ``fit`` and ``predict_proba``
methods. The classifier must also have a ``feature_importances_``
attribute.
title (string, optional): Title of the generated plot. Defaults ... | [
"Generates",
"a",
"plot",
"of",
"a",
"classifier",
"s",
"feature",
"importances",
"."
] | 2dd3e6a76df77edcbd724c4db25575f70abb57cb | https://github.com/reiinakano/scikit-plot/blob/2dd3e6a76df77edcbd724c4db25575f70abb57cb/scikitplot/plotters.py#L546-L661 | train |
reiinakano/scikit-plot | scikitplot/plotters.py | plot_silhouette | def plot_silhouette(clf, X, title='Silhouette Analysis', metric='euclidean',
copy=True, ax=None, figsize=None, cmap='nipy_spectral',
title_fontsize="large", text_fontsize="medium"):
"""Plots silhouette analysis of clusters using fit_predict.
Args:
clf: Clusterer ... | python | def plot_silhouette(clf, X, title='Silhouette Analysis', metric='euclidean',
copy=True, ax=None, figsize=None, cmap='nipy_spectral',
title_fontsize="large", text_fontsize="medium"):
"""Plots silhouette analysis of clusters using fit_predict.
Args:
clf: Clusterer ... | [
"def",
"plot_silhouette",
"(",
"clf",
",",
"X",
",",
"title",
"=",
"'Silhouette Analysis'",
",",
"metric",
"=",
"'euclidean'",
",",
"copy",
"=",
"True",
",",
"ax",
"=",
"None",
",",
"figsize",
"=",
"None",
",",
"cmap",
"=",
"'nipy_spectral'",
",",
"title... | Plots silhouette analysis of clusters using fit_predict.
Args:
clf: Clusterer instance that implements ``fit`` and ``fit_predict``
methods.
X (array-like, shape (n_samples, n_features)):
Data to cluster, where n_samples is the number of samples and
n_features is... | [
"Plots",
"silhouette",
"analysis",
"of",
"clusters",
"using",
"fit_predict",
"."
] | 2dd3e6a76df77edcbd724c4db25575f70abb57cb | https://github.com/reiinakano/scikit-plot/blob/2dd3e6a76df77edcbd724c4db25575f70abb57cb/scikitplot/plotters.py#L775-L888 | train |
reiinakano/scikit-plot | scikitplot/cluster.py | _clone_and_score_clusterer | def _clone_and_score_clusterer(clf, X, n_clusters):
"""Clones and scores clusterer instance.
Args:
clf: Clusterer instance that implements ``fit``,``fit_predict``, and
``score`` methods, and an ``n_clusters`` hyperparameter.
e.g. :class:`sklearn.cluster.KMeans` instance
... | python | def _clone_and_score_clusterer(clf, X, n_clusters):
"""Clones and scores clusterer instance.
Args:
clf: Clusterer instance that implements ``fit``,``fit_predict``, and
``score`` methods, and an ``n_clusters`` hyperparameter.
e.g. :class:`sklearn.cluster.KMeans` instance
... | [
"def",
"_clone_and_score_clusterer",
"(",
"clf",
",",
"X",
",",
"n_clusters",
")",
":",
"start",
"=",
"time",
".",
"time",
"(",
")",
"clf",
"=",
"clone",
"(",
"clf",
")",
"setattr",
"(",
"clf",
",",
"'n_clusters'",
",",
"n_clusters",
")",
"return",
"cl... | Clones and scores clusterer instance.
Args:
clf: Clusterer instance that implements ``fit``,``fit_predict``, and
``score`` methods, and an ``n_clusters`` hyperparameter.
e.g. :class:`sklearn.cluster.KMeans` instance
X (array-like, shape (n_samples, n_features)):
... | [
"Clones",
"and",
"scores",
"clusterer",
"instance",
"."
] | 2dd3e6a76df77edcbd724c4db25575f70abb57cb | https://github.com/reiinakano/scikit-plot/blob/2dd3e6a76df77edcbd724c4db25575f70abb57cb/scikitplot/cluster.py#L110-L132 | train |
reiinakano/scikit-plot | scikitplot/estimators.py | plot_learning_curve | def plot_learning_curve(clf, X, y, title='Learning Curve', cv=None,
shuffle=False, random_state=None,
train_sizes=None, n_jobs=1, scoring=None,
ax=None, figsize=None, title_fontsize="large",
text_fontsize="medium"):
"""G... | python | def plot_learning_curve(clf, X, y, title='Learning Curve', cv=None,
shuffle=False, random_state=None,
train_sizes=None, n_jobs=1, scoring=None,
ax=None, figsize=None, title_fontsize="large",
text_fontsize="medium"):
"""G... | [
"def",
"plot_learning_curve",
"(",
"clf",
",",
"X",
",",
"y",
",",
"title",
"=",
"'Learning Curve'",
",",
"cv",
"=",
"None",
",",
"shuffle",
"=",
"False",
",",
"random_state",
"=",
"None",
",",
"train_sizes",
"=",
"None",
",",
"n_jobs",
"=",
"1",
",",
... | Generates a plot of the train and test learning curves for a classifier.
Args:
clf: Classifier instance that implements ``fit`` and ``predict``
methods.
X (array-like, shape (n_samples, n_features)):
Training vector, where n_samples is the number of samples and
... | [
"Generates",
"a",
"plot",
"of",
"the",
"train",
"and",
"test",
"learning",
"curves",
"for",
"a",
"classifier",
"."
] | 2dd3e6a76df77edcbd724c4db25575f70abb57cb | https://github.com/reiinakano/scikit-plot/blob/2dd3e6a76df77edcbd724c4db25575f70abb57cb/scikitplot/estimators.py#L135-L247 | train |
reiinakano/scikit-plot | scikitplot/metrics.py | plot_calibration_curve | def plot_calibration_curve(y_true, probas_list, clf_names=None, n_bins=10,
title='Calibration plots (Reliability Curves)',
ax=None, figsize=None, cmap='nipy_spectral',
title_fontsize="large", text_fontsize="medium"):
"""Plots calibrati... | python | def plot_calibration_curve(y_true, probas_list, clf_names=None, n_bins=10,
title='Calibration plots (Reliability Curves)',
ax=None, figsize=None, cmap='nipy_spectral',
title_fontsize="large", text_fontsize="medium"):
"""Plots calibrati... | [
"def",
"plot_calibration_curve",
"(",
"y_true",
",",
"probas_list",
",",
"clf_names",
"=",
"None",
",",
"n_bins",
"=",
"10",
",",
"title",
"=",
"'Calibration plots (Reliability Curves)'",
",",
"ax",
"=",
"None",
",",
"figsize",
"=",
"None",
",",
"cmap",
"=",
... | Plots calibration curves for a set of classifier probability estimates.
Plotting the calibration curves of a classifier is useful for determining
whether or not you can interpret their predicted probabilities directly as
as confidence level. For instance, a well-calibrated binary classifier
should clas... | [
"Plots",
"calibration",
"curves",
"for",
"a",
"set",
"of",
"classifier",
"probability",
"estimates",
"."
] | 2dd3e6a76df77edcbd724c4db25575f70abb57cb | https://github.com/reiinakano/scikit-plot/blob/2dd3e6a76df77edcbd724c4db25575f70abb57cb/scikitplot/metrics.py#L911-L1042 | train |
reiinakano/scikit-plot | scikitplot/clustering.py | clustering_factory | def clustering_factory(clf):
"""Embeds scikit-plot plotting methods in an sklearn clusterer instance.
Args:
clf: Scikit-learn clusterer instance
Returns:
The same scikit-learn clusterer instance passed in **clf** with
embedded scikit-plot instance methods.
Raises:
Valu... | python | def clustering_factory(clf):
"""Embeds scikit-plot plotting methods in an sklearn clusterer instance.
Args:
clf: Scikit-learn clusterer instance
Returns:
The same scikit-learn clusterer instance passed in **clf** with
embedded scikit-plot instance methods.
Raises:
Valu... | [
"def",
"clustering_factory",
"(",
"clf",
")",
":",
"required_methods",
"=",
"[",
"'fit'",
",",
"'fit_predict'",
"]",
"for",
"method",
"in",
"required_methods",
":",
"if",
"not",
"hasattr",
"(",
"clf",
",",
"method",
")",
":",
"raise",
"TypeError",
"(",
"'\... | Embeds scikit-plot plotting methods in an sklearn clusterer instance.
Args:
clf: Scikit-learn clusterer instance
Returns:
The same scikit-learn clusterer instance passed in **clf** with
embedded scikit-plot instance methods.
Raises:
ValueError: If **clf** does not contain ... | [
"Embeds",
"scikit",
"-",
"plot",
"plotting",
"methods",
"in",
"an",
"sklearn",
"clusterer",
"instance",
"."
] | 2dd3e6a76df77edcbd724c4db25575f70abb57cb | https://github.com/reiinakano/scikit-plot/blob/2dd3e6a76df77edcbd724c4db25575f70abb57cb/scikitplot/clustering.py#L18-L50 | train |
reiinakano/scikit-plot | scikitplot/helpers.py | validate_labels | def validate_labels(known_classes, passed_labels, argument_name):
"""Validates the labels passed into the true_labels or pred_labels
arguments in the plot_confusion_matrix function.
Raises a ValueError exception if any of the passed labels are not in the
set of known classes or if there are duplicate l... | python | def validate_labels(known_classes, passed_labels, argument_name):
"""Validates the labels passed into the true_labels or pred_labels
arguments in the plot_confusion_matrix function.
Raises a ValueError exception if any of the passed labels are not in the
set of known classes or if there are duplicate l... | [
"def",
"validate_labels",
"(",
"known_classes",
",",
"passed_labels",
",",
"argument_name",
")",
":",
"known_classes",
"=",
"np",
".",
"array",
"(",
"known_classes",
")",
"passed_labels",
"=",
"np",
".",
"array",
"(",
"passed_labels",
")",
"unique_labels",
",",
... | Validates the labels passed into the true_labels or pred_labels
arguments in the plot_confusion_matrix function.
Raises a ValueError exception if any of the passed labels are not in the
set of known classes or if there are duplicate labels. Otherwise returns
None.
Args:
known_classes (arra... | [
"Validates",
"the",
"labels",
"passed",
"into",
"the",
"true_labels",
"or",
"pred_labels",
"arguments",
"in",
"the",
"plot_confusion_matrix",
"function",
"."
] | 2dd3e6a76df77edcbd724c4db25575f70abb57cb | https://github.com/reiinakano/scikit-plot/blob/2dd3e6a76df77edcbd724c4db25575f70abb57cb/scikitplot/helpers.py#L108-L154 | train |
reiinakano/scikit-plot | scikitplot/helpers.py | cumulative_gain_curve | def cumulative_gain_curve(y_true, y_score, pos_label=None):
"""This function generates the points necessary to plot the Cumulative Gain
Note: This implementation is restricted to the binary classification task.
Args:
y_true (array-like, shape (n_samples)): True labels of the data.
y_score... | python | def cumulative_gain_curve(y_true, y_score, pos_label=None):
"""This function generates the points necessary to plot the Cumulative Gain
Note: This implementation is restricted to the binary classification task.
Args:
y_true (array-like, shape (n_samples)): True labels of the data.
y_score... | [
"def",
"cumulative_gain_curve",
"(",
"y_true",
",",
"y_score",
",",
"pos_label",
"=",
"None",
")",
":",
"y_true",
",",
"y_score",
"=",
"np",
".",
"asarray",
"(",
"y_true",
")",
",",
"np",
".",
"asarray",
"(",
"y_score",
")",
"classes",
"=",
"np",
".",
... | This function generates the points necessary to plot the Cumulative Gain
Note: This implementation is restricted to the binary classification task.
Args:
y_true (array-like, shape (n_samples)): True labels of the data.
y_score (array-like, shape (n_samples)): Target scores, can either be
... | [
"This",
"function",
"generates",
"the",
"points",
"necessary",
"to",
"plot",
"the",
"Cumulative",
"Gain"
] | 2dd3e6a76df77edcbd724c4db25575f70abb57cb | https://github.com/reiinakano/scikit-plot/blob/2dd3e6a76df77edcbd724c4db25575f70abb57cb/scikitplot/helpers.py#L157-L213 | train |
allure-framework/allure-python | allure-python-commons/src/utils.py | getargspec | def getargspec(func):
"""
Used because getargspec for python 2.7 does not accept functools.partial
which is the type for pytest fixtures.
getargspec excerpted from:
sphinx.util.inspect
~~~~~~~~~~~~~~~~~~~
Helpers for inspecting Python modules.
:copyright: Copyright 2007-2018 by the Sph... | python | def getargspec(func):
"""
Used because getargspec for python 2.7 does not accept functools.partial
which is the type for pytest fixtures.
getargspec excerpted from:
sphinx.util.inspect
~~~~~~~~~~~~~~~~~~~
Helpers for inspecting Python modules.
:copyright: Copyright 2007-2018 by the Sph... | [
"def",
"getargspec",
"(",
"func",
")",
":",
"if",
"inspect",
".",
"ismethod",
"(",
"func",
")",
":",
"func",
"=",
"func",
".",
"__func__",
"parts",
"=",
"0",
",",
"(",
")",
"if",
"type",
"(",
"func",
")",
"is",
"partial",
":",
"keywords",
"=",
"f... | Used because getargspec for python 2.7 does not accept functools.partial
which is the type for pytest fixtures.
getargspec excerpted from:
sphinx.util.inspect
~~~~~~~~~~~~~~~~~~~
Helpers for inspecting Python modules.
:copyright: Copyright 2007-2018 by the Sphinx team, see AUTHORS.
:licens... | [
"Used",
"because",
"getargspec",
"for",
"python",
"2",
".",
"7",
"does",
"not",
"accept",
"functools",
".",
"partial",
"which",
"is",
"the",
"type",
"for",
"pytest",
"fixtures",
"."
] | 070fdcc093e8743cc5e58f5f108b21f12ec8ddaf | https://github.com/allure-framework/allure-python/blob/070fdcc093e8743cc5e58f5f108b21f12ec8ddaf/allure-python-commons/src/utils.py#L18-L61 | train |
miLibris/flask-rest-jsonapi | flask_rest_jsonapi/querystring.py | QueryStringManager.querystring | def querystring(self):
"""Return original querystring but containing only managed keys
:return dict: dict of managed querystring parameter
"""
return {key: value for (key, value) in self.qs.items()
if key.startswith(self.MANAGED_KEYS) or self._get_key_values('filter[')} | python | def querystring(self):
"""Return original querystring but containing only managed keys
:return dict: dict of managed querystring parameter
"""
return {key: value for (key, value) in self.qs.items()
if key.startswith(self.MANAGED_KEYS) or self._get_key_values('filter[')} | [
"def",
"querystring",
"(",
"self",
")",
":",
"return",
"{",
"key",
":",
"value",
"for",
"(",
"key",
",",
"value",
")",
"in",
"self",
".",
"qs",
".",
"items",
"(",
")",
"if",
"key",
".",
"startswith",
"(",
"self",
".",
"MANAGED_KEYS",
")",
"or",
"... | Return original querystring but containing only managed keys
:return dict: dict of managed querystring parameter | [
"Return",
"original",
"querystring",
"but",
"containing",
"only",
"managed",
"keys"
] | ecc8f2cd2b54cc0bfae7acd6cffcda0ba1140c43 | https://github.com/miLibris/flask-rest-jsonapi/blob/ecc8f2cd2b54cc0bfae7acd6cffcda0ba1140c43/flask_rest_jsonapi/querystring.py#L68-L74 | train |
miLibris/flask-rest-jsonapi | flask_rest_jsonapi/querystring.py | QueryStringManager.filters | def filters(self):
"""Return filters from query string.
:return list: filter information
"""
results = []
filters = self.qs.get('filter')
if filters is not None:
try:
results.extend(json.loads(filters))
except (ValueError, TypeErro... | python | def filters(self):
"""Return filters from query string.
:return list: filter information
"""
results = []
filters = self.qs.get('filter')
if filters is not None:
try:
results.extend(json.loads(filters))
except (ValueError, TypeErro... | [
"def",
"filters",
"(",
"self",
")",
":",
"results",
"=",
"[",
"]",
"filters",
"=",
"self",
".",
"qs",
".",
"get",
"(",
"'filter'",
")",
"if",
"filters",
"is",
"not",
"None",
":",
"try",
":",
"results",
".",
"extend",
"(",
"json",
".",
"loads",
"(... | Return filters from query string.
:return list: filter information | [
"Return",
"filters",
"from",
"query",
"string",
"."
] | ecc8f2cd2b54cc0bfae7acd6cffcda0ba1140c43 | https://github.com/miLibris/flask-rest-jsonapi/blob/ecc8f2cd2b54cc0bfae7acd6cffcda0ba1140c43/flask_rest_jsonapi/querystring.py#L77-L91 | train |
miLibris/flask-rest-jsonapi | flask_rest_jsonapi/querystring.py | QueryStringManager.pagination | def pagination(self):
"""Return all page parameters as a dict.
:return dict: a dict of pagination information
To allow multiples strategies, all parameters starting with `page` will be included. e.g::
{
"number": '25',
"size": '150',
}
... | python | def pagination(self):
"""Return all page parameters as a dict.
:return dict: a dict of pagination information
To allow multiples strategies, all parameters starting with `page` will be included. e.g::
{
"number": '25',
"size": '150',
}
... | [
"def",
"pagination",
"(",
"self",
")",
":",
"result",
"=",
"self",
".",
"_get_key_values",
"(",
"'page'",
")",
"for",
"key",
",",
"value",
"in",
"result",
".",
"items",
"(",
")",
":",
"if",
"key",
"not",
"in",
"(",
"'number'",
",",
"'size'",
")",
"... | Return all page parameters as a dict.
:return dict: a dict of pagination information
To allow multiples strategies, all parameters starting with `page` will be included. e.g::
{
"number": '25',
"size": '150',
}
Example with number strat... | [
"Return",
"all",
"page",
"parameters",
"as",
"a",
"dict",
"."
] | ecc8f2cd2b54cc0bfae7acd6cffcda0ba1140c43 | https://github.com/miLibris/flask-rest-jsonapi/blob/ecc8f2cd2b54cc0bfae7acd6cffcda0ba1140c43/flask_rest_jsonapi/querystring.py#L94-L130 | train |
miLibris/flask-rest-jsonapi | flask_rest_jsonapi/querystring.py | QueryStringManager.fields | def fields(self):
"""Return fields wanted by client.
:return dict: a dict of sparse fieldsets information
Return value will be a dict containing all fields by resource, for example::
{
"user": ['name', 'email'],
}
"""
result = self._get... | python | def fields(self):
"""Return fields wanted by client.
:return dict: a dict of sparse fieldsets information
Return value will be a dict containing all fields by resource, for example::
{
"user": ['name', 'email'],
}
"""
result = self._get... | [
"def",
"fields",
"(",
"self",
")",
":",
"result",
"=",
"self",
".",
"_get_key_values",
"(",
"'fields'",
")",
"for",
"key",
",",
"value",
"in",
"result",
".",
"items",
"(",
")",
":",
"if",
"not",
"isinstance",
"(",
"value",
",",
"list",
")",
":",
"r... | Return fields wanted by client.
:return dict: a dict of sparse fieldsets information
Return value will be a dict containing all fields by resource, for example::
{
"user": ['name', 'email'],
} | [
"Return",
"fields",
"wanted",
"by",
"client",
"."
] | ecc8f2cd2b54cc0bfae7acd6cffcda0ba1140c43 | https://github.com/miLibris/flask-rest-jsonapi/blob/ecc8f2cd2b54cc0bfae7acd6cffcda0ba1140c43/flask_rest_jsonapi/querystring.py#L133-L156 | train |
miLibris/flask-rest-jsonapi | flask_rest_jsonapi/querystring.py | QueryStringManager.sorting | def sorting(self):
"""Return fields to sort by including sort name for SQLAlchemy and row
sort parameter for other ORMs
:return list: a list of sorting information
Example of return value::
[
{'field': 'created_at', 'order': 'desc'},
]
... | python | def sorting(self):
"""Return fields to sort by including sort name for SQLAlchemy and row
sort parameter for other ORMs
:return list: a list of sorting information
Example of return value::
[
{'field': 'created_at', 'order': 'desc'},
]
... | [
"def",
"sorting",
"(",
"self",
")",
":",
"if",
"self",
".",
"qs",
".",
"get",
"(",
"'sort'",
")",
":",
"sorting_results",
"=",
"[",
"]",
"for",
"sort_field",
"in",
"self",
".",
"qs",
"[",
"'sort'",
"]",
".",
"split",
"(",
"','",
")",
":",
"field"... | Return fields to sort by including sort name for SQLAlchemy and row
sort parameter for other ORMs
:return list: a list of sorting information
Example of return value::
[
{'field': 'created_at', 'order': 'desc'},
] | [
"Return",
"fields",
"to",
"sort",
"by",
"including",
"sort",
"name",
"for",
"SQLAlchemy",
"and",
"row",
"sort",
"parameter",
"for",
"other",
"ORMs"
] | ecc8f2cd2b54cc0bfae7acd6cffcda0ba1140c43 | https://github.com/miLibris/flask-rest-jsonapi/blob/ecc8f2cd2b54cc0bfae7acd6cffcda0ba1140c43/flask_rest_jsonapi/querystring.py#L159-L185 | train |
miLibris/flask-rest-jsonapi | flask_rest_jsonapi/querystring.py | QueryStringManager.include | def include(self):
"""Return fields to include
:return list: a list of include information
"""
include_param = self.qs.get('include', [])
if current_app.config.get('MAX_INCLUDE_DEPTH') is not None:
for include_path in include_param:
if len(include_pa... | python | def include(self):
"""Return fields to include
:return list: a list of include information
"""
include_param = self.qs.get('include', [])
if current_app.config.get('MAX_INCLUDE_DEPTH') is not None:
for include_path in include_param:
if len(include_pa... | [
"def",
"include",
"(",
"self",
")",
":",
"include_param",
"=",
"self",
".",
"qs",
".",
"get",
"(",
"'include'",
",",
"[",
"]",
")",
"if",
"current_app",
".",
"config",
".",
"get",
"(",
"'MAX_INCLUDE_DEPTH'",
")",
"is",
"not",
"None",
":",
"for",
"inc... | Return fields to include
:return list: a list of include information | [
"Return",
"fields",
"to",
"include"
] | ecc8f2cd2b54cc0bfae7acd6cffcda0ba1140c43 | https://github.com/miLibris/flask-rest-jsonapi/blob/ecc8f2cd2b54cc0bfae7acd6cffcda0ba1140c43/flask_rest_jsonapi/querystring.py#L188-L201 | train |
miLibris/flask-rest-jsonapi | flask_rest_jsonapi/exceptions.py | JsonApiException.to_dict | def to_dict(self):
"""Return values of each fields of an jsonapi error"""
error_dict = {}
for field in ('status', 'source', 'title', 'detail', 'id', 'code', 'links', 'meta'):
if getattr(self, field, None):
error_dict.update({field: getattr(self, field)})
retu... | python | def to_dict(self):
"""Return values of each fields of an jsonapi error"""
error_dict = {}
for field in ('status', 'source', 'title', 'detail', 'id', 'code', 'links', 'meta'):
if getattr(self, field, None):
error_dict.update({field: getattr(self, field)})
retu... | [
"def",
"to_dict",
"(",
"self",
")",
":",
"error_dict",
"=",
"{",
"}",
"for",
"field",
"in",
"(",
"'status'",
",",
"'source'",
",",
"'title'",
",",
"'detail'",
",",
"'id'",
",",
"'code'",
",",
"'links'",
",",
"'meta'",
")",
":",
"if",
"getattr",
"(",
... | Return values of each fields of an jsonapi error | [
"Return",
"values",
"of",
"each",
"fields",
"of",
"an",
"jsonapi",
"error"
] | ecc8f2cd2b54cc0bfae7acd6cffcda0ba1140c43 | https://github.com/miLibris/flask-rest-jsonapi/blob/ecc8f2cd2b54cc0bfae7acd6cffcda0ba1140c43/flask_rest_jsonapi/exceptions.py#L30-L37 | train |
miLibris/flask-rest-jsonapi | flask_rest_jsonapi/resource.py | Resource.dispatch_request | def dispatch_request(self, *args, **kwargs):
"""Logic of how to handle a request"""
method = getattr(self, request.method.lower(), None)
if method is None and request.method == 'HEAD':
method = getattr(self, 'get', None)
assert method is not None, 'Unimplemented method {}'.fo... | python | def dispatch_request(self, *args, **kwargs):
"""Logic of how to handle a request"""
method = getattr(self, request.method.lower(), None)
if method is None and request.method == 'HEAD':
method = getattr(self, 'get', None)
assert method is not None, 'Unimplemented method {}'.fo... | [
"def",
"dispatch_request",
"(",
"self",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"method",
"=",
"getattr",
"(",
"self",
",",
"request",
".",
"method",
".",
"lower",
"(",
")",
",",
"None",
")",
"if",
"method",
"is",
"None",
"and",
"request",
... | Logic of how to handle a request | [
"Logic",
"of",
"how",
"to",
"handle",
"a",
"request"
] | ecc8f2cd2b54cc0bfae7acd6cffcda0ba1140c43 | https://github.com/miLibris/flask-rest-jsonapi/blob/ecc8f2cd2b54cc0bfae7acd6cffcda0ba1140c43/flask_rest_jsonapi/resource.py#L62-L96 | train |
miLibris/flask-rest-jsonapi | flask_rest_jsonapi/resource.py | ResourceList.get | def get(self, *args, **kwargs):
"""Retrieve a collection of objects"""
self.before_get(args, kwargs)
qs = QSManager(request.args, self.schema)
objects_count, objects = self.get_collection(qs, kwargs)
schema_kwargs = getattr(self, 'get_schema_kwargs', dict())
schema_kwa... | python | def get(self, *args, **kwargs):
"""Retrieve a collection of objects"""
self.before_get(args, kwargs)
qs = QSManager(request.args, self.schema)
objects_count, objects = self.get_collection(qs, kwargs)
schema_kwargs = getattr(self, 'get_schema_kwargs', dict())
schema_kwa... | [
"def",
"get",
"(",
"self",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"self",
".",
"before_get",
"(",
"args",
",",
"kwargs",
")",
"qs",
"=",
"QSManager",
"(",
"request",
".",
"args",
",",
"self",
".",
"schema",
")",
"objects_count",
",",
"obj... | Retrieve a collection of objects | [
"Retrieve",
"a",
"collection",
"of",
"objects"
] | ecc8f2cd2b54cc0bfae7acd6cffcda0ba1140c43 | https://github.com/miLibris/flask-rest-jsonapi/blob/ecc8f2cd2b54cc0bfae7acd6cffcda0ba1140c43/flask_rest_jsonapi/resource.py#L103-L133 | train |
miLibris/flask-rest-jsonapi | flask_rest_jsonapi/resource.py | ResourceList.post | def post(self, *args, **kwargs):
"""Create an object"""
json_data = request.get_json() or {}
qs = QSManager(request.args, self.schema)
schema = compute_schema(self.schema,
getattr(self, 'post_schema_kwargs', dict()),
qs,
... | python | def post(self, *args, **kwargs):
"""Create an object"""
json_data = request.get_json() or {}
qs = QSManager(request.args, self.schema)
schema = compute_schema(self.schema,
getattr(self, 'post_schema_kwargs', dict()),
qs,
... | [
"def",
"post",
"(",
"self",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"json_data",
"=",
"request",
".",
"get_json",
"(",
")",
"or",
"{",
"}",
"qs",
"=",
"QSManager",
"(",
"request",
".",
"args",
",",
"self",
".",
"schema",
")",
"schema",
"... | Create an object | [
"Create",
"an",
"object"
] | ecc8f2cd2b54cc0bfae7acd6cffcda0ba1140c43 | https://github.com/miLibris/flask-rest-jsonapi/blob/ecc8f2cd2b54cc0bfae7acd6cffcda0ba1140c43/flask_rest_jsonapi/resource.py#L136-L181 | train |
miLibris/flask-rest-jsonapi | flask_rest_jsonapi/resource.py | ResourceDetail.get | def get(self, *args, **kwargs):
"""Get object details"""
self.before_get(args, kwargs)
qs = QSManager(request.args, self.schema)
obj = self.get_object(kwargs, qs)
self.before_marshmallow(args, kwargs)
schema = compute_schema(self.schema,
... | python | def get(self, *args, **kwargs):
"""Get object details"""
self.before_get(args, kwargs)
qs = QSManager(request.args, self.schema)
obj = self.get_object(kwargs, qs)
self.before_marshmallow(args, kwargs)
schema = compute_schema(self.schema,
... | [
"def",
"get",
"(",
"self",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"self",
".",
"before_get",
"(",
"args",
",",
"kwargs",
")",
"qs",
"=",
"QSManager",
"(",
"request",
".",
"args",
",",
"self",
".",
"schema",
")",
"obj",
"=",
"self",
".",... | Get object details | [
"Get",
"object",
"details"
] | ecc8f2cd2b54cc0bfae7acd6cffcda0ba1140c43 | https://github.com/miLibris/flask-rest-jsonapi/blob/ecc8f2cd2b54cc0bfae7acd6cffcda0ba1140c43/flask_rest_jsonapi/resource.py#L213-L232 | train |
miLibris/flask-rest-jsonapi | flask_rest_jsonapi/resource.py | ResourceDetail.patch | def patch(self, *args, **kwargs):
"""Update an object"""
json_data = request.get_json() or {}
qs = QSManager(request.args, self.schema)
schema_kwargs = getattr(self, 'patch_schema_kwargs', dict())
schema_kwargs.update({'partial': True})
self.before_marshmallow(args, kwa... | python | def patch(self, *args, **kwargs):
"""Update an object"""
json_data = request.get_json() or {}
qs = QSManager(request.args, self.schema)
schema_kwargs = getattr(self, 'patch_schema_kwargs', dict())
schema_kwargs.update({'partial': True})
self.before_marshmallow(args, kwa... | [
"def",
"patch",
"(",
"self",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"json_data",
"=",
"request",
".",
"get_json",
"(",
")",
"or",
"{",
"}",
"qs",
"=",
"QSManager",
"(",
"request",
".",
"args",
",",
"self",
".",
"schema",
")",
"schema_kwar... | Update an object | [
"Update",
"an",
"object"
] | ecc8f2cd2b54cc0bfae7acd6cffcda0ba1140c43 | https://github.com/miLibris/flask-rest-jsonapi/blob/ecc8f2cd2b54cc0bfae7acd6cffcda0ba1140c43/flask_rest_jsonapi/resource.py#L235-L286 | train |
miLibris/flask-rest-jsonapi | flask_rest_jsonapi/resource.py | ResourceDetail.delete | def delete(self, *args, **kwargs):
"""Delete an object"""
self.before_delete(args, kwargs)
self.delete_object(kwargs)
result = {'meta': {'message': 'Object successfully deleted'}}
final_result = self.after_delete(result)
return final_result | python | def delete(self, *args, **kwargs):
"""Delete an object"""
self.before_delete(args, kwargs)
self.delete_object(kwargs)
result = {'meta': {'message': 'Object successfully deleted'}}
final_result = self.after_delete(result)
return final_result | [
"def",
"delete",
"(",
"self",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"self",
".",
"before_delete",
"(",
"args",
",",
"kwargs",
")",
"self",
".",
"delete_object",
"(",
"kwargs",
")",
"result",
"=",
"{",
"'meta'",
":",
"{",
"'message'",
":",
... | Delete an object | [
"Delete",
"an",
"object"
] | ecc8f2cd2b54cc0bfae7acd6cffcda0ba1140c43 | https://github.com/miLibris/flask-rest-jsonapi/blob/ecc8f2cd2b54cc0bfae7acd6cffcda0ba1140c43/flask_rest_jsonapi/resource.py#L289-L299 | train |
miLibris/flask-rest-jsonapi | flask_rest_jsonapi/resource.py | ResourceRelationship.get | def get(self, *args, **kwargs):
"""Get a relationship details"""
self.before_get(args, kwargs)
relationship_field, model_relationship_field, related_type_, related_id_field = self._get_relationship_data()
obj, data = self._data_layer.get_relationship(model_relationship_field,
... | python | def get(self, *args, **kwargs):
"""Get a relationship details"""
self.before_get(args, kwargs)
relationship_field, model_relationship_field, related_type_, related_id_field = self._get_relationship_data()
obj, data = self._data_layer.get_relationship(model_relationship_field,
... | [
"def",
"get",
"(",
"self",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"self",
".",
"before_get",
"(",
"args",
",",
"kwargs",
")",
"relationship_field",
",",
"model_relationship_field",
",",
"related_type_",
",",
"related_id_field",
"=",
"self",
".",
... | Get a relationship details | [
"Get",
"a",
"relationship",
"details"
] | ecc8f2cd2b54cc0bfae7acd6cffcda0ba1140c43 | https://github.com/miLibris/flask-rest-jsonapi/blob/ecc8f2cd2b54cc0bfae7acd6cffcda0ba1140c43/flask_rest_jsonapi/resource.py#L346-L370 | train |
miLibris/flask-rest-jsonapi | flask_rest_jsonapi/resource.py | ResourceRelationship.patch | def patch(self, *args, **kwargs):
"""Update a relationship"""
json_data = request.get_json() or {}
relationship_field, model_relationship_field, related_type_, related_id_field = self._get_relationship_data()
if 'data' not in json_data:
raise BadRequest('You must provide da... | python | def patch(self, *args, **kwargs):
"""Update a relationship"""
json_data = request.get_json() or {}
relationship_field, model_relationship_field, related_type_, related_id_field = self._get_relationship_data()
if 'data' not in json_data:
raise BadRequest('You must provide da... | [
"def",
"patch",
"(",
"self",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"json_data",
"=",
"request",
".",
"get_json",
"(",
")",
"or",
"{",
"}",
"relationship_field",
",",
"model_relationship_field",
",",
"related_type_",
",",
"related_id_field",
"=",
... | Update a relationship | [
"Update",
"a",
"relationship"
] | ecc8f2cd2b54cc0bfae7acd6cffcda0ba1140c43 | https://github.com/miLibris/flask-rest-jsonapi/blob/ecc8f2cd2b54cc0bfae7acd6cffcda0ba1140c43/flask_rest_jsonapi/resource.py#L417-L458 | train |
miLibris/flask-rest-jsonapi | flask_rest_jsonapi/resource.py | ResourceRelationship._get_relationship_data | def _get_relationship_data(self):
"""Get useful data for relationship management"""
relationship_field = request.path.split('/')[-1].replace('-', '_')
if relationship_field not in get_relationships(self.schema):
raise RelationNotFound("{} has no attribute {}".format(self.schema.__na... | python | def _get_relationship_data(self):
"""Get useful data for relationship management"""
relationship_field = request.path.split('/')[-1].replace('-', '_')
if relationship_field not in get_relationships(self.schema):
raise RelationNotFound("{} has no attribute {}".format(self.schema.__na... | [
"def",
"_get_relationship_data",
"(",
"self",
")",
":",
"relationship_field",
"=",
"request",
".",
"path",
".",
"split",
"(",
"'/'",
")",
"[",
"-",
"1",
"]",
".",
"replace",
"(",
"'-'",
",",
"'_'",
")",
"if",
"relationship_field",
"not",
"in",
"get_relat... | Get useful data for relationship management | [
"Get",
"useful",
"data",
"for",
"relationship",
"management"
] | ecc8f2cd2b54cc0bfae7acd6cffcda0ba1140c43 | https://github.com/miLibris/flask-rest-jsonapi/blob/ecc8f2cd2b54cc0bfae7acd6cffcda0ba1140c43/flask_rest_jsonapi/resource.py#L504-L515 | train |
miLibris/flask-rest-jsonapi | flask_rest_jsonapi/schema.py | compute_schema | def compute_schema(schema_cls, default_kwargs, qs, include):
"""Compute a schema around compound documents and sparse fieldsets
:param Schema schema_cls: the schema class
:param dict default_kwargs: the schema default kwargs
:param QueryStringManager qs: qs
:param list include: the relation field t... | python | def compute_schema(schema_cls, default_kwargs, qs, include):
"""Compute a schema around compound documents and sparse fieldsets
:param Schema schema_cls: the schema class
:param dict default_kwargs: the schema default kwargs
:param QueryStringManager qs: qs
:param list include: the relation field t... | [
"def",
"compute_schema",
"(",
"schema_cls",
",",
"default_kwargs",
",",
"qs",
",",
"include",
")",
":",
"schema_kwargs",
"=",
"default_kwargs",
"schema_kwargs",
"[",
"'include_data'",
"]",
"=",
"tuple",
"(",
")",
"related_includes",
"=",
"{",
"}",
"if",
"inclu... | Compute a schema around compound documents and sparse fieldsets
:param Schema schema_cls: the schema class
:param dict default_kwargs: the schema default kwargs
:param QueryStringManager qs: qs
:param list include: the relation field to include data from
:return Schema schema: the schema computed | [
"Compute",
"a",
"schema",
"around",
"compound",
"documents",
"and",
"sparse",
"fieldsets"
] | ecc8f2cd2b54cc0bfae7acd6cffcda0ba1140c43 | https://github.com/miLibris/flask-rest-jsonapi/blob/ecc8f2cd2b54cc0bfae7acd6cffcda0ba1140c43/flask_rest_jsonapi/schema.py#L12-L82 | train |
miLibris/flask-rest-jsonapi | flask_rest_jsonapi/schema.py | get_model_field | def get_model_field(schema, field):
"""Get the model field of a schema field
:param Schema schema: a marshmallow schema
:param str field: the name of the schema field
:return str: the name of the field in the model
"""
if schema._declared_fields.get(field) is None:
raise Exception("{} h... | python | def get_model_field(schema, field):
"""Get the model field of a schema field
:param Schema schema: a marshmallow schema
:param str field: the name of the schema field
:return str: the name of the field in the model
"""
if schema._declared_fields.get(field) is None:
raise Exception("{} h... | [
"def",
"get_model_field",
"(",
"schema",
",",
"field",
")",
":",
"if",
"schema",
".",
"_declared_fields",
".",
"get",
"(",
"field",
")",
"is",
"None",
":",
"raise",
"Exception",
"(",
"\"{} has no attribute {}\"",
".",
"format",
"(",
"schema",
".",
"__name__"... | Get the model field of a schema field
:param Schema schema: a marshmallow schema
:param str field: the name of the schema field
:return str: the name of the field in the model | [
"Get",
"the",
"model",
"field",
"of",
"a",
"schema",
"field"
] | ecc8f2cd2b54cc0bfae7acd6cffcda0ba1140c43 | https://github.com/miLibris/flask-rest-jsonapi/blob/ecc8f2cd2b54cc0bfae7acd6cffcda0ba1140c43/flask_rest_jsonapi/schema.py#L85-L97 | train |
miLibris/flask-rest-jsonapi | flask_rest_jsonapi/schema.py | get_nested_fields | def get_nested_fields(schema, model_field=False):
"""Return nested fields of a schema to support a join
:param Schema schema: a marshmallow schema
:param boolean model_field: whether to extract the model field for the nested fields
:return list: list of nested fields of the schema
"""
nested_f... | python | def get_nested_fields(schema, model_field=False):
"""Return nested fields of a schema to support a join
:param Schema schema: a marshmallow schema
:param boolean model_field: whether to extract the model field for the nested fields
:return list: list of nested fields of the schema
"""
nested_f... | [
"def",
"get_nested_fields",
"(",
"schema",
",",
"model_field",
"=",
"False",
")",
":",
"nested_fields",
"=",
"[",
"]",
"for",
"(",
"key",
",",
"value",
")",
"in",
"schema",
".",
"_declared_fields",
".",
"items",
"(",
")",
":",
"if",
"isinstance",
"(",
... | Return nested fields of a schema to support a join
:param Schema schema: a marshmallow schema
:param boolean model_field: whether to extract the model field for the nested fields
:return list: list of nested fields of the schema | [
"Return",
"nested",
"fields",
"of",
"a",
"schema",
"to",
"support",
"a",
"join"
] | ecc8f2cd2b54cc0bfae7acd6cffcda0ba1140c43 | https://github.com/miLibris/flask-rest-jsonapi/blob/ecc8f2cd2b54cc0bfae7acd6cffcda0ba1140c43/flask_rest_jsonapi/schema.py#L99-L117 | train |
miLibris/flask-rest-jsonapi | flask_rest_jsonapi/schema.py | get_relationships | def get_relationships(schema, model_field=False):
"""Return relationship fields of a schema
:param Schema schema: a marshmallow schema
:param list: list of relationship fields of a schema
"""
relationships = [key for (key, value) in schema._declared_fields.items() if isinstance(value, Relationship)... | python | def get_relationships(schema, model_field=False):
"""Return relationship fields of a schema
:param Schema schema: a marshmallow schema
:param list: list of relationship fields of a schema
"""
relationships = [key for (key, value) in schema._declared_fields.items() if isinstance(value, Relationship)... | [
"def",
"get_relationships",
"(",
"schema",
",",
"model_field",
"=",
"False",
")",
":",
"relationships",
"=",
"[",
"key",
"for",
"(",
"key",
",",
"value",
")",
"in",
"schema",
".",
"_declared_fields",
".",
"items",
"(",
")",
"if",
"isinstance",
"(",
"valu... | Return relationship fields of a schema
:param Schema schema: a marshmallow schema
:param list: list of relationship fields of a schema | [
"Return",
"relationship",
"fields",
"of",
"a",
"schema"
] | ecc8f2cd2b54cc0bfae7acd6cffcda0ba1140c43 | https://github.com/miLibris/flask-rest-jsonapi/blob/ecc8f2cd2b54cc0bfae7acd6cffcda0ba1140c43/flask_rest_jsonapi/schema.py#L119-L130 | train |
miLibris/flask-rest-jsonapi | flask_rest_jsonapi/schema.py | get_schema_from_type | def get_schema_from_type(resource_type):
"""Retrieve a schema from the registry by his type
:param str type_: the type of the resource
:return Schema: the schema class
"""
for cls_name, cls in class_registry._registry.items():
try:
if cls[0].opts.type_ == resource_type:
... | python | def get_schema_from_type(resource_type):
"""Retrieve a schema from the registry by his type
:param str type_: the type of the resource
:return Schema: the schema class
"""
for cls_name, cls in class_registry._registry.items():
try:
if cls[0].opts.type_ == resource_type:
... | [
"def",
"get_schema_from_type",
"(",
"resource_type",
")",
":",
"for",
"cls_name",
",",
"cls",
"in",
"class_registry",
".",
"_registry",
".",
"items",
"(",
")",
":",
"try",
":",
"if",
"cls",
"[",
"0",
"]",
".",
"opts",
".",
"type_",
"==",
"resource_type",... | Retrieve a schema from the registry by his type
:param str type_: the type of the resource
:return Schema: the schema class | [
"Retrieve",
"a",
"schema",
"from",
"the",
"registry",
"by",
"his",
"type"
] | ecc8f2cd2b54cc0bfae7acd6cffcda0ba1140c43 | https://github.com/miLibris/flask-rest-jsonapi/blob/ecc8f2cd2b54cc0bfae7acd6cffcda0ba1140c43/flask_rest_jsonapi/schema.py#L143-L156 | train |
miLibris/flask-rest-jsonapi | flask_rest_jsonapi/schema.py | get_schema_field | def get_schema_field(schema, field):
"""Get the schema field of a model field
:param Schema schema: a marshmallow schema
:param str field: the name of the model field
:return str: the name of the field in the schema
"""
schema_fields_to_model = {key: get_model_field(schema, key) for (key, value... | python | def get_schema_field(schema, field):
"""Get the schema field of a model field
:param Schema schema: a marshmallow schema
:param str field: the name of the model field
:return str: the name of the field in the schema
"""
schema_fields_to_model = {key: get_model_field(schema, key) for (key, value... | [
"def",
"get_schema_field",
"(",
"schema",
",",
"field",
")",
":",
"schema_fields_to_model",
"=",
"{",
"key",
":",
"get_model_field",
"(",
"schema",
",",
"key",
")",
"for",
"(",
"key",
",",
"value",
")",
"in",
"schema",
".",
"_declared_fields",
".",
"items"... | Get the schema field of a model field
:param Schema schema: a marshmallow schema
:param str field: the name of the model field
:return str: the name of the field in the schema | [
"Get",
"the",
"schema",
"field",
"of",
"a",
"model",
"field"
] | ecc8f2cd2b54cc0bfae7acd6cffcda0ba1140c43 | https://github.com/miLibris/flask-rest-jsonapi/blob/ecc8f2cd2b54cc0bfae7acd6cffcda0ba1140c43/flask_rest_jsonapi/schema.py#L159-L171 | train |
miLibris/flask-rest-jsonapi | flask_rest_jsonapi/data_layers/base.py | BaseDataLayer.bound_rewritable_methods | def bound_rewritable_methods(self, methods):
"""Bound additional methods to current instance
:param class meta: information from Meta class used to configure the data layer instance
"""
for key, value in methods.items():
if key in self.REWRITABLE_METHODS:
set... | python | def bound_rewritable_methods(self, methods):
"""Bound additional methods to current instance
:param class meta: information from Meta class used to configure the data layer instance
"""
for key, value in methods.items():
if key in self.REWRITABLE_METHODS:
set... | [
"def",
"bound_rewritable_methods",
"(",
"self",
",",
"methods",
")",
":",
"for",
"key",
",",
"value",
"in",
"methods",
".",
"items",
"(",
")",
":",
"if",
"key",
"in",
"self",
".",
"REWRITABLE_METHODS",
":",
"setattr",
"(",
"self",
",",
"key",
",",
"typ... | Bound additional methods to current instance
:param class meta: information from Meta class used to configure the data layer instance | [
"Bound",
"additional",
"methods",
"to",
"current",
"instance"
] | ecc8f2cd2b54cc0bfae7acd6cffcda0ba1140c43 | https://github.com/miLibris/flask-rest-jsonapi/blob/ecc8f2cd2b54cc0bfae7acd6cffcda0ba1140c43/flask_rest_jsonapi/data_layers/base.py#L318-L325 | train |
miLibris/flask-rest-jsonapi | flask_rest_jsonapi/data_layers/filtering/alchemy.py | create_filters | def create_filters(model, filter_info, resource):
"""Apply filters from filters information to base query
:param DeclarativeMeta model: the model of the node
:param dict filter_info: current node filter information
:param Resource resource: the resource
"""
filters = []
for filter_ in filte... | python | def create_filters(model, filter_info, resource):
"""Apply filters from filters information to base query
:param DeclarativeMeta model: the model of the node
:param dict filter_info: current node filter information
:param Resource resource: the resource
"""
filters = []
for filter_ in filte... | [
"def",
"create_filters",
"(",
"model",
",",
"filter_info",
",",
"resource",
")",
":",
"filters",
"=",
"[",
"]",
"for",
"filter_",
"in",
"filter_info",
":",
"filters",
".",
"append",
"(",
"Node",
"(",
"model",
",",
"filter_",
",",
"resource",
",",
"resour... | Apply filters from filters information to base query
:param DeclarativeMeta model: the model of the node
:param dict filter_info: current node filter information
:param Resource resource: the resource | [
"Apply",
"filters",
"from",
"filters",
"information",
"to",
"base",
"query"
] | ecc8f2cd2b54cc0bfae7acd6cffcda0ba1140c43 | https://github.com/miLibris/flask-rest-jsonapi/blob/ecc8f2cd2b54cc0bfae7acd6cffcda0ba1140c43/flask_rest_jsonapi/data_layers/filtering/alchemy.py#L11-L22 | train |
miLibris/flask-rest-jsonapi | flask_rest_jsonapi/data_layers/filtering/alchemy.py | Node.resolve | def resolve(self):
"""Create filter for a particular node of the filter tree"""
if 'or' not in self.filter_ and 'and' not in self.filter_ and 'not' not in self.filter_:
value = self.value
if isinstance(value, dict):
value = Node(self.related_model, value, self.re... | python | def resolve(self):
"""Create filter for a particular node of the filter tree"""
if 'or' not in self.filter_ and 'and' not in self.filter_ and 'not' not in self.filter_:
value = self.value
if isinstance(value, dict):
value = Node(self.related_model, value, self.re... | [
"def",
"resolve",
"(",
"self",
")",
":",
"if",
"'or'",
"not",
"in",
"self",
".",
"filter_",
"and",
"'and'",
"not",
"in",
"self",
".",
"filter_",
"and",
"'not'",
"not",
"in",
"self",
".",
"filter_",
":",
"value",
"=",
"self",
".",
"value",
"if",
"is... | Create filter for a particular node of the filter tree | [
"Create",
"filter",
"for",
"a",
"particular",
"node",
"of",
"the",
"filter",
"tree"
] | ecc8f2cd2b54cc0bfae7acd6cffcda0ba1140c43 | https://github.com/miLibris/flask-rest-jsonapi/blob/ecc8f2cd2b54cc0bfae7acd6cffcda0ba1140c43/flask_rest_jsonapi/data_layers/filtering/alchemy.py#L41-L62 | train |
miLibris/flask-rest-jsonapi | flask_rest_jsonapi/data_layers/filtering/alchemy.py | Node.name | def name(self):
"""Return the name of the node or raise a BadRequest exception
:return str: the name of the field to filter on
"""
name = self.filter_.get('name')
if name is None:
raise InvalidFilters("Can't find name of a filter")
if '__' in name:
... | python | def name(self):
"""Return the name of the node or raise a BadRequest exception
:return str: the name of the field to filter on
"""
name = self.filter_.get('name')
if name is None:
raise InvalidFilters("Can't find name of a filter")
if '__' in name:
... | [
"def",
"name",
"(",
"self",
")",
":",
"name",
"=",
"self",
".",
"filter_",
".",
"get",
"(",
"'name'",
")",
"if",
"name",
"is",
"None",
":",
"raise",
"InvalidFilters",
"(",
"\"Can't find name of a filter\"",
")",
"if",
"'__'",
"in",
"name",
":",
"name",
... | Return the name of the node or raise a BadRequest exception
:return str: the name of the field to filter on | [
"Return",
"the",
"name",
"of",
"the",
"node",
"or",
"raise",
"a",
"BadRequest",
"exception"
] | ecc8f2cd2b54cc0bfae7acd6cffcda0ba1140c43 | https://github.com/miLibris/flask-rest-jsonapi/blob/ecc8f2cd2b54cc0bfae7acd6cffcda0ba1140c43/flask_rest_jsonapi/data_layers/filtering/alchemy.py#L65-L81 | train |
miLibris/flask-rest-jsonapi | flask_rest_jsonapi/data_layers/filtering/alchemy.py | Node.column | def column(self):
"""Get the column object
:param DeclarativeMeta model: the model
:param str field: the field
:return InstrumentedAttribute: the column to filter on
"""
field = self.name
model_field = get_model_field(self.schema, field)
try:
... | python | def column(self):
"""Get the column object
:param DeclarativeMeta model: the model
:param str field: the field
:return InstrumentedAttribute: the column to filter on
"""
field = self.name
model_field = get_model_field(self.schema, field)
try:
... | [
"def",
"column",
"(",
"self",
")",
":",
"field",
"=",
"self",
".",
"name",
"model_field",
"=",
"get_model_field",
"(",
"self",
".",
"schema",
",",
"field",
")",
"try",
":",
"return",
"getattr",
"(",
"self",
".",
"model",
",",
"model_field",
")",
"excep... | Get the column object
:param DeclarativeMeta model: the model
:param str field: the field
:return InstrumentedAttribute: the column to filter on | [
"Get",
"the",
"column",
"object"
] | ecc8f2cd2b54cc0bfae7acd6cffcda0ba1140c43 | https://github.com/miLibris/flask-rest-jsonapi/blob/ecc8f2cd2b54cc0bfae7acd6cffcda0ba1140c43/flask_rest_jsonapi/data_layers/filtering/alchemy.py#L95-L109 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.