function stringlengths 11 56k | repo_name stringlengths 5 60 | features list |
|---|---|---|
def colorsrc(self, val):
self["colorsrc"] = val | plotly/python-api | [
13052,
2308,
13052,
1319,
1385013188
] |
def family(self):
"""
HTML font family - the typeface that will be applied by the web
browser. The web browser will only be able to apply a font if
it is available on the system which it operates. Provide
multiple font families, separated by commas, to indicate the
preference in which to apply fonts if they aren't available on
the system. The Chart Studio Cloud (at https://chart-
studio.plotly.com or on-premise) generates images on a server,
where only a select number of fonts are installed and
supported. These include "Arial", "Balto", "Courier New",
"Droid Sans",, "Droid Serif", "Droid Sans Mono", "Gravitas
One", "Old Standard TT", "Open Sans", "Overpass", "PT Sans
Narrow", "Raleway", "Times New Roman". | plotly/python-api | [
13052,
2308,
13052,
1319,
1385013188
] |
def family(self, val):
self["family"] = val | plotly/python-api | [
13052,
2308,
13052,
1319,
1385013188
] |
def familysrc(self):
"""
Sets the source reference on Chart Studio Cloud for family . | plotly/python-api | [
13052,
2308,
13052,
1319,
1385013188
] |
def familysrc(self, val):
self["familysrc"] = val | plotly/python-api | [
13052,
2308,
13052,
1319,
1385013188
] |
def size(self):
"""
The 'size' property is a number and may be specified as:
- An int or float in the interval [1, inf]
- A tuple, list, or one-dimensional numpy array of the above
Returns
-------
int|float|numpy.ndarray
"""
return self["size"] | plotly/python-api | [
13052,
2308,
13052,
1319,
1385013188
] |
def size(self, val):
self["size"] = val | plotly/python-api | [
13052,
2308,
13052,
1319,
1385013188
] |
def sizesrc(self):
"""
Sets the source reference on Chart Studio Cloud for size . | plotly/python-api | [
13052,
2308,
13052,
1319,
1385013188
] |
def sizesrc(self, val):
self["sizesrc"] = val | plotly/python-api | [
13052,
2308,
13052,
1319,
1385013188
] |
def _prop_descriptions(self):
return """\
color
colorsrc
Sets the source reference on Chart Studio Cloud for
color .
family
HTML font family - the typeface that will be applied by
the web browser. The web browser will only be able to
apply a font if it is available on the system which it
operates. Provide multiple font families, separated by
commas, to indicate the preference in which to apply
fonts if they aren't available on the system. The Chart
Studio Cloud (at https://chart-studio.plotly.com or on-
premise) generates images on a server, where only a
select number of fonts are installed and supported.
These include "Arial", "Balto", "Courier New", "Droid
Sans",, "Droid Serif", "Droid Sans Mono", "Gravitas
One", "Old Standard TT", "Open Sans", "Overpass", "PT
Sans Narrow", "Raleway", "Times New Roman".
familysrc
Sets the source reference on Chart Studio Cloud for
family .
size
sizesrc
Sets the source reference on Chart Studio Cloud for
size .
""" | plotly/python-api | [
13052,
2308,
13052,
1319,
1385013188
] |
def __init__(self, ts=[], ids=[], index_cycles=[], slices=None,
time_bounds=[], select_ids={}, container_label=None,
experiment_label=None):
# ts is a Coordinates instance
self.container_label = container_label
self.experiment_label = experiment_label
if isinstance(ts, Coordinates):
self._timeseries = ts
# ts is a numpy array (structured if possible)
elif isinstance(ts, np.ndarray):
# convert structured arrays to 2d ndarrays
if ts.dtype.names is not None:
_arr = ts.view((float, len(ts.dtype.names)))
_x_name, _y_name = ts.dtype.names[:2] # take only first 2 cols
else:
_arr = ts
_x_name, _y_name = 'x', 'y'
_x = _arr[:, 0]
_y = _arr[:, 1]
self._timeseries = Coordinates(_x, _y,
x_name=_x_name, y_name=_y_name)
# ... list of couples
elif isinstance(ts, collections.Iterable):
_ts = list(ts)
_x, _y = map(np.array, zip(*_ts))
self._timeseries = Coordinates(_x, _y)
self.time_bounds = time_bounds
self.slices = []
if index_cycles: # array indices corresponding to (first, last) frame for each cell
self.index_cycles = index_cycles
slices = []
for item in index_cycles:
if item is None:
slices.append(None)
# indices are reported as a single None
# when no data is reported for a given cell
else:
i, j = item
if j is not None:
slices.append(slice(i, j+1))
else:
slices.append(slice(i, None))
self.slices = slices
elif slices is not None:
self.slices = slices
index_cycles = []
for item in slices:
if item is None:
index_cycles.append(None)
else:
if item.stop is not None:
index_cycles.append((item.start, item.stop - 1))
else:
index_cycles.append((item.start, None))
self.index_cycles = index_cycles
self.ids = ids
if len(select_ids.keys()) > 0: # master is already defined
self.selections = select_ids
else: # nothing is defined, we define master here
self.selections = {'master': [True for _ in self.ids]}
return | LeBarbouze/tunacell | [
1,
5,
1,
1,
1502214471
] |
def timeseries(self):
return self._timeseries | LeBarbouze/tunacell | [
1,
5,
1,
1,
1502214471
] |
def __repr__(self):
return repr(self.timeseries) | LeBarbouze/tunacell | [
1,
5,
1,
1,
1502214471
] |
def __init__(
self,
plotly_name="templateitemname",
parent_name="histogram2d.colorbar.tickformatstop",
**kwargs | plotly/plotly.py | [
13052,
2308,
13052,
1319,
1385013188
] |
def __init__(
self, plotly_name="bgcolorsrc", parent_name="histogram.marker.pattern", **kwargs | plotly/plotly.py | [
13052,
2308,
13052,
1319,
1385013188
] |
def setUp(self):
self.tempdir = tempfile.mkdtemp()
self.temppath = os.path.join(self.tempdir, "tempfile")
self.mock_user = mock()
self.mock_user.user_id = 1234 | scottrice/Ice | [
818,
108,
818,
209,
1356404560
] |
def test_previous_managed_ids_returns_none_for_missing_file(self):
missing_path = os.path.join("some", "stupid", "path")
self.assertFalse(os.path.exists(missing_path))
archive = ManagedROMArchive(missing_path)
self.assertIsNone(archive.previous_managed_ids(self.mock_user)) | scottrice/Ice | [
818,
108,
818,
209,
1356404560
] |
def test_previous_managed_ids_returns_empty_list_for_missing_user(self):
data = {
"1337": []
}
with open(self.temppath, "w+") as f:
f.write(json.dumps(data))
archive = ManagedROMArchive(self.temppath)
self.assertEquals(archive.previous_managed_ids(self.mock_user), []) | scottrice/Ice | [
818,
108,
818,
209,
1356404560
] |
def test_set_managed_ids_creates_new_file_if_needed(self):
self.assertFalse(os.path.exists(self.temppath))
archive = ManagedROMArchive(self.temppath)
archive.set_managed_ids(self.mock_user, ["1234567890"])
self.assertTrue(os.path.exists(self.temppath)) | scottrice/Ice | [
818,
108,
818,
209,
1356404560
] |
def make_lemmatizer(
nlp: Language, model: Optional[Model], name: str, mode: str, overwrite: bool | spacy-io/spaCy | [
25459,
4045,
25459,
98,
1404400540
] |
def __init__(self, client, config, serializer, deserializer):
self._client = client
self._serialize = serializer
self._deserialize = deserializer
self._config = config | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def begin_delete(
self,
resource_group_name, # type: str
azure_firewall_name, # type: str
**kwargs # type: Any | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def get_long_running_output(pipeline_response):
if cls:
return cls(pipeline_response, None, {}) | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def get(
self,
resource_group_name, # type: str
azure_firewall_name, # type: str
**kwargs # type: Any | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def _create_or_update_initial(
self,
resource_group_name, # type: str
azure_firewall_name, # type: str
parameters, # type: "_models.AzureFirewall"
**kwargs # type: Any | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def begin_create_or_update(
self,
resource_group_name, # type: str
azure_firewall_name, # type: str
parameters, # type: "_models.AzureFirewall"
**kwargs # type: Any | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def get_long_running_output(pipeline_response):
deserialized = self._deserialize('AzureFirewall', pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def update_tags(
self,
resource_group_name, # type: str
azure_firewall_name, # type: str
parameters, # type: "_models.AzureFirewall"
**kwargs # type: Any | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def list(
self,
resource_group_name, # type: str
**kwargs # type: Any | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def prepare_request(next_link=None):
# Construct headers
header_parameters = {} # type: Dict[str, Any]
header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
if not next_link:
# Construct URL
url = self.list.metadata['url'] # type: ignore
path_format_arguments = {
'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
}
url = self._client.format_url(url, **path_format_arguments)
# Construct parameters
query_parameters = {} # type: Dict[str, Any]
query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
request = self._client.get(url, query_parameters, header_parameters)
else:
url = next_link
query_parameters = {} # type: Dict[str, Any]
request = self._client.get(url, query_parameters, header_parameters)
return request | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response
if response.status_code not in [200]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise HttpResponseError(response=response, error_format=ARMErrorFormat)
return pipeline_response | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def list_all(
self,
**kwargs # type: Any | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def prepare_request(next_link=None):
# Construct headers
header_parameters = {} # type: Dict[str, Any]
header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
if not next_link:
# Construct URL
url = self.list_all.metadata['url'] # type: ignore
path_format_arguments = {
'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
}
url = self._client.format_url(url, **path_format_arguments)
# Construct parameters
query_parameters = {} # type: Dict[str, Any]
query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
request = self._client.get(url, query_parameters, header_parameters)
else:
url = next_link
query_parameters = {} # type: Dict[str, Any]
request = self._client.get(url, query_parameters, header_parameters)
return request | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def get_next(next_link=None):
request = prepare_request(next_link)
pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response
if response.status_code not in [200]:
map_error(status_code=response.status_code, response=response, error_map=error_map)
raise HttpResponseError(response=response, error_format=ARMErrorFormat)
return pipeline_response | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def test_upload_letters_button_only_with_letters_permission(
client_request,
service_one,
mock_get_uploads,
mock_get_jobs,
mock_get_no_contact_lists,
extra_permissions, | alphagov/notifications-admin | [
38,
31,
38,
7,
1447854917
] |
def test_all_users_have_upload_contact_list(
client_request,
mock_get_uploads,
mock_get_jobs,
mock_get_no_contact_lists,
user, | alphagov/notifications-admin | [
38,
31,
38,
7,
1447854917
] |
def test_get_upload_hub_with_no_uploads(
mocker,
client_request,
service_one,
mock_get_no_uploads,
mock_get_no_contact_lists,
extra_permissions,
expected_empty_message, | alphagov/notifications-admin | [
38,
31,
38,
7,
1447854917
] |
def test_get_upload_hub_page(
mocker,
client_request,
service_one,
mock_get_uploads,
mock_get_no_contact_lists, | alphagov/notifications-admin | [
38,
31,
38,
7,
1447854917
] |
def test_get_uploaded_letters(
mocker,
client_request,
service_one,
mock_get_uploaded_letters, | alphagov/notifications-admin | [
38,
31,
38,
7,
1447854917
] |
def test_get_empty_uploaded_letters_page(
mocker,
client_request,
service_one,
mock_get_no_uploaded_letters, | alphagov/notifications-admin | [
38,
31,
38,
7,
1447854917
] |
def test_get_uploaded_letters_passes_through_page_argument(
mocker,
client_request,
service_one,
mock_get_uploaded_letters, | alphagov/notifications-admin | [
38,
31,
38,
7,
1447854917
] |
def test_get_uploaded_letters_404s_for_bad_page_arguments(
mocker,
client_request, | alphagov/notifications-admin | [
38,
31,
38,
7,
1447854917
] |
def test_get_uploaded_letters_404s_for_invalid_date(
mocker,
client_request, | alphagov/notifications-admin | [
38,
31,
38,
7,
1447854917
] |
def test_uploads_page_shows_scheduled_jobs(
mocker,
client_request,
mock_get_no_uploads,
mock_get_jobs,
mock_get_no_contact_lists,
user, | alphagov/notifications-admin | [
38,
31,
38,
7,
1447854917
] |
def test_uploads_page_shows_contact_lists_first(
mocker,
client_request,
mock_get_no_uploads,
mock_get_jobs,
mock_get_contact_lists,
mock_get_service_data_retention, | alphagov/notifications-admin | [
38,
31,
38,
7,
1447854917
] |
def test_get_uploads_shows_pagination(
client_request,
active_user_with_permissions,
mock_get_jobs,
mock_get_uploads,
mock_get_no_contact_lists, | alphagov/notifications-admin | [
38,
31,
38,
7,
1447854917
] |
def test_capitalize(self, size):
SUBSTR = ' abc def ghi'
s = '-' * size + SUBSTR
caps = s.capitalize()
self.assertEquals(caps[-len(SUBSTR):],
SUBSTR.capitalize())
self.assertEquals(caps.lstrip('-'), SUBSTR) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_center(self, size):
SUBSTR = ' abc def ghi'
s = SUBSTR.center(size)
self.assertEquals(len(s), size)
lpadsize = rpadsize = (len(s) - len(SUBSTR)) // 2
if len(s) % 2:
lpadsize += 1
self.assertEquals(s[lpadsize:-rpadsize], SUBSTR)
self.assertEquals(s.strip(), SUBSTR.strip()) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_center_unicode(self, size):
SUBSTR = u' abc def ghi'
try:
s = SUBSTR.center(size)
except OverflowError:
pass # acceptable on 32-bit
else:
self.assertEquals(len(s), size)
lpadsize = rpadsize = (len(s) - len(SUBSTR)) // 2
if len(s) % 2:
lpadsize += 1
self.assertEquals(s[lpadsize:-rpadsize], SUBSTR)
self.assertEquals(s.strip(), SUBSTR.strip())
del s | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_count(self, size):
SUBSTR = ' abc def ghi'
s = '.' * size + SUBSTR
self.assertEquals(s.count('.'), size)
s += '.'
self.assertEquals(s.count('.'), size + 1)
self.assertEquals(s.count(' '), 3)
self.assertEquals(s.count('i'), 1)
self.assertEquals(s.count('j'), 0) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_decode(self, size):
s = '.' * size
self.assertEquals(len(s.decode('utf-8')), size) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def basic_encode_test(self, size, enc, c=u'.', expectedsize=None):
if expectedsize is None:
expectedsize = size | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_encode(self, size):
return self.basic_encode_test(size, 'utf-8') | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_encode_raw_unicode_escape(self, size):
try:
return self.basic_encode_test(size, 'raw_unicode_escape')
except MemoryError:
pass # acceptable on 32-bit | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_encode_utf7(self, size):
try:
return self.basic_encode_test(size, 'utf7')
except MemoryError:
pass # acceptable on 32-bit | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_encode_utf32(self, size):
try:
return self.basic_encode_test(size, 'utf32', expectedsize=4*size+4)
except MemoryError:
pass # acceptable on 32-bit | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_decodeascii(self, size):
return self.basic_encode_test(size, 'ascii', c='A') | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_unicode_repr_oflw(self, size):
try:
s = u"\uAAAA"*size
r = repr(s)
except MemoryError:
pass # acceptable on 32-bit
else:
self.failUnless(s == eval(r)) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_endswith(self, size):
SUBSTR = ' abc def ghi'
s = '-' * size + SUBSTR
self.failUnless(s.endswith(SUBSTR))
self.failUnless(s.endswith(s))
s2 = '...' + s
self.failUnless(s2.endswith(s))
self.failIf(s.endswith('a' + SUBSTR))
self.failIf(SUBSTR.endswith(s)) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_expandtabs(self, size):
s = '-' * size
tabsize = 8
self.assertEquals(s.expandtabs(), s)
del s
slen, remainder = divmod(size, tabsize)
s = ' \t' * slen
s = s.expandtabs(tabsize)
self.assertEquals(len(s), size - remainder)
self.assertEquals(len(s.strip(' ')), 0) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_find(self, size):
SUBSTR = ' abc def ghi'
sublen = len(SUBSTR)
s = ''.join([SUBSTR, '-' * size, SUBSTR])
self.assertEquals(s.find(' '), 0)
self.assertEquals(s.find(SUBSTR), 0)
self.assertEquals(s.find(' ', sublen), sublen + size)
self.assertEquals(s.find(SUBSTR, len(SUBSTR)), sublen + size)
self.assertEquals(s.find('i'), SUBSTR.find('i'))
self.assertEquals(s.find('i', sublen),
sublen + size + SUBSTR.find('i'))
self.assertEquals(s.find('i', size),
sublen + size + SUBSTR.find('i'))
self.assertEquals(s.find('j'), -1) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_index(self, size):
SUBSTR = ' abc def ghi'
sublen = len(SUBSTR)
s = ''.join([SUBSTR, '-' * size, SUBSTR])
self.assertEquals(s.index(' '), 0)
self.assertEquals(s.index(SUBSTR), 0)
self.assertEquals(s.index(' ', sublen), sublen + size)
self.assertEquals(s.index(SUBSTR, sublen), sublen + size)
self.assertEquals(s.index('i'), SUBSTR.index('i'))
self.assertEquals(s.index('i', sublen),
sublen + size + SUBSTR.index('i'))
self.assertEquals(s.index('i', size),
sublen + size + SUBSTR.index('i'))
self.assertRaises(ValueError, s.index, 'j') | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_isalnum(self, size):
SUBSTR = '123456'
s = 'a' * size + SUBSTR
self.failUnless(s.isalnum())
s += '.'
self.failIf(s.isalnum()) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_isalpha(self, size):
SUBSTR = 'zzzzzzz'
s = 'a' * size + SUBSTR
self.failUnless(s.isalpha())
s += '.'
self.failIf(s.isalpha()) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_isdigit(self, size):
SUBSTR = '123456'
s = '9' * size + SUBSTR
self.failUnless(s.isdigit())
s += 'z'
self.failIf(s.isdigit()) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_islower(self, size):
chars = ''.join([ chr(c) for c in range(255) if not chr(c).isupper() ])
repeats = size // len(chars) + 2
s = chars * repeats
self.failUnless(s.islower())
s += 'A'
self.failIf(s.islower()) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_isspace(self, size):
whitespace = ' \f\n\r\t\v'
repeats = size // len(whitespace) + 2
s = whitespace * repeats
self.failUnless(s.isspace())
s += 'j'
self.failIf(s.isspace()) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_istitle(self, size):
SUBSTR = '123456'
s = ''.join(['A', 'a' * size, SUBSTR])
self.failUnless(s.istitle())
s += 'A'
self.failUnless(s.istitle())
s += 'aA'
self.failIf(s.istitle()) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_isupper(self, size):
chars = ''.join([ chr(c) for c in range(255) if not chr(c).islower() ])
repeats = size // len(chars) + 2
s = chars * repeats
self.failUnless(s.isupper())
s += 'a'
self.failIf(s.isupper()) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_join(self, size):
s = 'A' * size
x = s.join(['aaaaa', 'bbbbb'])
self.assertEquals(x.count('a'), 5)
self.assertEquals(x.count('b'), 5)
self.failUnless(x.startswith('aaaaaA'))
self.failUnless(x.endswith('Abbbbb')) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_ljust(self, size):
SUBSTR = ' abc def ghi'
s = SUBSTR.ljust(size)
self.failUnless(s.startswith(SUBSTR + ' '))
self.assertEquals(len(s), size)
self.assertEquals(s.strip(), SUBSTR.strip()) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_lower(self, size):
s = 'A' * size
s = s.lower()
self.assertEquals(len(s), size)
self.assertEquals(s.count('a'), size) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_lstrip(self, size):
SUBSTR = 'abc def ghi'
s = SUBSTR.rjust(size)
self.assertEquals(len(s), size)
self.assertEquals(s.lstrip(), SUBSTR.lstrip())
del s
s = SUBSTR.ljust(size)
self.assertEquals(len(s), size)
stripped = s.lstrip()
self.failUnless(stripped is s) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_replace(self, size):
replacement = 'a'
s = ' ' * size
s = s.replace(' ', replacement)
self.assertEquals(len(s), size)
self.assertEquals(s.count(replacement), size)
s = s.replace(replacement, ' ', size - 4)
self.assertEquals(len(s), size)
self.assertEquals(s.count(replacement), 4)
self.assertEquals(s[-10:], ' aaaa') | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_rfind(self, size):
SUBSTR = ' abc def ghi'
sublen = len(SUBSTR)
s = ''.join([SUBSTR, '-' * size, SUBSTR])
self.assertEquals(s.rfind(' '), sublen + size + SUBSTR.rfind(' '))
self.assertEquals(s.rfind(SUBSTR), sublen + size)
self.assertEquals(s.rfind(' ', 0, size), SUBSTR.rfind(' '))
self.assertEquals(s.rfind(SUBSTR, 0, sublen + size), 0)
self.assertEquals(s.rfind('i'), sublen + size + SUBSTR.rfind('i'))
self.assertEquals(s.rfind('i', 0, sublen), SUBSTR.rfind('i'))
self.assertEquals(s.rfind('i', 0, sublen + size),
SUBSTR.rfind('i'))
self.assertEquals(s.rfind('j'), -1) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_rindex(self, size):
SUBSTR = ' abc def ghi'
sublen = len(SUBSTR)
s = ''.join([SUBSTR, '-' * size, SUBSTR])
self.assertEquals(s.rindex(' '),
sublen + size + SUBSTR.rindex(' '))
self.assertEquals(s.rindex(SUBSTR), sublen + size)
self.assertEquals(s.rindex(' ', 0, sublen + size - 1),
SUBSTR.rindex(' '))
self.assertEquals(s.rindex(SUBSTR, 0, sublen + size), 0)
self.assertEquals(s.rindex('i'),
sublen + size + SUBSTR.rindex('i'))
self.assertEquals(s.rindex('i', 0, sublen), SUBSTR.rindex('i'))
self.assertEquals(s.rindex('i', 0, sublen + size),
SUBSTR.rindex('i'))
self.assertRaises(ValueError, s.rindex, 'j') | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_rjust(self, size):
SUBSTR = ' abc def ghi'
s = SUBSTR.ljust(size)
self.failUnless(s.startswith(SUBSTR + ' '))
self.assertEquals(len(s), size)
self.assertEquals(s.strip(), SUBSTR.strip()) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_rstrip(self, size):
SUBSTR = ' abc def ghi'
s = SUBSTR.ljust(size)
self.assertEquals(len(s), size)
self.assertEquals(s.rstrip(), SUBSTR.rstrip())
del s
s = SUBSTR.rjust(size)
self.assertEquals(len(s), size)
stripped = s.rstrip()
self.failUnless(stripped is s) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_split_small(self, size):
# Crudely calculate an estimate so that the result of s.split won't
# take up an inordinate amount of memory
chunksize = int(size ** 0.5 + 2)
SUBSTR = 'a' + ' ' * chunksize
s = SUBSTR * chunksize
l = s.split()
self.assertEquals(len(l), chunksize)
self.assertEquals(set(l), set(['a']))
del l
l = s.split('a')
self.assertEquals(len(l), chunksize + 1)
self.assertEquals(set(l), set(['', ' ' * chunksize])) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_split_large(self, size):
s = ' a' * size + ' '
l = s.split()
self.assertEquals(len(l), size)
self.assertEquals(set(l), set(['a']))
del l
l = s.split('a')
self.assertEquals(len(l), size + 1)
self.assertEquals(set(l), set([' '])) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_splitlines(self, size):
# Crudely calculate an estimate so that the result of s.split won't
# take up an inordinate amount of memory
chunksize = int(size ** 0.5 + 2) // 2
SUBSTR = ' ' * chunksize + '\n' + ' ' * chunksize + '\r\n'
s = SUBSTR * chunksize
l = s.splitlines()
self.assertEquals(len(l), chunksize * 2)
self.assertEquals(set(l), set([' ' * chunksize])) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_startswith(self, size):
SUBSTR = ' abc def ghi'
s = '-' * size + SUBSTR
self.failUnless(s.startswith(s))
self.failUnless(s.startswith('-' * size))
self.failIf(s.startswith(SUBSTR)) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_strip(self, size):
SUBSTR = ' abc def ghi '
s = SUBSTR.rjust(size)
self.assertEquals(len(s), size)
self.assertEquals(s.strip(), SUBSTR.strip())
del s
s = SUBSTR.ljust(size)
self.assertEquals(len(s), size)
self.assertEquals(s.strip(), SUBSTR.strip()) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_swapcase(self, size):
SUBSTR = "aBcDeFG12.'\xa9\x00"
sublen = len(SUBSTR)
repeats = size // sublen + 2
s = SUBSTR * repeats
s = s.swapcase()
self.assertEquals(len(s), sublen * repeats)
self.assertEquals(s[:sublen * 3], SUBSTR.swapcase() * 3)
self.assertEquals(s[-sublen * 3:], SUBSTR.swapcase() * 3) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_title(self, size):
SUBSTR = 'SpaaHAaaAaham'
s = SUBSTR * (size // len(SUBSTR) + 2)
s = s.title()
self.failUnless(s.startswith((SUBSTR * 3).title()))
self.failUnless(s.endswith(SUBSTR.lower() * 3)) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_translate(self, size):
trans = string.maketrans('.aZ', '-!$')
SUBSTR = 'aZz.z.Aaz.'
sublen = len(SUBSTR)
repeats = size // sublen + 2
s = SUBSTR * repeats
s = s.translate(trans)
self.assertEquals(len(s), repeats * sublen)
self.assertEquals(s[:sublen], SUBSTR.translate(trans))
self.assertEquals(s[-sublen:], SUBSTR.translate(trans))
self.assertEquals(s.count('.'), 0)
self.assertEquals(s.count('!'), repeats * 2)
self.assertEquals(s.count('z'), repeats * 3) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_upper(self, size):
s = 'a' * size
s = s.upper()
self.assertEquals(len(s), size)
self.assertEquals(s.count('A'), size) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_zfill(self, size):
SUBSTR = '-568324723598234'
s = SUBSTR.zfill(size)
self.failUnless(s.endswith('0' + SUBSTR[1:]))
self.failUnless(s.startswith('-0'))
self.assertEquals(len(s), size)
self.assertEquals(s.count('0'), size - len(SUBSTR)) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_format(self, size):
s = '-' * size
sf = '%s' % (s,)
self.failUnless(s == sf)
del sf
sf = '..%s..' % (s,)
self.assertEquals(len(sf), len(s) + 4)
self.failUnless(sf.startswith('..-'))
self.failUnless(sf.endswith('-..'))
del s, sf | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_repr_small(self, size):
s = '-' * size
s = repr(s)
self.assertEquals(len(s), size + 2)
self.assertEquals(s[0], "'")
self.assertEquals(s[-1], "'")
self.assertEquals(s.count('-'), size)
del s
# repr() will create a string four times as large as this 'binary
# string', but we don't want to allocate much more than twice
# size in total. (We do extra testing in test_repr_large())
size = size // 5 * 2
s = '\x00' * size
s = repr(s)
self.assertEquals(len(s), size * 4 + 2)
self.assertEquals(s[0], "'")
self.assertEquals(s[-1], "'")
self.assertEquals(s.count('\\'), size)
self.assertEquals(s.count('0'), size * 2) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_repr_large(self, size):
s = '\x00' * size
s = repr(s)
self.assertEquals(len(s), size * 4 + 2)
self.assertEquals(s[0], "'")
self.assertEquals(s[-1], "'")
self.assertEquals(s.count('\\'), size)
self.assertEquals(s.count('0'), size * 2) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_unicode_repr(self, size):
s = u"\uAAAA" * size
self.failUnless(len(repr(s)) > size) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_concat(self, size):
s = '.' * size
self.assertEquals(len(s), size)
s = s + s
self.assertEquals(len(s), size * 2)
self.assertEquals(s.count('.'), size * 2) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_repeat(self, size):
s = '.' * size
self.assertEquals(len(s), size)
s = s * 2
self.assertEquals(len(s), size * 2)
self.assertEquals(s.count('.'), size * 2) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_slice_and_getitem(self, size):
SUBSTR = '0123456789'
sublen = len(SUBSTR)
s = SUBSTR * (size // sublen)
stepsize = len(s) // 100
stepsize = stepsize - (stepsize % sublen)
for i in range(0, len(s) - stepsize, stepsize):
self.assertEquals(s[i], SUBSTR[0])
self.assertEquals(s[i:i + sublen], SUBSTR)
self.assertEquals(s[i:i + sublen:2], SUBSTR[::2])
if i > 0:
self.assertEquals(s[i + sublen - 1:i - 1:-3],
SUBSTR[sublen::-3])
# Make sure we do some slicing and indexing near the end of the
# string, too.
self.assertEquals(s[len(s) - 1], SUBSTR[-1])
self.assertEquals(s[-1], SUBSTR[-1])
self.assertEquals(s[len(s) - 10], SUBSTR[0])
self.assertEquals(s[-sublen], SUBSTR[0])
self.assertEquals(s[len(s):], '')
self.assertEquals(s[len(s) - 1:], SUBSTR[-1])
self.assertEquals(s[-1:], SUBSTR[-1])
self.assertEquals(s[len(s) - sublen:], SUBSTR)
self.assertEquals(s[-sublen:], SUBSTR)
self.assertEquals(len(s[:]), len(s))
self.assertEquals(len(s[:len(s) - 5]), len(s) - 5)
self.assertEquals(len(s[5:-5]), len(s) - 10) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_contains(self, size):
SUBSTR = '0123456789'
edge = '-' * (size // 2)
s = ''.join([edge, SUBSTR, edge])
del edge
self.failUnless(SUBSTR in s)
self.failIf(SUBSTR * 2 in s)
self.failUnless('-' in s)
self.failIf('a' in s)
s += 'a'
self.failUnless('a' in s) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_compare(self, size):
s1 = '-' * size
s2 = '-' * size
self.failUnless(s1 == s2)
del s2
s2 = s1 + 'a'
self.failIf(s1 == s2)
del s2
s2 = '.' * size
self.failIf(s1 == s2) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_hash(self, size):
# Not sure if we can do any meaningful tests here... Even if we
# start relying on the exact algorithm used, the result will be
# different depending on the size of the C 'long int'. Even this
# test is dodgy (there's no *guarantee* that the two things should
# have a different hash, even if they, in the current
# implementation, almost always do.)
s = '\x00' * size
h1 = hash(s)
del s
s = '\x00' * (size + 1)
self.failIf(h1 == hash(s)) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_compare(self, size):
t1 = (u'',) * size
t2 = (u'',) * size
self.failUnless(t1 == t2)
del t2
t2 = (u'',) * (size + 1)
self.failIf(t1 == t2)
del t2
t2 = (1,) * size
self.failIf(t1 == t2) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def basic_concat_test(self, size):
t = ((),) * size
self.assertEquals(len(t), size)
t = t + t
self.assertEquals(len(t), size * 2) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.