_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
75
19.8k
language
stringclasses
1 value
meta_information
dict
q229900
is10
train
def is10(msg): """Check if a message is likely to be BDS code 1,0 Args: msg (String): 28 bytes hexadecimal message string Returns: bool: True or False """ if allzeros(msg): return False d = hex2bin(data(msg)) # first 8 bits must be 0x10 if d[0:8] != '00010000...
python
{ "resource": "" }
q229901
is17
train
def is17(msg): """Check if a message is likely to be BDS code 1,7 Args: msg (String): 28 bytes hexadecimal message string Returns: bool: True or False """ if allzeros(msg): return False d = hex2bin(data(msg)) if bin2int(d[28:56]) != 0: return False c...
python
{ "resource": "" }
q229902
cap17
train
def cap17(msg): """Extract capacities from BDS 1,7 message Args: msg (String): 28 bytes hexadecimal message string Returns: list: list of suport BDS codes """ allbds = ['05', '06', '07', '08', '09', '0A', '20', '21', '40', '41', '42', '43', '44', '45', '48', '50', '51...
python
{ "resource": "" }
q229903
Stream.get_aircraft
train
def get_aircraft(self): """all aircraft that are stored in memeory""" acs = self.acs icaos = list(acs.keys()) for icao in icaos: if acs[icao]['lat'] is None: acs.pop(icao) return acs
python
{ "resource": "" }
q229904
altitude_diff
train
def altitude_diff(msg): """Decode the differece between GNSS and barometric altitude Args: msg (string): 28 bytes hexadecimal message string, TC=19 Returns: int: Altitude difference in ft. Negative value indicates GNSS altitude below barometric altitude. """ tc = common...
python
{ "resource": "" }
q229905
is50or60
train
def is50or60(msg, spd_ref, trk_ref, alt_ref): """Use reference ground speed and trk to determine BDS50 and DBS60. Args: msg (String): 28 bytes hexadecimal message string spd_ref (float): reference speed (ADS-B ground speed), kts trk_ref (float): reference track (ADS-B track angle), deg ...
python
{ "resource": "" }
q229906
infer
train
def infer(msg, mrar=False): """Estimate the most likely BDS code of an message. Args: msg (String): 28 bytes hexadecimal message string mrar (bool): Also infer MRAR (BDS 44) and MHR (BDS 45). Defaults to False. Returns: String or None: BDS version, or possible versions, or None if ...
python
{ "resource": "" }
q229907
is40
train
def is40(msg): """Check if a message is likely to be BDS code 4,0 Args: msg (String): 28 bytes hexadecimal message string Returns: bool: True or False """ if allzeros(msg): return False d = hex2bin(data(msg)) # status bit 1, 14, and 27 if wrongstatus(d, 1, 2...
python
{ "resource": "" }
q229908
alt40fms
train
def alt40fms(msg): """Selected altitude, FMS Args: msg (String): 28 bytes hexadecimal message (BDS40) string Returns: int: altitude in feet """ d = hex2bin(data(msg)) if d[13] == '0': return None alt = bin2int(d[14:26]) * 16 # ft return alt
python
{ "resource": "" }
q229909
p40baro
train
def p40baro(msg): """Barometric pressure setting Args: msg (String): 28 bytes hexadecimal message (BDS40) string Returns: float: pressure in millibar """ d = hex2bin(data(msg)) if d[26] == '0': return None p = bin2int(d[27:39]) * 0.1 + 800 # millibar return...
python
{ "resource": "" }
q229910
is44
train
def is44(msg): """Check if a message is likely to be BDS code 4,4. Meteorological routine air report Args: msg (String): 28 bytes hexadecimal message string Returns: bool: True or False """ if allzeros(msg): return False d = hex2bin(data(msg)) # status bit 5...
python
{ "resource": "" }
q229911
wind44
train
def wind44(msg): """Wind speed and direction. Args: msg (String): 28 bytes hexadecimal message string Returns: (int, float): speed (kt), direction (degree) """ d = hex2bin(data(msg)) status = int(d[4]) if not status: return None speed = bin2int(d[5:14]) # k...
python
{ "resource": "" }
q229912
p44
train
def p44(msg): """Static pressure. Args: msg (String): 28 bytes hexadecimal message string Returns: int: static pressure in hPa """ d = hex2bin(data(msg)) if d[34] == '0': return None p = bin2int(d[35:46]) # hPa return p
python
{ "resource": "" }
q229913
is60
train
def is60(msg): """Check if a message is likely to be BDS code 6,0 Args: msg (String): 28 bytes hexadecimal message string Returns: bool: True or False """ if allzeros(msg): return False d = hex2bin(data(msg)) # status bit 1, 13, 24, 35, 46 if wrongstatus(d, ...
python
{ "resource": "" }
q229914
hdg60
train
def hdg60(msg): """Megnetic heading of aircraft Args: msg (String): 28 bytes hexadecimal message (BDS60) string Returns: float: heading in degrees to megnetic north (from 0 to 360) """ d = hex2bin(data(msg)) if d[0] == '0': return None sign = int(d[1]) # 1 -> w...
python
{ "resource": "" }
q229915
mach60
train
def mach60(msg): """Aircraft MACH number Args: msg (String): 28 bytes hexadecimal message (BDS60) string Returns: float: MACH number """ d = hex2bin(data(msg)) if d[23] == '0': return None mach = bin2int(d[24:34]) * 2.048 / 512.0 return round(mach, 3)
python
{ "resource": "" }
q229916
vr60baro
train
def vr60baro(msg): """Vertical rate from barometric measurement, this value may be very noisy. Args: msg (String): 28 bytes hexadecimal message (BDS60) string Returns: int: vertical rate in feet/minutes """ d = hex2bin(data(msg)) if d[34] == '0': return None sign ...
python
{ "resource": "" }
q229917
is45
train
def is45(msg): """Check if a message is likely to be BDS code 4,5. Meteorological hazard report Args: msg (String): 28 bytes hexadecimal message string Returns: bool: True or False """ if allzeros(msg): return False d = hex2bin(data(msg)) # status bit 1, 4, ...
python
{ "resource": "" }
q229918
ws45
train
def ws45(msg): """Wind shear. Args: msg (String): 28 bytes hexadecimal message string Returns: int: Wind shear level. 0=NIL, 1=Light, 2=Moderate, 3=Severe """ d = hex2bin(data(msg)) if d[3] == '0': return None ws = bin2int(d[4:6]) return ws
python
{ "resource": "" }
q229919
wv45
train
def wv45(msg): """Wake vortex. Args: msg (String): 28 bytes hexadecimal message string Returns: int: Wake vortex level. 0=NIL, 1=Light, 2=Moderate, 3=Severe """ d = hex2bin(data(msg)) if d[12] == '0': return None ws = bin2int(d[13:15]) return ws
python
{ "resource": "" }
q229920
p45
train
def p45(msg): """Average static pressure. Args: msg (String): 28 bytes hexadecimal message string Returns: int: static pressure in hPa """ d = hex2bin(data(msg)) if d[26] == '0': return None p = bin2int(d[27:38]) # hPa return p
python
{ "resource": "" }
q229921
rh45
train
def rh45(msg): """Radio height. Args: msg (String): 28 bytes hexadecimal message string Returns: int: radio height in ft """ d = hex2bin(data(msg)) if d[38] == '0': return None rh = bin2int(d[39:51]) * 16 return rh
python
{ "resource": "" }
q229922
vsound
train
def vsound(H): """Speed of sound""" T = temperature(H) a = np.sqrt(gamma * R * T) return a
python
{ "resource": "" }
q229923
distance
train
def distance(lat1, lon1, lat2, lon2, H=0): """ Compute spherical distance from spherical coordinates. For two locations in spherical coordinates (1, theta, phi) and (1, theta', phi') cosine( arc length ) = sin phi sin phi' cos(theta-theta') + cos phi cos phi' distance = rho * arc length ...
python
{ "resource": "" }
q229924
tas2mach
train
def tas2mach(Vtas, H): """True Airspeed to Mach number""" a = vsound(H) Mach = Vtas/a return Mach
python
{ "resource": "" }
q229925
mach2tas
train
def mach2tas(Mach, H): """Mach number to True Airspeed""" a = vsound(H) Vtas = Mach*a return Vtas
python
{ "resource": "" }
q229926
tas2eas
train
def tas2eas(Vtas, H): """True Airspeed to Equivalent Airspeed""" rho = density(H) Veas = Vtas * np.sqrt(rho/rho0) return Veas
python
{ "resource": "" }
q229927
cas2tas
train
def cas2tas(Vcas, H): """Calibrated Airspeed to True Airspeed""" p, rho, T = atmos(H) qdyn = p0*((1.+rho0*Vcas*Vcas/(7.*p0))**3.5-1.) Vtas = np.sqrt(7.*p/rho*((1.+qdyn/p)**(2./7.)-1.)) return Vtas
python
{ "resource": "" }
q229928
mach2cas
train
def mach2cas(Mach, H): """Mach number to Calibrated Airspeed""" Vtas = mach2tas(Mach, H) Vcas = tas2cas(Vtas, H) return Vcas
python
{ "resource": "" }
q229929
cas2mach
train
def cas2mach(Vcas, H): """Calibrated Airspeed to Mach number""" Vtas = cas2tas(Vcas, H) Mach = tas2mach(Vtas, H) return Mach
python
{ "resource": "" }
q229930
markdown_search_user
train
def markdown_search_user(request): """ Json usernames of the users registered & actived. url(method=get): /martor/search-user/?username={username} Response: error: - `status` is status code (204) - `error` is error message. success: - `status...
python
{ "resource": "" }
q229931
MentionPattern.handleMatch
train
def handleMatch(self, m): username = self.unescape(m.group(2)) """Makesure `username` is registered and actived.""" if MARTOR_ENABLE_CONFIGS['mention'] == 'true': if username in [u.username for u in User.objects.exclude(is_active=False)]: url = '{0}{1}/'.format(MARTO...
python
{ "resource": "" }
q229932
markdownify
train
def markdownify(markdown_content): """ Render the markdown content to HTML. Basic: >>> from martor.utils import markdownify >>> content = "![awesome](http://i.imgur.com/hvguiSn.jpg)" >>> markdownify(content) '<p><img alt="awesome" src="http://i.imgur.com/hvguiSn.jpg" /></p>'...
python
{ "resource": "" }
q229933
get_entry_url
train
def get_entry_url(entry, blog_page, root_page): """ Get the entry url given and entry page a blog page instances. It will use an url or another depending if blog_page is the root page. """ if root_page == blog_page: return reverse('entry_page_serve', kwargs={ 'year': entry.date.s...
python
{ "resource": "" }
q229934
get_feeds_url
train
def get_feeds_url(blog_page, root_page): """ Get the feeds urls a blog page instance. It will use an url or another depending if blog_page is the root page. """ if root_page == blog_page: return reverse('blog_page_feed') else: blog_path = strip_prefix_and_ending_slash(blog_page.s...
python
{ "resource": "" }
q229935
install_dependencies
train
def install_dependencies(dependencies, verbose=False): """Install all packages in dependency list via pip.""" if not dependencies: return stdout = stderr = None if verbose else subprocess.DEVNULL with tempfile.TemporaryDirectory() as req_dir: req_file = Path(req_dir) / "requirements.txt...
python
{ "resource": "" }
q229936
install_translations
train
def install_translations(config): """Add check translations according to ``config`` as a fallback to existing translations""" if not config: return from . import _translation checks_translation = gettext.translation(domain=config["domain"], localedi...
python
{ "resource": "" }
q229937
hash
train
def hash(file): """ Hashes file using SHA-256. :param file: name of file to be hashed :type file: str :rtype: str :raises check50.Failure: if ``file`` does not exist """ exists(file) log(_("hashing {}...").format(file)) # https://stackoverflow.com/a/22058673 with open(fil...
python
{ "resource": "" }
q229938
exists
train
def exists(*paths): """ Assert that all given paths exist. :params paths: files/directories to be checked for existence :raises check50.Failure: if any ``path in paths`` does not exist Example usage:: check50.exists("foo.c", "foo.h") """ for path in paths: log(_("checking...
python
{ "resource": "" }
q229939
import_checks
train
def import_checks(path): """ Import checks module given relative path. :param path: relative path from which to import checks module :type path: str :returns: the imported module :raises FileNotFoundError: if ``path / .check50.yaml`` does not exist :raises yaml.YAMLError: if ``path / .check...
python
{ "resource": "" }
q229940
_raw
train
def _raw(s): """Get raw representation of s, truncating if too long.""" if isinstance(s, list): s = "\n".join(_raw(item) for item in s) if s == EOF: return "EOF" s = repr(s) # Get raw representation of string s = s[1:-1] # Strip away quotation marks if len(s) > 15: s...
python
{ "resource": "" }
q229941
_copy
train
def _copy(src, dst): """Copy src to dst, copying recursively if src is a directory.""" try: shutil.copy(src, dst) except IsADirectoryError: if os.path.isdir(dst): dst = os.path.join(dst, os.path.basename(src)) shutil.copytree(src, dst)
python
{ "resource": "" }
q229942
run.stdin
train
def stdin(self, line, prompt=True, timeout=3): """ Send line to stdin, optionally expect a prompt. :param line: line to be send to stdin :type line: str :param prompt: boolean indicating whether a prompt is expected, if True absorbs \ all of stdout before ...
python
{ "resource": "" }
q229943
run.reject
train
def reject(self, timeout=1): """ Check that the process survives for timeout. Useful for checking whether program is waiting on input. :param timeout: number of seconds to wait :type timeout: int / float :raises check50.Failure: if process ends before ``timeout`` """ ...
python
{ "resource": "" }
q229944
import_file
train
def import_file(name, path): """ Import a file given a raw file path. :param name: Name of module to be imported :type name: str :param path: Path to Python file :type path: str / Path """ spec = importlib.util.spec_from_file_location(name, path) mod = importlib.util.module_from_spe...
python
{ "resource": "" }
q229945
compile
train
def compile(*files, exe_name=None, cc=CC, **cflags): """ Compile C source files. :param files: filenames to be compiled :param exe_name: name of resulting executable :param cc: compiler to use (:data:`check50.c.CC` by default) :param cflags: additional flags to pass to the compiler :raises ...
python
{ "resource": "" }
q229946
valgrind
train
def valgrind(command, env={}): """Run a command with valgrind. :param command: command to be run :type command: str :param env: environment in which to run command :type env: str :raises check50.Failure: if, at the end of the check, valgrind reports any errors This function works exactly l...
python
{ "resource": "" }
q229947
_check_valgrind
train
def _check_valgrind(xml_file): """Log and report any errors encountered by valgrind.""" log(_("checking for valgrind errors...")) # Load XML file created by valgrind xml = ET.ElementTree(file=xml_file) # Ensure that we don't get duplicate error messages. reported = set() for error in xml.i...
python
{ "resource": "" }
q229948
_timeout
train
def _timeout(seconds): """Context manager that runs code block until timeout is reached. Example usage:: try: with _timeout(10): do_stuff() except Timeout: print("do_stuff timed out") """ def _handle_timeout(*args): raise Timeout(seconds...
python
{ "resource": "" }
q229949
CheckRunner.run
train
def run(self, files, working_area): """ Run checks concurrently. Returns a list of CheckResults ordered by declaration order of the checks in the imported module """ # Ensure that dictionary is ordered by check declaration order (via self.check_names) # NOTE: Requires CP...
python
{ "resource": "" }
q229950
append_code
train
def append_code(original, codefile): """Append the contents of one file to another. :param original: name of file that will be appended to :type original: str :param codefile: name of file that will be appende :type codefile: str This function is particularly useful when one wants to replace a...
python
{ "resource": "" }
q229951
import_
train
def import_(path): """Import a Python program given a raw file path :param path: path to python file to be imported :type path: str :raises check50.Failure: if ``path`` doesn't exist, or if the Python file at ``path`` throws an exception when imported. """ exists(path) log(_("importing {}.....
python
{ "resource": "" }
q229952
compile
train
def compile(file): """ Compile a Python program into byte code :param file: file to be compiled :raises check50.Failure: if compilation fails e.g. if there is a SyntaxError """ log(_("compiling {} into byte code...").format(file)) try: py_compile.compile(file, doraise=True) exc...
python
{ "resource": "" }
q229953
app.get
train
def get(self, route, data=None, params=None, follow_redirects=True): """Send GET request to app. :param route: route to send request to :type route: str :param data: form data to include in request :type data: dict :param params: URL parameters to include in request ...
python
{ "resource": "" }
q229954
app.post
train
def post(self, route, data=None, params=None, follow_redirects=True): """Send POST request to app. :param route: route to send request to :type route: str :param data: form data to include in request :type data: dict :param params: URL parameters to include in request ...
python
{ "resource": "" }
q229955
app.status
train
def status(self, code=None): """Check status code in response returned by application. If ``code`` is not None, assert that ``code`` is returned by application, else simply return the status code. :param code: ``code`` to assert that application returns :type code: int ...
python
{ "resource": "" }
q229956
app.raw_content
train
def raw_content(self, output=None, str_output=None): """Searches for `output` regex match within content of page, regardless of mimetype.""" return self._search_page(output, str_output, self.response.data, lambda regex, content: regex.search(content.decode()))
python
{ "resource": "" }
q229957
app.content
train
def content(self, output=None, str_output=None, **kwargs): """Searches for `output` regex within HTML page. kwargs are passed to BeautifulSoup's find function to filter for tags.""" if self.response.mimetype != "text/html": raise Failure(_("expected request to return HTML, but it returned {}...
python
{ "resource": "" }
q229958
app._send
train
def _send(self, method, route, data, params, **kwargs): """Send request of type `method` to `route`.""" route = self._fmt_route(route, params) log(_("sending {} request to {}").format(method.upper(), route)) try: self.response = getattr(self._client, method.lower())(route, da...
python
{ "resource": "" }
q229959
compile
train
def compile(checks): """Returns compiled check50 checks from simple YAML checks in path.""" out = ["import check50"] for name, check in checks.items(): out.append(_compile_check(name, check)) return "\n\n".join(out)
python
{ "resource": "" }
q229960
days_at_time
train
def days_at_time(days, t, tz, day_offset=0): """ Create an index of days at time ``t``, interpreted in timezone ``tz``. The returned index is localized to UTC. Parameters ---------- days : DatetimeIndex An index of dates (represented as midnight). t : datetime.time The time...
python
{ "resource": "" }
q229961
weekend_boxing_day
train
def weekend_boxing_day(start_date=None, end_date=None, observance=None): """ If boxing day is saturday then Monday 28th is a holiday If boxing day is sunday then Tuesday 28th is a holiday """ return Holiday( "Weekend Boxing Day", month=12, day=28, days_of_week=(MONDAY...
python
{ "resource": "" }
q229962
is_holiday_or_weekend
train
def is_holiday_or_weekend(holidays, dt): """ Given a list of holidays, return whether dt is a holiday or it is on a weekend. """ one_day = timedelta(days=1) for h in holidays: if dt in h.dates(dt - one_day, dt + one_day) or \ dt.weekday() in WEEKENDS: return ...
python
{ "resource": "" }
q229963
next_non_holiday_weekday
train
def next_non_holiday_weekday(holidays, dt): """ If a holiday falls on a Sunday, observe it on the next non-holiday weekday. Parameters ---------- holidays : list[pd.tseries.holiday.Holiday] list of holidays dt : pd.Timestamp date of holiday. """ day_of_week = dt.weekday(...
python
{ "resource": "" }
q229964
compute_all_minutes
train
def compute_all_minutes(opens_in_ns, closes_in_ns): """ Given arrays of opens and closes, both in nanoseconds, return an array of each minute between the opens and closes. """ deltas = closes_in_ns - opens_in_ns # + 1 because we want 390 mins per standard day, not 389 daily_sizes = (deltas ...
python
{ "resource": "" }
q229965
TradingCalendarDispatcher.get_calendar
train
def get_calendar(self, name): """ Retrieves an instance of an TradingCalendar whose name is given. Parameters ---------- name : str The name of the TradingCalendar to be retrieved. Returns ------- calendar : calendars.TradingCalendar ...
python
{ "resource": "" }
q229966
TradingCalendarDispatcher.register_calendar
train
def register_calendar(self, name, calendar, force=False): """ Registers a calendar for retrieval by the get_calendar method. Parameters ---------- name: str The key with which to register this calendar. calendar: TradingCalendar The calendar to be...
python
{ "resource": "" }
q229967
TradingCalendarDispatcher.register_calendar_type
train
def register_calendar_type(self, name, calendar_type, force=False): """ Registers a calendar by type. This is useful for registering a new calendar to be lazily instantiated at some future point in time. Parameters ---------- name: str The key with w...
python
{ "resource": "" }
q229968
TradingCalendarDispatcher.register_calendar_alias
train
def register_calendar_alias(self, alias, real_name, force=False): """ Register an alias for a calendar. This is useful when multiple exchanges should share a calendar, or when there are multiple ways to refer to the same exchange. After calling ``register_alias('alias', 'real_n...
python
{ "resource": "" }
q229969
TradingCalendarDispatcher.resolve_alias
train
def resolve_alias(self, name): """ Resolve a calendar alias for retrieval. Parameters ---------- name : str The name of the requested calendar. Returns ------- canonical_name : str The real name of the calendar to create/return. ...
python
{ "resource": "" }
q229970
TradingCalendarDispatcher.deregister_calendar
train
def deregister_calendar(self, name): """ If a calendar is registered with the given name, it is de-registered. Parameters ---------- cal_name : str The name of the calendar to be deregistered. """ self._calendars.pop(name, None) self._calendar...
python
{ "resource": "" }
q229971
TradingCalendarDispatcher.clear_calendars
train
def clear_calendars(self): """ Deregisters all current registered calendars """ self._calendars.clear() self._calendar_factories.clear() self._aliases.clear()
python
{ "resource": "" }
q229972
_overwrite_special_dates
train
def _overwrite_special_dates(midnight_utcs, opens_or_closes, special_opens_or_closes): """ Overwrite dates in open_or_closes with corresponding dates in special_opens_or_closes, using midnight_utcs for alignment. """ # Short circuit when noth...
python
{ "resource": "" }
q229973
TradingCalendar.is_open_on_minute
train
def is_open_on_minute(self, dt): """ Given a dt, return whether this exchange is open at the given dt. Parameters ---------- dt: pd.Timestamp The dt for which to check if this exchange is open. Returns ------- bool Whether the exc...
python
{ "resource": "" }
q229974
TradingCalendar.next_open
train
def next_open(self, dt): """ Given a dt, returns the next open. If the given dt happens to be a session open, the next session's open will be returned. Parameters ---------- dt: pd.Timestamp The dt for which to get the next open. Returns ...
python
{ "resource": "" }
q229975
TradingCalendar.next_close
train
def next_close(self, dt): """ Given a dt, returns the next close. Parameters ---------- dt: pd.Timestamp The dt for which to get the next close. Returns ------- pd.Timestamp The UTC timestamp of the next close. """ ...
python
{ "resource": "" }
q229976
TradingCalendar.previous_open
train
def previous_open(self, dt): """ Given a dt, returns the previous open. Parameters ---------- dt: pd.Timestamp The dt for which to get the previous open. Returns ------- pd.Timestamp The UTC imestamp of the previous open. ...
python
{ "resource": "" }
q229977
TradingCalendar.previous_close
train
def previous_close(self, dt): """ Given a dt, returns the previous close. Parameters ---------- dt: pd.Timestamp The dt for which to get the previous close. Returns ------- pd.Timestamp The UTC timestamp of the previous close. ...
python
{ "resource": "" }
q229978
TradingCalendar.next_minute
train
def next_minute(self, dt): """ Given a dt, return the next exchange minute. If the given dt is not an exchange minute, returns the next exchange open. Parameters ---------- dt: pd.Timestamp The dt for which to get the next exchange minute. Returns ...
python
{ "resource": "" }
q229979
TradingCalendar.previous_minute
train
def previous_minute(self, dt): """ Given a dt, return the previous exchange minute. Raises KeyError if the given timestamp is not an exchange minute. Parameters ---------- dt: pd.Timestamp The dt for which to get the previous exchange minute. Return...
python
{ "resource": "" }
q229980
TradingCalendar.next_session_label
train
def next_session_label(self, session_label): """ Given a session label, returns the label of the next session. Parameters ---------- session_label: pd.Timestamp A session whose next session is desired. Returns ------- pd.Timestamp ...
python
{ "resource": "" }
q229981
TradingCalendar.previous_session_label
train
def previous_session_label(self, session_label): """ Given a session label, returns the label of the previous session. Parameters ---------- session_label: pd.Timestamp A session whose previous session is desired. Returns ------- pd.Timestamp...
python
{ "resource": "" }
q229982
TradingCalendar.minutes_for_session
train
def minutes_for_session(self, session_label): """ Given a session label, return the minutes for that session. Parameters ---------- session_label: pd.Timestamp (midnight UTC) A session label whose session's minutes are desired. Returns ------- ...
python
{ "resource": "" }
q229983
TradingCalendar.execution_minutes_for_session
train
def execution_minutes_for_session(self, session_label): """ Given a session label, return the execution minutes for that session. Parameters ---------- session_label: pd.Timestamp (midnight UTC) A session label whose session's minutes are desired. Returns ...
python
{ "resource": "" }
q229984
TradingCalendar.sessions_in_range
train
def sessions_in_range(self, start_session_label, end_session_label): """ Given start and end session labels, return all the sessions in that range, inclusive. Parameters ---------- start_session_label: pd.Timestamp (midnight UTC) The label representing the fi...
python
{ "resource": "" }
q229985
TradingCalendar.minutes_in_range
train
def minutes_in_range(self, start_minute, end_minute): """ Given start and end minutes, return all the calendar minutes in that range, inclusive. Given minutes don't need to be calendar minutes. Parameters ---------- start_minute: pd.Timestamp The min...
python
{ "resource": "" }
q229986
TradingCalendar.minutes_for_sessions_in_range
train
def minutes_for_sessions_in_range(self, start_session_label, end_session_label): """ Returns all the minutes for all the sessions from the given start session label to the given end session label, inclusive. Par...
python
{ "resource": "" }
q229987
TradingCalendar.open_and_close_for_session
train
def open_and_close_for_session(self, session_label): """ Returns a tuple of timestamps of the open and close of the session represented by the given label. Parameters ---------- session_label: pd.Timestamp The session whose open and close are desired. ...
python
{ "resource": "" }
q229988
TradingCalendar.all_minutes
train
def all_minutes(self): """ Returns a DatetimeIndex representing all the minutes in this calendar. """ opens_in_ns = self._opens.values.astype( 'datetime64[ns]', ).view('int64') closes_in_ns = self._closes.values.astype( 'datetime64[ns]', )...
python
{ "resource": "" }
q229989
TradingCalendar.minute_to_session_label
train
def minute_to_session_label(self, dt, direction="next"): """ Given a minute, get the label of its containing session. Parameters ---------- dt : pd.Timestamp or nanosecond offset The dt for which to get the containing session. direction: str "nex...
python
{ "resource": "" }
q229990
TradingCalendar.minute_index_to_session_labels
train
def minute_index_to_session_labels(self, index): """ Given a sorted DatetimeIndex of market minutes, return a DatetimeIndex of the corresponding session labels. Parameters ---------- index: pd.DatetimeIndex or pd.Series The ordered list of market minutes we w...
python
{ "resource": "" }
q229991
TradingCalendar._special_dates
train
def _special_dates(self, calendars, ad_hoc_dates, start_date, end_date): """ Compute a Series of times associated with special dates. Parameters ---------- holiday_calendars : list[(datetime.time, HolidayCalendar)] Pairs of time and calendar describing when that time...
python
{ "resource": "" }
q229992
read
train
def read(*paths): """Read a text file.""" basedir = os.path.dirname(__file__) fullpath = os.path.join(basedir, *paths) contents = io.open(fullpath, encoding='utf-8').read().strip() return contents
python
{ "resource": "" }
q229993
Encoding.parse
train
def parse(self, raw): """Returns a Python object decoded from the bytes of this encoding. Raises ------ ~ipfsapi.exceptions.DecodingError Parameters ---------- raw : bytes Data to be parsed Returns ------- object ...
python
{ "resource": "" }
q229994
Json.parse_partial
train
def parse_partial(self, data): """Incrementally decodes JSON data sets into Python objects. Raises ------ ~ipfsapi.exceptions.DecodingError Returns ------- generator """ try: # Python 3 requires all JSON data to be a text string ...
python
{ "resource": "" }
q229995
Json.parse_finalize
train
def parse_finalize(self): """Raises errors for incomplete buffered data that could not be parsed because the end of the input data has been reached. Raises ------ ~ipfsapi.exceptions.DecodingError Returns ------- tuple : Always empty """ ...
python
{ "resource": "" }
q229996
Json.encode
train
def encode(self, obj): """Returns ``obj`` serialized as JSON formatted bytes. Raises ------ ~ipfsapi.exceptions.EncodingError Parameters ---------- obj : str | list | dict | int JSON serializable Python object Returns ------- ...
python
{ "resource": "" }
q229997
Pickle.parse_finalize
train
def parse_finalize(self): """Parses the buffered data and yields the result. Raises ------ ~ipfsapi.exceptions.DecodingError Returns ------- generator """ try: self._buffer.seek(0, 0) yield pickle.load(self._buffer)...
python
{ "resource": "" }
q229998
Pickle.encode
train
def encode(self, obj): """Returns ``obj`` serialized as a pickle binary string. Raises ------ ~ipfsapi.exceptions.EncodingError Parameters ---------- obj : object Serializable Python object Returns ------- bytes "...
python
{ "resource": "" }
q229999
glob_compile
train
def glob_compile(pat): """Translate a shell glob PATTERN to a regular expression. This is almost entirely based on `fnmatch.translate` source-code from the python 3.5 standard-library. """ i, n = 0, len(pat) res = '' while i < n: c = pat[i] i = i + 1 if c == '/' and...
python
{ "resource": "" }