body stringlengths 26 98.2k | body_hash int64 -9,222,864,604,528,158,000 9,221,803,474B | docstring stringlengths 1 16.8k | path stringlengths 5 230 | name stringlengths 1 96 | repository_name stringlengths 7 89 | lang stringclasses 1
value | body_without_docstring stringlengths 20 98.2k |
|---|---|---|---|---|---|---|---|
def plot_filter(h, sfreq, freq=None, gain=None, title=None, color='#1f77b4', flim=None, fscale='log', alim=_DEFAULT_ALIM, show=True, compensate=False, plot=('time', 'magnitude', 'delay'), axes=None):
'Plot properties of a filter.\n\n Parameters\n ----------\n h : dict or ndarray\n An IIR dict or 1D ... | -8,341,377,506,035,980,000 | Plot properties of a filter.
Parameters
----------
h : dict or ndarray
An IIR dict or 1D ndarray of coefficients (for FIR filter).
sfreq : float
Sample rate of the data (Hz).
freq : array-like or None
The ideal response frequencies to plot (must be in ascending order).
If None (default), do not plot th... | mne/viz/misc.py | plot_filter | Aniket-Pradhan/mne-python | python | def plot_filter(h, sfreq, freq=None, gain=None, title=None, color='#1f77b4', flim=None, fscale='log', alim=_DEFAULT_ALIM, show=True, compensate=False, plot=('time', 'magnitude', 'delay'), axes=None):
'Plot properties of a filter.\n\n Parameters\n ----------\n h : dict or ndarray\n An IIR dict or 1D ... |
def plot_ideal_filter(freq, gain, axes=None, title='', flim=None, fscale='log', alim=_DEFAULT_ALIM, color='r', alpha=0.5, linestyle='--', show=True):
'Plot an ideal filter response.\n\n Parameters\n ----------\n freq : array-like\n The ideal response frequencies to plot (must be in ascending order).... | 1,679,440,645,691,839,700 | Plot an ideal filter response.
Parameters
----------
freq : array-like
The ideal response frequencies to plot (must be in ascending order).
gain : array-like or None
The ideal response gains to plot.
axes : instance of Axes | None
The subplot handle. With None (default), axes are created.
title : str
T... | mne/viz/misc.py | plot_ideal_filter | Aniket-Pradhan/mne-python | python | def plot_ideal_filter(freq, gain, axes=None, title=, flim=None, fscale='log', alim=_DEFAULT_ALIM, color='r', alpha=0.5, linestyle='--', show=True):
'Plot an ideal filter response.\n\n Parameters\n ----------\n freq : array-like\n The ideal response frequencies to plot (must be in ascending order).\n... |
def _handle_event_colors(color_dict, unique_events, event_id):
'Create event-integer-to-color mapping, assigning defaults as needed.'
default_colors = dict(zip(sorted(unique_events), cycle(_get_color_list())))
if (color_dict is None):
if (len(unique_events) > len(_get_color_list())):
war... | 2,246,880,496,342,512,400 | Create event-integer-to-color mapping, assigning defaults as needed. | mne/viz/misc.py | _handle_event_colors | Aniket-Pradhan/mne-python | python | def _handle_event_colors(color_dict, unique_events, event_id):
default_colors = dict(zip(sorted(unique_events), cycle(_get_color_list())))
if (color_dict is None):
if (len(unique_events) > len(_get_color_list())):
warn('More events than default colors available. You should pass a list o... |
def plot_csd(csd, info=None, mode='csd', colorbar=True, cmap=None, n_cols=None, show=True):
"Plot CSD matrices.\n\n A sub-plot is created for each frequency. If an info object is passed to\n the function, different channel types are plotted in different figures.\n\n Parameters\n ----------\n csd : in... | -1,834,918,576,187,389,200 | Plot CSD matrices.
A sub-plot is created for each frequency. If an info object is passed to
the function, different channel types are plotted in different figures.
Parameters
----------
csd : instance of CrossSpectralDensity
The CSD matrix to plot.
info : instance of Info | None
To split the figure by channel... | mne/viz/misc.py | plot_csd | Aniket-Pradhan/mne-python | python | def plot_csd(csd, info=None, mode='csd', colorbar=True, cmap=None, n_cols=None, show=True):
"Plot CSD matrices.\n\n A sub-plot is created for each frequency. If an info object is passed to\n the function, different channel types are plotted in different figures.\n\n Parameters\n ----------\n csd : in... |
def close(self):
'Stops to collect replies from its task.'
self.set_exception(TaskClosed)
self.collector.remove_result(self) | 576,972,578,691,620,700 | Stops to collect replies from its task. | zeronimo/results.py | close | sublee/zeronimo | python | def close(self):
self.set_exception(TaskClosed)
self.collector.remove_result(self) |
def set_remote_exception(self, remote_exc_info):
'Raises an exception as a :exc:`RemoteException`.'
(exc_type, exc_str, filename, lineno) = remote_exc_info[:4]
exc_type = RemoteException.compose(exc_type)
exc = exc_type(exc_str, filename, lineno, self.worker_info)
if (len(remote_exc_info) > 4):
... | -8,435,482,650,142,885,000 | Raises an exception as a :exc:`RemoteException`. | zeronimo/results.py | set_remote_exception | sublee/zeronimo | python | def set_remote_exception(self, remote_exc_info):
(exc_type, exc_str, filename, lineno) = remote_exc_info[:4]
exc_type = RemoteException.compose(exc_type)
exc = exc_type(exc_str, filename, lineno, self.worker_info)
if (len(remote_exc_info) > 4):
state = remote_exc_info[4]
exc.__setst... |
def parseKeyValueData(astr):
"Parses a string of the form:\n 'keyword1=value11, value12,...; keyword2=value21, value22; keyword3=; keyword4; ...'\n returning an opscore.RO.Alg.OrderedDict of the form:\n {keyword1:(value11, value12,...), keyword2:(value21, value22, ...),\n keyword3: (), keyw... | -1,682,904,546,708,252,200 | Parses a string of the form:
'keyword1=value11, value12,...; keyword2=value21, value22; keyword3=; keyword4; ...'
returning an opscore.RO.Alg.OrderedDict of the form:
{keyword1:(value11, value12,...), keyword2:(value21, value22, ...),
keyword3: (), keyword4: (), ...}
Inputs:
- astr: the string to parse, o... | python/opscore/RO/ParseMsg/ParseData.py | parseKeyValueData | sdss/opscore | python | def parseKeyValueData(astr):
"Parses a string of the form:\n 'keyword1=value11, value12,...; keyword2=value21, value22; keyword3=; keyword4; ...'\n returning an opscore.RO.Alg.OrderedDict of the form:\n {keyword1:(value11, value12,...), keyword2:(value21, value22, ...),\n keyword3: (), keyw... |
def multi_gpu_test(model, data_loader, tmpdir=None, gpu_collect=False):
"Test model with multiple gpus.\n\n This method tests model with multiple gpus and collects the results\n under two different modes: gpu and cpu modes. By setting 'gpu_collect=True'\n it encodes results to gpu tensors and use gpu commu... | -1,266,325,845,621,321,200 | Test model with multiple gpus.
This method tests model with multiple gpus and collects the results
under two different modes: gpu and cpu modes. By setting 'gpu_collect=True'
it encodes results to gpu tensors and use gpu communication for results
collection. On cpu mode it saves the results on different gpus to 'tmpdi... | mmdetection/mmdet/apis/test.py | multi_gpu_test | lizhaoliu-Lec/Conformer | python | def multi_gpu_test(model, data_loader, tmpdir=None, gpu_collect=False):
"Test model with multiple gpus.\n\n This method tests model with multiple gpus and collects the results\n under two different modes: gpu and cpu modes. By setting 'gpu_collect=True'\n it encodes results to gpu tensors and use gpu commu... |
def dlcboxplot(file, variable, ylab, comparison, jitter=False, colors=False, title=False, save=False, output_dir=None):
'\n file is typically \'dlc_all_avgs_updated.csv\'\n variable is either \'cat_ditance\' or \'vel\'\n ylab is the y-axis label\n colors is a list of two colors (e.g., ["#0062FF", "#DB62FF"])\n ... | -8,660,963,386,661,336,000 | file is typically 'dlc_all_avgs_updated.csv'
variable is either 'cat_ditance' or 'vel'
ylab is the y-axis label
colors is a list of two colors (e.g., ["#0062FF", "#DB62FF"])
output_dir to save the plot in a specific dir when save is True | toxopy/dlcboxplot.py | dlcboxplot | bchaselab/Toxopy | python | def dlcboxplot(file, variable, ylab, comparison, jitter=False, colors=False, title=False, save=False, output_dir=None):
'\n file is typically \'dlc_all_avgs_updated.csv\'\n variable is either \'cat_ditance\' or \'vel\'\n ylab is the y-axis label\n colors is a list of two colors (e.g., ["#0062FF", "#DB62FF"])\n ... |
@task
def set_version(ctx, version):
'Set project version in `src/robot/version.py`` file.\n\n Args:\n version: Project version to set or ``dev`` to set development version.\n\n Following PEP-440 compatible version numbers are supported:\n - Final version like 3.0 or 3.1.2.\n - Alpha, beta or rel... | 7,406,903,226,480,384,000 | Set project version in `src/robot/version.py`` file.
Args:
version: Project version to set or ``dev`` to set development version.
Following PEP-440 compatible version numbers are supported:
- Final version like 3.0 or 3.1.2.
- Alpha, beta or release candidate with ``a``, ``b`` or ``rc`` postfix,
respectively, a... | tasks.py | set_version | ConradDjedjebi/robotframework | python | @task
def set_version(ctx, version):
'Set project version in `src/robot/version.py`` file.\n\n Args:\n version: Project version to set or ``dev`` to set development version.\n\n Following PEP-440 compatible version numbers are supported:\n - Final version like 3.0 or 3.1.2.\n - Alpha, beta or rel... |
@task
def print_version(ctx):
'Print the current project version.'
print(Version(path=VERSION_PATH, pattern=VERSION_PATTERN)) | -8,988,342,015,607,977,000 | Print the current project version. | tasks.py | print_version | ConradDjedjebi/robotframework | python | @task
def print_version(ctx):
print(Version(path=VERSION_PATH, pattern=VERSION_PATTERN)) |
@task
def library_docs(ctx, name):
'Generate standard library documentation.\n\n Args:\n name: Name of the library or ``all`` to generate docs for all libs.\n Name is case-insensitive and can be shortened as long as it\n is a unique prefix. For example, ``b`` is equivalent to\... | 1,785,087,739,899,642,000 | Generate standard library documentation.
Args:
name: Name of the library or ``all`` to generate docs for all libs.
Name is case-insensitive and can be shortened as long as it
is a unique prefix. For example, ``b`` is equivalent to
``BuiltIn`` and ``di`` equivalent to ``Dialogs``. | tasks.py | library_docs | ConradDjedjebi/robotframework | python | @task
def library_docs(ctx, name):
'Generate standard library documentation.\n\n Args:\n name: Name of the library or ``all`` to generate docs for all libs.\n Name is case-insensitive and can be shortened as long as it\n is a unique prefix. For example, ``b`` is equivalent to\... |
@task
def release_notes(ctx, version=None, username=None, password=None, write=False):
"Generate release notes based on issues in the issue tracker.\n\n Args:\n version: Generate release notes for this version. If not given,\n generated them for the current version.\n username: Gi... | 196,812,704,242,137,700 | Generate release notes based on issues in the issue tracker.
Args:
version: Generate release notes for this version. If not given,
generated them for the current version.
username: GitHub username.
password: GitHub password.
write: When set to True, write release notes to a file overw... | tasks.py | release_notes | ConradDjedjebi/robotframework | python | @task
def release_notes(ctx, version=None, username=None, password=None, write=False):
"Generate release notes based on issues in the issue tracker.\n\n Args:\n version: Generate release notes for this version. If not given,\n generated them for the current version.\n username: Gi... |
@task
def init_labels(ctx, username=None, password=None):
'Initialize project by setting labels in the issue tracker.\n\n Args:\n username: GitHub username.\n password: GitHub password.\n\n Username and password can also be specified using ``GITHUB_USERNAME`` and\n ``GITHUB_PASSWORD`` environ... | -2,619,656,879,941,839,400 | Initialize project by setting labels in the issue tracker.
Args:
username: GitHub username.
password: GitHub password.
Username and password can also be specified using ``GITHUB_USERNAME`` and
``GITHUB_PASSWORD`` environment variable, respectively.
Should only be executed once when taking ``rellu`` tooling t... | tasks.py | init_labels | ConradDjedjebi/robotframework | python | @task
def init_labels(ctx, username=None, password=None):
'Initialize project by setting labels in the issue tracker.\n\n Args:\n username: GitHub username.\n password: GitHub password.\n\n Username and password can also be specified using ``GITHUB_USERNAME`` and\n ``GITHUB_PASSWORD`` environ... |
@task
def jar(ctx, jython_version='2.7.0', pyyaml_version='3.11', remove_dist=False):
"Create JAR distribution.\n\n Downloads Jython JAR and PyYAML if needed.\n\n Args:\n jython_version: Jython version to use as a base. Must match version in\n `jython-standalone-<version>.jar` found from Mav... | -4,522,507,211,498,932,000 | Create JAR distribution.
Downloads Jython JAR and PyYAML if needed.
Args:
jython_version: Jython version to use as a base. Must match version in
`jython-standalone-<version>.jar` found from Maven central.
pyyaml_version: Version of PyYAML that will be included in the
standalone jar. The versio... | tasks.py | jar | ConradDjedjebi/robotframework | python | @task
def jar(ctx, jython_version='2.7.0', pyyaml_version='3.11', remove_dist=False):
"Create JAR distribution.\n\n Downloads Jython JAR and PyYAML if needed.\n\n Args:\n jython_version: Jython version to use as a base. Must match version in\n `jython-standalone-<version>.jar` found from Mav... |
@asyncio.coroutine
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
'Setup the Time and Date sensor.'
if (hass.config.time_zone is None):
_LOGGER.error('Timezone is not set in Home Assistant configuration')
return False
devices = []
for variable in config[C... | -7,925,590,846,427,815,000 | Setup the Time and Date sensor. | homeassistant/components/sensor/time_date.py | async_setup_platform | mweinelt/home-assistant | python | @asyncio.coroutine
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
if (hass.config.time_zone is None):
_LOGGER.error('Timezone is not set in Home Assistant configuration')
return False
devices = []
for variable in config[CONF_DISPLAY_OPTIONS]:
dev... |
def __init__(self, option_type):
'Initialize the sensor.'
self._name = OPTION_TYPES[option_type]
self.type = option_type
self._state = None | -915,315,216,129,578,400 | Initialize the sensor. | homeassistant/components/sensor/time_date.py | __init__ | mweinelt/home-assistant | python | def __init__(self, option_type):
self._name = OPTION_TYPES[option_type]
self.type = option_type
self._state = None |
@property
def name(self):
'Return the name of the sensor.'
return self._name | 8,691,954,631,286,512,000 | Return the name of the sensor. | homeassistant/components/sensor/time_date.py | name | mweinelt/home-assistant | python | @property
def name(self):
return self._name |
@property
def state(self):
'Return the state of the sensor.'
return self._state | -2,324,550,726,442,955,000 | Return the state of the sensor. | homeassistant/components/sensor/time_date.py | state | mweinelt/home-assistant | python | @property
def state(self):
return self._state |
@property
def icon(self):
'Icon to use in the frontend, if any.'
if (('date' in self.type) and ('time' in self.type)):
return 'mdi:calendar-clock'
elif ('date' in self.type):
return 'mdi:calendar'
else:
return 'mdi:clock' | -2,937,875,691,628,948,000 | Icon to use in the frontend, if any. | homeassistant/components/sensor/time_date.py | icon | mweinelt/home-assistant | python | @property
def icon(self):
if (('date' in self.type) and ('time' in self.type)):
return 'mdi:calendar-clock'
elif ('date' in self.type):
return 'mdi:calendar'
else:
return 'mdi:clock' |
@asyncio.coroutine
def async_update(self):
'Get the latest data and updates the states.'
time_date = dt_util.utcnow()
time = dt_util.as_local(time_date).strftime(TIME_STR_FORMAT)
time_utc = time_date.strftime(TIME_STR_FORMAT)
date = dt_util.as_local(time_date).date().isoformat()
time_bmt = (time... | -2,005,476,636,452,129,800 | Get the latest data and updates the states. | homeassistant/components/sensor/time_date.py | async_update | mweinelt/home-assistant | python | @asyncio.coroutine
def async_update(self):
time_date = dt_util.utcnow()
time = dt_util.as_local(time_date).strftime(TIME_STR_FORMAT)
time_utc = time_date.strftime(TIME_STR_FORMAT)
date = dt_util.as_local(time_date).date().isoformat()
time_bmt = (time_date + timedelta(hours=1))
delta = timed... |
def get_local_ip():
'Rewrite this stub, it is used in code not checked in yet '
return '127.0.0.1' | -8,942,152,617,992,478,000 | Rewrite this stub, it is used in code not checked in yet | CMR/python/cmr/util/network.py | get_local_ip | nasa/eo-metadata-tools | python | def get_local_ip():
' '
return '127.0.0.1' |
def value_to_param(key, value):
'\n Convert a key value pair into a URL parameter pair\n '
value = str(value)
encoded_key = urllib.parse.quote(key)
encoded_value = urllib.parse.quote(value)
result = ((encoded_key + '=') + encoded_value)
return result | -646,888,271,832,497,000 | Convert a key value pair into a URL parameter pair | CMR/python/cmr/util/network.py | value_to_param | nasa/eo-metadata-tools | python | def value_to_param(key, value):
'\n \n '
value = str(value)
encoded_key = urllib.parse.quote(key)
encoded_value = urllib.parse.quote(value)
result = ((encoded_key + '=') + encoded_value)
return result |
def expand_parameter_to_parameters(key, parameter):
'\n Convert a list of values into a list of URL parameters\n '
result = []
if isinstance(parameter, list):
for item in parameter:
param = value_to_param(key, item)
result.append(param)
else:
value = str(par... | 7,476,469,016,591,322,000 | Convert a list of values into a list of URL parameters | CMR/python/cmr/util/network.py | expand_parameter_to_parameters | nasa/eo-metadata-tools | python | def expand_parameter_to_parameters(key, parameter):
'\n \n '
result = []
if isinstance(parameter, list):
for item in parameter:
param = value_to_param(key, item)
result.append(param)
else:
value = str(parameter)
encoded_key = urllib.parse.quote(key)
... |
def expand_query_to_parameters(query=None):
' Convert a dictionary to URL parameters '
params = []
if (query is None):
return ''
keys = sorted(query.keys())
for key in keys:
value = query[key]
params = (params + expand_parameter_to_parameters(key, value))
return '&'.join(... | 3,580,768,496,016,687,000 | Convert a dictionary to URL parameters | CMR/python/cmr/util/network.py | expand_query_to_parameters | nasa/eo-metadata-tools | python | def expand_query_to_parameters(query=None):
' '
params = []
if (query is None):
return
keys = sorted(query.keys())
for key in keys:
value = query[key]
params = (params + expand_parameter_to_parameters(key, value))
return '&'.join(params) |
def apply_headers_to_request(req, headers):
'Apply a headers to a urllib request object '
if ((headers is not None) and (req is not None)):
for key in headers:
value = headers[key]
if ((value is not None) and (len(value) > 0)):
req.add_header(key, value) | -7,944,122,521,479,747,000 | Apply a headers to a urllib request object | CMR/python/cmr/util/network.py | apply_headers_to_request | nasa/eo-metadata-tools | python | def apply_headers_to_request(req, headers):
' '
if ((headers is not None) and (req is not None)):
for key in headers:
value = headers[key]
if ((value is not None) and (len(value) > 0)):
req.add_header(key, value) |
def transform_results(results, keys_of_interest):
'\n Take a list of results and convert them to a multi valued dictionary. The\n real world use case is to take values from a list of collections and pass\n them to a granule search.\n\n [{key1:value1},{key1:value2},...] -> {"key1": [value1,value2]} ->\n ... | 5,444,962,081,587,083,000 | Take a list of results and convert them to a multi valued dictionary. The
real world use case is to take values from a list of collections and pass
them to a granule search.
[{key1:value1},{key1:value2},...] -> {"key1": [value1,value2]} ->
&key1=value1&key1=value2 ( via expand_query_to_parameters() ) | CMR/python/cmr/util/network.py | transform_results | nasa/eo-metadata-tools | python | def transform_results(results, keys_of_interest):
'\n Take a list of results and convert them to a multi valued dictionary. The\n real world use case is to take values from a list of collections and pass\n them to a granule search.\n\n [{key1:value1},{key1:value2},...] -> {"key1": [value1,value2]} ->\n ... |
def config_to_header(config, source_key, headers, destination_key=None, default=None):
'\n Copy a value in the config into a header dictionary for use by urllib. Written\n to reduce boiler plate code\n\n config[key] -> [or default] -> [rename] -> headers[key]\n\n Parameters:\n config(dictionary):... | -482,853,321,896,843,800 | Copy a value in the config into a header dictionary for use by urllib. Written
to reduce boiler plate code
config[key] -> [or default] -> [rename] -> headers[key]
Parameters:
config(dictionary): where to look for values
source_key(string): name if configuration in config
headers(dictionary): where to copy... | CMR/python/cmr/util/network.py | config_to_header | nasa/eo-metadata-tools | python | def config_to_header(config, source_key, headers, destination_key=None, default=None):
'\n Copy a value in the config into a header dictionary for use by urllib. Written\n to reduce boiler plate code\n\n config[key] -> [or default] -> [rename] -> headers[key]\n\n Parameters:\n config(dictionary):... |
def post(url, body, accept=None, headers=None):
'\n Make a basic HTTP call to CMR using the POST action\n Parameters:\n url (string): resource to get\n body (dictionary): parameters to send, or string if raw text to be sent\n accept (string): encoding of the returned data, some form of js... | 4,660,827,970,494,226,000 | Make a basic HTTP call to CMR using the POST action
Parameters:
url (string): resource to get
body (dictionary): parameters to send, or string if raw text to be sent
accept (string): encoding of the returned data, some form of json is expected
client_id (string): name of the client making the (not pytho... | CMR/python/cmr/util/network.py | post | nasa/eo-metadata-tools | python | def post(url, body, accept=None, headers=None):
'\n Make a basic HTTP call to CMR using the POST action\n Parameters:\n url (string): resource to get\n body (dictionary): parameters to send, or string if raw text to be sent\n accept (string): encoding of the returned data, some form of js... |
def get(url, accept=None, headers=None):
'\n Make a basic HTTP call to CMR using the POST action\n Parameters:\n url (string): resource to get\n body (dictionary): parameters to send, or string if raw text to be sent\n accept (string): encoding of the returned data, some form of json is e... | -1,446,447,083,311,810,600 | Make a basic HTTP call to CMR using the POST action
Parameters:
url (string): resource to get
body (dictionary): parameters to send, or string if raw text to be sent
accept (string): encoding of the returned data, some form of json is expected
client_id (string): name of the client making the (not pytho... | CMR/python/cmr/util/network.py | get | nasa/eo-metadata-tools | python | def get(url, accept=None, headers=None):
'\n Make a basic HTTP call to CMR using the POST action\n Parameters:\n url (string): resource to get\n body (dictionary): parameters to send, or string if raw text to be sent\n accept (string): encoding of the returned data, some form of json is e... |
def __init__(self, options):
'\n Constructor\n '
'\n Initialize ROC SDK. looks for the license file and optionally we can provide a log file. If it cannot find the license then it will quit. Roc_ensure catches the error and aborts.\n '
global roc
import roc as _local_roc
... | -5,256,902,782,774,535,000 | Constructor | src/faro/face_workers/RankOneFaceWorker.py | __init__ | ORNL/faro | python | def __init__(self, options):
'\n \n '
'\n Initialize ROC SDK. looks for the license file and optionally we can provide a log file. If it cannot find the license then it will quit. Roc_ensure catches the error and aborts.\n '
global roc
import roc as _local_roc
roc = _loca... |
def _rocFlatten(self, tmpl):
'\n Converts roc template to serialized data.\n Datatype = bytes\n '
buffer_size = roc.new_size_t()
roc.roc_flattened_bytes(tmpl, buffer_size)
buffer_size_int = roc.size_t_value(buffer_size)
roc_buffer_src = roc.new_uint8_t_array(buffer_size_int)
... | -7,773,845,692,104,771,000 | Converts roc template to serialized data.
Datatype = bytes | src/faro/face_workers/RankOneFaceWorker.py | _rocFlatten | ORNL/faro | python | def _rocFlatten(self, tmpl):
'\n Converts roc template to serialized data.\n Datatype = bytes\n '
buffer_size = roc.new_size_t()
roc.roc_flattened_bytes(tmpl, buffer_size)
buffer_size_int = roc.size_t_value(buffer_size)
roc_buffer_src = roc.new_uint8_t_array(buffer_size_int)
... |
def _rocUnFlatten(self, buff, template_dst):
'\n Converts serialized data back to roc template.\n '
roc_buffer_dst = roc.new_uint8_t_array((len(buff) + 1))
roc.memmove(roc_buffer_dst, buff)
roc.roc_unflatten(roc_buffer_dst, template_dst)
roc.delete_uint8_t_array(roc_buffer_dst)
ret... | -7,051,053,376,622,155,000 | Converts serialized data back to roc template. | src/faro/face_workers/RankOneFaceWorker.py | _rocUnFlatten | ORNL/faro | python | def _rocUnFlatten(self, buff, template_dst):
'\n \n '
roc_buffer_dst = roc.new_uint8_t_array((len(buff) + 1))
roc.memmove(roc_buffer_dst, buff)
roc.roc_unflatten(roc_buffer_dst, template_dst)
roc.delete_uint8_t_array(roc_buffer_dst)
return template_dst |
def _detect(self, im, opts):
'\n In RankOne, face detection happends within the roc_represent function.\n There is no explicit face detection step like in dlib. \n But we will output the bounding box. but it is not really useful in this case. \n '
'\n Rank one requires the i... | 5,703,304,084,208,401,000 | In RankOne, face detection happends within the roc_represent function.
There is no explicit face detection step like in dlib.
But we will output the bounding box. but it is not really useful in this case. | src/faro/face_workers/RankOneFaceWorker.py | _detect | ORNL/faro | python | def _detect(self, im, opts):
'\n In RankOne, face detection happends within the roc_represent function.\n There is no explicit face detection step like in dlib. \n But we will output the bounding box. but it is not really useful in this case. \n '
'\n Rank one requires the i... |
def locate(self, img, face_records, options):
'\n Not needed as we find the location of the eyes, nose and chin during detection and have \n added it to face records during detection\n '
pass | -7,378,047,175,457,492,000 | Not needed as we find the location of the eyes, nose and chin during detection and have
added it to face records during detection | src/faro/face_workers/RankOneFaceWorker.py | locate | ORNL/faro | python | def locate(self, img, face_records, options):
'\n Not needed as we find the location of the eyes, nose and chin during detection and have \n added it to face records during detection\n '
pass |
def align(self, image, face_records):
'Align the images to a standard size and orientation to allow \n recognition.'
pass | 1,324,541,208,925,305,900 | Align the images to a standard size and orientation to allow
recognition. | src/faro/face_workers/RankOneFaceWorker.py | align | ORNL/faro | python | def align(self, image, face_records):
'Align the images to a standard size and orientation to allow \n recognition.'
pass |
def scoreType(self):
'Return the method used to create a score from the template.\n \n By default server computation is required.\n \n SCORE_L1, SCORE_L2, SCORE_DOT, SCORE_SERVER\n '
return fsd.SERVER | -8,849,982,573,337,070,000 | Return the method used to create a score from the template.
By default server computation is required.
SCORE_L1, SCORE_L2, SCORE_DOT, SCORE_SERVER | src/faro/face_workers/RankOneFaceWorker.py | scoreType | ORNL/faro | python | def scoreType(self):
'Return the method used to create a score from the template.\n \n By default server computation is required.\n \n SCORE_L1, SCORE_L2, SCORE_DOT, SCORE_SERVER\n '
return fsd.SERVER |
def score(self, score_request):
'Compare templates to produce scores.'
score_type = self.scoreType()
result = geo.Matrix()
if (score_type not in [fsd.SERVER]):
raise NotImplementedError(('Score type <%s> not implemented.' % (score_type,)))
if (len(score_request.template_probes.templates) == ... | -6,922,211,263,441,873,000 | Compare templates to produce scores. | src/faro/face_workers/RankOneFaceWorker.py | score | ORNL/faro | python | def score(self, score_request):
score_type = self.scoreType()
result = geo.Matrix()
if (score_type not in [fsd.SERVER]):
raise NotImplementedError(('Score type <%s> not implemented.' % (score_type,)))
if (len(score_request.template_probes.templates) == 0):
raise ValueError('no probe... |
def status(self):
'Return a simple status message.'
print('Handeling status request.')
status_message = fsd.FaceServiceInfo()
status_message.status = fsd.READY
status_message.detection_support = True
status_message.extract_support = True
status_message.score_support = False
status_messag... | -402,292,803,537,436,900 | Return a simple status message. | src/faro/face_workers/RankOneFaceWorker.py | status | ORNL/faro | python | def status(self):
print('Handeling status request.')
status_message = fsd.FaceServiceInfo()
status_message.status = fsd.READY
status_message.detection_support = True
status_message.extract_support = True
status_message.score_support = False
status_message.score_type = self.scoreType()
... |
def recommendedDetectionThreshold(self):
'\n The false_detection_rate parameter specifies the allowable \n false positive rate for face detection.The suggested default \n value for false_detection_rate is 0.02 which corresponds to \n one false detection in 50 images on the FDDB benchmark... | -550,635,710,567,225,800 | The false_detection_rate parameter specifies the allowable
false positive rate for face detection.The suggested default
value for false_detection_rate is 0.02 which corresponds to
one false detection in 50 images on the FDDB benchmark. A
higher false detection rate will correctly detect more faces
at the cost of a... | src/faro/face_workers/RankOneFaceWorker.py | recommendedDetectionThreshold | ORNL/faro | python | def recommendedDetectionThreshold(self):
'\n The false_detection_rate parameter specifies the allowable \n false positive rate for face detection.The suggested default \n value for false_detection_rate is 0.02 which corresponds to \n one false detection in 50 images on the FDDB benchmark... |
def recommendedScoreThreshold(self, far=(- 1)):
'Return the method used to create a score from the template.\n \n By default server computation is required.\n \n Should return a recommended score threshold.\n \n DLIB recommends a value of 0.6 for LFW dataset \n '
... | 2,327,120,922,743,612,000 | Return the method used to create a score from the template.
By default server computation is required.
Should return a recommended score threshold.
DLIB recommends a value of 0.6 for LFW dataset | src/faro/face_workers/RankOneFaceWorker.py | recommendedScoreThreshold | ORNL/faro | python | def recommendedScoreThreshold(self, far=(- 1)):
'Return the method used to create a score from the template.\n \n By default server computation is required.\n \n Should return a recommended score threshold.\n \n DLIB recommends a value of 0.6 for LFW dataset \n '
... |
def present(save_fn: str, duration=120, n_trials=2010, iti=0.5, soa=3.0, jitter=0.2, volume=0.8, random_state=42, eeg=None, cf1=900, amf1=45, cf2=770, amf2=40.018, sample_rate=44100):
'\n\n Auditory SSAEP Experiment\n ===========================\n\n\n Parameters:\n -----------\n\n duration - duration... | -1,716,731,095,930,829,300 | Auditory SSAEP Experiment
===========================
Parameters:
-----------
duration - duration of the recording in seconds (default 10)
n_trials - number of trials (default 10)
iti - intertrial interval (default 0.3)
soa - stimulus onset asynchrony, = interval between end of stimulus
and next trial (defa... | eegnb/experiments/auditory_ssaep/ssaep.py | present | Neuroelektroteknia/eeg-notebooks | python | def present(save_fn: str, duration=120, n_trials=2010, iti=0.5, soa=3.0, jitter=0.2, volume=0.8, random_state=42, eeg=None, cf1=900, amf1=45, cf2=770, amf2=40.018, sample_rate=44100):
'\n\n Auditory SSAEP Experiment\n ===========================\n\n\n Parameters:\n -----------\n\n duration - duration... |
def generate_am_waveform(carrier_freq, am_freq, secs=1, sample_rate=None, am_type='gaussian', gaussian_std_ratio=8):
"Generate an amplitude-modulated waveform.\n\n Generate a sine wave amplitude-modulated by a second sine wave or a\n Gaussian envelope with standard deviation = period_AM/8.\n\n Args:\n ... | -6,215,639,081,792,676,000 | Generate an amplitude-modulated waveform.
Generate a sine wave amplitude-modulated by a second sine wave or a
Gaussian envelope with standard deviation = period_AM/8.
Args:
carrier_freq (float): carrier wave frequency, in Hz
am_freq (float): amplitude modulation frequency, in Hz
Keyword Args:
secs (float... | eegnb/experiments/auditory_ssaep/ssaep.py | generate_am_waveform | Neuroelektroteknia/eeg-notebooks | python | def generate_am_waveform(carrier_freq, am_freq, secs=1, sample_rate=None, am_type='gaussian', gaussian_std_ratio=8):
"Generate an amplitude-modulated waveform.\n\n Generate a sine wave amplitude-modulated by a second sine wave or a\n Gaussian envelope with standard deviation = period_AM/8.\n\n Args:\n ... |
def get_script_name(environ):
"\n Returns the equivalent of the HTTP request's SCRIPT_NAME environment\n variable. If Apache mod_rewrite has been used, returns what would have been\n the script name prior to any rewriting (so it's the script name as seen\n from the client's perspective), unless the FORC... | -4,577,672,714,947,128,300 | Returns the equivalent of the HTTP request's SCRIPT_NAME environment
variable. If Apache mod_rewrite has been used, returns what would have been
the script name prior to any rewriting (so it's the script name as seen
from the client's perspective), unless the FORCE_SCRIPT_NAME setting is
set (to anything). | django/core/handlers/base.py | get_script_name | chalkchisel/django | python | def get_script_name(environ):
"\n Returns the equivalent of the HTTP request's SCRIPT_NAME environment\n variable. If Apache mod_rewrite has been used, returns what would have been\n the script name prior to any rewriting (so it's the script name as seen\n from the client's perspective), unless the FORC... |
def load_middleware(self):
'\n Populate middleware lists from settings.MIDDLEWARE_CLASSES.\n\n Must be called after the environment is fixed (see __call__ in subclasses).\n '
from django.conf import settings
from django.core import exceptions
self._view_middleware = []
self._tem... | 3,131,384,541,514,060,000 | Populate middleware lists from settings.MIDDLEWARE_CLASSES.
Must be called after the environment is fixed (see __call__ in subclasses). | django/core/handlers/base.py | load_middleware | chalkchisel/django | python | def load_middleware(self):
'\n Populate middleware lists from settings.MIDDLEWARE_CLASSES.\n\n Must be called after the environment is fixed (see __call__ in subclasses).\n '
from django.conf import settings
from django.core import exceptions
self._view_middleware = []
self._tem... |
def get_response(self, request):
'Returns an HttpResponse object for the given HttpRequest'
from django.core import exceptions, urlresolvers
from django.conf import settings
try:
urlconf = settings.ROOT_URLCONF
urlresolvers.set_urlconf(urlconf)
resolver = urlresolvers.RegexURLRes... | 6,400,287,607,290,851,000 | Returns an HttpResponse object for the given HttpRequest | django/core/handlers/base.py | get_response | chalkchisel/django | python | def get_response(self, request):
from django.core import exceptions, urlresolvers
from django.conf import settings
try:
urlconf = settings.ROOT_URLCONF
urlresolvers.set_urlconf(urlconf)
resolver = urlresolvers.RegexURLResolver('^/', urlconf)
try:
response = N... |
def handle_uncaught_exception(self, request, resolver, exc_info):
'\n Processing for any otherwise uncaught exceptions (those that will\n generate HTTP 500 responses). Can be overridden by subclasses who want\n customised 500 handling.\n\n Be *very* careful when overriding this because t... | 1,751,742,861,078,187,500 | Processing for any otherwise uncaught exceptions (those that will
generate HTTP 500 responses). Can be overridden by subclasses who want
customised 500 handling.
Be *very* careful when overriding this because the error could be
caused by anything, so assuming something like the database is always
available would be an... | django/core/handlers/base.py | handle_uncaught_exception | chalkchisel/django | python | def handle_uncaught_exception(self, request, resolver, exc_info):
'\n Processing for any otherwise uncaught exceptions (those that will\n generate HTTP 500 responses). Can be overridden by subclasses who want\n customised 500 handling.\n\n Be *very* careful when overriding this because t... |
def apply_response_fixes(self, request, response):
'\n Applies each of the functions in self.response_fixes to the request and\n response, modifying the response in the process. Returns the new\n response.\n '
for func in self.response_fixes:
response = func(request, response... | -1,219,089,826,869,694,000 | Applies each of the functions in self.response_fixes to the request and
response, modifying the response in the process. Returns the new
response. | django/core/handlers/base.py | apply_response_fixes | chalkchisel/django | python | def apply_response_fixes(self, request, response):
'\n Applies each of the functions in self.response_fixes to the request and\n response, modifying the response in the process. Returns the new\n response.\n '
for func in self.response_fixes:
response = func(request, response... |
def _construct_simple(coeffs, opt):
'Handle simple domains, e.g.: ZZ, QQ, RR and algebraic domains. '
(result, rationals, reals, algebraics) = ({}, False, False, False)
if (opt.extension is True):
is_algebraic = (lambda coeff: ask(Q.algebraic(coeff)))
else:
is_algebraic = (lambda coeff: ... | -4,415,115,649,839,476,700 | Handle simple domains, e.g.: ZZ, QQ, RR and algebraic domains. | sympy/polys/constructor.py | _construct_simple | jegerjensen/sympy | python | def _construct_simple(coeffs, opt):
' '
(result, rationals, reals, algebraics) = ({}, False, False, False)
if (opt.extension is True):
is_algebraic = (lambda coeff: ask(Q.algebraic(coeff)))
else:
is_algebraic = (lambda coeff: False)
for coeff in coeffs:
if coeff.is_Rational:
... |
def _construct_algebraic(coeffs, opt):
'We know that coefficients are algebraic so construct the extension. '
from sympy.polys.numberfields import primitive_element
(result, exts) = ([], set([]))
for coeff in coeffs:
if coeff.is_Rational:
coeff = (None, 0, QQ.from_sympy(coeff))
... | -7,388,822,707,878,778,000 | We know that coefficients are algebraic so construct the extension. | sympy/polys/constructor.py | _construct_algebraic | jegerjensen/sympy | python | def _construct_algebraic(coeffs, opt):
' '
from sympy.polys.numberfields import primitive_element
(result, exts) = ([], set([]))
for coeff in coeffs:
if coeff.is_Rational:
coeff = (None, 0, QQ.from_sympy(coeff))
else:
a = coeff.as_coeff_add()[0]
coeff ... |
def _construct_composite(coeffs, opt):
'Handle composite domains, e.g.: ZZ[X], QQ[X], ZZ(X), QQ(X). '
(numers, denoms) = ([], [])
for coeff in coeffs:
(numer, denom) = coeff.as_numer_denom()
numers.append(numer)
denoms.append(denom)
(polys, gens) = parallel_dict_from_basic((numer... | -7,897,564,059,083,854,000 | Handle composite domains, e.g.: ZZ[X], QQ[X], ZZ(X), QQ(X). | sympy/polys/constructor.py | _construct_composite | jegerjensen/sympy | python | def _construct_composite(coeffs, opt):
' '
(numers, denoms) = ([], [])
for coeff in coeffs:
(numer, denom) = coeff.as_numer_denom()
numers.append(numer)
denoms.append(denom)
(polys, gens) = parallel_dict_from_basic((numers + denoms))
if any((gen.is_number for gen in gens)):
... |
def _construct_expression(coeffs, opt):
'The last resort case, i.e. use the expression domain. '
(domain, result) = (EX, [])
for coeff in coeffs:
result.append(domain.from_sympy(coeff))
return (domain, result) | 8,277,807,598,530,472,000 | The last resort case, i.e. use the expression domain. | sympy/polys/constructor.py | _construct_expression | jegerjensen/sympy | python | def _construct_expression(coeffs, opt):
' '
(domain, result) = (EX, [])
for coeff in coeffs:
result.append(domain.from_sympy(coeff))
return (domain, result) |
def construct_domain(obj, **args):
'Construct a minimal domain for the list of coefficients. '
opt = build_options(args)
if hasattr(obj, '__iter__'):
if isinstance(obj, dict):
(monoms, coeffs) = zip(*obj.items())
else:
coeffs = obj
else:
coeffs = [obj]
... | 8,700,327,246,323,492,000 | Construct a minimal domain for the list of coefficients. | sympy/polys/constructor.py | construct_domain | jegerjensen/sympy | python | def construct_domain(obj, **args):
' '
opt = build_options(args)
if hasattr(obj, '__iter__'):
if isinstance(obj, dict):
(monoms, coeffs) = zip(*obj.items())
else:
coeffs = obj
else:
coeffs = [obj]
coeffs = map(sympify, coeffs)
result = _construct_s... |
def send_osc_message(self, osc_datagram, address, port):
'Send OSC message via UDP.'
self.sock.sendto(osc_datagram, (address, port)) | 850,267,935,205,644,000 | Send OSC message via UDP. | robojam/tiny_performance_player.py | send_osc_message | cpmpercussion/robojam | python | def send_osc_message(self, osc_datagram, address, port):
self.sock.sendto(osc_datagram, (address, port)) |
def pad_dgram_four_bytes(self, dgram):
'Pad a datagram up to a multiple of 4 bytes.'
return (dgram + (b'\x00' * (4 - (len(dgram) % 4)))) | 4,929,957,407,282,971,000 | Pad a datagram up to a multiple of 4 bytes. | robojam/tiny_performance_player.py | pad_dgram_four_bytes | cpmpercussion/robojam | python | def pad_dgram_four_bytes(self, dgram):
return (dgram + (b'\x00' * (4 - (len(dgram) % 4)))) |
def setSynth(self, instrument='strings', address=DEFAULT_OSC_ADDRESS, port=DEFAULT_OSC_PORT):
'Sends an OSC message to set the synth instrument.'
dgram = b''
dgram += self.pad_dgram_four_bytes('/inst'.encode('utf-8'))
dgram += self.pad_dgram_four_bytes(',s')
dgram += self.pad_dgram_four_bytes(instru... | -3,863,916,716,206,835,700 | Sends an OSC message to set the synth instrument. | robojam/tiny_performance_player.py | setSynth | cpmpercussion/robojam | python | def setSynth(self, instrument='strings', address=DEFAULT_OSC_ADDRESS, port=DEFAULT_OSC_PORT):
dgram = b
dgram += self.pad_dgram_four_bytes('/inst'.encode('utf-8'))
dgram += self.pad_dgram_four_bytes(',s')
dgram += self.pad_dgram_four_bytes(instrument.encode('utf-8'))
self.send_osc_message(dgram... |
def setSynthRandom(self):
'Choose a random synth for performance playback'
self.setSynth(random.choice(['chirp', 'keys', 'drums', 'strings'])) | -7,457,364,301,034,360,000 | Choose a random synth for performance playback | robojam/tiny_performance_player.py | setSynthRandom | cpmpercussion/robojam | python | def setSynthRandom(self):
self.setSynth(random.choice(['chirp', 'keys', 'drums', 'strings'])) |
def sendTouch(self, x, y, z, address=DEFAULT_OSC_ADDRESS, port=DEFAULT_OSC_PORT):
'Sends an OSC message to trigger a touch sound.'
dgram = b''
dgram += self.pad_dgram_four_bytes('/touch'.encode('utf-8'))
dgram += self.pad_dgram_four_bytes(',sfsfsf')
dgram += self.pad_dgram_four_bytes('/x'.encode('ut... | -7,923,912,209,772,948,000 | Sends an OSC message to trigger a touch sound. | robojam/tiny_performance_player.py | sendTouch | cpmpercussion/robojam | python | def sendTouch(self, x, y, z, address=DEFAULT_OSC_ADDRESS, port=DEFAULT_OSC_PORT):
dgram = b
dgram += self.pad_dgram_four_bytes('/touch'.encode('utf-8'))
dgram += self.pad_dgram_four_bytes(',sfsfsf')
dgram += self.pad_dgram_four_bytes('/x'.encode('utf-8'))
dgram += struct.pack('>f', x)
dgram... |
def playPerformance(self, perf_df):
'Schedule performance of a tiny performance dataframe.'
for row in perf_df.iterrows():
Timer(row[0], self.sendTouch, args=[row[1].x, row[1].y, row[1].z]).start() | 861,108,620,275,963,300 | Schedule performance of a tiny performance dataframe. | robojam/tiny_performance_player.py | playPerformance | cpmpercussion/robojam | python | def playPerformance(self, perf_df):
for row in perf_df.iterrows():
Timer(row[0], self.sendTouch, args=[row[1].x, row[1].y, row[1].z]).start() |
def get_loader(data_source: Iterable[dict], open_fn: Callable, dict_transform: Callable=None, sampler=None, collate_fn: Callable=default_collate_fn, batch_size: int=32, num_workers: int=4, shuffle: bool=False, drop_last: bool=False):
'Creates a DataLoader from given source and its open/transform params.\n\n Args... | 4,295,637,937,727,917,600 | Creates a DataLoader from given source and its open/transform params.
Args:
data_source (Iterable[dict]): and iterable containing your
data annotations,
(for example path to images, labels, bboxes, etc)
open_fn (Callable): function, that can open your
annotations dict and
transf... | catalyst/dl/utils/torch.py | get_loader | Inkln/catalyst | python | def get_loader(data_source: Iterable[dict], open_fn: Callable, dict_transform: Callable=None, sampler=None, collate_fn: Callable=default_collate_fn, batch_size: int=32, num_workers: int=4, shuffle: bool=False, drop_last: bool=False):
'Creates a DataLoader from given source and its open/transform params.\n\n Args... |
def template_to_descriptor(template: AttributeTemplate, *, headers: List[str]=[]) -> Descriptor:
'\n Convert a GEMD attribute template into an AI Engine Descriptor.\n\n IntBounds cannot be converted because they have no matching descriptor type.\n CompositionBounds can only be converted when every componen... | 1,347,197,254,586,883,000 | Convert a GEMD attribute template into an AI Engine Descriptor.
IntBounds cannot be converted because they have no matching descriptor type.
CompositionBounds can only be converted when every component is an element, in which case
they are converted to ChemicalFormulaDescriptors.
Parameters
----------
template: Attri... | src/citrine/builders/descriptors.py | template_to_descriptor | CitrineInformatics/citrine-python | python | def template_to_descriptor(template: AttributeTemplate, *, headers: List[str]=[]) -> Descriptor:
'\n Convert a GEMD attribute template into an AI Engine Descriptor.\n\n IntBounds cannot be converted because they have no matching descriptor type.\n CompositionBounds can only be converted when every componen... |
@staticmethod
def from_templates(*, project: Project, scope: str):
'\n Build a PlatformVocabulary from the templates visible to a project.\n\n All of the templates with the given scope are downloaded and converted into descriptors.\n The uid values associated with that scope are used as the ind... | -2,609,227,021,841,906,000 | Build a PlatformVocabulary from the templates visible to a project.
All of the templates with the given scope are downloaded and converted into descriptors.
The uid values associated with that scope are used as the index into the dictionary.
For example, using scope "my_templates" with a template with
uids={"my_templa... | src/citrine/builders/descriptors.py | from_templates | CitrineInformatics/citrine-python | python | @staticmethod
def from_templates(*, project: Project, scope: str):
'\n Build a PlatformVocabulary from the templates visible to a project.\n\n All of the templates with the given scope are downloaded and converted into descriptors.\n The uid values associated with that scope are used as the ind... |
@staticmethod
def from_material(*, project: Project, material: Union[(str, UUID, LinkByUID, MaterialRun)], mode: AutoConfigureMode=AutoConfigureMode.PLAIN, full_history: bool=True):
"[ALPHA] Build a PlatformVocabulary from templates appearing in a material history.\n\n All of the attribute templates that app... | 5,403,301,014,726,067,000 | [ALPHA] Build a PlatformVocabulary from templates appearing in a material history.
All of the attribute templates that appear throughout the material's history
are extracted and converted into descriptors.
Descriptor keys are formatted according to the option set by mode.
For example, if a condition template with nam... | src/citrine/builders/descriptors.py | from_material | CitrineInformatics/citrine-python | python | @staticmethod
def from_material(*, project: Project, material: Union[(str, UUID, LinkByUID, MaterialRun)], mode: AutoConfigureMode=AutoConfigureMode.PLAIN, full_history: bool=True):
"[ALPHA] Build a PlatformVocabulary from templates appearing in a material history.\n\n All of the attribute templates that app... |
def drifting(self):
'Get list of drifting times'
return [n for n in self if n.drifting] | 5,809,092,777,298,942,000 | Get list of drifting times | pyannote/core/transcription.py | drifting | Parisson/pyannote-core | python | def drifting(self):
return [n for n in self if n.drifting] |
def anchored(self):
'Get list of anchored times'
return [n for n in self if n.anchored] | 8,031,248,592,374,523,000 | Get list of anchored times | pyannote/core/transcription.py | anchored | Parisson/pyannote-core | python | def anchored(self):
return [n for n in self if n.anchored] |
def add_edge(self, t1, t2, key=None, attr_dict=None, **attrs):
"Add annotation to the graph between times t1 and t2\n\n Parameters\n ----------\n t1, t2: float, str or None\n data : dict, optional\n {annotation_type: annotation_value} dictionary\n\n Example\n ---... | 1,268,003,944,537,095,000 | Add annotation to the graph between times t1 and t2
Parameters
----------
t1, t2: float, str or None
data : dict, optional
{annotation_type: annotation_value} dictionary
Example
-------
>>> G = Transcription()
>>> G.add_edge(T(1.), T(), speaker='John', 'speech'='Hello world!') | pyannote/core/transcription.py | add_edge | Parisson/pyannote-core | python | def add_edge(self, t1, t2, key=None, attr_dict=None, **attrs):
"Add annotation to the graph between times t1 and t2\n\n Parameters\n ----------\n t1, t2: float, str or None\n data : dict, optional\n {annotation_type: annotation_value} dictionary\n\n Example\n ---... |
def relabel_drifting_nodes(self, mapping=None):
'Relabel drifting nodes\n\n Parameters\n ----------\n mapping : dict, optional\n A dictionary with the old labels as keys and new labels as values.\n\n Returns\n -------\n g : Transcription\n New annotati... | 7,044,763,319,659,581,000 | Relabel drifting nodes
Parameters
----------
mapping : dict, optional
A dictionary with the old labels as keys and new labels as values.
Returns
-------
g : Transcription
New annotation graph
mapping : dict
A dictionary with the new labels as keys and old labels as values.
Can be used to get back to t... | pyannote/core/transcription.py | relabel_drifting_nodes | Parisson/pyannote-core | python | def relabel_drifting_nodes(self, mapping=None):
'Relabel drifting nodes\n\n Parameters\n ----------\n mapping : dict, optional\n A dictionary with the old labels as keys and new labels as values.\n\n Returns\n -------\n g : Transcription\n New annotati... |
def crop(self, source, target=None):
'Get minimum subgraph between source time and target time\n\n Parameters\n ----------\n source : Segment\n target : float or str, optional\n\n Returns\n -------\n g : Transcription\n Sub-graph between source and target\... | -6,786,418,825,337,886,000 | Get minimum subgraph between source time and target time
Parameters
----------
source : Segment
target : float or str, optional
Returns
-------
g : Transcription
Sub-graph between source and target | pyannote/core/transcription.py | crop | Parisson/pyannote-core | python | def crop(self, source, target=None):
'Get minimum subgraph between source time and target time\n\n Parameters\n ----------\n source : Segment\n target : float or str, optional\n\n Returns\n -------\n g : Transcription\n Sub-graph between source and target\... |
def _merge(self, drifting_t, another_t):
'Helper function to merge `drifting_t` with `another_t`\n\n Assumes that both `drifting_t` and `another_t` exists.\n Also assumes that `drifting_t` is an instance of `TFloating`\n (otherwise, this might lead to weird graph configuration)\n\n Param... | 4,310,718,418,287,191,000 | Helper function to merge `drifting_t` with `another_t`
Assumes that both `drifting_t` and `another_t` exists.
Also assumes that `drifting_t` is an instance of `TFloating`
(otherwise, this might lead to weird graph configuration)
Parameters
----------
drifting_t :
Existing drifting time in graph
another_t :
Ex... | pyannote/core/transcription.py | _merge | Parisson/pyannote-core | python | def _merge(self, drifting_t, another_t):
'Helper function to merge `drifting_t` with `another_t`\n\n Assumes that both `drifting_t` and `another_t` exists.\n Also assumes that `drifting_t` is an instance of `TFloating`\n (otherwise, this might lead to weird graph configuration)\n\n Param... |
def anchor(self, drifting_t, anchored_t):
'\n ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n o -- [ D ] -- o ==> o -- [ A ] -- o\n\n ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n Anchor `drifting_t` at `anchored_t`\n\n Parameters\n ----------\n drifting_t :\n Dri... | -7,984,834,150,691,994,000 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
o -- [ D ] -- o ==> o -- [ A ] -- o
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Anchor `drifting_t` at `anchored_t`
Parameters
----------
drifting_t :
Drifting time to anchor
anchored_t :
When to anchor `drifting_t` | pyannote/core/transcription.py | anchor | Parisson/pyannote-core | python | def anchor(self, drifting_t, anchored_t):
'\n ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n o -- [ D ] -- o ==> o -- [ A ] -- o\n\n ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n Anchor `drifting_t` at `anchored_t`\n\n Parameters\n ----------\n drifting_t :\n Dri... |
def align(self, one_t, another_t):
'\n Align two (potentially drifting) times\n ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n o -- [ F ] -- o o o\n ⟍ ⟋\n ==> [ F ]\n ⟋ ⟍\n o -- [ f ] -- o... | -763,909,109,057,423,700 | Align two (potentially drifting) times
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
o -- [ F ] -- o o o
⟍ ⟋
==> [ F ]
⟋ ⟍
o -- [ f ] -- o o o
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Parameters
----------
one_t, another_t
Two tim... | pyannote/core/transcription.py | align | Parisson/pyannote-core | python | def align(self, one_t, another_t):
'\n Align two (potentially drifting) times\n ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n o -- [ F ] -- o o o\n ⟍ ⟋\n ==> [ F ]\n ⟋ ⟍\n o -- [ f ] -- o... |
def pre_align(self, t1, t2, t):
"\n ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n p -- [ t1 ] p [ t1 ]\n ⟍ ⟋\n ==> [ t ]\n ⟋ ⟍\n p' -- [ t2 ] p' [ t2 ]\n\n ~~~~~~~~~~~~~~~~~~~~~~~~~~... | -7,347,736,569,357,508,000 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
p -- [ t1 ] p [ t1 ]
⟍ ⟋
==> [ t ]
⟋ ⟍
p' -- [ t2 ] p' [ t2 ]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | pyannote/core/transcription.py | pre_align | Parisson/pyannote-core | python | def pre_align(self, t1, t2, t):
"\n ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n p -- [ t1 ] p [ t1 ]\n ⟍ ⟋\n ==> [ t ]\n ⟋ ⟍\n p' -- [ t2 ] p' [ t2 ]\n\n ~~~~~~~~~~~~~~~~~~~~~~~~~~... |
def post_align(self, t1, t2, t):
"\n ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n [ t1 ] -- s [ t1 ] s\n ⟍ ⟋\n ==> [ t ]\n ⟋ ⟍\n [ t2 ] -- s' [ t2 ] s'\n\n ~~~~~~~~~~~~~... | 2,734,299,867,145,611,000 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[ t1 ] -- s [ t1 ] s
⟍ ⟋
==> [ t ]
⟋ ⟍
[ t2 ] -- s' [ t2 ] s'
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | pyannote/core/transcription.py | post_align | Parisson/pyannote-core | python | def post_align(self, t1, t2, t):
"\n ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n [ t1 ] -- s [ t1 ] s\n ⟍ ⟋\n ==> [ t ]\n ⟋ ⟍\n [ t2 ] -- s' [ t2 ] s'\n\n ~~~~~~~~~~~~~... |
def ordering_graph(self):
'Ordering graph\n\n t1 --> t2 in the ordering graph indicates that t1 happens before t2.\n A missing edge simply means that it is not clear yet.\n\n '
g = nx.DiGraph()
for t in self.nodes_iter():
g.add_node(t)
for (t1, t2) in self.edges_iter():
... | -4,126,337,984,936,054,000 | Ordering graph
t1 --> t2 in the ordering graph indicates that t1 happens before t2.
A missing edge simply means that it is not clear yet. | pyannote/core/transcription.py | ordering_graph | Parisson/pyannote-core | python | def ordering_graph(self):
'Ordering graph\n\n t1 --> t2 in the ordering graph indicates that t1 happens before t2.\n A missing edge simply means that it is not clear yet.\n\n '
g = nx.DiGraph()
for t in self.nodes_iter():
g.add_node(t)
for (t1, t2) in self.edges_iter():
... |
def temporal_sort(self):
'Get nodes sorted in temporal order\n\n Remark\n ------\n This relies on a combination of temporal ordering of anchored times\n and topological ordering for drifting times.\n To be 100% sure that one drifting time happens before another time,\n chec... | 8,249,066,904,300,179,000 | Get nodes sorted in temporal order
Remark
------
This relies on a combination of temporal ordering of anchored times
and topological ordering for drifting times.
To be 100% sure that one drifting time happens before another time,
check the ordering graph (method .ordering_graph()). | pyannote/core/transcription.py | temporal_sort | Parisson/pyannote-core | python | def temporal_sort(self):
'Get nodes sorted in temporal order\n\n Remark\n ------\n This relies on a combination of temporal ordering of anchored times\n and topological ordering for drifting times.\n To be 100% sure that one drifting time happens before another time,\n chec... |
def ordered_edges_iter(self, nbunch=None, data=False, keys=False):
'Return an iterator over the edges in temporal order.\n\n Ordered edges are returned as tuples with optional data and keys\n in the order (t1, t2, key, data).\n\n Parameters\n ----------\n nbunch : iterable contain... | -6,821,498,659,858,628,000 | Return an iterator over the edges in temporal order.
Ordered edges are returned as tuples with optional data and keys
in the order (t1, t2, key, data).
Parameters
----------
nbunch : iterable container, optional (default= all nodes)
A container of nodes. The container will be iterated
through once.
data : boo... | pyannote/core/transcription.py | ordered_edges_iter | Parisson/pyannote-core | python | def ordered_edges_iter(self, nbunch=None, data=False, keys=False):
'Return an iterator over the edges in temporal order.\n\n Ordered edges are returned as tuples with optional data and keys\n in the order (t1, t2, key, data).\n\n Parameters\n ----------\n nbunch : iterable contain... |
def timerange(self, t1, t2, inside=True, sort=None):
'Infer edge timerange from graph structure\n\n a -- ... -- [ t1 ] -- A -- ... -- B -- [ t2 ] -- ... -- b\n\n ==> [a, b] (inside=False) or [A, B] (inside=True)\n\n Parameters\n ----------\n t1, t2 : anchored or drifting times\n ... | 7,552,954,080,013,591,000 | Infer edge timerange from graph structure
a -- ... -- [ t1 ] -- A -- ... -- B -- [ t2 ] -- ... -- b
==> [a, b] (inside=False) or [A, B] (inside=True)
Parameters
----------
t1, t2 : anchored or drifting times
inside : boolean, optional
Returns
-------
segment : Segment | pyannote/core/transcription.py | timerange | Parisson/pyannote-core | python | def timerange(self, t1, t2, inside=True, sort=None):
'Infer edge timerange from graph structure\n\n a -- ... -- [ t1 ] -- A -- ... -- B -- [ t2 ] -- ... -- b\n\n ==> [a, b] (inside=False) or [A, B] (inside=True)\n\n Parameters\n ----------\n t1, t2 : anchored or drifting times\n ... |
def build_options(gens, args=None):
'Construct options from keyword arguments or ... options. '
if (args is None):
(gens, args) = ((), gens)
if ((len(args) != 1) or ('opt' not in args) or gens):
return Options(gens, args)
else:
return args['opt'] | -3,557,484,308,317,494,000 | Construct options from keyword arguments or ... options. | PPTexEnv_x86_64/lib/python2.7/site-packages/sympy/polys/polyoptions.py | build_options | 18padx08/PPTex | python | def build_options(gens, args=None):
' '
if (args is None):
(gens, args) = ((), gens)
if ((len(args) != 1) or ('opt' not in args) or gens):
return Options(gens, args)
else:
return args['opt'] |
def allowed_flags(args, flags):
"\n Allow specified flags to be used in the given context.\n\n Examples\n ========\n\n >>> from sympy.polys.polyoptions import allowed_flags\n >>> from sympy.polys.domains import ZZ\n\n >>> allowed_flags({'domain': ZZ}, [])\n\n >>> allowed_flags({'domain': ZZ, 'f... | 7,278,552,867,825,473,000 | Allow specified flags to be used in the given context.
Examples
========
>>> from sympy.polys.polyoptions import allowed_flags
>>> from sympy.polys.domains import ZZ
>>> allowed_flags({'domain': ZZ}, [])
>>> allowed_flags({'domain': ZZ, 'frac': True}, [])
Traceback (most recent call last):
...
FlagError: 'frac' fla... | PPTexEnv_x86_64/lib/python2.7/site-packages/sympy/polys/polyoptions.py | allowed_flags | 18padx08/PPTex | python | def allowed_flags(args, flags):
"\n Allow specified flags to be used in the given context.\n\n Examples\n ========\n\n >>> from sympy.polys.polyoptions import allowed_flags\n >>> from sympy.polys.domains import ZZ\n\n >>> allowed_flags({'domain': ZZ}, [])\n\n >>> allowed_flags({'domain': ZZ, 'f... |
def set_defaults(options, **defaults):
'Update options with default values. '
if ('defaults' not in options):
options = dict(options)
options['defaults'] = defaults
return options | -2,880,402,475,341,957,000 | Update options with default values. | PPTexEnv_x86_64/lib/python2.7/site-packages/sympy/polys/polyoptions.py | set_defaults | 18padx08/PPTex | python | def set_defaults(options, **defaults):
' '
if ('defaults' not in options):
options = dict(options)
options['defaults'] = defaults
return options |
@classmethod
def _init_dependencies_order(cls):
"Resolve the order of options' processing. "
if (cls.__order__ is None):
(vertices, edges) = ([], set([]))
for (name, option) in cls.__options__.items():
vertices.append(name)
for _name in option.after:
edges... | 584,395,546,733,577,600 | Resolve the order of options' processing. | PPTexEnv_x86_64/lib/python2.7/site-packages/sympy/polys/polyoptions.py | _init_dependencies_order | 18padx08/PPTex | python | @classmethod
def _init_dependencies_order(cls):
" "
if (cls.__order__ is None):
(vertices, edges) = ([], set([]))
for (name, option) in cls.__options__.items():
vertices.append(name)
for _name in option.after:
edges.add((_name, name))
for _name... |
def clone(self, updates={}):
'Clone ``self`` and update specified options. '
obj = dict.__new__(self.__class__)
for (option, value) in self.items():
obj[option] = value
for (option, value) in updates.items():
obj[option] = value
return obj | -4,789,163,976,798,031,000 | Clone ``self`` and update specified options. | PPTexEnv_x86_64/lib/python2.7/site-packages/sympy/polys/polyoptions.py | clone | 18padx08/PPTex | python | def clone(self, updates={}):
' '
obj = dict.__new__(self.__class__)
for (option, value) in self.items():
obj[option] = value
for (option, value) in updates.items():
obj[option] = value
return obj |
def test_headRequest(self):
'\n L{Data.render} returns an empty response body for a I{HEAD} request.\n '
data = static.Data(b'foo', 'bar')
request = DummyRequest([''])
request.method = b'HEAD'
d = _render(data, request)
def cbRendered(ignored):
self.assertEqual(b''.join(re... | 5,796,402,234,009,444,000 | L{Data.render} returns an empty response body for a I{HEAD} request. | src/twisted/web/test/test_static.py | test_headRequest | ikingye/twisted | python | def test_headRequest(self):
'\n \n '
data = static.Data(b'foo', 'bar')
request = DummyRequest([])
request.method = b'HEAD'
d = _render(data, request)
def cbRendered(ignored):
self.assertEqual(b.join(request.written), b)
d.addCallback(cbRendered)
return d |
def test_invalidMethod(self):
'\n L{Data.render} raises L{UnsupportedMethod} in response to a non-I{GET},\n non-I{HEAD} request.\n '
data = static.Data(b'foo', b'bar')
request = DummyRequest([b''])
request.method = b'POST'
self.assertRaises(UnsupportedMethod, data.render, reques... | -5,311,282,060,070,802,000 | L{Data.render} raises L{UnsupportedMethod} in response to a non-I{GET},
non-I{HEAD} request. | src/twisted/web/test/test_static.py | test_invalidMethod | ikingye/twisted | python | def test_invalidMethod(self):
'\n L{Data.render} raises L{UnsupportedMethod} in response to a non-I{GET},\n non-I{HEAD} request.\n '
data = static.Data(b'foo', b'bar')
request = DummyRequest([b])
request.method = b'POST'
self.assertRaises(UnsupportedMethod, data.render, request) |
def test_ignoredExtTrue(self):
'\n Passing C{1} as the value to L{File}\'s C{ignoredExts} argument\n issues a warning and sets the ignored extensions to the\n wildcard C{"*"}.\n '
with warnings.catch_warnings(record=True) as caughtWarnings:
file = static.File(self.mktemp(), i... | -4,848,127,279,368,782,000 | Passing C{1} as the value to L{File}'s C{ignoredExts} argument
issues a warning and sets the ignored extensions to the
wildcard C{"*"}. | src/twisted/web/test/test_static.py | test_ignoredExtTrue | ikingye/twisted | python | def test_ignoredExtTrue(self):
'\n Passing C{1} as the value to L{File}\'s C{ignoredExts} argument\n issues a warning and sets the ignored extensions to the\n wildcard C{"*"}.\n '
with warnings.catch_warnings(record=True) as caughtWarnings:
file = static.File(self.mktemp(), i... |
def test_ignoredExtFalse(self):
"\n Passing C{1} as the value to L{File}'s C{ignoredExts} argument\n issues a warning and sets the ignored extensions to the empty\n list.\n "
with warnings.catch_warnings(record=True) as caughtWarnings:
file = static.File(self.mktemp(), ignore... | 1,052,521,521,552,563,600 | Passing C{1} as the value to L{File}'s C{ignoredExts} argument
issues a warning and sets the ignored extensions to the empty
list. | src/twisted/web/test/test_static.py | test_ignoredExtFalse | ikingye/twisted | python | def test_ignoredExtFalse(self):
"\n Passing C{1} as the value to L{File}'s C{ignoredExts} argument\n issues a warning and sets the ignored extensions to the empty\n list.\n "
with warnings.catch_warnings(record=True) as caughtWarnings:
file = static.File(self.mktemp(), ignore... |
def test_allowExt(self):
"\n Passing C{1} as the value to L{File}'s C{allowExt} argument\n issues a warning and sets the ignored extensions to the\n wildcard C{*}.\n "
with warnings.catch_warnings(record=True) as caughtWarnings:
file = static.File(self.mktemp(), ignoredExts=T... | -3,628,029,843,179,005,400 | Passing C{1} as the value to L{File}'s C{allowExt} argument
issues a warning and sets the ignored extensions to the
wildcard C{*}. | src/twisted/web/test/test_static.py | test_allowExt | ikingye/twisted | python | def test_allowExt(self):
"\n Passing C{1} as the value to L{File}'s C{allowExt} argument\n issues a warning and sets the ignored extensions to the\n wildcard C{*}.\n "
with warnings.catch_warnings(record=True) as caughtWarnings:
file = static.File(self.mktemp(), ignoredExts=T... |
def test_invalidMethod(self):
'\n L{File.render} raises L{UnsupportedMethod} in response to a non-I{GET},\n non-I{HEAD} request.\n '
request = DummyRequest([b''])
request.method = b'POST'
path = FilePath(self.mktemp())
path.setContent(b'foo')
file = static.File(path.path)
... | -420,214,662,511,013,250 | L{File.render} raises L{UnsupportedMethod} in response to a non-I{GET},
non-I{HEAD} request. | src/twisted/web/test/test_static.py | test_invalidMethod | ikingye/twisted | python | def test_invalidMethod(self):
'\n L{File.render} raises L{UnsupportedMethod} in response to a non-I{GET},\n non-I{HEAD} request.\n '
request = DummyRequest([b])
request.method = b'POST'
path = FilePath(self.mktemp())
path.setContent(b'foo')
file = static.File(path.path)
... |
def test_notFound(self):
'\n If a request is made which encounters a L{File} before a final segment\n which does not correspond to any file in the path the L{File} was\n created with, a not found response is sent.\n '
base = FilePath(self.mktemp())
base.makedirs()
file = stat... | 2,187,499,811,497,714,200 | If a request is made which encounters a L{File} before a final segment
which does not correspond to any file in the path the L{File} was
created with, a not found response is sent. | src/twisted/web/test/test_static.py | test_notFound | ikingye/twisted | python | def test_notFound(self):
'\n If a request is made which encounters a L{File} before a final segment\n which does not correspond to any file in the path the L{File} was\n created with, a not found response is sent.\n '
base = FilePath(self.mktemp())
base.makedirs()
file = stat... |
def test_emptyChild(self):
"\n The C{''} child of a L{File} which corresponds to a directory in the\n filesystem is a L{DirectoryLister}.\n "
base = FilePath(self.mktemp())
base.makedirs()
file = static.File(base.path)
request = DummyRequest([b''])
child = resource.getChildF... | -5,078,275,424,837,194,000 | The C{''} child of a L{File} which corresponds to a directory in the
filesystem is a L{DirectoryLister}. | src/twisted/web/test/test_static.py | test_emptyChild | ikingye/twisted | python | def test_emptyChild(self):
"\n The C{} child of a L{File} which corresponds to a directory in the\n filesystem is a L{DirectoryLister}.\n "
base = FilePath(self.mktemp())
base.makedirs()
file = static.File(base.path)
request = DummyRequest([b])
child = resource.getChildForRe... |
def test_emptyChildUnicodeParent(self):
"\n The C{u''} child of a L{File} which corresponds to a directory\n whose path is text is a L{DirectoryLister} that renders to a\n binary listing.\n\n @see: U{https://twistedmatrix.com/trac/ticket/9438}\n "
textBase = FilePath(self.mkte... | 992,252,466,549,817,900 | The C{u''} child of a L{File} which corresponds to a directory
whose path is text is a L{DirectoryLister} that renders to a
binary listing.
@see: U{https://twistedmatrix.com/trac/ticket/9438} | src/twisted/web/test/test_static.py | test_emptyChildUnicodeParent | ikingye/twisted | python | def test_emptyChildUnicodeParent(self):
"\n The C{u} child of a L{File} which corresponds to a directory\n whose path is text is a L{DirectoryLister} that renders to a\n binary listing.\n\n @see: U{https://twistedmatrix.com/trac/ticket/9438}\n "
textBase = FilePath(self.mktemp... |
def test_securityViolationNotFound(self):
'\n If a request is made which encounters a L{File} before a final segment\n which cannot be looked up in the filesystem due to security\n considerations, a not found response is sent.\n '
base = FilePath(self.mktemp())
base.makedirs()
... | -566,705,790,611,264,000 | If a request is made which encounters a L{File} before a final segment
which cannot be looked up in the filesystem due to security
considerations, a not found response is sent. | src/twisted/web/test/test_static.py | test_securityViolationNotFound | ikingye/twisted | python | def test_securityViolationNotFound(self):
'\n If a request is made which encounters a L{File} before a final segment\n which cannot be looked up in the filesystem due to security\n considerations, a not found response is sent.\n '
base = FilePath(self.mktemp())
base.makedirs()
... |
@skipIf(platform.isWindows(), 'Cannot remove read permission on Windows')
def test_forbiddenResource(self):
'\n If the file in the filesystem which would satisfy a request cannot be\n read, L{File.render} sets the HTTP response code to I{FORBIDDEN}.\n '
base = FilePath(self.mktemp())
ba... | 2,634,763,309,614,467,000 | If the file in the filesystem which would satisfy a request cannot be
read, L{File.render} sets the HTTP response code to I{FORBIDDEN}. | src/twisted/web/test/test_static.py | test_forbiddenResource | ikingye/twisted | python | @skipIf(platform.isWindows(), 'Cannot remove read permission on Windows')
def test_forbiddenResource(self):
'\n If the file in the filesystem which would satisfy a request cannot be\n read, L{File.render} sets the HTTP response code to I{FORBIDDEN}.\n '
base = FilePath(self.mktemp())
ba... |
def test_undecodablePath(self):
'\n A request whose path cannot be decoded as UTF-8 receives a not\n found response, and the failure is logged.\n '
path = self.mktemp()
if isinstance(path, bytes):
path = path.decode('ascii')
base = FilePath(path)
base.makedirs()
file... | 6,257,857,815,952,183,000 | A request whose path cannot be decoded as UTF-8 receives a not
found response, and the failure is logged. | src/twisted/web/test/test_static.py | test_undecodablePath | ikingye/twisted | python | def test_undecodablePath(self):
'\n A request whose path cannot be decoded as UTF-8 receives a not\n found response, and the failure is logged.\n '
path = self.mktemp()
if isinstance(path, bytes):
path = path.decode('ascii')
base = FilePath(path)
base.makedirs()
file... |
def test_forbiddenResource_default(self):
'\n L{File.forbidden} defaults to L{resource.ForbiddenResource}.\n '
self.assertIsInstance(static.File(b'.').forbidden, resource.ForbiddenResource) | -3,599,652,922,653,693,400 | L{File.forbidden} defaults to L{resource.ForbiddenResource}. | src/twisted/web/test/test_static.py | test_forbiddenResource_default | ikingye/twisted | python | def test_forbiddenResource_default(self):
'\n \n '
self.assertIsInstance(static.File(b'.').forbidden, resource.ForbiddenResource) |
def test_forbiddenResource_customize(self):
'\n The resource rendered for forbidden requests is stored as a class\n member so that users can customize it.\n '
base = FilePath(self.mktemp())
base.setContent(b'')
markerResponse = b'custom-forbidden-response'
def failingOpenForRea... | 7,500,880,065,751,543,000 | The resource rendered for forbidden requests is stored as a class
member so that users can customize it. | src/twisted/web/test/test_static.py | test_forbiddenResource_customize | ikingye/twisted | python | def test_forbiddenResource_customize(self):
'\n The resource rendered for forbidden requests is stored as a class\n member so that users can customize it.\n '
base = FilePath(self.mktemp())
base.setContent(b)
markerResponse = b'custom-forbidden-response'
def failingOpenForReadi... |
def test_indexNames(self):
"\n If a request is made which encounters a L{File} before a final empty\n segment, a file in the L{File} instance's C{indexNames} list which\n exists in the path the L{File} was created with is served as the\n response to the request.\n "
base = Fil... | -3,557,248,638,458,413,000 | If a request is made which encounters a L{File} before a final empty
segment, a file in the L{File} instance's C{indexNames} list which
exists in the path the L{File} was created with is served as the
response to the request. | src/twisted/web/test/test_static.py | test_indexNames | ikingye/twisted | python | def test_indexNames(self):
"\n If a request is made which encounters a L{File} before a final empty\n segment, a file in the L{File} instance's C{indexNames} list which\n exists in the path the L{File} was created with is served as the\n response to the request.\n "
base = Fil... |
def test_staticFile(self):
'\n If a request is made which encounters a L{File} before a final segment\n which names a file in the path the L{File} was created with, that file\n is served as the response to the request.\n '
base = FilePath(self.mktemp())
base.makedirs()
base.c... | 2,431,746,271,335,141,000 | If a request is made which encounters a L{File} before a final segment
which names a file in the path the L{File} was created with, that file
is served as the response to the request. | src/twisted/web/test/test_static.py | test_staticFile | ikingye/twisted | python | def test_staticFile(self):
'\n If a request is made which encounters a L{File} before a final segment\n which names a file in the path the L{File} was created with, that file\n is served as the response to the request.\n '
base = FilePath(self.mktemp())
base.makedirs()
base.c... |
@skipIf((sys.getfilesystemencoding().lower() not in ('utf-8', 'mcbs')), 'Cannot write unicode filenames with file system encoding of {}'.format(sys.getfilesystemencoding()))
def test_staticFileUnicodeFileName(self):
'\n A request for a existing unicode file path encoded as UTF-8\n returns the contents... | -9,114,157,304,539,470,000 | A request for a existing unicode file path encoded as UTF-8
returns the contents of that file. | src/twisted/web/test/test_static.py | test_staticFileUnicodeFileName | ikingye/twisted | python | @skipIf((sys.getfilesystemencoding().lower() not in ('utf-8', 'mcbs')), 'Cannot write unicode filenames with file system encoding of {}'.format(sys.getfilesystemencoding()))
def test_staticFileUnicodeFileName(self):
'\n A request for a existing unicode file path encoded as UTF-8\n returns the contents... |
def test_staticFileDeletedGetChild(self):
'\n A L{static.File} created for a directory which does not exist should\n return childNotFound from L{static.File.getChild}.\n '
staticFile = static.File(self.mktemp())
request = DummyRequest([b'foo.bar'])
child = staticFile.getChild(b'foo.... | -6,216,197,732,870,106,000 | A L{static.File} created for a directory which does not exist should
return childNotFound from L{static.File.getChild}. | src/twisted/web/test/test_static.py | test_staticFileDeletedGetChild | ikingye/twisted | python | def test_staticFileDeletedGetChild(self):
'\n A L{static.File} created for a directory which does not exist should\n return childNotFound from L{static.File.getChild}.\n '
staticFile = static.File(self.mktemp())
request = DummyRequest([b'foo.bar'])
child = staticFile.getChild(b'foo.... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.