body
stringlengths
26
98.2k
body_hash
int64
-9,222,864,604,528,158,000
9,221,803,474B
docstring
stringlengths
1
16.8k
path
stringlengths
5
230
name
stringlengths
1
96
repository_name
stringlengths
7
89
lang
stringclasses
1 value
body_without_docstring
stringlengths
20
98.2k
def seconds(s): '\n Return seconds as days.\n ' return (float(s) / SEC_PER_DAY)
-8,024,640,055,269,441,000
Return seconds as days.
env/lib/python2.7/site-packages/matplotlib/dates.py
seconds
rbalda/neural_ocr
python
def seconds(s): '\n \n ' return (float(s) / SEC_PER_DAY)
def minutes(m): '\n Return minutes as days.\n ' return (float(m) / MINUTES_PER_DAY)
2,918,726,190,601,350,000
Return minutes as days.
env/lib/python2.7/site-packages/matplotlib/dates.py
minutes
rbalda/neural_ocr
python
def minutes(m): '\n \n ' return (float(m) / MINUTES_PER_DAY)
def hours(h): '\n Return hours as days.\n ' return (h / HOURS_PER_DAY)
-7,078,883,573,613,321,000
Return hours as days.
env/lib/python2.7/site-packages/matplotlib/dates.py
hours
rbalda/neural_ocr
python
def hours(h): '\n \n ' return (h / HOURS_PER_DAY)
def weeks(w): '\n Return weeks as days.\n ' return (w * DAYS_PER_WEEK)
3,757,993,147,974,712,000
Return weeks as days.
env/lib/python2.7/site-packages/matplotlib/dates.py
weeks
rbalda/neural_ocr
python
def weeks(w): '\n \n ' return (w * DAYS_PER_WEEK)
def __init__(self, fmt): ' fmt: any valid strptime format is supported ' self.fmt = fmt
-4,169,169,694,858,552,000
fmt: any valid strptime format is supported
env/lib/python2.7/site-packages/matplotlib/dates.py
__init__
rbalda/neural_ocr
python
def __init__(self, fmt): ' ' self.fmt = fmt
def __call__(self, s): 's : string to be converted\n return value: a date2num float\n ' return date2num(datetime.datetime(*time.strptime(s, self.fmt)[:6]))
6,304,710,515,264,939,000
s : string to be converted return value: a date2num float
env/lib/python2.7/site-packages/matplotlib/dates.py
__call__
rbalda/neural_ocr
python
def __call__(self, s): 's : string to be converted\n return value: a date2num float\n ' return date2num(datetime.datetime(*time.strptime(s, self.fmt)[:6]))
def __init__(self, fmt, encoding='utf-8'): "\n Args:\n fmt: any valid strptime format is supported\n encoding: encoding to use on byte input (default: 'utf-8')\n " super(bytespdate2num, self).__init__(fmt) self.encoding = encoding
-7,057,810,267,372,294,000
Args: fmt: any valid strptime format is supported encoding: encoding to use on byte input (default: 'utf-8')
env/lib/python2.7/site-packages/matplotlib/dates.py
__init__
rbalda/neural_ocr
python
def __init__(self, fmt, encoding='utf-8'): "\n Args:\n fmt: any valid strptime format is supported\n encoding: encoding to use on byte input (default: 'utf-8')\n " super(bytespdate2num, self).__init__(fmt) self.encoding = encoding
def __call__(self, b): '\n Args:\n b: byte input to be converted\n Returns:\n A date2num float\n ' s = b.decode(self.encoding) return super(bytespdate2num, self).__call__(s)
6,083,521,617,235,164,000
Args: b: byte input to be converted Returns: A date2num float
env/lib/python2.7/site-packages/matplotlib/dates.py
__call__
rbalda/neural_ocr
python
def __call__(self, b): '\n Args:\n b: byte input to be converted\n Returns:\n A date2num float\n ' s = b.decode(self.encoding) return super(bytespdate2num, self).__call__(s)
def __init__(self, fmt, tz=None): '\n *fmt* is a :func:`strftime` format string; *tz* is the\n :class:`tzinfo` instance.\n ' if (tz is None): tz = _get_rc_timezone() self.fmt = fmt self.tz = tz
-7,895,130,219,791,011,000
*fmt* is a :func:`strftime` format string; *tz* is the :class:`tzinfo` instance.
env/lib/python2.7/site-packages/matplotlib/dates.py
__init__
rbalda/neural_ocr
python
def __init__(self, fmt, tz=None): '\n *fmt* is a :func:`strftime` format string; *tz* is the\n :class:`tzinfo` instance.\n ' if (tz is None): tz = _get_rc_timezone() self.fmt = fmt self.tz = tz
def _replace_common_substr(self, s1, s2, sub1, sub2, replacement): 'Helper function for replacing substrings sub1 and sub2\n located at the same indexes in strings s1 and s2 respectively,\n with the string replacement. It is expected that sub1 and sub2\n have the same length. Returns the pair...
-8,579,673,710,969,332,000
Helper function for replacing substrings sub1 and sub2 located at the same indexes in strings s1 and s2 respectively, with the string replacement. It is expected that sub1 and sub2 have the same length. Returns the pair s1, s2 after the substitutions.
env/lib/python2.7/site-packages/matplotlib/dates.py
_replace_common_substr
rbalda/neural_ocr
python
def _replace_common_substr(self, s1, s2, sub1, sub2, replacement): 'Helper function for replacing substrings sub1 and sub2\n located at the same indexes in strings s1 and s2 respectively,\n with the string replacement. It is expected that sub1 and sub2\n have the same length. Returns the pair...
def strftime_pre_1900(self, dt, fmt=None): "Call time.strftime for years before 1900 by rolling\n forward a multiple of 28 years.\n\n *fmt* is a :func:`strftime` format string.\n\n Dalke: I hope I did this math right. Every 28 years the\n calendar repeats, except through century leap ye...
-3,409,017,546,486,234,000
Call time.strftime for years before 1900 by rolling forward a multiple of 28 years. *fmt* is a :func:`strftime` format string. Dalke: I hope I did this math right. Every 28 years the calendar repeats, except through century leap years excepting the 400 year leap years. But only if you're using the Gregorian calenda...
env/lib/python2.7/site-packages/matplotlib/dates.py
strftime_pre_1900
rbalda/neural_ocr
python
def strftime_pre_1900(self, dt, fmt=None): "Call time.strftime for years before 1900 by rolling\n forward a multiple of 28 years.\n\n *fmt* is a :func:`strftime` format string.\n\n Dalke: I hope I did this math right. Every 28 years the\n calendar repeats, except through century leap ye...
def strftime(self, dt, fmt=None): 'Refer to documentation for datetime.strftime.\n\n *fmt* is a :func:`strftime` format string.\n\n Warning: For years before 1900, depending upon the current\n locale it is possible that the year displayed with %x might\n be incorrect. For years before 10...
-7,673,140,819,755,084,000
Refer to documentation for datetime.strftime. *fmt* is a :func:`strftime` format string. Warning: For years before 1900, depending upon the current locale it is possible that the year displayed with %x might be incorrect. For years before 100, %y and %Y will yield zero-padded strings.
env/lib/python2.7/site-packages/matplotlib/dates.py
strftime
rbalda/neural_ocr
python
def strftime(self, dt, fmt=None): 'Refer to documentation for datetime.strftime.\n\n *fmt* is a :func:`strftime` format string.\n\n Warning: For years before 1900, depending upon the current\n locale it is possible that the year displayed with %x might\n be incorrect. For years before 10...
def __init__(self, t, fmt, tz=None): '\n *t* is a sequence of dates (floating point days). *fmt* is a\n :func:`strftime` format string.\n ' if (tz is None): tz = _get_rc_timezone() self.t = t self.fmt = fmt self.tz = tz
3,572,620,911,891,964,000
*t* is a sequence of dates (floating point days). *fmt* is a :func:`strftime` format string.
env/lib/python2.7/site-packages/matplotlib/dates.py
__init__
rbalda/neural_ocr
python
def __init__(self, t, fmt, tz=None): '\n *t* is a sequence of dates (floating point days). *fmt* is a\n :func:`strftime` format string.\n ' if (tz is None): tz = _get_rc_timezone() self.t = t self.fmt = fmt self.tz = tz
def __call__(self, x, pos=0): 'Return the label for time *x* at position *pos*' ind = int(round(x)) if ((ind >= len(self.t)) or (ind <= 0)): return '' dt = num2date(self.t[ind], self.tz) return cbook.unicode_safe(dt.strftime(self.fmt))
7,515,494,125,788,098,000
Return the label for time *x* at position *pos*
env/lib/python2.7/site-packages/matplotlib/dates.py
__call__
rbalda/neural_ocr
python
def __call__(self, x, pos=0): ind = int(round(x)) if ((ind >= len(self.t)) or (ind <= 0)): return dt = num2date(self.t[ind], self.tz) return cbook.unicode_safe(dt.strftime(self.fmt))
def __init__(self, locator, tz=None, defaultfmt='%Y-%m-%d'): '\n Autoformat the date labels. The default format is the one to use\n if none of the values in ``self.scaled`` are greater than the unit\n returned by ``locator._get_unit()``.\n ' self._locator = locator self._tz = tz...
-1,554,169,645,260,470,300
Autoformat the date labels. The default format is the one to use if none of the values in ``self.scaled`` are greater than the unit returned by ``locator._get_unit()``.
env/lib/python2.7/site-packages/matplotlib/dates.py
__init__
rbalda/neural_ocr
python
def __init__(self, locator, tz=None, defaultfmt='%Y-%m-%d'): '\n Autoformat the date labels. The default format is the one to use\n if none of the values in ``self.scaled`` are greater than the unit\n returned by ``locator._get_unit()``.\n ' self._locator = locator self._tz = tz...
def __init__(self, tz=None): '\n *tz* is a :class:`tzinfo` instance.\n ' if (tz is None): tz = _get_rc_timezone() self.tz = tz
-9,082,949,987,731,717,000
*tz* is a :class:`tzinfo` instance.
env/lib/python2.7/site-packages/matplotlib/dates.py
__init__
rbalda/neural_ocr
python
def __init__(self, tz=None): '\n \n ' if (tz is None): tz = _get_rc_timezone() self.tz = tz
def set_tzinfo(self, tz): '\n Set time zone info.\n ' self.tz = tz
-1,745,468,367,312,040,700
Set time zone info.
env/lib/python2.7/site-packages/matplotlib/dates.py
set_tzinfo
rbalda/neural_ocr
python
def set_tzinfo(self, tz): '\n \n ' self.tz = tz
def datalim_to_dt(self): '\n Convert axis data interval to datetime objects.\n ' (dmin, dmax) = self.axis.get_data_interval() if (dmin > dmax): (dmin, dmax) = (dmax, dmin) return (num2date(dmin, self.tz), num2date(dmax, self.tz))
-7,588,518,086,582,918,000
Convert axis data interval to datetime objects.
env/lib/python2.7/site-packages/matplotlib/dates.py
datalim_to_dt
rbalda/neural_ocr
python
def datalim_to_dt(self): '\n \n ' (dmin, dmax) = self.axis.get_data_interval() if (dmin > dmax): (dmin, dmax) = (dmax, dmin) return (num2date(dmin, self.tz), num2date(dmax, self.tz))
def viewlim_to_dt(self): '\n Converts the view interval to datetime objects.\n ' (vmin, vmax) = self.axis.get_view_interval() if (vmin > vmax): (vmin, vmax) = (vmax, vmin) return (num2date(vmin, self.tz), num2date(vmax, self.tz))
9,095,579,861,209,821,000
Converts the view interval to datetime objects.
env/lib/python2.7/site-packages/matplotlib/dates.py
viewlim_to_dt
rbalda/neural_ocr
python
def viewlim_to_dt(self): '\n \n ' (vmin, vmax) = self.axis.get_view_interval() if (vmin > vmax): (vmin, vmax) = (vmax, vmin) return (num2date(vmin, self.tz), num2date(vmax, self.tz))
def _get_unit(self): '\n Return how many days a unit of the locator is; used for\n intelligent autoscaling.\n ' return 1
-8,673,055,773,312,316,000
Return how many days a unit of the locator is; used for intelligent autoscaling.
env/lib/python2.7/site-packages/matplotlib/dates.py
_get_unit
rbalda/neural_ocr
python
def _get_unit(self): '\n Return how many days a unit of the locator is; used for\n intelligent autoscaling.\n ' return 1
def _get_interval(self): '\n Return the number of units for each tick.\n ' return 1
2,503,878,047,653,216,000
Return the number of units for each tick.
env/lib/python2.7/site-packages/matplotlib/dates.py
_get_interval
rbalda/neural_ocr
python
def _get_interval(self): '\n \n ' return 1
def nonsingular(self, vmin, vmax): '\n Given the proposed upper and lower extent, adjust the range\n if it is too close to being singular (i.e. a range of ~0).\n\n ' unit = self._get_unit() interval = self._get_interval() if (abs((vmax - vmin)) < 1e-06): vmin -= ((2 * unit) ...
6,927,860,421,802,992,000
Given the proposed upper and lower extent, adjust the range if it is too close to being singular (i.e. a range of ~0).
env/lib/python2.7/site-packages/matplotlib/dates.py
nonsingular
rbalda/neural_ocr
python
def nonsingular(self, vmin, vmax): '\n Given the proposed upper and lower extent, adjust the range\n if it is too close to being singular (i.e. a range of ~0).\n\n ' unit = self._get_unit() interval = self._get_interval() if (abs((vmax - vmin)) < 1e-06): vmin -= ((2 * unit) ...
def _get_unit(self): '\n Return how many days a unit of the locator is; used for\n intelligent autoscaling.\n ' freq = self.rule._rrule._freq return self.get_unit_generic(freq)
-6,887,433,986,755,907,000
Return how many days a unit of the locator is; used for intelligent autoscaling.
env/lib/python2.7/site-packages/matplotlib/dates.py
_get_unit
rbalda/neural_ocr
python
def _get_unit(self): '\n Return how many days a unit of the locator is; used for\n intelligent autoscaling.\n ' freq = self.rule._rrule._freq return self.get_unit_generic(freq)
def autoscale(self): '\n Set the view limits to include the data range.\n ' (dmin, dmax) = self.datalim_to_dt() delta = relativedelta(dmax, dmin) try: start = (dmin - delta) except ValueError: start = _from_ordinalf(1.0) try: stop = (dmax + delta) except...
2,355,684,293,106,261,500
Set the view limits to include the data range.
env/lib/python2.7/site-packages/matplotlib/dates.py
autoscale
rbalda/neural_ocr
python
def autoscale(self): '\n \n ' (dmin, dmax) = self.datalim_to_dt() delta = relativedelta(dmax, dmin) try: start = (dmin - delta) except ValueError: start = _from_ordinalf(1.0) try: stop = (dmax + delta) except ValueError: stop = _from_ordinalf(365...
def __init__(self, tz=None, minticks=5, maxticks=None, interval_multiples=False): "\n *minticks* is the minimum number of ticks desired, which is used to\n select the type of ticking (yearly, monthly, etc.).\n\n *maxticks* is the maximum number of ticks desired, which controls\n any inte...
-5,306,297,637,022,860,000
*minticks* is the minimum number of ticks desired, which is used to select the type of ticking (yearly, monthly, etc.). *maxticks* is the maximum number of ticks desired, which controls any interval between ticks (ticking every other, every 3, etc.). For really fine-grained control, this can be a dictionary mapping in...
env/lib/python2.7/site-packages/matplotlib/dates.py
__init__
rbalda/neural_ocr
python
def __init__(self, tz=None, minticks=5, maxticks=None, interval_multiples=False): "\n *minticks* is the minimum number of ticks desired, which is used to\n select the type of ticking (yearly, monthly, etc.).\n\n *maxticks* is the maximum number of ticks desired, which controls\n any inte...
def __call__(self): 'Return the locations of the ticks' self.refresh() return self._locator()
-4,865,864,161,449,296,000
Return the locations of the ticks
env/lib/python2.7/site-packages/matplotlib/dates.py
__call__
rbalda/neural_ocr
python
def __call__(self): self.refresh() return self._locator()
def refresh(self): 'Refresh internal information based on current limits.' (dmin, dmax) = self.viewlim_to_dt() self._locator = self.get_locator(dmin, dmax)
3,994,028,736,872,974,300
Refresh internal information based on current limits.
env/lib/python2.7/site-packages/matplotlib/dates.py
refresh
rbalda/neural_ocr
python
def refresh(self): (dmin, dmax) = self.viewlim_to_dt() self._locator = self.get_locator(dmin, dmax)
def autoscale(self): 'Try to choose the view limits intelligently.' (dmin, dmax) = self.datalim_to_dt() self._locator = self.get_locator(dmin, dmax) return self._locator.autoscale()
4,944,211,996,552,428,000
Try to choose the view limits intelligently.
env/lib/python2.7/site-packages/matplotlib/dates.py
autoscale
rbalda/neural_ocr
python
def autoscale(self): (dmin, dmax) = self.datalim_to_dt() self._locator = self.get_locator(dmin, dmax) return self._locator.autoscale()
def get_locator(self, dmin, dmax): 'Pick the best locator based on a distance.' delta = relativedelta(dmax, dmin) tdelta = (dmax - dmin) if (dmin > dmax): delta = (- delta) tdelta = (- tdelta) numYears = float(delta.years) numMonths = ((numYears * MONTHS_PER_YEAR) + delta.months)...
5,123,982,612,934,154,000
Pick the best locator based on a distance.
env/lib/python2.7/site-packages/matplotlib/dates.py
get_locator
rbalda/neural_ocr
python
def get_locator(self, dmin, dmax): delta = relativedelta(dmax, dmin) tdelta = (dmax - dmin) if (dmin > dmax): delta = (- delta) tdelta = (- tdelta) numYears = float(delta.years) numMonths = ((numYears * MONTHS_PER_YEAR) + delta.months) numDays = tdelta.days numHours = ((...
def __init__(self, base=1, month=1, day=1, tz=None): '\n Mark years that are multiple of base on a given month and day\n (default jan 1).\n ' DateLocator.__init__(self, tz) self.base = ticker.Base(base) self.replaced = {'month': month, 'day': day, 'hour': 0, 'minute': 0, 'second': 0...
2,204,420,914,898,779,400
Mark years that are multiple of base on a given month and day (default jan 1).
env/lib/python2.7/site-packages/matplotlib/dates.py
__init__
rbalda/neural_ocr
python
def __init__(self, base=1, month=1, day=1, tz=None): '\n Mark years that are multiple of base on a given month and day\n (default jan 1).\n ' DateLocator.__init__(self, tz) self.base = ticker.Base(base) self.replaced = {'month': month, 'day': day, 'hour': 0, 'minute': 0, 'second': 0...
def autoscale(self): '\n Set the view limits to include the data range.\n ' (dmin, dmax) = self.datalim_to_dt() ymin = self.base.le(dmin.year) ymax = self.base.ge(dmax.year) vmin = dmin.replace(year=ymin, **self.replaced) vmax = dmax.replace(year=ymax, **self.replaced) vmin = d...
-3,630,744,519,156,373,500
Set the view limits to include the data range.
env/lib/python2.7/site-packages/matplotlib/dates.py
autoscale
rbalda/neural_ocr
python
def autoscale(self): '\n \n ' (dmin, dmax) = self.datalim_to_dt() ymin = self.base.le(dmin.year) ymax = self.base.ge(dmax.year) vmin = dmin.replace(year=ymin, **self.replaced) vmax = dmax.replace(year=ymax, **self.replaced) vmin = date2num(vmin) vmax = date2num(vmax) re...
def __init__(self, bymonth=None, bymonthday=1, interval=1, tz=None): '\n Mark every month in *bymonth*; *bymonth* can be an int or\n sequence. Default is ``range(1,13)``, i.e. every month.\n\n *interval* is the interval between each iteration. For\n example, if ``interval=2``, mark eve...
-7,672,659,490,995,540,000
Mark every month in *bymonth*; *bymonth* can be an int or sequence. Default is ``range(1,13)``, i.e. every month. *interval* is the interval between each iteration. For example, if ``interval=2``, mark every second occurance.
env/lib/python2.7/site-packages/matplotlib/dates.py
__init__
rbalda/neural_ocr
python
def __init__(self, bymonth=None, bymonthday=1, interval=1, tz=None): '\n Mark every month in *bymonth*; *bymonth* can be an int or\n sequence. Default is ``range(1,13)``, i.e. every month.\n\n *interval* is the interval between each iteration. For\n example, if ``interval=2``, mark eve...
def __init__(self, byweekday=1, interval=1, tz=None): '\n Mark every weekday in *byweekday*; *byweekday* can be a number or\n sequence.\n\n Elements of *byweekday* must be one of MO, TU, WE, TH, FR, SA,\n SU, the constants from :mod:`dateutil.rrule`, which have been\n imported int...
-6,815,969,511,609,640,000
Mark every weekday in *byweekday*; *byweekday* can be a number or sequence. Elements of *byweekday* must be one of MO, TU, WE, TH, FR, SA, SU, the constants from :mod:`dateutil.rrule`, which have been imported into the :mod:`matplotlib.dates` namespace. *interval* specifies the number of weeks to skip. For example, ...
env/lib/python2.7/site-packages/matplotlib/dates.py
__init__
rbalda/neural_ocr
python
def __init__(self, byweekday=1, interval=1, tz=None): '\n Mark every weekday in *byweekday*; *byweekday* can be a number or\n sequence.\n\n Elements of *byweekday* must be one of MO, TU, WE, TH, FR, SA,\n SU, the constants from :mod:`dateutil.rrule`, which have been\n imported int...
def __init__(self, bymonthday=None, interval=1, tz=None): '\n Mark every day in *bymonthday*; *bymonthday* can be an int or\n sequence.\n\n Default is to tick every day of the month: ``bymonthday=range(1,32)``\n ' if (bymonthday is None): bymonthday = range(1, 32) elif is...
5,274,080,067,483,947,000
Mark every day in *bymonthday*; *bymonthday* can be an int or sequence. Default is to tick every day of the month: ``bymonthday=range(1,32)``
env/lib/python2.7/site-packages/matplotlib/dates.py
__init__
rbalda/neural_ocr
python
def __init__(self, bymonthday=None, interval=1, tz=None): '\n Mark every day in *bymonthday*; *bymonthday* can be an int or\n sequence.\n\n Default is to tick every day of the month: ``bymonthday=range(1,32)``\n ' if (bymonthday is None): bymonthday = range(1, 32) elif is...
def __init__(self, byhour=None, interval=1, tz=None): '\n Mark every hour in *byhour*; *byhour* can be an int or sequence.\n Default is to tick every hour: ``byhour=range(24)``\n\n *interval* is the interval between each iteration. For\n example, if ``interval=2``, mark every second occ...
-941,876,939,098,996,500
Mark every hour in *byhour*; *byhour* can be an int or sequence. Default is to tick every hour: ``byhour=range(24)`` *interval* is the interval between each iteration. For example, if ``interval=2``, mark every second occurrence.
env/lib/python2.7/site-packages/matplotlib/dates.py
__init__
rbalda/neural_ocr
python
def __init__(self, byhour=None, interval=1, tz=None): '\n Mark every hour in *byhour*; *byhour* can be an int or sequence.\n Default is to tick every hour: ``byhour=range(24)``\n\n *interval* is the interval between each iteration. For\n example, if ``interval=2``, mark every second occ...
def __init__(self, byminute=None, interval=1, tz=None): '\n Mark every minute in *byminute*; *byminute* can be an int or\n sequence. Default is to tick every minute: ``byminute=range(60)``\n\n *interval* is the interval between each iteration. For\n example, if ``interval=2``, mark eve...
296,218,444,658,126,300
Mark every minute in *byminute*; *byminute* can be an int or sequence. Default is to tick every minute: ``byminute=range(60)`` *interval* is the interval between each iteration. For example, if ``interval=2``, mark every second occurrence.
env/lib/python2.7/site-packages/matplotlib/dates.py
__init__
rbalda/neural_ocr
python
def __init__(self, byminute=None, interval=1, tz=None): '\n Mark every minute in *byminute*; *byminute* can be an int or\n sequence. Default is to tick every minute: ``byminute=range(60)``\n\n *interval* is the interval between each iteration. For\n example, if ``interval=2``, mark eve...
def __init__(self, bysecond=None, interval=1, tz=None): '\n Mark every second in *bysecond*; *bysecond* can be an int or\n sequence. Default is to tick every second: ``bysecond = range(60)``\n\n *interval* is the interval between each iteration. For\n example, if ``interval=2``, mark e...
-8,813,133,927,261,645,000
Mark every second in *bysecond*; *bysecond* can be an int or sequence. Default is to tick every second: ``bysecond = range(60)`` *interval* is the interval between each iteration. For example, if ``interval=2``, mark every second occurrence.
env/lib/python2.7/site-packages/matplotlib/dates.py
__init__
rbalda/neural_ocr
python
def __init__(self, bysecond=None, interval=1, tz=None): '\n Mark every second in *bysecond*; *bysecond* can be an int or\n sequence. Default is to tick every second: ``bysecond = range(60)``\n\n *interval* is the interval between each iteration. For\n example, if ``interval=2``, mark e...
def __init__(self, interval=1, tz=None): '\n *interval* is the interval between each iteration. For\n example, if ``interval=2``, mark every second microsecond.\n\n ' self._interval = interval self._wrapped_locator = ticker.MultipleLocator(interval) self.tz = tz
2,253,424,607,567,393,000
*interval* is the interval between each iteration. For example, if ``interval=2``, mark every second microsecond.
env/lib/python2.7/site-packages/matplotlib/dates.py
__init__
rbalda/neural_ocr
python
def __init__(self, interval=1, tz=None): '\n *interval* is the interval between each iteration. For\n example, if ``interval=2``, mark every second microsecond.\n\n ' self._interval = interval self._wrapped_locator = ticker.MultipleLocator(interval) self.tz = tz
def _get_unit(self): '\n Return how many days a unit of the locator is; used for\n intelligent autoscaling.\n ' return (1.0 / MUSECONDS_PER_DAY)
-8,244,895,826,175,361,000
Return how many days a unit of the locator is; used for intelligent autoscaling.
env/lib/python2.7/site-packages/matplotlib/dates.py
_get_unit
rbalda/neural_ocr
python
def _get_unit(self): '\n Return how many days a unit of the locator is; used for\n intelligent autoscaling.\n ' return (1.0 / MUSECONDS_PER_DAY)
def _get_interval(self): '\n Return the number of units for each tick.\n ' return self._interval
8,565,982,526,005,957,000
Return the number of units for each tick.
env/lib/python2.7/site-packages/matplotlib/dates.py
_get_interval
rbalda/neural_ocr
python
def _get_interval(self): '\n \n ' return self._interval
@staticmethod def axisinfo(unit, axis): '\n Return the :class:`~matplotlib.units.AxisInfo` for *unit*.\n\n *unit* is a tzinfo instance or None.\n The *axis* argument is required but not used.\n ' tz = unit majloc = AutoDateLocator(tz=tz) majfmt = AutoDateFormatter(majloc, tz=...
-3,760,185,637,134,109,700
Return the :class:`~matplotlib.units.AxisInfo` for *unit*. *unit* is a tzinfo instance or None. The *axis* argument is required but not used.
env/lib/python2.7/site-packages/matplotlib/dates.py
axisinfo
rbalda/neural_ocr
python
@staticmethod def axisinfo(unit, axis): '\n Return the :class:`~matplotlib.units.AxisInfo` for *unit*.\n\n *unit* is a tzinfo instance or None.\n The *axis* argument is required but not used.\n ' tz = unit majloc = AutoDateLocator(tz=tz) majfmt = AutoDateFormatter(majloc, tz=...
@staticmethod def convert(value, unit, axis): '\n If *value* is not already a number or sequence of numbers,\n convert it with :func:`date2num`.\n\n The *unit* and *axis* arguments are not used.\n ' if units.ConversionInterface.is_numlike(value): return value return date2...
1,106,963,852,552,765,200
If *value* is not already a number or sequence of numbers, convert it with :func:`date2num`. The *unit* and *axis* arguments are not used.
env/lib/python2.7/site-packages/matplotlib/dates.py
convert
rbalda/neural_ocr
python
@staticmethod def convert(value, unit, axis): '\n If *value* is not already a number or sequence of numbers,\n convert it with :func:`date2num`.\n\n The *unit* and *axis* arguments are not used.\n ' if units.ConversionInterface.is_numlike(value): return value return date2...
@staticmethod def default_units(x, axis): '\n Return the tzinfo instance of *x* or of its first element, or None\n ' if isinstance(x, np.ndarray): x = x.ravel() try: x = cbook.safe_first_element(x) except (TypeError, StopIteration): pass try: return x.tz...
8,571,303,660,489,029,000
Return the tzinfo instance of *x* or of its first element, or None
env/lib/python2.7/site-packages/matplotlib/dates.py
default_units
rbalda/neural_ocr
python
@staticmethod def default_units(x, axis): '\n \n ' if isinstance(x, np.ndarray): x = x.ravel() try: x = cbook.safe_first_element(x) except (TypeError, StopIteration): pass try: return x.tzinfo except AttributeError: pass return None
def _total_seconds(tdelta): '\n Alias providing support for datetime.timedelta.total_seconds() function\n calls even in Python < 2.7.\n\n The input `tdelta` is a datetime.timedelta object, and returns a float\n containing the total number of seconds representing the `tdelta`\n dur...
8,408,382,371,278,128,000
Alias providing support for datetime.timedelta.total_seconds() function calls even in Python < 2.7. The input `tdelta` is a datetime.timedelta object, and returns a float containing the total number of seconds representing the `tdelta` duration. For large durations (> 270 on most platforms), this loses microsecond acc...
env/lib/python2.7/site-packages/matplotlib/dates.py
_total_seconds
rbalda/neural_ocr
python
def _total_seconds(tdelta): '\n Alias providing support for datetime.timedelta.total_seconds() function\n calls even in Python < 2.7.\n\n The input `tdelta` is a datetime.timedelta object, and returns a float\n containing the total number of seconds representing the `tdelta`\n dur...
def create_hparams(experiment): 'Creates the hyper parameters.' hparams = {} hparams['batch_size'] = 64 hparams['eval_batch_size'] = 64 hparams['learning_rate_warmup_steps'] = 2000 hparams['learning_rate_constant'] = 1 hparams['learning_rate'] = 0.001 hparams['train_epoches'] = 20 hp...
6,100,350,083,624,158,000
Creates the hyper parameters.
widget_caption/widget_caption_model.py
create_hparams
AI21212019/google-research
python
def create_hparams(experiment): hparams = {} hparams['batch_size'] = 64 hparams['eval_batch_size'] = 64 hparams['learning_rate_warmup_steps'] = 2000 hparams['learning_rate_constant'] = 1 hparams['learning_rate'] = 0.001 hparams['train_epoches'] = 20 hparams['steps_per_epoch'] = 30 ...
def load_embed(file_name, vocab_size): 'Loads a pre-trained embedding matrix.\n\n Args:\n file_name: the file name of the embedding file.\n vocab_size: if > 0, only load embedding weights for vocab_size words.\n\n Returns:\n vocab: a list of tokens.\n embeds: a numpy array of embeddings for each token...
8,892,763,666,272,563,000
Loads a pre-trained embedding matrix. Args: file_name: the file name of the embedding file. vocab_size: if > 0, only load embedding weights for vocab_size words. Returns: vocab: a list of tokens. embeds: a numpy array of embeddings for each token plus an OOV embedding. depth: the depth of the embedding. Rai...
widget_caption/widget_caption_model.py
load_embed
AI21212019/google-research
python
def load_embed(file_name, vocab_size): 'Loads a pre-trained embedding matrix.\n\n Args:\n file_name: the file name of the embedding file.\n vocab_size: if > 0, only load embedding weights for vocab_size words.\n\n Returns:\n vocab: a list of tokens.\n embeds: a numpy array of embeddings for each token...
def compute_score(predictions, references, vocab=None): 'Computes the bleu score.\n\n Args:\n predictions: a numpy arrary in the shape of [batch_size, max_phrase_length]\n references: a numpy array in the shape of [batch_size, 7, 10]\n vocab: the vocabulary file.\n\n Returns:\n a scalar value for the ...
2,865,074,634,727,857,700
Computes the bleu score. Args: predictions: a numpy arrary in the shape of [batch_size, max_phrase_length] references: a numpy array in the shape of [batch_size, 7, 10] vocab: the vocabulary file. Returns: a scalar value for the corpus level bleu score.
widget_caption/widget_caption_model.py
compute_score
AI21212019/google-research
python
def compute_score(predictions, references, vocab=None): 'Computes the bleu score.\n\n Args:\n predictions: a numpy arrary in the shape of [batch_size, max_phrase_length]\n references: a numpy array in the shape of [batch_size, 7, 10]\n vocab: the vocabulary file.\n\n Returns:\n a scalar value for the ...
def init_resnet(hparams, model): 'Init resnet weights from a TF model if provided.' if (not hparams['widget_encoder_checkpoint']): return reader = tf.train.load_checkpoint(hparams['widget_encoder_checkpoint']) init_set = input_utils.input_fn(hparams['train_files'], 1, hparams['vocab_size'], hpar...
-5,117,677,739,210,213,000
Init resnet weights from a TF model if provided.
widget_caption/widget_caption_model.py
init_resnet
AI21212019/google-research
python
def init_resnet(hparams, model): if (not hparams['widget_encoder_checkpoint']): return reader = tf.train.load_checkpoint(hparams['widget_encoder_checkpoint']) init_set = input_utils.input_fn(hparams['train_files'], 1, hparams['vocab_size'], hparams['max_pixel_pos'], hparams['max_dom_pos'], epoc...
def call(self, input_tensor, training, dropout=0.0): 'Defines a single encoding layer.' x = input_tensor skip = x x = self._conv_layer_1(x) x = self._batch_norm_layer_1(x, training=training) x = tf.nn.relu(x) if training: x = tf.nn.dropout(x, rate=dropout) x = self._conv_layer_2(...
6,565,116,154,512,076,000
Defines a single encoding layer.
widget_caption/widget_caption_model.py
call
AI21212019/google-research
python
def call(self, input_tensor, training, dropout=0.0): x = input_tensor skip = x x = self._conv_layer_1(x) x = self._batch_norm_layer_1(x, training=training) x = tf.nn.relu(x) if training: x = tf.nn.dropout(x, rate=dropout) x = self._conv_layer_2(x) x = self._batch_norm_layer_...
def _get_encoder3(self, initial_channel_size=3): 'Defines the encoding model with a pre-defined filter/kernel sizes.' pixel_layers = [] filter_groups = [[initial_channel_size, initial_channel_size, 4], [4, 4, 16], [16, 16, 32], [32, 32, 64], [64, 64, 128], [128, 128, 256]] kernel_size_groups = [[5, 3, 5...
9,135,900,090,690,072,000
Defines the encoding model with a pre-defined filter/kernel sizes.
widget_caption/widget_caption_model.py
_get_encoder3
AI21212019/google-research
python
def _get_encoder3(self, initial_channel_size=3): pixel_layers = [] filter_groups = [[initial_channel_size, initial_channel_size, 4], [4, 4, 16], [16, 16, 32], [32, 32, 64], [64, 64, 128], [128, 128, 256]] kernel_size_groups = [[5, 3, 5], [5, 3, 3], [3, 3, 3], [3, 3, 3], [3, 3, 3], [3, 3, 3]] for (i...
def _embed_composite_feature(self, features, embedding_layers): 'Embed a position feature.' embedding_list = [] for i in range(len(embedding_layers)): embedding_list.append(embedding_layers[i](features[:, :, i])) embedding = tf.add_n(embedding_list) return embedding
-2,585,779,683,394,142,700
Embed a position feature.
widget_caption/widget_caption_model.py
_embed_composite_feature
AI21212019/google-research
python
def _embed_composite_feature(self, features, embedding_layers): embedding_list = [] for i in range(len(embedding_layers)): embedding_list.append(embedding_layers[i](features[:, :, i])) embedding = tf.add_n(embedding_list) return embedding
def _encode_view_hierarchy(self, features, object_selector, training): 'Encodes view hierarchy.' logging.info('Using Transformer screen encoder') developer_embeddings = self._word_embedding_layer(features['developer_token_id']) resource_embeddings = self._word_embedding_layer(features['resource_token_id...
5,191,364,270,785,644,000
Encodes view hierarchy.
widget_caption/widget_caption_model.py
_encode_view_hierarchy
AI21212019/google-research
python
def _encode_view_hierarchy(self, features, object_selector, training): logging.info('Using Transformer screen encoder') developer_embeddings = self._word_embedding_layer(features['developer_token_id']) resource_embeddings = self._word_embedding_layer(features['resource_token_id']) developer_embeddi...
def _aggregate_text_embedding(self, token_ids, embeddings): 'Aggregate text embedding for a UI element.' if (self._hparams['obj_text_aggregation'] == 'max'): valid_token_mask = tf.greater_equal(token_ids, 4) invalid_token_bias = (tf.cast(tf.logical_not(valid_token_mask), tf.float32) * (- 1000000...
-6,579,745,571,836,428,000
Aggregate text embedding for a UI element.
widget_caption/widget_caption_model.py
_aggregate_text_embedding
AI21212019/google-research
python
def _aggregate_text_embedding(self, token_ids, embeddings): if (self._hparams['obj_text_aggregation'] == 'max'): valid_token_mask = tf.greater_equal(token_ids, 4) invalid_token_bias = (tf.cast(tf.logical_not(valid_token_mask), tf.float32) * (- 1000000000.0)) embeddings = (embeddings + t...
def call(self, decoder_inputs, encoder_outputs, decoder_self_attention_bias, attention_bias, training, cache=None): 'Return the output of the decoder layer stacks.\n\n Args:\n decoder_inputs: A tensor with shape [batch_size, target_length,\n hidden_size].\n encoder_outputs: A tensor with shape [...
-5,761,504,163,877,722,000
Return the output of the decoder layer stacks. Args: decoder_inputs: A tensor with shape [batch_size, target_length, hidden_size]. encoder_outputs: A tensor with shape [batch_size, input_length, hidden_size] decoder_self_attention_bias: A tensor with shape [1, 1, target_len, target_length], the bias ...
widget_caption/widget_caption_model.py
call
AI21212019/google-research
python
def call(self, decoder_inputs, encoder_outputs, decoder_self_attention_bias, attention_bias, training, cache=None): 'Return the output of the decoder layer stacks.\n\n Args:\n decoder_inputs: A tensor with shape [batch_size, target_length,\n hidden_size].\n encoder_outputs: A tensor with shape [...
def compute_caption_metrics(self, predictions, references): 'Computes the eval metrics for decoding.' py_types = ([tf.float32] * len(self._SCORE_NAMES)) scores = tf.py_function(compute_score, (predictions, references, self._word_vocab), py_types) for (name, score) in zip(self._SCORE_NAMES, scores): ...
-774,783,375,998,931,000
Computes the eval metrics for decoding.
widget_caption/widget_caption_model.py
compute_caption_metrics
AI21212019/google-research
python
def compute_caption_metrics(self, predictions, references): py_types = ([tf.float32] * len(self._SCORE_NAMES)) scores = tf.py_function(compute_score, (predictions, references, self._word_vocab), py_types) for (name, score) in zip(self._SCORE_NAMES, scores): scoped_name = 'COCO/{}'.format(name) ...
def decode(self, targets, encoder_outputs, training): 'Generate logits for each value in the target sequence.\n\n Args:\n targets: target values for the output sequence. int tensor with shape\n [batch_size, target_length]\n encoder_outputs: continuous representation of input sequence. float tens...
5,422,571,246,841,141,000
Generate logits for each value in the target sequence. Args: targets: target values for the output sequence. int tensor with shape [batch_size, target_length] encoder_outputs: continuous representation of input sequence. float tensor with shape [batch_size, input_length, hidden_size] training: boolean, w...
widget_caption/widget_caption_model.py
decode
AI21212019/google-research
python
def decode(self, targets, encoder_outputs, training): 'Generate logits for each value in the target sequence.\n\n Args:\n targets: target values for the output sequence. int tensor with shape\n [batch_size, target_length]\n encoder_outputs: continuous representation of input sequence. float tens...
def predict(self, encoder_outputs, training): 'Return predicted sequence.' batch_size = tf.shape(encoder_outputs)[0] symbols_to_logits_fn = self._get_symbols_to_logits_fn(max_decode_length=self._MAX_DECODE_LENGTH, training=training) initial_ids = (tf.ones([batch_size], dtype=tf.int32) * input_utils.STAR...
-2,499,680,710,903,466,500
Return predicted sequence.
widget_caption/widget_caption_model.py
predict
AI21212019/google-research
python
def predict(self, encoder_outputs, training): batch_size = tf.shape(encoder_outputs)[0] symbols_to_logits_fn = self._get_symbols_to_logits_fn(max_decode_length=self._MAX_DECODE_LENGTH, training=training) initial_ids = (tf.ones([batch_size], dtype=tf.int32) * input_utils.START) init_decode_length = ...
def compute_targets(self, features): 'Compute the target token ids and phrase ids.' batch_size = tf.shape(features['label_flag'])[0] num_objects = tf.shape(features['label_flag'])[1] worker_position = self._caption_object_selector(features) valid_references = tf.gather(tf.reshape(features['reference...
402,812,099,101,840,260
Compute the target token ids and phrase ids.
widget_caption/widget_caption_model.py
compute_targets
AI21212019/google-research
python
def compute_targets(self, features): batch_size = tf.shape(features['label_flag'])[0] num_objects = tf.shape(features['label_flag'])[1] worker_position = self._caption_object_selector(features) valid_references = tf.gather(tf.reshape(features['reference'], [(- 1)]), worker_position) target_phra...
def _get_symbols_to_logits_fn(self, max_decode_length, training): 'Returns a decoding function that calculates logits of the next tokens.' timing_signal = self._position_embedding_layer(inputs=None, length=max_decode_length) decoder_self_attention_bias = model_utils.get_decoder_self_attention_bias(max_decod...
-132,147,364,262,350,850
Returns a decoding function that calculates logits of the next tokens.
widget_caption/widget_caption_model.py
_get_symbols_to_logits_fn
AI21212019/google-research
python
def _get_symbols_to_logits_fn(self, max_decode_length, training): timing_signal = self._position_embedding_layer(inputs=None, length=max_decode_length) decoder_self_attention_bias = model_utils.get_decoder_self_attention_bias(max_decode_length) def symbols_to_logits_fn(ids, i, cache): 'Generat...
def symbols_to_logits_fn(ids, i, cache): 'Generate logits for next potential IDs.\n\n Args:\n ids: Current decoded sequences. int tensor with shape [batch_size *\n beam_size, i + 1].\n i: Loop index.\n cache: dictionary of values storing the encoder output, encoder-decoder\n ...
-6,548,694,566,543,476,000
Generate logits for next potential IDs. Args: ids: Current decoded sequences. int tensor with shape [batch_size * beam_size, i + 1]. i: Loop index. cache: dictionary of values storing the encoder output, encoder-decoder attention bias, and previous decoder attention values. Returns: Tuple of (logi...
widget_caption/widget_caption_model.py
symbols_to_logits_fn
AI21212019/google-research
python
def symbols_to_logits_fn(ids, i, cache): 'Generate logits for next potential IDs.\n\n Args:\n ids: Current decoded sequences. int tensor with shape [batch_size *\n beam_size, i + 1].\n i: Loop index.\n cache: dictionary of values storing the encoder output, encoder-decoder\n ...
@deprecation.deprecated(date, instructions) def _fn(arg0, arg1): 'fn doc.\n\n Args:\n arg0: Arg 0.\n arg1: Arg 1.\n\n Returns:\n Sum of args.\n ' return (arg0 + arg1)
8,087,309,597,350,725,000
fn doc. Args: arg0: Arg 0. arg1: Arg 1. Returns: Sum of args.
tensorflow/python/util/deprecation_test.py
_fn
AccelAI/tensorflow
python
@deprecation.deprecated(date, instructions) def _fn(arg0, arg1): 'fn doc.\n\n Args:\n arg0: Arg 0.\n arg1: Arg 1.\n\n Returns:\n Sum of args.\n ' return (arg0 + arg1)
@deprecation.deprecated(date, instructions) def _fn(arg0, arg1): 'fn doc.' return (arg0 + arg1)
-2,257,126,715,904,382,700
fn doc.
tensorflow/python/util/deprecation_test.py
_fn
AccelAI/tensorflow
python
@deprecation.deprecated(date, instructions) def _fn(arg0, arg1): return (arg0 + arg1)
@deprecation.deprecated_args(date, instructions, 'deprecated') def _fn(arg0, arg1, deprecated=True): 'fn doc.\n\n Args:\n arg0: Arg 0.\n arg1: Arg 1.\n deprecated: Deprecated!\n\n Returns:\n Sum of args.\n ' return ((arg0 + arg1) if deprecated else (arg1 + arg0))
8,094,843,131,514,642,000
fn doc. Args: arg0: Arg 0. arg1: Arg 1. deprecated: Deprecated! Returns: Sum of args.
tensorflow/python/util/deprecation_test.py
_fn
AccelAI/tensorflow
python
@deprecation.deprecated_args(date, instructions, 'deprecated') def _fn(arg0, arg1, deprecated=True): 'fn doc.\n\n Args:\n arg0: Arg 0.\n arg1: Arg 1.\n deprecated: Deprecated!\n\n Returns:\n Sum of args.\n ' return ((arg0 + arg1) if deprecated else (arg1 + arg0))
@deprecation.deprecated_args(date, instructions, 'deprecated') def _fn(arg0, arg1, deprecated=True): 'fn doc.' return ((arg0 + arg1) if deprecated else (arg1 + arg0))
94,406,864,349,320,930
fn doc.
tensorflow/python/util/deprecation_test.py
_fn
AccelAI/tensorflow
python
@deprecation.deprecated_args(date, instructions, 'deprecated') def _fn(arg0, arg1, deprecated=True): return ((arg0 + arg1) if deprecated else (arg1 + arg0))
@deprecation.deprecated_arg_values(date, instructions, deprecated=True) def _fn(arg0, arg1, deprecated=True): 'fn doc.\n\n Args:\n arg0: Arg 0.\n arg1: Arg 1.\n deprecated: Deprecated!\n\n Returns:\n Sum of args.\n ' return ((arg0 + arg1) if deprecated else (arg1 + arg...
6,193,847,633,101,739,000
fn doc. Args: arg0: Arg 0. arg1: Arg 1. deprecated: Deprecated! Returns: Sum of args.
tensorflow/python/util/deprecation_test.py
_fn
AccelAI/tensorflow
python
@deprecation.deprecated_arg_values(date, instructions, deprecated=True) def _fn(arg0, arg1, deprecated=True): 'fn doc.\n\n Args:\n arg0: Arg 0.\n arg1: Arg 1.\n deprecated: Deprecated!\n\n Returns:\n Sum of args.\n ' return ((arg0 + arg1) if deprecated else (arg1 + arg...
@deprecation.deprecated_arg_values(date, instructions, deprecated=True) def _fn(arg0, arg1, deprecated=True): 'fn doc.' return ((arg0 + arg1) if deprecated else (arg1 + arg0))
1,241,249,845,256,133,000
fn doc.
tensorflow/python/util/deprecation_test.py
_fn
AccelAI/tensorflow
python
@deprecation.deprecated_arg_values(date, instructions, deprecated=True) def _fn(arg0, arg1, deprecated=True): return ((arg0 + arg1) if deprecated else (arg1 + arg0))
@deprecation.deprecated(date, instructions) def _fn(self, arg0, arg1): 'fn doc.\n\n Args:\n arg0: Arg 0.\n arg1: Arg 1.\n\n Returns:\n Sum of args.\n ' return (arg0 + arg1)
3,140,255,006,421,992,400
fn doc. Args: arg0: Arg 0. arg1: Arg 1. Returns: Sum of args.
tensorflow/python/util/deprecation_test.py
_fn
AccelAI/tensorflow
python
@deprecation.deprecated(date, instructions) def _fn(self, arg0, arg1): 'fn doc.\n\n Args:\n arg0: Arg 0.\n arg1: Arg 1.\n\n Returns:\n Sum of args.\n ' return (arg0 + arg1)
@deprecation.deprecated(date, instructions) def _fn(self, arg0, arg1): 'fn doc.' return (arg0 + arg1)
-8,935,820,396,118,256,000
fn doc.
tensorflow/python/util/deprecation_test.py
_fn
AccelAI/tensorflow
python
@deprecation.deprecated(date, instructions) def _fn(self, arg0, arg1): return (arg0 + arg1)
@property @deprecation.deprecated(date, instructions) def _prop(self): 'prop doc.\n\n Returns:\n String.\n ' return 'prop_with_doc'
-8,016,098,677,120,810,000
prop doc. Returns: String.
tensorflow/python/util/deprecation_test.py
_prop
AccelAI/tensorflow
python
@property @deprecation.deprecated(date, instructions) def _prop(self): 'prop doc.\n\n Returns:\n String.\n ' return 'prop_with_doc'
def terms_from_trace(tr): 'Helper function to extract elbo components from execution traces.' terms = {'log_factors': [], 'log_measures': [], 'scale': to_funsor(1.0), 'plate_vars': frozenset(), 'measure_vars': frozenset(), 'plate_to_step': dict()} for (name, node) in tr.nodes.items(): if (node['type...
1,669,444,825,470,947,600
Helper function to extract elbo components from execution traces.
pyro/contrib/funsor/infer/traceenum_elbo.py
terms_from_trace
1989Ryan/pyro
python
def terms_from_trace(tr): terms = {'log_factors': [], 'log_measures': [], 'scale': to_funsor(1.0), 'plate_vars': frozenset(), 'measure_vars': frozenset(), 'plate_to_step': dict()} for (name, node) in tr.nodes.items(): if (node['type'] == 'markov_chain'): terms['plate_to_step'][node['nam...
@pytest.mark.parametrize('url', ['https://dev.renku.ch/projects/rokroskar/scratch-project/datasets/7eba3f50-1a19-4282-8a86-2497e0f43809/']) @pytest.mark.integration @flaky(max_runs=30, min_passes=1) def test_dataset_url_import_job(url, svc_client_with_repo): 'Test dataset import via url.' (svc_client, headers, ...
3,253,797,028,710,346,000
Test dataset import via url.
tests/service/jobs/test_datasets.py
test_dataset_url_import_job
mohammad-sdsc/renku-python
python
@pytest.mark.parametrize('url', ['https://dev.renku.ch/projects/rokroskar/scratch-project/datasets/7eba3f50-1a19-4282-8a86-2497e0f43809/']) @pytest.mark.integration @flaky(max_runs=30, min_passes=1) def test_dataset_url_import_job(url, svc_client_with_repo): (svc_client, headers, project_id, url_components) = ...
@pytest.mark.parametrize('doi', ['10.5281/zenodo.3239980', '10.5281/zenodo.3188334', '10.7910/DVN/TJCLKP']) @pytest.mark.integration @pytest.mark.service @flaky(max_runs=30, min_passes=1) def test_dataset_import_job(doi, svc_client_with_repo): 'Test dataset import via doi.' (svc_client, headers, project_id, url...
-5,676,521,830,175,043,000
Test dataset import via doi.
tests/service/jobs/test_datasets.py
test_dataset_import_job
mohammad-sdsc/renku-python
python
@pytest.mark.parametrize('doi', ['10.5281/zenodo.3239980', '10.5281/zenodo.3188334', '10.7910/DVN/TJCLKP']) @pytest.mark.integration @pytest.mark.service @flaky(max_runs=30, min_passes=1) def test_dataset_import_job(doi, svc_client_with_repo): (svc_client, headers, project_id, url_components) = svc_client_with...
@pytest.mark.parametrize('doi,expected_err', [('junkjunkjunk', 'Invalid parameter value'), ('10.5281/zenodo.11111111111111111', 'Invalid parameter value')]) @pytest.mark.integration @pytest.mark.service @flaky(max_runs=30, min_passes=1) def test_dataset_import_junk_job(doi, expected_err, svc_client_with_repo): 'Tes...
3,725,200,170,761,904,000
Test dataset import.
tests/service/jobs/test_datasets.py
test_dataset_import_junk_job
mohammad-sdsc/renku-python
python
@pytest.mark.parametrize('doi,expected_err', [('junkjunkjunk', 'Invalid parameter value'), ('10.5281/zenodo.11111111111111111', 'Invalid parameter value')]) @pytest.mark.integration @pytest.mark.service @flaky(max_runs=30, min_passes=1) def test_dataset_import_junk_job(doi, expected_err, svc_client_with_repo): ...
@pytest.mark.parametrize('doi', ['10.5281/zenodo.3634052']) @pytest.mark.integration @pytest.mark.service @flaky(max_runs=30, min_passes=1) def test_dataset_import_twice_job(doi, svc_client_with_repo): 'Test dataset import.' (svc_client, headers, project_id, url_components) = svc_client_with_repo user = {'u...
-2,663,811,129,041,810,000
Test dataset import.
tests/service/jobs/test_datasets.py
test_dataset_import_twice_job
mohammad-sdsc/renku-python
python
@pytest.mark.parametrize('doi', ['10.5281/zenodo.3634052']) @pytest.mark.integration @pytest.mark.service @flaky(max_runs=30, min_passes=1) def test_dataset_import_twice_job(doi, svc_client_with_repo): (svc_client, headers, project_id, url_components) = svc_client_with_repo user = {'user_id': headers['Renk...
@pytest.mark.parametrize('url', ['https://gist.github.com/jsam/d957f306ed0fe4ff018e902df6a1c8e3']) @pytest.mark.integration @pytest.mark.service @flaky(max_runs=30, min_passes=1) def test_dataset_add_remote_file(url, svc_client_with_repo): 'Test dataset add a remote file.' (svc_client, headers, project_id, url_...
-4,038,006,578,331,544,600
Test dataset add a remote file.
tests/service/jobs/test_datasets.py
test_dataset_add_remote_file
mohammad-sdsc/renku-python
python
@pytest.mark.parametrize('url', ['https://gist.github.com/jsam/d957f306ed0fe4ff018e902df6a1c8e3']) @pytest.mark.integration @pytest.mark.service @flaky(max_runs=30, min_passes=1) def test_dataset_add_remote_file(url, svc_client_with_repo): (svc_client, headers, project_id, url_components) = svc_client_with_rep...
@pytest.mark.parametrize('doi', ['10.5281/zenodo.3761586']) @pytest.mark.integration @pytest.mark.service def test_dataset_project_lock(doi, svc_client_with_repo): 'Test dataset project lock.' (svc_client, headers, project_id, url_components) = svc_client_with_repo user = {'user_id': headers['Renku-User-Id'...
4,504,835,722,190,145,500
Test dataset project lock.
tests/service/jobs/test_datasets.py
test_dataset_project_lock
mohammad-sdsc/renku-python
python
@pytest.mark.parametrize('doi', ['10.5281/zenodo.3761586']) @pytest.mark.integration @pytest.mark.service def test_dataset_project_lock(doi, svc_client_with_repo): (svc_client, headers, project_id, url_components) = svc_client_with_repo user = {'user_id': headers['Renku-User-Id']} payload = {'project_i...
async def _list_and_update(self): '\n Update current list of resources by doing a full fetch.\n\n Overwrites all current resource info.\n ' initial_resources = None kwargs = dict(label_selector=self.label_selector, field_selector=self.field_selector, _request_timeout=self.request_timeou...
8,317,582,099,941,674,000
Update current list of resources by doing a full fetch. Overwrites all current resource info.
kubespawner/reflector.py
_list_and_update
choldgraf/kubespawner
python
async def _list_and_update(self): '\n Update current list of resources by doing a full fetch.\n\n Overwrites all current resource info.\n ' initial_resources = None kwargs = dict(label_selector=self.label_selector, field_selector=self.field_selector, _request_timeout=self.request_timeou...
async def _watch_and_update(self): "\n Keeps the current list of resources up-to-date\n\n We first fetch the list of current resources, and store that. Then we\n register to be notified of changes to those resources, and keep our\n local store up-to-date based on these notifications.\n\n...
1,615,267,037,276,851,700
Keeps the current list of resources up-to-date We first fetch the list of current resources, and store that. Then we register to be notified of changes to those resources, and keep our local store up-to-date based on these notifications. We also perform exponential backoff, giving up after we hit 32s wait time. This ...
kubespawner/reflector.py
_watch_and_update
choldgraf/kubespawner
python
async def _watch_and_update(self): "\n Keeps the current list of resources up-to-date\n\n We first fetch the list of current resources, and store that. Then we\n register to be notified of changes to those resources, and keep our\n local store up-to-date based on these notifications.\n\n...
async def start(self): "\n Start the reflection process!\n\n We'll do a blocking read of all resources first, so that we don't\n race with any operations that are checking the state of the pod\n store - such as polls. This should be called only once at the\n start of program initi...
7,907,563,787,778,749,000
Start the reflection process! We'll do a blocking read of all resources first, so that we don't race with any operations that are checking the state of the pod store - such as polls. This should be called only once at the start of program initialization (when the singleton is being created), and not afterwards!
kubespawner/reflector.py
start
choldgraf/kubespawner
python
async def start(self): "\n Start the reflection process!\n\n We'll do a blocking read of all resources first, so that we don't\n race with any operations that are checking the state of the pod\n store - such as polls. This should be called only once at the\n start of program initi...
async def stop(self): '\n Cleanly shut down the watch task.\n ' self._stopping = True if (self.watch_task and (not self.watch_task.done())): self.watch_task.cancel() try: timeout = 5 (await asyncio.wait_for(self.watch_task, timeout)) except async...
-6,765,147,635,296,929,000
Cleanly shut down the watch task.
kubespawner/reflector.py
stop
choldgraf/kubespawner
python
async def stop(self): '\n \n ' self._stopping = True if (self.watch_task and (not self.watch_task.done())): self.watch_task.cancel() try: timeout = 5 (await asyncio.wait_for(self.watch_task, timeout)) except asyncio.TimeoutError: self...
def __init__(self, configuration): 'Initialize the model.\n ' super().__init__(configuration) self.loss_names = ['segmentation'] self.network_names = ['unet'] self.netunet = UNet(1, 2) self.netunet = self.netunet.to(self.device) if self.is_train: self.criterion_loss = torch.nn...
-4,904,474,162,502,732,000
Initialize the model.
models/segmentation_model.py
__init__
Semere-Gr/PyTorchProjectFramework
python
def __init__(self, configuration): '\n ' super().__init__(configuration) self.loss_names = ['segmentation'] self.network_names = ['unet'] self.netunet = UNet(1, 2) self.netunet = self.netunet.to(self.device) if self.is_train: self.criterion_loss = torch.nn.CrossEntropyLoss() ...
def forward(self): 'Run forward pass.\n ' self.output = self.netunet(self.input)
4,487,781,734,835,777,000
Run forward pass.
models/segmentation_model.py
forward
Semere-Gr/PyTorchProjectFramework
python
def forward(self): '\n ' self.output = self.netunet(self.input)
def backward(self): 'Calculate losses; called in every training iteration.\n ' self.loss_segmentation = self.criterion_loss(self.output, self.label)
830,833,094,205,316,900
Calculate losses; called in every training iteration.
models/segmentation_model.py
backward
Semere-Gr/PyTorchProjectFramework
python
def backward(self): '\n ' self.loss_segmentation = self.criterion_loss(self.output, self.label)
def optimize_parameters(self): 'Calculate gradients and update network weights.\n ' self.loss_segmentation.backward() self.optimizer.step() self.optimizer.zero_grad() torch.cuda.empty_cache()
-8,851,077,193,266,028,000
Calculate gradients and update network weights.
models/segmentation_model.py
optimize_parameters
Semere-Gr/PyTorchProjectFramework
python
def optimize_parameters(self): '\n ' self.loss_segmentation.backward() self.optimizer.step() self.optimizer.zero_grad() torch.cuda.empty_cache()
def _str_to_identifier(string): 'Convert a string to a valid Python identifier.' return re.sub('\\W|^(?=\\d)', '_', string)
6,501,756,464,600,183,000
Convert a string to a valid Python identifier.
utils/test/test_tutorials.py
_str_to_identifier
ignaziopedone/qiskit-iqx-tutorials
python
def _str_to_identifier(string): return re.sub('\\W|^(?=\\d)', '_', string)
def create_test(filename): 'Return a new test function.' def test_function(self): self._run_notebook(filename) return test_function
-7,282,264,453,090,514,000
Return a new test function.
utils/test/test_tutorials.py
create_test
ignaziopedone/qiskit-iqx-tutorials
python
def create_test(filename): def test_function(self): self._run_notebook(filename) return test_function
@app.route((url_prefix + 'oauth2/clients/<client_id>'), methods=['GET']) @auth_required def oauth2_clients(client_id: str) -> Response: '\n Return OAuth2 client applications\n\n :return:\n GET /ajax/oauth2/clients: list of OAuth2 clients\n ' client = next((c for c in oauth_clients.values() if (c...
4,067,921,045,567,628,000
Return OAuth2 client applications :return: GET /ajax/oauth2/clients: list of OAuth2 clients
afterglow_core/views/ajax_api/oauth2_clients.py
oauth2_clients
SkynetRTN/afterglow-access-server
python
@app.route((url_prefix + 'oauth2/clients/<client_id>'), methods=['GET']) @auth_required def oauth2_clients(client_id: str) -> Response: '\n Return OAuth2 client applications\n\n :return:\n GET /ajax/oauth2/clients: list of OAuth2 clients\n ' client = next((c for c in oauth_clients.values() if (c...
def pws_constants(t): 'Lookup-table for water vapor saturation pressure constants (A, m, Tn).' if (t < (- 20)): raise ValueError('Temperature out of range (-20 - 350°C') if (t < 50): return (6.116441, 7.591386, 240.7263) if (t < 100): return (6.004918, 7.337936, 229.3975) if ...
3,113,030,149,863,625,000
Lookup-table for water vapor saturation pressure constants (A, m, Tn).
sht21_usermode.py
pws_constants
AmedeeBulle/collectd-python-plugins
python
def pws_constants(t): if (t < (- 20)): raise ValueError('Temperature out of range (-20 - 350°C') if (t < 50): return (6.116441, 7.591386, 240.7263) if (t < 100): return (6.004918, 7.337936, 229.3975) if (t < 150): return (5.856548, 7.27731, 225.1033) if (t < 200)...
def pws(t): '\n Calculate water vapor saturation pressure based on temperature (in hPa).\n\n P_{WS} = A \\cdot 10^{\\frac{m \\cdot T}{T + T_n}}\n\n ' (A, m, Tn) = pws_constants(t) power = ((m * t) / (t + Tn)) return (A * (10 ** power))
-7,582,722,841,005,355,000
Calculate water vapor saturation pressure based on temperature (in hPa). P_{WS} = A \cdot 10^{\frac{m \cdot T}{T + T_n}}
sht21_usermode.py
pws
AmedeeBulle/collectd-python-plugins
python
def pws(t): '\n Calculate water vapor saturation pressure based on temperature (in hPa).\n\n P_{WS} = A \\cdot 10^{\\frac{m \\cdot T}{T + T_n}}\n\n ' (A, m, Tn) = pws_constants(t) power = ((m * t) / (t + Tn)) return (A * (10 ** power))
def pw(t, rh): '\n Calculate Pw (in hPa).\n\n P_W = P_{WS} \\cdot RH / 100\n\n ' return ((pws(t) * rh) / 100)
5,758,262,469,975,820,000
Calculate Pw (in hPa). P_W = P_{WS} \cdot RH / 100
sht21_usermode.py
pw
AmedeeBulle/collectd-python-plugins
python
def pw(t, rh): '\n Calculate Pw (in hPa).\n\n P_W = P_{WS} \\cdot RH / 100\n\n ' return ((pws(t) * rh) / 100)
def td(t, rh): '\n Calculate the dew point (in °C).\n\n T_d = \\frac{T_n}{\\frac{m}{log_{10}\\left(\\frac{P_w}{A}\\right)} - 1}\n\n ' (A, m, Tn) = pws_constants(t) Pw = pw(t, rh) return (Tn / ((m / math.log((Pw / A), 10)) - 1))
7,101,251,171,650,572,000
Calculate the dew point (in °C). T_d = \frac{T_n}{\frac{m}{log_{10}\left(\frac{P_w}{A}\right)} - 1}
sht21_usermode.py
td
AmedeeBulle/collectd-python-plugins
python
def td(t, rh): '\n Calculate the dew point (in °C).\n\n T_d = \\frac{T_n}{\\frac{m}{log_{10}\\left(\\frac{P_w}{A}\\right)} - 1}\n\n ' (A, m, Tn) = pws_constants(t) Pw = pw(t, rh) return (Tn / ((m / math.log((Pw / A), 10)) - 1))
def ah(t, rh): '\n Calculate the absolute humidity (in g/m³).\n\n A = C \\cdot P_w / T\n\n ' C = 2.16679 Pw = pw(t, rh) T = celsius_to_kelvin(t) return ((C * (Pw * 100)) / T)
-6,017,293,510,570,832,000
Calculate the absolute humidity (in g/m³). A = C \cdot P_w / T
sht21_usermode.py
ah
AmedeeBulle/collectd-python-plugins
python
def ah(t, rh): '\n Calculate the absolute humidity (in g/m³).\n\n A = C \\cdot P_w / T\n\n ' C = 2.16679 Pw = pw(t, rh) T = celsius_to_kelvin(t) return ((C * (Pw * 100)) / T)
def labels_to_one_hot(labels, n_classes=(43 + 1)): 'Convert 1D array of labels to one hot representation\n\n Args:\n labels: 1D numpy array\n ' new_labels = np.zeros((n_classes,)) new_labels[labels] = 1 return new_labels
-3,730,193,699,893,287,000
Convert 1D array of labels to one hot representation Args: labels: 1D numpy array
test_single.py
labels_to_one_hot
stevenwudi/CarND-Traffic-Sign-Classifier-Project
python
def labels_to_one_hot(labels, n_classes=(43 + 1)): 'Convert 1D array of labels to one hot representation\n\n Args:\n labels: 1D numpy array\n ' new_labels = np.zeros((n_classes,)) new_labels[labels] = 1 return new_labels
def orga_events(request): 'Add data to all template contexts.' context = {'settings': settings} if (not request.path.startswith('/orga/')): return {} if ((not getattr(request, 'user', None)) or (not request.user.is_authenticated)): return context if (not getattr(request, 'event', Non...
5,796,924,850,713,361,000
Add data to all template contexts.
src/pretalx/orga/context_processors.py
orga_events
ThomasWaldmann/pretalx
python
def orga_events(request): context = {'settings': settings} if (not request.path.startswith('/orga/')): return {} if ((not getattr(request, 'user', None)) or (not request.user.is_authenticated)): return context if (not getattr(request, 'event', None)): context['nav_global'] =...
def testTrack(self): 'Test Track' pass
7,473,533,764,582,402,000
Test Track
test/test_track.py
testTrack
dgiacomo/mux-python
python
def testTrack(self): pass
async def test_default_supported_features(hass, mqtt_mock): 'Test that the correct supported features.' assert (await async_setup_component(hass, vacuum.DOMAIN, {vacuum.DOMAIN: DEFAULT_CONFIG})) entity = hass.states.get('vacuum.mqtttest') entity_features = entity.attributes.get(mqttvacuum.CONF_SUPPORTED...
-7,954,197,594,334,600,000
Test that the correct supported features.
tests/components/mqtt/test_state_vacuum.py
test_default_supported_features
FuqiangSong/home-assistant
python
async def test_default_supported_features(hass, mqtt_mock): assert (await async_setup_component(hass, vacuum.DOMAIN, {vacuum.DOMAIN: DEFAULT_CONFIG})) entity = hass.states.get('vacuum.mqtttest') entity_features = entity.attributes.get(mqttvacuum.CONF_SUPPORTED_FEATURES, 0) assert (sorted(services_t...
async def test_all_commands(hass, mqtt_mock): 'Test simple commands send to the vacuum.' config = deepcopy(DEFAULT_CONFIG) config[mqttvacuum.CONF_SUPPORTED_FEATURES] = services_to_strings(mqttvacuum.ALL_SERVICES, SERVICE_TO_STRING) assert (await async_setup_component(hass, vacuum.DOMAIN, {vacuum.DOMAIN:...
8,679,773,904,677,183,000
Test simple commands send to the vacuum.
tests/components/mqtt/test_state_vacuum.py
test_all_commands
FuqiangSong/home-assistant
python
async def test_all_commands(hass, mqtt_mock): config = deepcopy(DEFAULT_CONFIG) config[mqttvacuum.CONF_SUPPORTED_FEATURES] = services_to_strings(mqttvacuum.ALL_SERVICES, SERVICE_TO_STRING) assert (await async_setup_component(hass, vacuum.DOMAIN, {vacuum.DOMAIN: config})) (await hass.services.async_...
async def test_commands_without_supported_features(hass, mqtt_mock): 'Test commands which are not supported by the vacuum.' config = deepcopy(DEFAULT_CONFIG) services = mqttvacuum.STRING_TO_SERVICE['status'] config[mqttvacuum.CONF_SUPPORTED_FEATURES] = services_to_strings(services, SERVICE_TO_STRING) ...
4,664,079,603,008,944,000
Test commands which are not supported by the vacuum.
tests/components/mqtt/test_state_vacuum.py
test_commands_without_supported_features
FuqiangSong/home-assistant
python
async def test_commands_without_supported_features(hass, mqtt_mock): config = deepcopy(DEFAULT_CONFIG) services = mqttvacuum.STRING_TO_SERVICE['status'] config[mqttvacuum.CONF_SUPPORTED_FEATURES] = services_to_strings(services, SERVICE_TO_STRING) assert (await async_setup_component(hass, vacuum.DOM...
async def test_status(hass, mqtt_mock): 'Test status updates from the vacuum.' config = deepcopy(DEFAULT_CONFIG) config[mqttvacuum.CONF_SUPPORTED_FEATURES] = services_to_strings(mqttvacuum.ALL_SERVICES, SERVICE_TO_STRING) assert (await async_setup_component(hass, vacuum.DOMAIN, {vacuum.DOMAIN: config}))...
-3,601,749,714,720,768,000
Test status updates from the vacuum.
tests/components/mqtt/test_state_vacuum.py
test_status
FuqiangSong/home-assistant
python
async def test_status(hass, mqtt_mock): config = deepcopy(DEFAULT_CONFIG) config[mqttvacuum.CONF_SUPPORTED_FEATURES] = services_to_strings(mqttvacuum.ALL_SERVICES, SERVICE_TO_STRING) assert (await async_setup_component(hass, vacuum.DOMAIN, {vacuum.DOMAIN: config})) message = '{\n "battery_le...
async def test_no_fan_vacuum(hass, mqtt_mock): 'Test status updates from the vacuum when fan is not supported.' config = deepcopy(DEFAULT_CONFIG) del config[mqttvacuum.CONF_FAN_SPEED_LIST] config[mqttvacuum.CONF_SUPPORTED_FEATURES] = services_to_strings(mqttvacuum.DEFAULT_SERVICES, SERVICE_TO_STRING) ...
-5,363,847,290,666,027,000
Test status updates from the vacuum when fan is not supported.
tests/components/mqtt/test_state_vacuum.py
test_no_fan_vacuum
FuqiangSong/home-assistant
python
async def test_no_fan_vacuum(hass, mqtt_mock): config = deepcopy(DEFAULT_CONFIG) del config[mqttvacuum.CONF_FAN_SPEED_LIST] config[mqttvacuum.CONF_SUPPORTED_FEATURES] = services_to_strings(mqttvacuum.DEFAULT_SERVICES, SERVICE_TO_STRING) assert (await async_setup_component(hass, vacuum.DOMAIN, {vacu...