Search is not available for this dataset
identifier
stringlengths
1
155
parameters
stringlengths
2
6.09k
docstring
stringlengths
11
63.4k
docstring_summary
stringlengths
0
63.4k
function
stringlengths
29
99.8k
function_tokens
list
start_point
list
end_point
list
language
stringclasses
1 value
docstring_language
stringlengths
2
7
docstring_language_predictions
stringlengths
18
23
is_langid_reliable
stringclasses
2 values
Dashboard._autodiscover
(self)
Discovers panels to register from the current dashboard module.
Discovers panels to register from the current dashboard module.
def _autodiscover(self): """Discovers panels to register from the current dashboard module.""" if getattr(self, "_autodiscover_complete", False): return panels_to_discover = [] panel_groups = [] # If we have a flat iterable of panel names, wrap it again so # ...
[ "def", "_autodiscover", "(", "self", ")", ":", "if", "getattr", "(", "self", ",", "\"_autodiscover_complete\"", ",", "False", ")", ":", "return", "panels_to_discover", "=", "[", "]", "panel_groups", "=", "[", "]", "# If we have a flat iterable of panel names, wrap i...
[ 586, 4 ]
[ 633, 42 ]
python
en
['en', 'en', 'en']
True
Dashboard.register
(cls, panel)
Registers a :class:`~horizon.Panel` with this dashboard.
Registers a :class:`~horizon.Panel` with this dashboard.
def register(cls, panel): """Registers a :class:`~horizon.Panel` with this dashboard.""" panel_class = Horizon.register_panel(cls, panel) # Support template loading from panel template directories. panel_mod = import_module(panel.__module__) panel_dir = os.path.dirname(panel_mod....
[ "def", "register", "(", "cls", ",", "panel", ")", ":", "panel_class", "=", "Horizon", ".", "register_panel", "(", "cls", ",", "panel", ")", "# Support template loading from panel template directories.", "panel_mod", "=", "import_module", "(", "panel", ".", "__module...
[ 636, 4 ]
[ 646, 26 ]
python
en
['en', 'en', 'en']
True
Dashboard.unregister
(cls, panel)
Unregisters a :class:`~horizon.Panel` from this dashboard.
Unregisters a :class:`~horizon.Panel` from this dashboard.
def unregister(cls, panel): """Unregisters a :class:`~horizon.Panel` from this dashboard.""" success = Horizon.unregister_panel(cls, panel) if success: # Remove the panel's template directory. key = os.path.join(cls.slug, panel.slug) if key in loaders.panel_te...
[ "def", "unregister", "(", "cls", ",", "panel", ")", ":", "success", "=", "Horizon", ".", "unregister_panel", "(", "cls", ",", "panel", ")", "if", "success", ":", "# Remove the panel's template directory.", "key", "=", "os", ".", "path", ".", "join", "(", "...
[ 649, 4 ]
[ 657, 22 ]
python
en
['en', 'en', 'en']
True
Dashboard.allowed
(self, context)
Checks for role based access for this dashboard. Checks for access to any panels in the dashboard and of the dashboard itself. This method should be overridden to return the result of any policy checks required for the user to access this dashboard when more complex checks are ...
Checks for role based access for this dashboard.
def allowed(self, context): """Checks for role based access for this dashboard. Checks for access to any panels in the dashboard and of the dashboard itself. This method should be overridden to return the result of any policy checks required for the user to access this dashboar...
[ "def", "allowed", "(", "self", ",", "context", ")", ":", "# if the dashboard has policy rules, honor those above individual", "# panels", "if", "not", "self", ".", "_can_access", "(", "context", "[", "'request'", "]", ")", ":", "return", "False", "# check if access is...
[ 659, 4 ]
[ 681, 20 ]
python
en
['en', 'en', 'en']
True
Site.register
(self, dashboard)
Registers a :class:`~horizon.Dashboard` with Horizon.
Registers a :class:`~horizon.Dashboard` with Horizon.
def register(self, dashboard): """Registers a :class:`~horizon.Dashboard` with Horizon.""" return self._register(dashboard)
[ "def", "register", "(", "self", ",", "dashboard", ")", ":", "return", "self", ".", "_register", "(", "dashboard", ")" ]
[ 736, 4 ]
[ 738, 40 ]
python
en
['en', 'en', 'en']
True
Site.unregister
(self, dashboard)
Unregisters a :class:`~horizon.Dashboard` from Horizon.
Unregisters a :class:`~horizon.Dashboard` from Horizon.
def unregister(self, dashboard): """Unregisters a :class:`~horizon.Dashboard` from Horizon.""" return self._unregister(dashboard)
[ "def", "unregister", "(", "self", ",", "dashboard", ")", ":", "return", "self", ".", "_unregister", "(", "dashboard", ")" ]
[ 740, 4 ]
[ 742, 42 ]
python
en
['en', 'en', 'en']
True
Site.get_dashboard
(self, dashboard)
Returns the specified :class:`~horizon.Dashboard` instance.
Returns the specified :class:`~horizon.Dashboard` instance.
def get_dashboard(self, dashboard): """Returns the specified :class:`~horizon.Dashboard` instance.""" return self._registered(dashboard)
[ "def", "get_dashboard", "(", "self", ",", "dashboard", ")", ":", "return", "self", ".", "_registered", "(", "dashboard", ")" ]
[ 758, 4 ]
[ 760, 42 ]
python
en
['en', 'en', 'en']
True
Site.get_dashboards
(self)
Returns an ordered tuple of :class:`~horizon.Dashboard` modules. Orders dashboards according to the ``"dashboards"`` key in ``HORIZON_CONFIG`` or else returns all registered dashboards in alphabetical order. Any remaining :class:`~horizon.Dashboard` classes registered with Hori...
Returns an ordered tuple of :class:`~horizon.Dashboard` modules.
def get_dashboards(self): """Returns an ordered tuple of :class:`~horizon.Dashboard` modules. Orders dashboards according to the ``"dashboards"`` key in ``HORIZON_CONFIG`` or else returns all registered dashboards in alphabetical order. Any remaining :class:`~horizon.Dashboard`...
[ "def", "get_dashboards", "(", "self", ")", ":", "if", "self", ".", "dashboards", ":", "registered", "=", "copy", ".", "copy", "(", "self", ".", "_registry", ")", "dashboards", "=", "[", "]", "for", "item", "in", "self", ".", "dashboards", ":", "dashboa...
[ 762, 4 ]
[ 785, 50 ]
python
en
['en', 'en', 'en']
True
Site.get_default_dashboard
(self)
Returns the default :class:`~horizon.Dashboard` instance. If ``"default_dashboard"`` is specified in ``HORIZON_CONFIG`` then that dashboard will be returned. If not, the first dashboard returned by :func:`~horizon.get_dashboards` will be returned.
Returns the default :class:`~horizon.Dashboard` instance.
def get_default_dashboard(self): """Returns the default :class:`~horizon.Dashboard` instance. If ``"default_dashboard"`` is specified in ``HORIZON_CONFIG`` then that dashboard will be returned. If not, the first dashboard returned by :func:`~horizon.get_dashboards` will be returned. ...
[ "def", "get_default_dashboard", "(", "self", ")", ":", "if", "self", ".", "default_dashboard", ":", "return", "self", ".", "_registered", "(", "self", ".", "default_dashboard", ")", "elif", "self", ".", "_registry", ":", "return", "self", ".", "get_dashboards"...
[ 787, 4 ]
[ 799, 77 ]
python
en
['en', 'lb', 'en']
True
Site.get_user_home
(self, user)
Returns the default URL for a particular user. This method can be used to customize where a user is sent when they log in, etc. By default it returns the value of :meth:`get_absolute_url`. An alternative function can be supplied to customize this behavior by specifying a either...
Returns the default URL for a particular user.
def get_user_home(self, user): """Returns the default URL for a particular user. This method can be used to customize where a user is sent when they log in, etc. By default it returns the value of :meth:`get_absolute_url`. An alternative function can be supplied to customize th...
[ "def", "get_user_home", "(", "self", ",", "user", ")", ":", "user_home", "=", "self", ".", "_conf", "[", "'user_home'", "]", "if", "user_home", ":", "if", "callable", "(", "user_home", ")", ":", "return", "user_home", "(", "user", ")", "elif", "isinstanc...
[ 801, 4 ]
[ 837, 42 ]
python
en
['en', 'en', 'en']
True
Site.get_absolute_url
(self)
Returns the default URL for Horizon's URLconf. The default URL is determined by calling :meth:`~horizon.Dashboard.get_absolute_url` on the :class:`~horizon.Dashboard` instance returned by :meth:`~horizon.get_default_dashboard`.
Returns the default URL for Horizon's URLconf.
def get_absolute_url(self): """Returns the default URL for Horizon's URLconf. The default URL is determined by calling :meth:`~horizon.Dashboard.get_absolute_url` on the :class:`~horizon.Dashboard` instance returned by :meth:`~horizon.get_default_dashboard`. """ ...
[ "def", "get_absolute_url", "(", "self", ")", ":", "return", "self", ".", "get_default_dashboard", "(", ")", ".", "get_absolute_url", "(", ")" ]
[ 839, 4 ]
[ 847, 62 ]
python
en
['en', 'no', 'en']
True
Site._lazy_urls
(self)
Lazy loading for URL patterns. This method avoids problems associated with attempting to evaluate the URLconf before the settings module has been loaded.
Lazy loading for URL patterns.
def _lazy_urls(self): """Lazy loading for URL patterns. This method avoids problems associated with attempting to evaluate the URLconf before the settings module has been loaded. """ def url_patterns(): return self._urls()[0] return LazyURLPattern(url_patter...
[ "def", "_lazy_urls", "(", "self", ")", ":", "def", "url_patterns", "(", ")", ":", "return", "self", ".", "_urls", "(", ")", "[", "0", "]", "return", "LazyURLPattern", "(", "url_patterns", ")", ",", "self", ".", "namespace", ",", "self", ".", "slug" ]
[ 850, 4 ]
[ 859, 70 ]
python
en
['pl', 'en', 'en']
True
Site._urls
(self)
Constructs the URLconf for Horizon from registered Dashboards.
Constructs the URLconf for Horizon from registered Dashboards.
def _urls(self): """Constructs the URLconf for Horizon from registered Dashboards.""" urlpatterns = self._get_default_urlpatterns() self._autodiscover() # Discover each dashboard's panels. for dash in self._registry.values(): dash._autodiscover() # Load the ...
[ "def", "_urls", "(", "self", ")", ":", "urlpatterns", "=", "self", ".", "_get_default_urlpatterns", "(", ")", "self", ".", "_autodiscover", "(", ")", "# Discover each dashboard's panels.", "for", "dash", "in", "self", ".", "_registry", ".", "values", "(", ")",...
[ 861, 4 ]
[ 894, 53 ]
python
en
['en', 'en', 'en']
True
Site._autodiscover
(self)
Discovers modules to register from ``settings.INSTALLED_APPS``. This makes sure that the appropriate modules get imported to register themselves with Horizon.
Discovers modules to register from ``settings.INSTALLED_APPS``.
def _autodiscover(self): """Discovers modules to register from ``settings.INSTALLED_APPS``. This makes sure that the appropriate modules get imported to register themselves with Horizon. """ if not getattr(self, '_registerable_class', None): raise ImproperlyConfigure...
[ "def", "_autodiscover", "(", "self", ")", ":", "if", "not", "getattr", "(", "self", ",", "'_registerable_class'", ",", "None", ")", ":", "raise", "ImproperlyConfigured", "(", "'You must set a '", "'\"_registerable_class\" property '", "'in order to use autodiscovery.'", ...
[ 896, 4 ]
[ 916, 29 ]
python
en
['en', 'en', 'en']
True
Site._load_panel_customization
(self)
Applies the plugin-based panel configurations. This method parses the panel customization from the ``HORIZON_CONFIG`` and make changes to the dashboard accordingly. It supports adding, removing and setting default panels on the dashboard. It also support registering a panel group. ...
Applies the plugin-based panel configurations.
def _load_panel_customization(self): """Applies the plugin-based panel configurations. This method parses the panel customization from the ``HORIZON_CONFIG`` and make changes to the dashboard accordingly. It supports adding, removing and setting default panels on the dashboard....
[ "def", "_load_panel_customization", "(", "self", ")", ":", "panel_customization", "=", "self", ".", "_conf", ".", "get", "(", "\"panel_customization\"", ",", "[", "]", ")", "# Process all the panel groups first so that they exist before panels", "# are added to them and Dashb...
[ 918, 4 ]
[ 943, 53 ]
python
en
['en', 'en', 'en']
True
Site._process_panel_configuration
(self, config)
Add, remove and set default panels on the dashboard.
Add, remove and set default panels on the dashboard.
def _process_panel_configuration(self, config): """Add, remove and set default panels on the dashboard.""" try: dashboard = config.get('PANEL_DASHBOARD') if not dashboard: LOG.warning("Skipping %s because it doesn't have " "PANEL_DASHBO...
[ "def", "_process_panel_configuration", "(", "self", ",", "config", ")", ":", "try", ":", "dashboard", "=", "config", ".", "get", "(", "'PANEL_DASHBOARD'", ")", "if", "not", "dashboard", ":", "LOG", ".", "warning", "(", "\"Skipping %s because it doesn't have \"", ...
[ 945, 4 ]
[ 996, 56 ]
python
en
['en', 'en', 'en']
True
Site._process_panel_group_configuration
(self, config)
Adds a panel group to the dashboard.
Adds a panel group to the dashboard.
def _process_panel_group_configuration(self, config): """Adds a panel group to the dashboard.""" panel_group_slug = config.get('PANEL_GROUP') try: dashboard = config.get('PANEL_GROUP_DASHBOARD') if not dashboard: LOG.warning("Skipping %s because it doesn't...
[ "def", "_process_panel_group_configuration", "(", "self", ",", "config", ")", ":", "panel_group_slug", "=", "config", ".", "get", "(", "'PANEL_GROUP'", ")", "try", ":", "dashboard", "=", "config", ".", "get", "(", "'PANEL_GROUP_DASHBOARD'", ")", "if", "not", "...
[ 998, 4 ]
[ 1030, 68 ]
python
en
['en', 'en', 'en']
True
html_escape
(text)
Produce entities within text.
Produce entities within text.
def html_escape(text): """Produce entities within text.""" return "".join(html_escape_table.get(c,c) for c in text)
[ "def", "html_escape", "(", "text", ")", ":", "return", "\"\"", ".", "join", "(", "html_escape_table", ".", "get", "(", "c", ",", "c", ")", "for", "c", "in", "text", ")" ]
[ 52, 0 ]
[ 54, 60 ]
python
en
['en', 'en', 'en']
True
FieldFactory.register_field_cls
(cls, field_class, base_classes=None)
Register new field class. Add new field class and remove all base classes from the set of registered classes as they should not be in.
Register new field class.
def register_field_cls(cls, field_class, base_classes=None): """Register new field class. Add new field class and remove all base classes from the set of registered classes as they should not be in. """ cls.FORM_FIELDS_TYPES.add(field_class) cls.FORM_FIELDS_TYPES -= set(...
[ "def", "register_field_cls", "(", "cls", ",", "field_class", ",", "base_classes", "=", "None", ")", ":", "cls", ".", "FORM_FIELDS_TYPES", ".", "add", "(", "field_class", ")", "cls", ".", "FORM_FIELDS_TYPES", "-=", "set", "(", "base_classes", ")" ]
[ 44, 4 ]
[ 51, 50 ]
python
en
['en', 'mt', 'en']
True
FormRegion.set_field_values
(self, data)
Set fields values data - {field_name: field_value, field_name: field_value ...}
Set fields values
def set_field_values(self, data): """Set fields values data - {field_name: field_value, field_name: field_value ...} """ for field_name in data: field = getattr(self, field_name, None) # Field form does not exist if field is None: rais...
[ "def", "set_field_values", "(", "self", ",", "data", ")", ":", "for", "field_name", "in", "data", ":", "field", "=", "getattr", "(", "self", ",", "field_name", ",", "None", ")", "# Field form does not exist", "if", "field", "is", "None", ":", "raise", "Att...
[ 364, 4 ]
[ 385, 39 ]
python
en
['en', 'fy', 'en']
True
FormRegion.header
(self)
Form header.
Form header.
def header(self): """Form header.""" return self._get_element(*self._header_locator)
[ "def", "header", "(", "self", ")", ":", "return", "self", ".", "_get_element", "(", "*", "self", ".", "_header_locator", ")" ]
[ 389, 4 ]
[ 391, 55 ]
python
en
['en', 'sv', 'en']
False
FormRegion.sideinfo
(self)
Right part of form, usually contains description.
Right part of form, usually contains description.
def sideinfo(self): """Right part of form, usually contains description.""" return self._get_element(*self._side_info_locator)
[ "def", "sideinfo", "(", "self", ")", ":", "return", "self", ".", "_get_element", "(", "*", "self", ".", "_side_info_locator", ")" ]
[ 394, 4 ]
[ 396, 58 ]
python
en
['en', 'en', 'en']
True
FormRegion.fields
(self)
List of all fields that form contains.
List of all fields that form contains.
def fields(self): """List of all fields that form contains.""" return self._get_form_fields()
[ "def", "fields", "(", "self", ")", ":", "return", "self", ".", "_get_form_fields", "(", ")" ]
[ 399, 4 ]
[ 401, 38 ]
python
en
['en', 'en', 'en']
True
safe_get
(q, timeout=1e6, msg='Queue timeout')
Using queue.get() with timeout is necessary, otherwise KeyboardInterrupt is not handled.
Using queue.get() with timeout is necessary, otherwise KeyboardInterrupt is not handled.
def safe_get(q, timeout=1e6, msg='Queue timeout'): """Using queue.get() with timeout is necessary, otherwise KeyboardInterrupt is not handled.""" while True: try: return q.get(timeout=timeout) except Empty: log.warning(msg)
[ "def", "safe_get", "(", "q", ",", "timeout", "=", "1e6", ",", "msg", "=", "'Queue timeout'", ")", ":", "while", "True", ":", "try", ":", "return", "q", ".", "get", "(", "timeout", "=", "timeout", ")", "except", "Empty", ":", "log", ".", "warning", ...
[ 48, 0 ]
[ 54, 28 ]
python
en
['en', 'en', 'en']
True
MultiAgentEnvWorker._get_info
(env)
Specific to custom VizDoom environments.
Specific to custom VizDoom environments.
def _get_info(env): """Specific to custom VizDoom environments.""" info = {} if hasattr(env.unwrapped, 'get_info_all'): info = env.unwrapped.get_info_all() # info for the new episode return info
[ "def", "_get_info", "(", "env", ")", ":", "info", "=", "{", "}", "if", "hasattr", "(", "env", ".", "unwrapped", ",", "'get_info_all'", ")", ":", "info", "=", "env", ".", "unwrapped", ".", "get_info_all", "(", ")", "# info for the new episode", "return", ...
[ 117, 4 ]
[ 122, 19 ]
python
en
['en', 'sr', 'en']
True
MultiAgentEnvWorker._set_env_attr
(self, env, player_id, attr_chain, value)
Allows us to set an arbitrary attribute of the environment, e.g. attr_chain can be unwrapped.foo.bar
Allows us to set an arbitrary attribute of the environment, e.g. attr_chain can be unwrapped.foo.bar
def _set_env_attr(self, env, player_id, attr_chain, value): """Allows us to set an arbitrary attribute of the environment, e.g. attr_chain can be unwrapped.foo.bar""" assert player_id == self.player_id attrs = attr_chain.split('.') curr_attr = env try: for attr_name ...
[ "def", "_set_env_attr", "(", "self", ",", "env", ",", "player_id", ",", "attr_chain", ",", "value", ")", ":", "assert", "player_id", "==", "self", ".", "player_id", "attrs", "=", "attr_chain", ".", "split", "(", "'.'", ")", "curr_attr", "=", "env", "try"...
[ 124, 4 ]
[ 137, 46 ]
python
en
['en', 'en', 'en']
True
MultiAgentEnv.await_tasks
(self, data, task_type, timeout=None)
Task result is always a tuple of lists, e.g.: ( [0th_agent_obs, 1st_agent_obs, ... ], [0th_agent_reward, 1st_agent_reward, ... ], ... ) If your "task" returns only one result per agent (e.g. reset() returns only the observation), the result w...
Task result is always a tuple of lists, e.g.: ( [0th_agent_obs, 1st_agent_obs, ... ], [0th_agent_reward, 1st_agent_reward, ... ], ... )
def await_tasks(self, data, task_type, timeout=None): """ Task result is always a tuple of lists, e.g.: ( [0th_agent_obs, 1st_agent_obs, ... ], [0th_agent_reward, 1st_agent_reward, ... ], ... ) If your "task" returns only one result per agent ...
[ "def", "await_tasks", "(", "self", ",", "data", ",", "task_type", ",", "timeout", "=", "None", ")", ":", "if", "data", "is", "None", ":", "data", "=", "[", "None", "]", "*", "self", ".", "num_agents", "assert", "len", "(", "data", ")", "==", "self"...
[ 224, 4 ]
[ 262, 27 ]
python
en
['en', 'error', 'th']
False
MultiAgentEnv.seed
(self, seed=None)
Does not really make sense for the wrapper. Individual envs will be uniquely seeded on init.
Does not really make sense for the wrapper. Individual envs will be uniquely seeded on init.
def seed(self, seed=None): """Does not really make sense for the wrapper. Individual envs will be uniquely seeded on init.""" pass
[ "def", "seed", "(", "self", ",", "seed", "=", "None", ")", ":", "pass" ]
[ 363, 4 ]
[ 365, 12 ]
python
en
['en', 'en', 'en']
True
_key_chord_distribution
(chord_pitch_out_of_key_prob)
Probability distribution over chords for each key.
Probability distribution over chords for each key.
def _key_chord_distribution(chord_pitch_out_of_key_prob): """Probability distribution over chords for each key.""" num_pitches_in_key = np.zeros([12, len(_CHORDS)], dtype=np.int32) num_pitches_out_of_key = np.zeros([12, len(_CHORDS)], dtype=np.int32) # For each key and chord, compute the number of chord notes ...
[ "def", "_key_chord_distribution", "(", "chord_pitch_out_of_key_prob", ")", ":", "num_pitches_in_key", "=", "np", ".", "zeros", "(", "[", "12", ",", "len", "(", "_CHORDS", ")", "]", ",", "dtype", "=", "np", ".", "int32", ")", "num_pitches_out_of_key", "=", "n...
[ 66, 0 ]
[ 87, 12 ]
python
en
['en', 'en', 'en']
True
_key_chord_transition_distribution
( key_chord_distribution, key_change_prob, chord_change_prob)
Transition distribution between key-chord pairs.
Transition distribution between key-chord pairs.
def _key_chord_transition_distribution( key_chord_distribution, key_change_prob, chord_change_prob): """Transition distribution between key-chord pairs.""" mat = np.zeros([len(_KEY_CHORDS), len(_KEY_CHORDS)]) for i, key_chord_1 in enumerate(_KEY_CHORDS): key_1, chord_1 = key_chord_1 chord_index_1 = i...
[ "def", "_key_chord_transition_distribution", "(", "key_chord_distribution", ",", "key_change_prob", ",", "chord_change_prob", ")", ":", "mat", "=", "np", ".", "zeros", "(", "[", "len", "(", "_KEY_CHORDS", ")", ",", "len", "(", "_KEY_CHORDS", ")", "]", ")", "fo...
[ 90, 0 ]
[ 125, 12 ]
python
en
['nl', 'en', 'en']
True
_chord_pitch_vectors
()
Unit vectors over pitch classes for all chords.
Unit vectors over pitch classes for all chords.
def _chord_pitch_vectors(): """Unit vectors over pitch classes for all chords.""" x = np.zeros([len(_CHORDS), 12]) for i, chord in enumerate(_CHORDS[1:]): root, kind = chord for offset in _CHORD_KIND_PITCHES[kind]: x[i + 1, (root + offset) % 12] = 1 x[1:, :] /= np.linalg.norm(x[1:, :], axis=1)[:, ...
[ "def", "_chord_pitch_vectors", "(", ")", ":", "x", "=", "np", ".", "zeros", "(", "[", "len", "(", "_CHORDS", ")", ",", "12", "]", ")", "for", "i", ",", "chord", "in", "enumerate", "(", "_CHORDS", "[", "1", ":", "]", ")", ":", "root", ",", "kind...
[ 128, 0 ]
[ 136, 10 ]
python
en
['en', 'en', 'en']
True
sequence_note_pitch_vectors
(sequence, seconds_per_frame)
Compute pitch class vectors for temporal frames across a sequence. Args: sequence: The NoteSequence for which to compute pitch class vectors. seconds_per_frame: The size of the frame corresponding to each pitch class vector, in seconds. Alternatively, a list of frame boundary times in seconds...
Compute pitch class vectors for temporal frames across a sequence.
def sequence_note_pitch_vectors(sequence, seconds_per_frame): """Compute pitch class vectors for temporal frames across a sequence. Args: sequence: The NoteSequence for which to compute pitch class vectors. seconds_per_frame: The size of the frame corresponding to each pitch class vector, in second...
[ "def", "sequence_note_pitch_vectors", "(", "sequence", ",", "seconds_per_frame", ")", ":", "if", "isinstance", "(", "seconds_per_frame", ",", "numbers", ".", "Number", ")", ":", "# Construct array of frame boundary times.", "num_frames", "=", "int", "(", "math", ".", ...
[ 139, 0 ]
[ 187, 10 ]
python
en
['en', 'en', 'en']
True
_chord_frame_log_likelihood
(note_pitch_vectors, chord_note_concentration)
Log-likelihood of observing each frame of note pitches under each chord.
Log-likelihood of observing each frame of note pitches under each chord.
def _chord_frame_log_likelihood(note_pitch_vectors, chord_note_concentration): """Log-likelihood of observing each frame of note pitches under each chord.""" return chord_note_concentration * np.dot(note_pitch_vectors, _chord_pitch_vectors().T)
[ "def", "_chord_frame_log_likelihood", "(", "note_pitch_vectors", ",", "chord_note_concentration", ")", ":", "return", "chord_note_concentration", "*", "np", ".", "dot", "(", "note_pitch_vectors", ",", "_chord_pitch_vectors", "(", ")", ".", "T", ")" ]
[ 190, 0 ]
[ 193, 68 ]
python
en
['en', 'en', 'en']
True
_key_chord_viterbi
(chord_frame_loglik, key_chord_loglik, key_chord_transition_loglik)
Use the Viterbi algorithm to infer a sequence of key-chord pairs.
Use the Viterbi algorithm to infer a sequence of key-chord pairs.
def _key_chord_viterbi(chord_frame_loglik, key_chord_loglik, key_chord_transition_loglik): """Use the Viterbi algorithm to infer a sequence of key-chord pairs.""" num_frames, num_chords = chord_frame_loglik.shape num_key_chords = len(key_chord_transition_loglik) lo...
[ "def", "_key_chord_viterbi", "(", "chord_frame_loglik", ",", "key_chord_loglik", ",", "key_chord_transition_loglik", ")", ":", "num_frames", ",", "num_chords", "=", "chord_frame_loglik", ".", "shape", "num_key_chords", "=", "len", "(", "key_chord_transition_loglik", ")", ...
[ 196, 0 ]
[ 232, 34 ]
python
en
['en', 'en', 'en']
True
infer_chords_for_sequence
(sequence, chords_per_bar=None, key_change_prob=0.001, chord_change_prob=0.5, chord_pitch_out_of_key_prob=0.01, chord_note_concentration=100.0, ...
Infer chords for a NoteSequence using the Viterbi algorithm. This uses some heuristics to infer chords for a quantized NoteSequence. At each chord position a key and chord will be inferred, and the chords will be added (as text annotations) to the sequence. If the sequence is quantized relative to meter, a fi...
Infer chords for a NoteSequence using the Viterbi algorithm.
def infer_chords_for_sequence(sequence, chords_per_bar=None, key_change_prob=0.001, chord_change_prob=0.5, chord_pitch_out_of_key_prob=0.01, chord_note_concentration=100....
[ "def", "infer_chords_for_sequence", "(", "sequence", ",", "chords_per_bar", "=", "None", ",", "key_change_prob", "=", "0.001", ",", "chord_change_prob", "=", "0.5", ",", "chord_pitch_out_of_key_prob", "=", "0.01", ",", "chord_note_concentration", "=", "100.0", ",", ...
[ 259, 0 ]
[ 437, 33 ]
python
en
['en', 'en', 'en']
True
PitchChordsEncoderDecoder.events_to_input
(self, events, position)
Returns the input vector for the given position in the chord progression. Indices [0, 36]: [0]: Whether or not this chord is "no chord". [1, 12]: A one-hot encoding of the chord root pitch class. [13, 24]: Whether or not each pitch class is present in the chord. [25, 36]: A one-hot encoding of the ...
Returns the input vector for the given position in the chord progression.
def events_to_input(self, events, position): """Returns the input vector for the given position in the chord progression. Indices [0, 36]: [0]: Whether or not this chord is "no chord". [1, 12]: A one-hot encoding of the chord root pitch class. [13, 24]: Whether or not each pitch class is present in...
[ "def", "events_to_input", "(", "self", ",", "events", ",", "position", ")", ":", "chord", "=", "events", "[", "position", "]", "input_", "=", "[", "0.0", "]", "*", "self", ".", "input_size", "if", "chord", "==", "NO_CHORD", ":", "input_", "[", "0", "...
[ 158, 2 ]
[ 191, 17 ]
python
en
['en', 'en', 'en']
True
unpack
(path, dest='.')
Unpack a wheel. Wheel content will be unpacked to {dest}/{name}-{ver}, where {name} is the package name and {ver} its version. :param path: The path to the wheel. :param dest: Destination directory (default to current directory).
Unpack a wheel.
def unpack(path, dest='.'): """Unpack a wheel. Wheel content will be unpacked to {dest}/{name}-{ver}, where {name} is the package name and {ver} its version. :param path: The path to the wheel. :param dest: Destination directory (default to current directory). """ with WheelFile(path) as w...
[ "def", "unpack", "(", "path", ",", "dest", "=", "'.'", ")", ":", "with", "WheelFile", "(", "path", ")", "as", "wf", ":", "namever", "=", "wf", ".", "parsed_filename", ".", "group", "(", "'namever'", ")", "destination", "=", "os", ".", "path", ".", ...
[ 8, 0 ]
[ 24, 15 ]
python
en
['en', 'gd', 'en']
True
install_lib.get_exclusions
(self)
Return a collections.Sized collections.Container of paths to be excluded for single_version_externally_managed installations.
Return a collections.Sized collections.Container of paths to be excluded for single_version_externally_managed installations.
def get_exclusions(self): """ Return a collections.Sized collections.Container of paths to be excluded for single_version_externally_managed installations. """ all_packages = ( pkg for ns_pkg in self._get_SVEM_NSPs() for pkg in self._all_packag...
[ "def", "get_exclusions", "(", "self", ")", ":", "all_packages", "=", "(", "pkg", "for", "ns_pkg", "in", "self", ".", "_get_SVEM_NSPs", "(", ")", "for", "pkg", "in", "self", ".", "_all_packages", "(", "ns_pkg", ")", ")", "excl_specs", "=", "product", "(",...
[ 16, 4 ]
[ 28, 63 ]
python
en
['en', 'error', 'th']
False
install_lib._exclude_pkg_path
(self, pkg, exclusion_path)
Given a package name and exclusion path within that package, compute the full exclusion path.
Given a package name and exclusion path within that package, compute the full exclusion path.
def _exclude_pkg_path(self, pkg, exclusion_path): """ Given a package name and exclusion path within that package, compute the full exclusion path. """ parts = pkg.split('.') + [exclusion_path] return os.path.join(self.install_dir, *parts)
[ "def", "_exclude_pkg_path", "(", "self", ",", "pkg", ",", "exclusion_path", ")", ":", "parts", "=", "pkg", ".", "split", "(", "'.'", ")", "+", "[", "exclusion_path", "]", "return", "os", ".", "path", ".", "join", "(", "self", ".", "install_dir", ",", ...
[ 30, 4 ]
[ 36, 53 ]
python
en
['en', 'error', 'th']
False
install_lib._all_packages
(pkg_name)
>>> list(install_lib._all_packages('foo.bar.baz')) ['foo.bar.baz', 'foo.bar', 'foo']
>>> list(install_lib._all_packages('foo.bar.baz')) ['foo.bar.baz', 'foo.bar', 'foo']
def _all_packages(pkg_name): """ >>> list(install_lib._all_packages('foo.bar.baz')) ['foo.bar.baz', 'foo.bar', 'foo'] """ while pkg_name: yield pkg_name pkg_name, sep, child = pkg_name.rpartition('.')
[ "def", "_all_packages", "(", "pkg_name", ")", ":", "while", "pkg_name", ":", "yield", "pkg_name", "pkg_name", ",", "sep", ",", "child", "=", "pkg_name", ".", "rpartition", "(", "'.'", ")" ]
[ 39, 4 ]
[ 46, 59 ]
python
en
['en', 'error', 'th']
False
install_lib._get_SVEM_NSPs
(self)
Get namespace packages (list) but only for single_version_externally_managed installations and empty otherwise.
Get namespace packages (list) but only for single_version_externally_managed installations and empty otherwise.
def _get_SVEM_NSPs(self): """ Get namespace packages (list) but only for single_version_externally_managed installations and empty otherwise. """ # TODO: is it necessary to short-circuit here? i.e. what's the cost # if get_finalized_command is called even when namespace_p...
[ "def", "_get_SVEM_NSPs", "(", "self", ")", ":", "# TODO: is it necessary to short-circuit here? i.e. what's the cost", "# if get_finalized_command is called even when namespace_packages is", "# False?", "if", "not", "self", ".", "distribution", ".", "namespace_packages", ":", "retu...
[ 48, 4 ]
[ 62, 67 ]
python
en
['en', 'error', 'th']
False
install_lib._gen_exclusion_paths
()
Generate file paths to be excluded for namespace packages (bytecode cache files).
Generate file paths to be excluded for namespace packages (bytecode cache files).
def _gen_exclusion_paths(): """ Generate file paths to be excluded for namespace packages (bytecode cache files). """ # always exclude the package module itself yield '__init__.py' yield '__init__.pyc' yield '__init__.pyo' if not hasattr(sys, 'im...
[ "def", "_gen_exclusion_paths", "(", ")", ":", "# always exclude the package module itself", "yield", "'__init__.py'", "yield", "'__init__.pyc'", "yield", "'__init__.pyo'", "if", "not", "hasattr", "(", "sys", ",", "'implementation'", ")", ":", "return", "base", "=", "o...
[ 65, 4 ]
[ 84, 33 ]
python
en
['en', 'error', 'th']
False
bufsize
(w, h, bits, indexed=False)
this function determines required buffer size depending on the color depth
this function determines required buffer size depending on the color depth
def bufsize(w, h, bits, indexed=False): """this function determines required buffer size depending on the color depth""" size = (w * bits // 8 + 1) * h if indexed: # + 4 bytes per palette color size += 4 * (2**bits) return size
[ "def", "bufsize", "(", "w", ",", "h", ",", "bits", ",", "indexed", "=", "False", ")", ":", "size", "=", "(", "w", "*", "bits", "//", "8", "+", "1", ")", "*", "h", "if", "indexed", ":", "# + 4 bytes per palette color", "size", "+=", "4", "*", "(",...
[ 5, 0 ]
[ 12, 15 ]
python
en
['en', 'en', 'en']
True
truncate_if_required
(explanation, item, max_length=None)
Truncate this assertion explanation if the given test item is eligible.
Truncate this assertion explanation if the given test item is eligible.
def truncate_if_required(explanation, item, max_length=None): """ Truncate this assertion explanation if the given test item is eligible. """ if _should_truncate_item(item): return _truncate_explanation(explanation) return explanation
[ "def", "truncate_if_required", "(", "explanation", ",", "item", ",", "max_length", "=", "None", ")", ":", "if", "_should_truncate_item", "(", "item", ")", ":", "return", "_truncate_explanation", "(", "explanation", ")", "return", "explanation" ]
[ 17, 0 ]
[ 23, 22 ]
python
en
['en', 'error', 'th']
False
_should_truncate_item
(item)
Whether or not this test item is eligible for truncation.
Whether or not this test item is eligible for truncation.
def _should_truncate_item(item): """ Whether or not this test item is eligible for truncation. """ verbose = item.config.option.verbose return verbose < 2 and not _running_on_ci()
[ "def", "_should_truncate_item", "(", "item", ")", ":", "verbose", "=", "item", ".", "config", ".", "option", ".", "verbose", "return", "verbose", "<", "2", "and", "not", "_running_on_ci", "(", ")" ]
[ 26, 0 ]
[ 31, 47 ]
python
en
['en', 'error', 'th']
False
_running_on_ci
()
Check if we're currently running on a CI system.
Check if we're currently running on a CI system.
def _running_on_ci(): """Check if we're currently running on a CI system.""" env_vars = ['CI', 'BUILD_NUMBER'] return any(var in os.environ for var in env_vars)
[ "def", "_running_on_ci", "(", ")", ":", "env_vars", "=", "[", "'CI'", ",", "'BUILD_NUMBER'", "]", "return", "any", "(", "var", "in", "os", ".", "environ", "for", "var", "in", "env_vars", ")" ]
[ 34, 0 ]
[ 37, 53 ]
python
en
['en', 'en', 'en']
True
_truncate_explanation
(input_lines, max_lines=None, max_chars=None)
Truncate given list of strings that makes up the assertion explanation. Truncates to either 8 lines, or 640 characters - whichever the input reaches first. The remaining lines will be replaced by a usage message.
Truncate given list of strings that makes up the assertion explanation.
def _truncate_explanation(input_lines, max_lines=None, max_chars=None): """ Truncate given list of strings that makes up the assertion explanation. Truncates to either 8 lines, or 640 characters - whichever the input reaches first. The remaining lines will be replaced by a usage message. """ i...
[ "def", "_truncate_explanation", "(", "input_lines", ",", "max_lines", "=", "None", ",", "max_chars", "=", "None", ")", ":", "if", "max_lines", "is", "None", ":", "max_lines", "=", "DEFAULT_MAX_LINES", "if", "max_chars", "is", "None", ":", "max_chars", "=", "...
[ 40, 0 ]
[ 79, 32 ]
python
en
['en', 'error', 'th']
False
run_shell_command
(shell_cmd, cmd_dir=None)
Run a single shell command. @returns a tuple of shell command return code, stdout, stderr
Run a single shell command.
def run_shell_command(shell_cmd, cmd_dir=None): """ Run a single shell command. @returns a tuple of shell command return code, stdout, stderr """ if cmd_dir is not None and not os.path.exists(cmd_dir): run_shell_command("mkdir -p %s" % cmd_dir) start = time.time() print("\t>>> Running:...
[ "def", "run_shell_command", "(", "shell_cmd", ",", "cmd_dir", "=", "None", ")", ":", "if", "cmd_dir", "is", "not", "None", "and", "not", "os", ".", "path", ".", "exists", "(", "cmd_dir", ")", ":", "run_shell_command", "(", "\"mkdir -p %s\"", "%", "cmd_dir"...
[ 58, 0 ]
[ 83, 39 ]
python
cy
['cy', 'ny', 'en']
False
run_shell_commands
(shell_cmds, cmd_dir=None, verbose=False)
Execute a sequence of shell commands, which is equivalent to running `cmd1 && cmd2 && cmd3` @returns boolean indication if all commands succeeds.
Execute a sequence of shell commands, which is equivalent to running `cmd1 && cmd2 && cmd3`
def run_shell_commands(shell_cmds, cmd_dir=None, verbose=False): """ Execute a sequence of shell commands, which is equivalent to running `cmd1 && cmd2 && cmd3` @returns boolean indication if all commands succeeds. """ if cmd_dir: print("\t=== Set current working directory => %s" % ...
[ "def", "run_shell_commands", "(", "shell_cmds", ",", "cmd_dir", "=", "None", ",", "verbose", "=", "False", ")", ":", "if", "cmd_dir", ":", "print", "(", "\"\\t=== Set current working directory => %s\"", "%", "cmd_dir", ")", "for", "shell_cmd", "in", "shell_cmds", ...
[ 86, 0 ]
[ 107, 15 ]
python
en
['en', 'en', 'en']
True
ReactionEmojiTest.test_missing_emoji
(self)
Sending reaction without emoji fails
Sending reaction without emoji fails
def test_missing_emoji(self) -> None: """ Sending reaction without emoji fails """ sender = self.example_user("hamlet") reaction_info = { "emoji_name": "", } result = self.api_post(sender, "/api/v1/messages/1/reactions", reaction_info) self.as...
[ "def", "test_missing_emoji", "(", "self", ")", "->", "None", ":", "sender", "=", "self", ".", "example_user", "(", "\"hamlet\"", ")", "reaction_info", "=", "{", "\"emoji_name\"", ":", "\"\"", ",", "}", "result", "=", "self", ".", "api_post", "(", "sender",...
[ 17, 4 ]
[ 27, 49 ]
python
en
['en', 'error', 'th']
False
ReactionEmojiTest.test_add_invalid_emoji
(self)
Sending invalid emoji fails
Sending invalid emoji fails
def test_add_invalid_emoji(self) -> None: """ Sending invalid emoji fails """ sender = self.example_user("hamlet") reaction_info = { "emoji_name": "foo", } result = self.api_post(sender, "/api/v1/messages/1/reactions", reaction_info) self.asse...
[ "def", "test_add_invalid_emoji", "(", "self", ")", "->", "None", ":", "sender", "=", "self", ".", "example_user", "(", "\"hamlet\"", ")", "reaction_info", "=", "{", "\"emoji_name\"", ":", "\"foo\"", ",", "}", "result", "=", "self", ".", "api_post", "(", "s...
[ 29, 4 ]
[ 39, 68 ]
python
en
['en', 'error', 'th']
False
ReactionEmojiTest.test_add_deactivated_realm_emoji
(self)
Sending deactivated realm emoji fails.
Sending deactivated realm emoji fails.
def test_add_deactivated_realm_emoji(self) -> None: """ Sending deactivated realm emoji fails. """ emoji = RealmEmoji.objects.get(name="green_tick") emoji.deactivated = True emoji.save(update_fields=["deactivated"]) sender = self.example_user("hamlet") rea...
[ "def", "test_add_deactivated_realm_emoji", "(", "self", ")", "->", "None", ":", "emoji", "=", "RealmEmoji", ".", "objects", ".", "get", "(", "name", "=", "\"green_tick\"", ")", "emoji", ".", "deactivated", "=", "True", "emoji", ".", "save", "(", "update_fiel...
[ 41, 4 ]
[ 55, 75 ]
python
en
['en', 'error', 'th']
False
ReactionEmojiTest.test_valid_emoji
(self)
Reacting with valid emoji succeeds
Reacting with valid emoji succeeds
def test_valid_emoji(self) -> None: """ Reacting with valid emoji succeeds """ sender = self.example_user("hamlet") reaction_info = { "emoji_name": "smile", } base_query = Reaction.objects.filter( user_profile=sender, message=M...
[ "def", "test_valid_emoji", "(", "self", ")", "->", "None", ":", "sender", "=", "self", ".", "example_user", "(", "\"hamlet\"", ")", "reaction_info", "=", "{", "\"emoji_name\"", ":", "\"smile\"", ",", "}", "base_query", "=", "Reaction", ".", "objects", ".", ...
[ 57, 4 ]
[ 79, 91 ]
python
en
['en', 'error', 'th']
False
ReactionEmojiTest.test_cached_reaction_data
(self)
Formatted reactions data is saved in cache.
Formatted reactions data is saved in cache.
def test_cached_reaction_data(self) -> None: """ Formatted reactions data is saved in cache. """ sender = self.example_user("hamlet") reaction_info = { "emoji_name": "smile", } result = self.api_post(sender, "/api/v1/messages/1/reactions", reaction_inf...
[ "def", "test_cached_reaction_data", "(", "self", ")", "->", "None", ":", "sender", "=", "self", ".", "example_user", "(", "\"hamlet\"", ")", "reaction_info", "=", "{", "\"emoji_name\"", ":", "\"smile\"", ",", "}", "result", "=", "self", ".", "api_post", "(",...
[ 81, 4 ]
[ 109, 70 ]
python
en
['en', 'error', 'th']
False
ReactionEmojiTest.test_zulip_emoji
(self)
Reacting with zulip emoji succeeds
Reacting with zulip emoji succeeds
def test_zulip_emoji(self) -> None: """ Reacting with zulip emoji succeeds """ sender = self.example_user("hamlet") reaction_info = { "emoji_name": "zulip", "reaction_type": "zulip_extra_emoji", } base_query = Reaction.objects.filter( ...
[ "def", "test_zulip_emoji", "(", "self", ")", "->", "None", ":", "sender", "=", "self", ".", "example_user", "(", "\"hamlet\"", ")", "reaction_info", "=", "{", "\"emoji_name\"", ":", "\"zulip\"", ",", "\"reaction_type\"", ":", "\"zulip_extra_emoji\"", ",", "}", ...
[ 111, 4 ]
[ 133, 86 ]
python
en
['en', 'error', 'th']
False
ReactionEmojiTest.test_valid_emoji_react_historical
(self)
Reacting with valid emoji on a historical message succeeds
Reacting with valid emoji on a historical message succeeds
def test_valid_emoji_react_historical(self) -> None: """ Reacting with valid emoji on a historical message succeeds """ stream_name = "Saxony" self.subscribe(self.example_user("cordelia"), stream_name) message_id = self.send_stream_message(self.example_user("cordelia"), s...
[ "def", "test_valid_emoji_react_historical", "(", "self", ")", "->", "None", ":", "stream_name", "=", "\"Saxony\"", "self", ".", "subscribe", "(", "self", ".", "example_user", "(", "\"cordelia\"", ")", ",", "stream_name", ")", "message_id", "=", "self", ".", "s...
[ 135, 4 ]
[ 163, 52 ]
python
en
['en', 'error', 'th']
False
ReactionEmojiTest.test_valid_realm_emoji
(self)
Reacting with valid realm emoji succeeds
Reacting with valid realm emoji succeeds
def test_valid_realm_emoji(self) -> None: """ Reacting with valid realm emoji succeeds """ sender = self.example_user("hamlet") reaction_info = { "emoji_name": "green_tick", "reaction_type": "realm_emoji", } result = self.api_post(sender,...
[ "def", "test_valid_realm_emoji", "(", "self", ")", "->", "None", ":", "sender", "=", "self", ".", "example_user", "(", "\"hamlet\"", ")", "reaction_info", "=", "{", "\"emoji_name\"", ":", "\"green_tick\"", ",", "\"reaction_type\"", ":", "\"realm_emoji\"", ",", "...
[ 165, 4 ]
[ 177, 40 ]
python
en
['en', 'error', 'th']
False
ReactionEmojiTest.test_emoji_name_to_emoji_code
(self)
An emoji name is mapped canonically to emoji code.
An emoji name is mapped canonically to emoji code.
def test_emoji_name_to_emoji_code(self) -> None: """ An emoji name is mapped canonically to emoji code. """ realm = get_realm("zulip") realm_emoji = RealmEmoji.objects.get(name="green_tick") # Test active realm emoji. emoji_code, reaction_type = emoji_name_to_emo...
[ "def", "test_emoji_name_to_emoji_code", "(", "self", ")", "->", "None", ":", "realm", "=", "get_realm", "(", "\"zulip\"", ")", "realm_emoji", "=", "RealmEmoji", ".", "objects", ".", "get", "(", "name", "=", "\"green_tick\"", ")", "# Test active realm emoji.", "e...
[ 179, 4 ]
[ 232, 84 ]
python
en
['en', 'error', 'th']
False
ReactionMessageIDTest.test_missing_message_id
(self)
Reacting without a message_id fails
Reacting without a message_id fails
def test_missing_message_id(self) -> None: """ Reacting without a message_id fails """ sender = self.example_user("hamlet") reaction_info = { "emoji_name": "smile", } result = self.api_post(sender, "/api/v1/messages//reactions", reaction_info) ...
[ "def", "test_missing_message_id", "(", "self", ")", "->", "None", ":", "sender", "=", "self", ".", "example_user", "(", "\"hamlet\"", ")", "reaction_info", "=", "{", "\"emoji_name\"", ":", "\"smile\"", ",", "}", "result", "=", "self", ".", "api_post", "(", ...
[ 236, 4 ]
[ 246, 49 ]
python
en
['en', 'error', 'th']
False
ReactionMessageIDTest.test_invalid_message_id
(self)
Reacting to an invalid message id fails
Reacting to an invalid message id fails
def test_invalid_message_id(self) -> None: """ Reacting to an invalid message id fails """ sender = self.example_user("hamlet") reaction_info = { "emoji_name": "smile", } result = self.api_post(sender, "/api/v1/messages/-1/reactions", reaction_info) ...
[ "def", "test_invalid_message_id", "(", "self", ")", "->", "None", ":", "sender", "=", "self", ".", "example_user", "(", "\"hamlet\"", ")", "reaction_info", "=", "{", "\"emoji_name\"", ":", "\"smile\"", ",", "}", "result", "=", "self", ".", "api_post", "(", ...
[ 248, 4 ]
[ 258, 49 ]
python
en
['en', 'error', 'th']
False
ReactionMessageIDTest.test_inaccessible_message_id
(self)
Reacting to a inaccessible (for instance, private) message fails
Reacting to a inaccessible (for instance, private) message fails
def test_inaccessible_message_id(self) -> None: """ Reacting to a inaccessible (for instance, private) message fails """ pm_sender = self.example_user("hamlet") pm_recipient = self.example_user("othello") reaction_sender = self.example_user("iago") result = self....
[ "def", "test_inaccessible_message_id", "(", "self", ")", "->", "None", ":", "pm_sender", "=", "self", ".", "example_user", "(", "\"hamlet\"", ")", "pm_recipient", "=", "self", ".", "example_user", "(", "\"othello\"", ")", "reaction_sender", "=", "self", ".", "...
[ 260, 4 ]
[ 282, 60 ]
python
en
['en', 'error', 'th']
False
ReactionTest.test_add_existing_reaction
(self)
Creating the same reaction twice fails
Creating the same reaction twice fails
def test_add_existing_reaction(self) -> None: """ Creating the same reaction twice fails """ pm_sender = self.example_user("hamlet") pm_recipient = self.example_user("othello") reaction_sender = pm_recipient pm = self.api_post( pm_sender, ...
[ "def", "test_add_existing_reaction", "(", "self", ")", "->", "None", ":", "pm_sender", "=", "self", ".", "example_user", "(", "\"hamlet\"", ")", "pm_recipient", "=", "self", ".", "example_user", "(", "\"othello\"", ")", "reaction_sender", "=", "pm_recipient", "p...
[ 286, 4 ]
[ 314, 66 ]
python
en
['en', 'error', 'th']
False
ReactionTest.test_remove_nonexisting_reaction
(self)
Removing a reaction twice fails
Removing a reaction twice fails
def test_remove_nonexisting_reaction(self) -> None: """ Removing a reaction twice fails """ pm_sender = self.example_user("hamlet") pm_recipient = self.example_user("othello") reaction_sender = pm_recipient pm = self.api_post( pm_sender, "...
[ "def", "test_remove_nonexisting_reaction", "(", "self", ")", "->", "None", ":", "pm_sender", "=", "self", ".", "example_user", "(", "\"hamlet\"", ")", "pm_recipient", "=", "self", ".", "example_user", "(", "\"othello\"", ")", "reaction_sender", "=", "pm_recipient"...
[ 316, 4 ]
[ 348, 65 ]
python
en
['en', 'error', 'th']
False
ReactionTest.test_remove_existing_reaction_with_renamed_emoji
(self)
Removes an old existing reaction but the name of emoji got changed during various emoji infra changes.
Removes an old existing reaction but the name of emoji got changed during various emoji infra changes.
def test_remove_existing_reaction_with_renamed_emoji(self) -> None: """ Removes an old existing reaction but the name of emoji got changed during various emoji infra changes. """ realm = get_realm("zulip") sender = self.example_user("hamlet") emoji_code, reaction_...
[ "def", "test_remove_existing_reaction_with_renamed_emoji", "(", "self", ")", "->", "None", ":", "realm", "=", "get_realm", "(", "\"zulip\"", ")", "sender", "=", "self", ".", "example_user", "(", "\"hamlet\"", ")", "emoji_code", ",", "reaction_type", "=", "emoji_na...
[ 350, 4 ]
[ 369, 44 ]
python
en
['en', 'error', 'th']
False
ReactionTest.test_remove_existing_reaction_with_deactivated_realm_emoji
(self)
Removes an old existing reaction but the realm emoji used there has been deactivated.
Removes an old existing reaction but the realm emoji used there has been deactivated.
def test_remove_existing_reaction_with_deactivated_realm_emoji(self) -> None: """ Removes an old existing reaction but the realm emoji used there has been deactivated. """ sender = self.example_user("hamlet") emoji = RealmEmoji.objects.get(name="green_tick") reaction_in...
[ "def", "test_remove_existing_reaction_with_deactivated_realm_emoji", "(", "self", ")", "->", "None", ":", "sender", "=", "self", ".", "example_user", "(", "\"hamlet\"", ")", "emoji", "=", "RealmEmoji", ".", "objects", ".", "get", "(", "name", "=", "\"green_tick\""...
[ 371, 4 ]
[ 392, 40 ]
python
en
['en', 'error', 'th']
False
ReactionEventTest.test_add_event
(self)
Recipients of the message receive the reaction event and event contains relevant data
Recipients of the message receive the reaction event and event contains relevant data
def test_add_event(self) -> None: """ Recipients of the message receive the reaction event and event contains relevant data """ pm_sender = self.example_user("hamlet") pm_recipient = self.example_user("othello") reaction_sender = pm_recipient result = sel...
[ "def", "test_add_event", "(", "self", ")", "->", "None", ":", "pm_sender", "=", "self", ".", "example_user", "(", "\"hamlet\"", ")", "pm_recipient", "=", "self", ".", "example_user", "(", "\"othello\"", ")", "reaction_sender", "=", "pm_recipient", "result", "=...
[ 396, 4 ]
[ 435, 52 ]
python
en
['en', 'error', 'th']
False
ReactionEventTest.test_remove_event
(self)
Recipients of the message receive the reaction event and event contains relevant data
Recipients of the message receive the reaction event and event contains relevant data
def test_remove_event(self) -> None: """ Recipients of the message receive the reaction event and event contains relevant data """ pm_sender = self.example_user("hamlet") pm_recipient = self.example_user("othello") reaction_sender = pm_recipient result = ...
[ "def", "test_remove_event", "(", "self", ")", "->", "None", ":", "pm_sender", "=", "self", ".", "example_user", "(", "\"hamlet\"", ")", "pm_recipient", "=", "self", ".", "example_user", "(", "\"othello\"", ")", "reaction_sender", "=", "pm_recipient", "result", ...
[ 437, 4 ]
[ 480, 52 ]
python
en
['en', 'error', 'th']
False
DefaultEmojiReactionTests.test_react_historical
(self)
Reacting with valid emoji on a historical message succeeds.
Reacting with valid emoji on a historical message succeeds.
def test_react_historical(self) -> None: """ Reacting with valid emoji on a historical message succeeds. """ stream_name = "Saxony" self.subscribe(self.example_user("cordelia"), stream_name) message_id = self.send_stream_message(self.example_user("cordelia"), stream_name)...
[ "def", "test_react_historical", "(", "self", ")", "->", "None", ":", "stream_name", "=", "\"Saxony\"", "self", ".", "subscribe", "(", "self", ".", "example_user", "(", "\"cordelia\"", ")", ",", "stream_name", ")", "message_id", "=", "self", ".", "send_stream_m...
[ 848, 4 ]
[ 879, 52 ]
python
en
['en', 'error', 'th']
False
ReactionAPIEventTest.test_add_event
(self)
Recipients of the message receive the reaction event and event contains relevant data
Recipients of the message receive the reaction event and event contains relevant data
def test_add_event(self) -> None: """ Recipients of the message receive the reaction event and event contains relevant data """ pm_sender = self.example_user("hamlet") pm_recipient = self.example_user("othello") reaction_sender = pm_recipient pm_id = self....
[ "def", "test_add_event", "(", "self", ")", "->", "None", ":", "pm_sender", "=", "self", ".", "example_user", "(", "\"hamlet\"", ")", "pm_recipient", "=", "self", ".", "example_user", "(", "\"othello\"", ")", "reaction_sender", "=", "pm_recipient", "pm_id", "="...
[ 1021, 4 ]
[ 1054, 80 ]
python
en
['en', 'error', 'th']
False
ReactionAPIEventTest.test_remove_event
(self)
Recipients of the message receive the reaction event and event contains relevant data
Recipients of the message receive the reaction event and event contains relevant data
def test_remove_event(self) -> None: """ Recipients of the message receive the reaction event and event contains relevant data """ pm_sender = self.example_user("hamlet") pm_recipient = self.example_user("othello") reaction_sender = pm_recipient pm_id = se...
[ "def", "test_remove_event", "(", "self", ")", "->", "None", ":", "pm_sender", "=", "self", ".", "example_user", "(", "\"hamlet\"", ")", "pm_recipient", "=", "self", ".", "example_user", "(", "\"othello\"", ")", "reaction_sender", "=", "pm_recipient", "pm_id", ...
[ 1056, 4 ]
[ 1101, 80 ]
python
en
['en', 'error', 'th']
False
deprecated
(reason, replacement, gone_in, issue=None)
Helper to deprecate existing functionality. reason: Textual reason shown to the user about why this functionality has been deprecated. replacement: Textual suggestion shown to the user about what alternative functionality they can use. gone_in: The version of pip doe...
Helper to deprecate existing functionality.
def deprecated(reason, replacement, gone_in, issue=None): # type: (str, Optional[str], Optional[str], Optional[int]) -> None """Helper to deprecate existing functionality. reason: Textual reason shown to the user about why this functionality has been deprecated. replacement: Tex...
[ "def", "deprecated", "(", "reason", ",", "replacement", ",", "gone_in", ",", "issue", "=", "None", ")", ":", "# type: (str, Optional[str], Optional[str], Optional[int]) -> None", "# Construct a nice message.", "# This is eagerly formatted as we want it to get logged as if someone",...
[ 61, 0 ]
[ 103, 72 ]
python
en
['it', 'en', 'en']
True
get_environment_marker_support_level
()
Tests how well setuptools supports PEP-426 environment marker. The first known release to support it is 0.7 (and the earliest on PyPI seems to be 0.7.2 so we're using that), see: https://setuptools.readthedocs.io/en/latest/history.html#id350 The support is later enhanced to allow direct conditional i...
Tests how well setuptools supports PEP-426 environment marker.
def get_environment_marker_support_level(): """ Tests how well setuptools supports PEP-426 environment marker. The first known release to support it is 0.7 (and the earliest on PyPI seems to be 0.7.2 so we're using that), see: https://setuptools.readthedocs.io/en/latest/history.html#id350 The supp...
[ "def", "get_environment_marker_support_level", "(", ")", ":", "try", ":", "version", "=", "pkg_resources", ".", "parse_version", "(", "setuptools", ".", "__version__", ")", "if", "version", ">=", "pkg_resources", ".", "parse_version", "(", "'36.2.2'", ")", ":", ...
[ 25, 0 ]
[ 52, 12 ]
python
en
['en', 'error', 'th']
False
copy2_fixed
(src, dest)
Wrap shutil.copy2() but map errors copying socket files to SpecialFileError as expected. See also https://bugs.python.org/issue37700.
Wrap shutil.copy2() but map errors copying socket files to SpecialFileError as expected.
def copy2_fixed(src, dest): # type: (str, str) -> None """Wrap shutil.copy2() but map errors copying socket files to SpecialFileError as expected. See also https://bugs.python.org/issue37700. """ try: shutil.copy2(src, dest) except (OSError, IOError): for f in [src, dest]: ...
[ "def", "copy2_fixed", "(", "src", ",", "dest", ")", ":", "# type: (str, str) -> None", "try", ":", "shutil", ".", "copy2", "(", "src", ",", "dest", ")", "except", "(", "OSError", ",", "IOError", ")", ":", "for", "f", "in", "[", "src", ",", "dest", "]...
[ 58, 0 ]
[ 80, 13 ]
python
en
['en', 'en', 'en']
True
adjacent_tmp_file
(path, **kwargs)
Return a file-like object pointing to a tmp file next to path. The file is created securely and is ensured to be written to disk after the context reaches its end. kwargs will be passed to tempfile.NamedTemporaryFile to control the way the temporary file will be opened.
Return a file-like object pointing to a tmp file next to path.
def adjacent_tmp_file(path, **kwargs): # type: (str, **Any) -> Iterator[NamedTemporaryFileResult] """Return a file-like object pointing to a tmp file next to path. The file is created securely and is ensured to be written to disk after the context reaches its end. kwargs will be passed to tempfile...
[ "def", "adjacent_tmp_file", "(", "path", ",", "*", "*", "kwargs", ")", ":", "# type: (str, **Any) -> Iterator[NamedTemporaryFileResult]", "with", "NamedTemporaryFile", "(", "delete", "=", "False", ",", "dir", "=", "os", ".", "path", ".", "dirname", "(", "path", ...
[ 89, 0 ]
[ 111, 42 ]
python
en
['en', 'en', 'en']
True
test_writable_dir
(path)
Check if a directory is writable. Uses os.access() on POSIX, tries creating files on Windows.
Check if a directory is writable.
def test_writable_dir(path): # type: (str) -> bool """Check if a directory is writable. Uses os.access() on POSIX, tries creating files on Windows. """ # If the directory doesn't exist, find the closest parent that does. while not os.path.isdir(path): parent = os.path.dirname(path) ...
[ "def", "test_writable_dir", "(", "path", ")", ":", "# type: (str) -> bool", "# If the directory doesn't exist, find the closest parent that does.", "while", "not", "os", ".", "path", ".", "isdir", "(", "path", ")", ":", "parent", "=", "os", ".", "path", ".", "dirnam...
[ 132, 0 ]
[ 148, 39 ]
python
en
['en', 'en', 'en']
True
find_files
(path, pattern)
Returns a list of absolute paths of files beneath path, recursively, with filenames which match the UNIX-style shell glob pattern.
Returns a list of absolute paths of files beneath path, recursively, with filenames which match the UNIX-style shell glob pattern.
def find_files(path, pattern): # type: (str, str) -> List[str] """Returns a list of absolute paths of files beneath path, recursively, with filenames which match the UNIX-style shell glob pattern.""" result = [] # type: List[str] for root, _, files in os.walk(path): matches = fnmatch.filter...
[ "def", "find_files", "(", "path", ",", "pattern", ")", ":", "# type: (str, str) -> List[str]", "result", "=", "[", "]", "# type: List[str]", "for", "root", ",", "_", ",", "files", "in", "os", ".", "walk", "(", "path", ")", ":", "matches", "=", "fnmatch", ...
[ 187, 0 ]
[ 195, 17 ]
python
en
['en', 'en', 'en']
True
exists
(path)
Test whether a path exists. Returns False for broken symbolic links
Test whether a path exists. Returns False for broken symbolic links
def exists(path): """Test whether a path exists. Returns False for broken symbolic links""" try: os.stat(path) except OSError: return False return True
[ "def", "exists", "(", "path", ")", ":", "try", ":", "os", ".", "stat", "(", "path", ")", "except", "OSError", ":", "return", "False", "return", "True" ]
[ 15, 0 ]
[ 21, 15 ]
python
en
['en', 'en', 'en']
True
isfile
(path)
Test whether a path is a regular file
Test whether a path is a regular file
def isfile(path): """Test whether a path is a regular file""" try: st = os.stat(path) except OSError: return False return stat.S_ISREG(st.st_mode)
[ "def", "isfile", "(", "path", ")", ":", "try", ":", "st", "=", "os", ".", "stat", "(", "path", ")", "except", "OSError", ":", "return", "False", "return", "stat", ".", "S_ISREG", "(", "st", ".", "st_mode", ")" ]
[ 26, 0 ]
[ 32, 35 ]
python
en
['en', 'en', 'en']
True
isdir
(s)
Return true if the pathname refers to an existing directory.
Return true if the pathname refers to an existing directory.
def isdir(s): """Return true if the pathname refers to an existing directory.""" try: st = os.stat(s) except OSError: return False return stat.S_ISDIR(st.st_mode)
[ "def", "isdir", "(", "s", ")", ":", "try", ":", "st", "=", "os", ".", "stat", "(", "s", ")", "except", "OSError", ":", "return", "False", "return", "stat", ".", "S_ISDIR", "(", "st", ".", "st_mode", ")" ]
[ 38, 0 ]
[ 44, 35 ]
python
en
['en', 'en', 'en']
True
getsize
(filename)
Return the size of a file, reported by os.stat().
Return the size of a file, reported by os.stat().
def getsize(filename): """Return the size of a file, reported by os.stat().""" return os.stat(filename).st_size
[ "def", "getsize", "(", "filename", ")", ":", "return", "os", ".", "stat", "(", "filename", ")", ".", "st_size" ]
[ 47, 0 ]
[ 49, 36 ]
python
en
['en', 'en', 'en']
True
getmtime
(filename)
Return the last modification time of a file, reported by os.stat().
Return the last modification time of a file, reported by os.stat().
def getmtime(filename): """Return the last modification time of a file, reported by os.stat().""" return os.stat(filename).st_mtime
[ "def", "getmtime", "(", "filename", ")", ":", "return", "os", ".", "stat", "(", "filename", ")", ".", "st_mtime" ]
[ 52, 0 ]
[ 54, 37 ]
python
en
['en', 'en', 'en']
True
getatime
(filename)
Return the last access time of a file, reported by os.stat().
Return the last access time of a file, reported by os.stat().
def getatime(filename): """Return the last access time of a file, reported by os.stat().""" return os.stat(filename).st_atime
[ "def", "getatime", "(", "filename", ")", ":", "return", "os", ".", "stat", "(", "filename", ")", ".", "st_atime" ]
[ 57, 0 ]
[ 59, 37 ]
python
en
['en', 'en', 'en']
True
getctime
(filename)
Return the metadata change time of a file, reported by os.stat().
Return the metadata change time of a file, reported by os.stat().
def getctime(filename): """Return the metadata change time of a file, reported by os.stat().""" return os.stat(filename).st_ctime
[ "def", "getctime", "(", "filename", ")", ":", "return", "os", ".", "stat", "(", "filename", ")", ".", "st_ctime" ]
[ 62, 0 ]
[ 64, 37 ]
python
en
['en', 'en', 'en']
True
commonprefix
(m)
Given a list of pathnames, returns the longest common leading component
Given a list of pathnames, returns the longest common leading component
def commonprefix(m): "Given a list of pathnames, returns the longest common leading component" if not m: return '' # Some people pass in a list of pathname parts to operate in an OS-agnostic # fashion; don't try to translate in that case as that's an abuse of the # API and they are already doing wha...
[ "def", "commonprefix", "(", "m", ")", ":", "if", "not", "m", ":", "return", "''", "# Some people pass in a list of pathname parts to operate in an OS-agnostic", "# fashion; don't try to translate in that case as that's an abuse of the", "# API and they are already doing what they need to...
[ 68, 0 ]
[ 82, 13 ]
python
en
['en', 'en', 'en']
True
samestat
(s1, s2)
Test whether two stat buffers reference the same file
Test whether two stat buffers reference the same file
def samestat(s1, s2): """Test whether two stat buffers reference the same file""" return (s1.st_ino == s2.st_ino and s1.st_dev == s2.st_dev)
[ "def", "samestat", "(", "s1", ",", "s2", ")", ":", "return", "(", "s1", ".", "st_ino", "==", "s2", ".", "st_ino", "and", "s1", ".", "st_dev", "==", "s2", ".", "st_dev", ")" ]
[ 86, 0 ]
[ 89, 35 ]
python
en
['en', 'en', 'en']
True
samefile
(f1, f2)
Test whether two pathnames reference the same actual file
Test whether two pathnames reference the same actual file
def samefile(f1, f2): """Test whether two pathnames reference the same actual file""" s1 = os.stat(f1) s2 = os.stat(f2) return samestat(s1, s2)
[ "def", "samefile", "(", "f1", ",", "f2", ")", ":", "s1", "=", "os", ".", "stat", "(", "f1", ")", "s2", "=", "os", ".", "stat", "(", "f2", ")", "return", "samestat", "(", "s1", ",", "s2", ")" ]
[ 93, 0 ]
[ 97, 27 ]
python
en
['en', 'en', 'en']
True
sameopenfile
(fp1, fp2)
Test whether two open file objects reference the same file
Test whether two open file objects reference the same file
def sameopenfile(fp1, fp2): """Test whether two open file objects reference the same file""" s1 = os.fstat(fp1) s2 = os.fstat(fp2) return samestat(s1, s2)
[ "def", "sameopenfile", "(", "fp1", ",", "fp2", ")", ":", "s1", "=", "os", ".", "fstat", "(", "fp1", ")", "s2", "=", "os", ".", "fstat", "(", "fp2", ")", "return", "samestat", "(", "s1", ",", "s2", ")" ]
[ 102, 0 ]
[ 106, 27 ]
python
en
['en', 'en', 'en']
True
_splitext
(p, sep, altsep, extsep)
Split the extension from a pathname. Extension is everything from the last dot to the end, ignoring leading dots. Returns "(root, ext)"; ext may be empty.
Split the extension from a pathname.
def _splitext(p, sep, altsep, extsep): """Split the extension from a pathname. Extension is everything from the last dot to the end, ignoring leading dots. Returns "(root, ext)"; ext may be empty.""" # NOTE: This code must work for text and bytes strings. sepIndex = p.rfind(sep) if altsep: ...
[ "def", "_splitext", "(", "p", ",", "sep", ",", "altsep", ",", "extsep", ")", ":", "# NOTE: This code must work for text and bytes strings.", "sepIndex", "=", "p", ".", "rfind", "(", "sep", ")", "if", "altsep", ":", "altsepIndex", "=", "p", ".", "rfind", "(",...
[ 116, 0 ]
[ 137, 19 ]
python
en
['en', 'en', 'en']
True
MultiDrumOneHotEncoding.__init__
(self, drum_type_pitches=None, ignore_unknown_drums=True)
Initializes the MultiDrumOneHotEncoding. Args: drum_type_pitches: A Python list of the MIDI pitch values for each drum type. If None, `DEFAULT_DRUM_TYPE_PITCHES` will be used. ignore_unknown_drums: If True, unknown drum pitches will not be encoded. If False, a DrumsEncodingError wil...
Initializes the MultiDrumOneHotEncoding.
def __init__(self, drum_type_pitches=None, ignore_unknown_drums=True): """Initializes the MultiDrumOneHotEncoding. Args: drum_type_pitches: A Python list of the MIDI pitch values for each drum type. If None, `DEFAULT_DRUM_TYPE_PITCHES` will be used. ignore_unknown_drums: If True, unknown ...
[ "def", "__init__", "(", "self", ",", "drum_type_pitches", "=", "None", ",", "ignore_unknown_drums", "=", "True", ")", ":", "if", "drum_type_pitches", "is", "None", ":", "drum_type_pitches", "=", "DEFAULT_DRUM_TYPE_PITCHES", "self", ".", "_drum_map", "=", "dict", ...
[ 69, 2 ]
[ 85, 53 ]
python
en
['en', 'zu', 'en']
True
FencedCodeExtension.extendMarkdown
(self, md, md_globals)
Add FencedBlockPreprocessor to the Markdown instance.
Add FencedBlockPreprocessor to the Markdown instance.
def extendMarkdown(self, md, md_globals): """ Add FencedBlockPreprocessor to the Markdown instance. """ md.preprocessors.add('fenced_code_block', FencedBlockPreprocessor(md), "_begin")
[ "def", "extendMarkdown", "(", "self", ",", "md", ",", "md_globals", ")", ":", "md", ".", "preprocessors", ".", "add", "(", "'fenced_code_block'", ",", "FencedBlockPreprocessor", "(", "md", ")", ",", "\"_begin\"", ")" ]
[ 75, 4 ]
[ 80, 42 ]
python
en
['en', 'it', 'en']
True
FencedBlockPreprocessor.run
(self, lines)
Match and store Fenced Code Blocks in the HtmlStash.
Match and store Fenced Code Blocks in the HtmlStash.
def run(self, lines): """ Match and store Fenced Code Blocks in the HtmlStash. """ text = "\n".join(lines) while 1: m = FENCED_BLOCK_RE.search(text) if m: lang = '' if m.group('lang'): lang = LANG_TAG % m.group('lang') ...
[ "def", "run", "(", "self", ",", "lines", ")", ":", "text", "=", "\"\\n\"", ".", "join", "(", "lines", ")", "while", "1", ":", "m", "=", "FENCED_BLOCK_RE", ".", "search", "(", "text", ")", "if", "m", ":", "lang", "=", "''", "if", "m", ".", "grou...
[ 85, 4 ]
[ 99, 31 ]
python
en
['en', 'en', 'en']
True
FencedBlockPreprocessor._escape
(self, txt)
basic html escaping
basic html escaping
def _escape(self, txt): """ basic html escaping """ txt = txt.replace('&', '&amp;') txt = txt.replace('<', '&lt;') txt = txt.replace('>', '&gt;') txt = txt.replace('"', '&quot;') return txt
[ "def", "_escape", "(", "self", ",", "txt", ")", ":", "txt", "=", "txt", ".", "replace", "(", "'&'", ",", "'&amp;'", ")", "txt", "=", "txt", ".", "replace", "(", "'<'", ",", "'&lt;'", ")", "txt", "=", "txt", ".", "replace", "(", "'>'", ",", "'&g...
[ 101, 4 ]
[ 107, 18 ]
python
en
['es', 'en', 'en']
True
UptimeRobotHookTests.test_uptimerobot_monitor_down
(self)
Tests if uptimerobot monitor down is handled correctly
Tests if uptimerobot monitor down is handled correctly
def test_uptimerobot_monitor_down(self) -> None: """ Tests if uptimerobot monitor down is handled correctly """ expected_topic = "Web Server" expected_message = "Web Server (server1.example.com) is DOWN (Host Is Unreachable)." self.check_webhook("uptimerobot_monitor_down"...
[ "def", "test_uptimerobot_monitor_down", "(", "self", ")", "->", "None", ":", "expected_topic", "=", "\"Web Server\"", "expected_message", "=", "\"Web Server (server1.example.com) is DOWN (Host Is Unreachable).\"", "self", ".", "check_webhook", "(", "\"uptimerobot_monitor_down\"",...
[ 11, 4 ]
[ 17, 88 ]
python
en
['en', 'error', 'th']
False
UptimeRobotHookTests.test_uptimerobot_monitor_up
(self)
Tests if uptimerobot monitor up is handled correctly
Tests if uptimerobot monitor up is handled correctly
def test_uptimerobot_monitor_up(self) -> None: """ Tests if uptimerobot monitor up is handled correctly """ expected_topic = "Mail Server" expected_message = """ Mail Server (server2.example.com) is back UP (Host Is Reachable). It was down for 44 minutes and 37 seconds. """.strip...
[ "def", "test_uptimerobot_monitor_up", "(", "self", ")", "->", "None", ":", "expected_topic", "=", "\"Mail Server\"", "expected_message", "=", "\"\"\"\nMail Server (server2.example.com) is back UP (Host Is Reachable).\nIt was down for 44 minutes and 37 seconds.\n\"\"\"", ".", "strip", ...
[ 19, 4 ]
[ 28, 86 ]
python
en
['en', 'error', 'th']
False
UptimeRobotHookTests.test_uptimerobot_invalid_payload_with_missing_data
(self)
Tests if invalid uptime robot payloads are handled correctly
Tests if invalid uptime robot payloads are handled correctly
def test_uptimerobot_invalid_payload_with_missing_data(self) -> None: """ Tests if invalid uptime robot payloads are handled correctly """ self.url = self.build_webhook_url() payload = self.get_body("uptimerobot_invalid_payload_with_missing_data") result = self.client_pos...
[ "def", "test_uptimerobot_invalid_payload_with_missing_data", "(", "self", ")", "->", "None", ":", "self", ".", "url", "=", "self", ".", "build_webhook_url", "(", ")", "payload", "=", "self", ".", "get_body", "(", "\"uptimerobot_invalid_payload_with_missing_data\"", ")...
[ 30, 4 ]
[ 46, 64 ]
python
en
['en', 'error', 'th']
False
BaseView.__init__
(self)
Create BaseView object.
Create BaseView object.
def __init__(self): """Create BaseView object.""" pass
[ "def", "__init__", "(", "self", ")", ":", "pass" ]
[ 28, 4 ]
[ 30, 12 ]
python
en
['en', 'en', 'en']
True
BaseView.standard_params
(self, base_css, creation_date, hyperlinks)
Create dictionary of jinja id: HTML content pairs. Every view in hyperlinks keys is appended with file suffix as defined in the HTML template. Args: base_css (str): address of base css file creation_date (date): creation date of HTML hyperlinks (dict): 'view name': ...
Create dictionary of jinja id: HTML content pairs.
def standard_params(self, base_css, creation_date, hyperlinks): """Create dictionary of jinja id: HTML content pairs. Every view in hyperlinks keys is appended with file suffix as defined in the HTML template. Args: base_css (str): address of base css file creation_date...
[ "def", "standard_params", "(", "self", ",", "base_css", ",", "creation_date", ",", "hyperlinks", ")", ":", "output", "=", "{", "self", ".", "_base_css", ":", "base_css", ",", "self", ".", "_creation_date", ":", "creation_date", "}", "for", "view", ",", "pa...
[ 32, 4 ]
[ 53, 21 ]
python
en
['en', 'en', 'en']
True
Overview.__init__
(self, template, css_path, feature_description_class)
Create Overview object. Overrides __init__ from BaseView. Calls BaseView __init__ method. Args: template (jinja2.Template): loaded HTML template css_path (str): file path to Overview specific CSS file that will be included in HTML feature_description_class (str): HT...
Create Overview object. Overrides __init__ from BaseView.
def __init__(self, template, css_path, feature_description_class): """Create Overview object. Overrides __init__ from BaseView. Calls BaseView __init__ method. Args: template (jinja2.Template): loaded HTML template css_path (str): file path to Overview specific CSS file...
[ "def", "__init__", "(", "self", ",", "template", ",", "css_path", ",", "feature_description_class", ")", ":", "super", "(", ")", ".", "__init__", "(", ")", "self", ".", "template", "=", "template", "self", ".", "css", "=", "css_path", "self", ".", "featu...
[ 95, 4 ]
[ 109, 76 ]
python
en
['en', 'en', 'en']
True
Overview.render
(self, base_css, # base template params creation_date, hyperlinks, numerical_df, # main elements of the View categorical_df, unused_features, head_df, do_pairplot_flag, pairplot_path,...
Create HTML from loaded template and with provided arguments. Dict of 'jinja id': content pairs is created, fed into render method of provided template and returned. Standard params are obtained from BaseView. Link to the Pairplot might be included or not, depending on provided do_pairplot_flag...
Create HTML from loaded template and with provided arguments.
def render(self, base_css, # base template params creation_date, hyperlinks, numerical_df, # main elements of the View categorical_df, unused_features, head_df, do_pairplot_flag, pair...
[ "def", "render", "(", "self", ",", "base_css", ",", "# base template params", "creation_date", ",", "hyperlinks", ",", "numerical_df", ",", "# main elements of the View", "categorical_df", ",", "unused_features", ",", "head_df", ",", "do_pairplot_flag", ",", "pairplot_p...
[ 111, 4 ]
[ 172, 45 ]
python
en
['en', 'en', 'en']
True
Overview._tables
(self, numerical_df, categorical_df, head_df, mapping, descriptions)
Create dict of 'jinja ids': rendered tables HTML. Tables are stylized similarly and descriptions are appended whenever possible. If a given table is None, placeholder text is put in it's place. Args: numerical_df (pandas.DataFrame, None): 'describe' DataFrame of Numerical features ...
Create dict of 'jinja ids': rendered tables HTML.
def _tables(self, numerical_df, categorical_df, head_df, mapping, descriptions): """Create dict of 'jinja ids': rendered tables HTML. Tables are stylized similarly and descriptions are appended whenever possible. If a given table is None, placeholder text is put in it's place. Args: ...
[ "def", "_tables", "(", "self", ",", "numerical_df", ",", "categorical_df", ",", "head_df", ",", "mapping", ",", "descriptions", ")", ":", "output", "=", "{", "}", "tables_ids", "=", "[", "self", ".", "_numerical_table", ",", "self", ".", "_categorical_table"...
[ 174, 4 ]
[ 203, 21 ]
python
en
['en', 'en', 'en']
True