Search is not available for this dataset
identifier stringlengths 1 155 | parameters stringlengths 2 6.09k | docstring stringlengths 11 63.4k | docstring_summary stringlengths 0 63.4k | function stringlengths 29 99.8k | function_tokens list | start_point list | end_point list | language stringclasses 1
value | docstring_language stringlengths 2 7 | docstring_language_predictions stringlengths 18 23 | is_langid_reliable stringclasses 2
values |
|---|---|---|---|---|---|---|---|---|---|---|---|
get_package_libraries | (pkg) |
Recursively yield template tag libraries defined in submodules of a
package.
|
Recursively yield template tag libraries defined in submodules of a
package.
| def get_package_libraries(pkg):
"""
Recursively yield template tag libraries defined in submodules of a
package.
"""
for entry in walk_packages(pkg.__path__, pkg.__name__ + '.'):
try:
module = import_module(entry[1])
except ImportError as e:
raise InvalidTempl... | [
"def",
"get_package_libraries",
"(",
"pkg",
")",
":",
"for",
"entry",
"in",
"walk_packages",
"(",
"pkg",
".",
"__path__",
",",
"pkg",
".",
"__name__",
"+",
"'.'",
")",
":",
"try",
":",
"module",
"=",
"import_module",
"(",
"entry",
"[",
"1",
"]",
")",
... | [
113,
0
] | [
128,
26
] | python | en | ['en', 'error', 'th'] | False |
DjangoTemplates.get_templatetag_libraries | (self, custom_libraries) |
Return a collation of template tag libraries from installed
applications and the supplied custom_libraries argument.
|
Return a collation of template tag libraries from installed
applications and the supplied custom_libraries argument.
| def get_templatetag_libraries(self, custom_libraries):
"""
Return a collation of template tag libraries from installed
applications and the supplied custom_libraries argument.
"""
libraries = get_installed_libraries()
libraries.update(custom_libraries)
return libr... | [
"def",
"get_templatetag_libraries",
"(",
"self",
",",
"custom_libraries",
")",
":",
"libraries",
"=",
"get_installed_libraries",
"(",
")",
"libraries",
".",
"update",
"(",
"custom_libraries",
")",
"return",
"libraries"
] | [
37,
4
] | [
44,
24
] | python | en | ['en', 'error', 'th'] | False |
CurrentSiteManager._get_field_name | (self) | Return self.__field_name or 'site' or 'sites'. | Return self.__field_name or 'site' or 'sites'. | def _get_field_name(self):
""" Return self.__field_name or 'site' or 'sites'. """
if not self.__field_name:
try:
self.model._meta.get_field('site')
except FieldDoesNotExist:
self.__field_name = 'sites'
else:
self.__fiel... | [
"def",
"_get_field_name",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"__field_name",
":",
"try",
":",
"self",
".",
"model",
".",
"_meta",
".",
"get_field",
"(",
"'site'",
")",
"except",
"FieldDoesNotExist",
":",
"self",
".",
"__field_name",
"=",
"'... | [
46,
4
] | [
56,
32
] | python | en | ['en', 'en', 'en'] | True |
localize | (value) |
Force a value to be rendered as a localized value,
regardless of the value of ``settings.USE_L10N``.
|
Force a value to be rendered as a localized value,
regardless of the value of ``settings.USE_L10N``.
| def localize(value):
"""
Force a value to be rendered as a localized value,
regardless of the value of ``settings.USE_L10N``.
"""
return str(formats.localize(value, use_l10n=True)) | [
"def",
"localize",
"(",
"value",
")",
":",
"return",
"str",
"(",
"formats",
".",
"localize",
"(",
"value",
",",
"use_l10n",
"=",
"True",
")",
")"
] | [
7,
0
] | [
12,
54
] | python | en | ['en', 'error', 'th'] | False |
unlocalize | (value) |
Force a value to be rendered as a non-localized value,
regardless of the value of ``settings.USE_L10N``.
|
Force a value to be rendered as a non-localized value,
regardless of the value of ``settings.USE_L10N``.
| def unlocalize(value):
"""
Force a value to be rendered as a non-localized value,
regardless of the value of ``settings.USE_L10N``.
"""
return str(formats.localize(value, use_l10n=False)) | [
"def",
"unlocalize",
"(",
"value",
")",
":",
"return",
"str",
"(",
"formats",
".",
"localize",
"(",
"value",
",",
"use_l10n",
"=",
"False",
")",
")"
] | [
16,
0
] | [
21,
55
] | python | en | ['en', 'error', 'th'] | False |
localize_tag | (parser, token) |
Force or prevents localization of values, regardless of the value of
`settings.USE_L10N`.
Sample usage::
{% localize off %}
var pi = {{ 3.1415 }};
{% endlocalize %}
|
Force or prevents localization of values, regardless of the value of
`settings.USE_L10N`. | def localize_tag(parser, token):
"""
Force or prevents localization of values, regardless of the value of
`settings.USE_L10N`.
Sample usage::
{% localize off %}
var pi = {{ 3.1415 }};
{% endlocalize %}
"""
use_l10n = None
bits = list(token.split_contents())
... | [
"def",
"localize_tag",
"(",
"parser",
",",
"token",
")",
":",
"use_l10n",
"=",
"None",
"bits",
"=",
"list",
"(",
"token",
".",
"split_contents",
"(",
")",
")",
"if",
"len",
"(",
"bits",
")",
"==",
"1",
":",
"use_l10n",
"=",
"True",
"elif",
"len",
"... | [
41,
0
] | [
62,
43
] | python | en | ['en', 'error', 'th'] | False |
MigrationRecorder.ensure_schema | (self) |
Ensures the table exists and has the correct schema.
|
Ensures the table exists and has the correct schema.
| def ensure_schema(self):
"""
Ensures the table exists and has the correct schema.
"""
# If the table's there, that's fine - we've never changed its schema
# in the codebase.
if self.Migration._meta.db_table in self.connection.introspection.table_names(self.connection.curs... | [
"def",
"ensure_schema",
"(",
"self",
")",
":",
"# If the table's there, that's fine - we've never changed its schema",
"# in the codebase.",
"if",
"self",
".",
"Migration",
".",
"_meta",
".",
"db_table",
"in",
"self",
".",
"connection",
".",
"introspection",
".",
"table... | [
42,
4
] | [
52,
47
] | python | en | ['en', 'error', 'th'] | False |
MigrationRecorder.applied_migrations | (self) |
Returns a set of (app, name) of applied migrations.
|
Returns a set of (app, name) of applied migrations.
| def applied_migrations(self):
"""
Returns a set of (app, name) of applied migrations.
"""
self.ensure_schema()
return set(tuple(x) for x in self.migration_qs.values_list("app", "name")) | [
"def",
"applied_migrations",
"(",
"self",
")",
":",
"self",
".",
"ensure_schema",
"(",
")",
"return",
"set",
"(",
"tuple",
"(",
"x",
")",
"for",
"x",
"in",
"self",
".",
"migration_qs",
".",
"values_list",
"(",
"\"app\"",
",",
"\"name\"",
")",
")"
] | [
54,
4
] | [
59,
82
] | python | en | ['en', 'error', 'th'] | False |
MigrationRecorder.record_applied | (self, app, name) |
Records that a migration was applied.
|
Records that a migration was applied.
| def record_applied(self, app, name):
"""
Records that a migration was applied.
"""
self.ensure_schema()
self.migration_qs.create(app=app, name=name) | [
"def",
"record_applied",
"(",
"self",
",",
"app",
",",
"name",
")",
":",
"self",
".",
"ensure_schema",
"(",
")",
"self",
".",
"migration_qs",
".",
"create",
"(",
"app",
"=",
"app",
",",
"name",
"=",
"name",
")"
] | [
61,
4
] | [
66,
52
] | python | en | ['en', 'error', 'th'] | False |
MigrationRecorder.record_unapplied | (self, app, name) |
Records that a migration was unapplied.
|
Records that a migration was unapplied.
| def record_unapplied(self, app, name):
"""
Records that a migration was unapplied.
"""
self.ensure_schema()
self.migration_qs.filter(app=app, name=name).delete() | [
"def",
"record_unapplied",
"(",
"self",
",",
"app",
",",
"name",
")",
":",
"self",
".",
"ensure_schema",
"(",
")",
"self",
".",
"migration_qs",
".",
"filter",
"(",
"app",
"=",
"app",
",",
"name",
"=",
"name",
")",
".",
"delete",
"(",
")"
] | [
68,
4
] | [
73,
61
] | python | en | ['en', 'error', 'th'] | False |
MigrationRecorder.flush | (self) |
Deletes all migration records. Useful if you're testing migrations.
|
Deletes all migration records. Useful if you're testing migrations.
| def flush(self):
"""
Deletes all migration records. Useful if you're testing migrations.
"""
self.migration_qs.all().delete() | [
"def",
"flush",
"(",
"self",
")",
":",
"self",
".",
"migration_qs",
".",
"all",
"(",
")",
".",
"delete",
"(",
")"
] | [
75,
4
] | [
79,
40
] | python | en | ['en', 'error', 'th'] | False |
ContentTypesTests.test_lookup_cache | (self) |
Make sure that the content type cache (see ContentTypeManager)
works correctly. Lookups for a particular content type -- by model, ID
or natural key -- should hit the database only on the first lookup.
|
Make sure that the content type cache (see ContentTypeManager)
works correctly. Lookups for a particular content type -- by model, ID
or natural key -- should hit the database only on the first lookup.
| def test_lookup_cache(self):
"""
Make sure that the content type cache (see ContentTypeManager)
works correctly. Lookups for a particular content type -- by model, ID
or natural key -- should hit the database only on the first lookup.
"""
# At this point, a lookup for a ... | [
"def",
"test_lookup_cache",
"(",
"self",
")",
":",
"# At this point, a lookup for a ContentType should hit the DB",
"with",
"self",
".",
"assertNumQueries",
"(",
"1",
")",
":",
"ContentType",
".",
"objects",
".",
"get_for_model",
"(",
"ContentType",
")",
"# A second hit... | [
20,
4
] | [
54,
65
] | python | en | ['en', 'error', 'th'] | False |
ContentTypesTests.test_get_for_concrete_model | (self) |
Make sure the `for_concrete_model` kwarg correctly works
with concrete, proxy and deferred models
|
Make sure the `for_concrete_model` kwarg correctly works
with concrete, proxy and deferred models
| def test_get_for_concrete_model(self):
"""
Make sure the `for_concrete_model` kwarg correctly works
with concrete, proxy and deferred models
"""
concrete_model_ct = ContentType.objects.get_for_model(ConcreteModel)
self.assertEqual(concrete_model_ct,
ContentTy... | [
"def",
"test_get_for_concrete_model",
"(",
"self",
")",
":",
"concrete_model_ct",
"=",
"ContentType",
".",
"objects",
".",
"get_for_model",
"(",
"ConcreteModel",
")",
"self",
".",
"assertEqual",
"(",
"concrete_model_ct",
",",
"ContentType",
".",
"objects",
".",
"g... | [
86,
4
] | [
122,
72
] | python | en | ['en', 'error', 'th'] | False |
ContentTypesTests.test_get_for_concrete_models | (self) |
Make sure the `for_concrete_models` kwarg correctly works
with concrete, proxy and deferred models.
|
Make sure the `for_concrete_models` kwarg correctly works
with concrete, proxy and deferred models.
| def test_get_for_concrete_models(self):
"""
Make sure the `for_concrete_models` kwarg correctly works
with concrete, proxy and deferred models.
"""
concrete_model_ct = ContentType.objects.get_for_model(ConcreteModel)
cts = ContentType.objects.get_for_models(ConcreteModel... | [
"def",
"test_get_for_concrete_models",
"(",
"self",
")",
":",
"concrete_model_ct",
"=",
"ContentType",
".",
"objects",
".",
"get_for_model",
"(",
"ConcreteModel",
")",
"cts",
"=",
"ContentType",
".",
"objects",
".",
"get_for_models",
"(",
"ConcreteModel",
",",
"Pr... | [
124,
4
] | [
164,
10
] | python | en | ['en', 'error', 'th'] | False |
ContentTypesTests.test_shortcut_view | (self) |
Check that the shortcut view (used for the admin "view on site"
functionality) returns a complete URL regardless of whether the sites
framework is installed
|
Check that the shortcut view (used for the admin "view on site"
functionality) returns a complete URL regardless of whether the sites
framework is installed
| def test_shortcut_view(self):
"""
Check that the shortcut view (used for the admin "view on site"
functionality) returns a complete URL regardless of whether the sites
framework is installed
"""
request = HttpRequest()
request.META = {
"SERVER_NAME": ... | [
"def",
"test_shortcut_view",
"(",
"self",
")",
":",
"request",
"=",
"HttpRequest",
"(",
")",
"request",
".",
"META",
"=",
"{",
"\"SERVER_NAME\"",
":",
"\"Example.com\"",
",",
"\"SERVER_PORT\"",
":",
"\"80\"",
",",
"}",
"user_ct",
"=",
"ContentType",
".",
"ob... | [
167,
4
] | [
190,
66
] | python | en | ['en', 'error', 'th'] | False |
ContentTypesTests.test_shortcut_view_without_get_absolute_url | (self) |
Check that the shortcut view (used for the admin "view on site"
functionality) returns 404 when get_absolute_url is not defined.
|
Check that the shortcut view (used for the admin "view on site"
functionality) returns 404 when get_absolute_url is not defined.
| def test_shortcut_view_without_get_absolute_url(self):
"""
Check that the shortcut view (used for the admin "view on site"
functionality) returns 404 when get_absolute_url is not defined.
"""
request = HttpRequest()
request.META = {
"SERVER_NAME": "Example.co... | [
"def",
"test_shortcut_view_without_get_absolute_url",
"(",
"self",
")",
":",
"request",
"=",
"HttpRequest",
"(",
")",
"request",
".",
"META",
"=",
"{",
"\"SERVER_NAME\"",
":",
"\"Example.com\"",
",",
"\"SERVER_PORT\"",
":",
"\"80\"",
",",
"}",
"user_ct",
"=",
"C... | [
192,
4
] | [
206,
73
] | python | en | ['en', 'error', 'th'] | False |
ContentTypesTests.test_shortcut_view_with_broken_get_absolute_url | (self) |
Check that the shortcut view does not catch an AttributeError raised
by the model's get_absolute_url method.
Refs #8997.
|
Check that the shortcut view does not catch an AttributeError raised
by the model's get_absolute_url method.
Refs #8997.
| def test_shortcut_view_with_broken_get_absolute_url(self):
"""
Check that the shortcut view does not catch an AttributeError raised
by the model's get_absolute_url method.
Refs #8997.
"""
request = HttpRequest()
request.META = {
"SERVER_NAME": "Example... | [
"def",
"test_shortcut_view_with_broken_get_absolute_url",
"(",
"self",
")",
":",
"request",
"=",
"HttpRequest",
"(",
")",
"request",
".",
"META",
"=",
"{",
"\"SERVER_NAME\"",
":",
"\"Example.com\"",
",",
"\"SERVER_PORT\"",
":",
"\"80\"",
",",
"}",
"user_ct",
"=",
... | [
208,
4
] | [
222,
80
] | python | en | ['en', 'error', 'th'] | False |
ContentTypesTests.test_missing_model | (self) |
Ensures that displaying content types in admin (or anywhere) doesn't
break on leftover content type records in the DB for which no model
is defined anymore.
|
Ensures that displaying content types in admin (or anywhere) doesn't
break on leftover content type records in the DB for which no model
is defined anymore.
| def test_missing_model(self):
"""
Ensures that displaying content types in admin (or anywhere) doesn't
break on leftover content type records in the DB for which no model
is defined anymore.
"""
ct = ContentType.objects.create(
name='Old model',
ap... | [
"def",
"test_missing_model",
"(",
"self",
")",
":",
"ct",
"=",
"ContentType",
".",
"objects",
".",
"create",
"(",
"name",
"=",
"'Old model'",
",",
"app_label",
"=",
"'contenttypes'",
",",
"model",
"=",
"'OldModel'",
",",
")",
"self",
".",
"assertEqual",
"(... | [
224,
4
] | [
242,
51
] | python | en | ['en', 'error', 'th'] | False |
convert_markdown_syntax | (text: str, regex: str, zulip_keyword: str) |
Returns:
1. For strikethrough formatting: This maps Slack's '~strike~' to Zulip's '~~strike~~'
2. For bold formatting: This maps Slack's '*bold*' to Zulip's '**bold**'
3. For italic formatting: This maps Slack's '_italic_' to Zulip's '*italic*'
|
Returns:
1. For strikethrough formatting: This maps Slack's '~strike~' to Zulip's '~~strike~~'
2. For bold formatting: This maps Slack's '*bold*' to Zulip's '**bold**'
3. For italic formatting: This maps Slack's '_italic_' to Zulip's '*italic*'
| def convert_markdown_syntax(text: str, regex: str, zulip_keyword: str) -> str:
"""
Returns:
1. For strikethrough formatting: This maps Slack's '~strike~' to Zulip's '~~strike~~'
2. For bold formatting: This maps Slack's '*bold*' to Zulip's '**bold**'
3. For italic formatting: This maps Slack's '_ita... | [
"def",
"convert_markdown_syntax",
"(",
"text",
":",
"str",
",",
"regex",
":",
"str",
",",
"zulip_keyword",
":",
"str",
")",
"->",
"str",
":",
"for",
"match",
"in",
"re",
".",
"finditer",
"(",
"regex",
",",
"text",
",",
"re",
".",
"VERBOSE",
")",
":",... | [
140,
0
] | [
157,
15
] | python | en | ['en', 'error', 'th'] | False |
convert_link_format | (text: str) |
1. Converts '<https://foo.com>' to 'https://foo.com'
2. Converts '<https://foo.com|foo>' to 'https://foo.com|foo'
|
1. Converts '<https://foo.com>' to 'https://foo.com'
2. Converts '<https://foo.com|foo>' to 'https://foo.com|foo'
| def convert_link_format(text: str) -> Tuple[str, bool]:
"""
1. Converts '<https://foo.com>' to 'https://foo.com'
2. Converts '<https://foo.com|foo>' to 'https://foo.com|foo'
"""
has_link = False
for match in re.finditer(LINK_REGEX, text, re.VERBOSE):
converted_text = match.group(0).repla... | [
"def",
"convert_link_format",
"(",
"text",
":",
"str",
")",
"->",
"Tuple",
"[",
"str",
",",
"bool",
"]",
":",
"has_link",
"=",
"False",
"for",
"match",
"in",
"re",
".",
"finditer",
"(",
"LINK_REGEX",
",",
"text",
",",
"re",
".",
"VERBOSE",
")",
":",
... | [
160,
0
] | [
170,
25
] | python | en | ['en', 'error', 'th'] | False |
convert_mailto_format | (text: str) |
1. Converts '<mailto:foo@foo.com>' to 'mailto:foo@foo.com'
2. Converts '<mailto:foo@foo.com|foo@foo.com>' to 'mailto:foo@foo.com'
|
1. Converts '<mailto:foo | def convert_mailto_format(text: str) -> Tuple[str, bool]:
"""
1. Converts '<mailto:foo@foo.com>' to 'mailto:foo@foo.com'
2. Converts '<mailto:foo@foo.com|foo@foo.com>' to 'mailto:foo@foo.com'
"""
has_link = False
for match in re.finditer(SLACK_MAILTO_REGEX, text, re.VERBOSE):
has_link = ... | [
"def",
"convert_mailto_format",
"(",
"text",
":",
"str",
")",
"->",
"Tuple",
"[",
"str",
",",
"bool",
"]",
":",
"has_link",
"=",
"False",
"for",
"match",
"in",
"re",
".",
"finditer",
"(",
"SLACK_MAILTO_REGEX",
",",
"text",
",",
"re",
".",
"VERBOSE",
")... | [
173,
0
] | [
182,
25
] | python | en | ['en', 'error', 'th'] | False |
custom_key_func | (key, key_prefix, version) | A customized cache key function | A customized cache key function | def custom_key_func(key, key_prefix, version):
"A customized cache key function"
return 'CUSTOM-' + '-'.join([key_prefix, str(version), key]) | [
"def",
"custom_key_func",
"(",
"key",
",",
"key_prefix",
",",
"version",
")",
":",
"return",
"'CUSTOM-'",
"+",
"'-'",
".",
"join",
"(",
"[",
"key_prefix",
",",
"str",
"(",
"version",
")",
",",
"key",
"]",
")"
] | [
195,
0
] | [
197,
64
] | python | en | ['en', 'en', 'en'] | True |
BaseCacheTests.test_long_timeout | (self) |
Using a timeout greater than 30 days makes memcached think
it is an absolute expiration timestamp instead of a relative
offset. Test that we honour this convention. Refs #12399.
|
Using a timeout greater than 30 days makes memcached think
it is an absolute expiration timestamp instead of a relative
offset. Test that we honour this convention. Refs #12399.
| def test_long_timeout(self):
'''
Using a timeout greater than 30 days makes memcached think
it is an absolute expiration timestamp instead of a relative
offset. Test that we honour this convention. Refs #12399.
'''
cache.set('key1', 'eggs', 60 * 60 * 24 * 30 + 1) # 30 da... | [
"def",
"test_long_timeout",
"(",
"self",
")",
":",
"cache",
".",
"set",
"(",
"'key1'",
",",
"'eggs'",
",",
"60",
"*",
"60",
"*",
"24",
"*",
"30",
"+",
"1",
")",
"# 30 days + 1 second",
"self",
".",
"assertEqual",
"(",
"cache",
".",
"get",
"(",
"'key1... | [
469,
4
] | [
483,
61
] | python | en | ['en', 'error', 'th'] | False |
BaseCacheTests.test_forever_timeout | (self) |
Passing in None into timeout results in a value that is cached forever
|
Passing in None into timeout results in a value that is cached forever
| def test_forever_timeout(self):
'''
Passing in None into timeout results in a value that is cached forever
'''
cache.set('key1', 'eggs', None)
self.assertEqual(cache.get('key1'), 'eggs')
cache.add('key2', 'ham', None)
self.assertEqual(cache.get('key2'), 'ham')
... | [
"def",
"test_forever_timeout",
"(",
"self",
")",
":",
"cache",
".",
"set",
"(",
"'key1'",
",",
"'eggs'",
",",
"None",
")",
"self",
".",
"assertEqual",
"(",
"cache",
".",
"get",
"(",
"'key1'",
")",
",",
"'eggs'",
")",
"cache",
".",
"add",
"(",
"'key2'... | [
485,
4
] | [
500,
61
] | python | en | ['en', 'error', 'th'] | False |
BaseCacheTests.test_zero_timeout | (self) |
Passing in zero into timeout results in a value that is not cached
|
Passing in zero into timeout results in a value that is not cached
| def test_zero_timeout(self):
'''
Passing in zero into timeout results in a value that is not cached
'''
cache.set('key1', 'eggs', 0)
self.assertIsNone(cache.get('key1'))
cache.add('key2', 'ham', 0)
self.assertIsNone(cache.get('key2'))
cache.set_many({'ke... | [
"def",
"test_zero_timeout",
"(",
"self",
")",
":",
"cache",
".",
"set",
"(",
"'key1'",
",",
"'eggs'",
",",
"0",
")",
"self",
".",
"assertIsNone",
"(",
"cache",
".",
"get",
"(",
"'key1'",
")",
")",
"cache",
".",
"add",
"(",
"'key2'",
",",
"'ham'",
"... | [
502,
4
] | [
514,
44
] | python | en | ['en', 'error', 'th'] | False |
BaseCacheTests.test_invalid_keys | (self) |
All the builtin backends (except memcached, see below) should warn on
keys that would be refused by memcached. This encourages portable
caching code without making it too difficult to use production backends
with more liberal key rules. Refs #6447.
|
All the builtin backends (except memcached, see below) should warn on
keys that would be refused by memcached. This encourages portable
caching code without making it too difficult to use production backends
with more liberal key rules. Refs #6447. | def test_invalid_keys(self):
"""
All the builtin backends (except memcached, see below) should warn on
keys that would be refused by memcached. This encourages portable
caching code without making it too difficult to use production backends
with more liberal key rules. Refs #6447... | [
"def",
"test_invalid_keys",
"(",
"self",
")",
":",
"# mimic custom ``make_key`` method being defined since the default will",
"# never show the below warnings",
"def",
"func",
"(",
"key",
",",
"*",
"args",
")",
":",
"return",
"key",
"old_func",
"=",
"cache",
".",
"key_f... | [
539,
4
] | [
569,
37
] | python | en | ['en', 'error', 'th'] | False |
BaseCacheTests.test_add_fail_on_pickleerror | (self) | See https://code.djangoproject.com/ticket/21200 | See https://code.djangoproject.com/ticket/21200 | def test_add_fail_on_pickleerror(self):
"See https://code.djangoproject.com/ticket/21200"
with self.assertRaises(pickle.PickleError):
cache.add('unpickable', Unpickable()) | [
"def",
"test_add_fail_on_pickleerror",
"(",
"self",
")",
":",
"with",
"self",
".",
"assertRaises",
"(",
"pickle",
".",
"PickleError",
")",
":",
"cache",
".",
"add",
"(",
"'unpickable'",
",",
"Unpickable",
"(",
")",
")"
] | [
872,
4
] | [
875,
49
] | python | en | ['en', 'nl', 'sw'] | False |
BaseCacheTests.test_set_fail_on_pickleerror | (self) | See https://code.djangoproject.com/ticket/21200 | See https://code.djangoproject.com/ticket/21200 | def test_set_fail_on_pickleerror(self):
"See https://code.djangoproject.com/ticket/21200"
with self.assertRaises(pickle.PickleError):
cache.set('unpickable', Unpickable()) | [
"def",
"test_set_fail_on_pickleerror",
"(",
"self",
")",
":",
"with",
"self",
".",
"assertRaises",
"(",
"pickle",
".",
"PickleError",
")",
":",
"cache",
".",
"set",
"(",
"'unpickable'",
",",
"Unpickable",
"(",
")",
")"
] | [
877,
4
] | [
880,
49
] | python | en | ['en', 'nl', 'sw'] | False |
DefaultNonExpiringCacheKeyTests.test_default_expiration_time_for_keys_is_5_minutes | (self) | The default expiration time of a cache key is 5 minutes.
This value is defined inside the __init__() method of the
:class:`django.core.cache.backends.base.BaseCache` type.
| The default expiration time of a cache key is 5 minutes. | def test_default_expiration_time_for_keys_is_5_minutes(self):
"""The default expiration time of a cache key is 5 minutes.
This value is defined inside the __init__() method of the
:class:`django.core.cache.backends.base.BaseCache` type.
"""
self.assertEqual(300, self.DEFAULT_TIM... | [
"def",
"test_default_expiration_time_for_keys_is_5_minutes",
"(",
"self",
")",
":",
"self",
".",
"assertEqual",
"(",
"300",
",",
"self",
".",
"DEFAULT_TIMEOUT",
")"
] | [
1261,
4
] | [
1267,
51
] | python | en | ['en', 'en', 'en'] | True |
DefaultNonExpiringCacheKeyTests.test_caches_with_unset_timeout_has_correct_default_timeout | (self) | Caches that have the TIMEOUT parameter undefined in the default
settings will use the default 5 minute timeout.
| Caches that have the TIMEOUT parameter undefined in the default
settings will use the default 5 minute timeout.
| def test_caches_with_unset_timeout_has_correct_default_timeout(self):
"""Caches that have the TIMEOUT parameter undefined in the default
settings will use the default 5 minute timeout.
"""
cache = caches[DEFAULT_CACHE_ALIAS]
self.assertEqual(self.DEFAULT_TIMEOUT, cache.default_ti... | [
"def",
"test_caches_with_unset_timeout_has_correct_default_timeout",
"(",
"self",
")",
":",
"cache",
"=",
"caches",
"[",
"DEFAULT_CACHE_ALIAS",
"]",
"self",
".",
"assertEqual",
"(",
"self",
".",
"DEFAULT_TIMEOUT",
",",
"cache",
".",
"default_timeout",
")"
] | [
1269,
4
] | [
1274,
69
] | python | en | ['en', 'en', 'en'] | True |
DefaultNonExpiringCacheKeyTests.test_caches_set_with_timeout_as_none_has_correct_default_timeout | (self) | Memory caches that have the TIMEOUT parameter set to `None` in the
default settings with have `None` as the default timeout.
This means "no timeout".
| Memory caches that have the TIMEOUT parameter set to `None` in the
default settings with have `None` as the default timeout. | def test_caches_set_with_timeout_as_none_has_correct_default_timeout(self):
"""Memory caches that have the TIMEOUT parameter set to `None` in the
default settings with have `None` as the default timeout.
This means "no timeout".
"""
cache = caches[DEFAULT_CACHE_ALIAS]
se... | [
"def",
"test_caches_set_with_timeout_as_none_has_correct_default_timeout",
"(",
"self",
")",
":",
"cache",
"=",
"caches",
"[",
"DEFAULT_CACHE_ALIAS",
"]",
"self",
".",
"assertIsNone",
"(",
"cache",
".",
"default_timeout",
")",
"self",
".",
"assertIsNone",
"(",
"cache"... | [
1277,
4
] | [
1285,
54
] | python | en | ['en', 'en', 'en'] | True |
DefaultNonExpiringCacheKeyTests.test_caches_with_unset_timeout_set_expiring_key | (self) | Memory caches that have the TIMEOUT parameter unset will set cache
keys having the default 5 minute timeout.
| Memory caches that have the TIMEOUT parameter unset will set cache
keys having the default 5 minute timeout.
| def test_caches_with_unset_timeout_set_expiring_key(self):
"""Memory caches that have the TIMEOUT parameter unset will set cache
keys having the default 5 minute timeout.
"""
key = "my-key"
value = "my-value"
cache = caches[DEFAULT_CACHE_ALIAS]
cache.set(key, valu... | [
"def",
"test_caches_with_unset_timeout_set_expiring_key",
"(",
"self",
")",
":",
"key",
"=",
"\"my-key\"",
"value",
"=",
"\"my-value\"",
"cache",
"=",
"caches",
"[",
"DEFAULT_CACHE_ALIAS",
"]",
"cache",
".",
"set",
"(",
"key",
",",
"value",
")",
"cache_key",
"="... | [
1288,
4
] | [
1297,
59
] | python | en | ['en', 'en', 'en'] | True |
DefaultNonExpiringCacheKeyTests.text_caches_set_with_timeout_as_none_set_non_expiring_key | (self) | Memory caches that have the TIMEOUT parameter set to `None` will set
a non expiring key by default.
| Memory caches that have the TIMEOUT parameter set to `None` will set
a non expiring key by default.
| def text_caches_set_with_timeout_as_none_set_non_expiring_key(self):
"""Memory caches that have the TIMEOUT parameter set to `None` will set
a non expiring key by default.
"""
key = "another-key"
value = "another-value"
cache = caches[DEFAULT_CACHE_ALIAS]
cache.se... | [
"def",
"text_caches_set_with_timeout_as_none_set_non_expiring_key",
"(",
"self",
")",
":",
"key",
"=",
"\"another-key\"",
"value",
"=",
"\"another-value\"",
"cache",
"=",
"caches",
"[",
"DEFAULT_CACHE_ALIAS",
"]",
"cache",
".",
"set",
"(",
"key",
",",
"value",
")",
... | [
1300,
4
] | [
1309,
56
] | python | en | ['en', 'en', 'en'] | True |
CacheHandlerTest.test_same_instance | (self) |
Attempting to retrieve the same alias should yield the same instance.
|
Attempting to retrieve the same alias should yield the same instance.
| def test_same_instance(self):
"""
Attempting to retrieve the same alias should yield the same instance.
"""
cache1 = caches['default']
cache2 = caches['default']
self.assertTrue(cache1 is cache2) | [
"def",
"test_same_instance",
"(",
"self",
")",
":",
"cache1",
"=",
"caches",
"[",
"'default'",
"]",
"cache2",
"=",
"caches",
"[",
"'default'",
"]",
"self",
".",
"assertTrue",
"(",
"cache1",
"is",
"cache2",
")"
] | [
2098,
4
] | [
2105,
41
] | python | en | ['en', 'error', 'th'] | False |
CacheHandlerTest.test_per_thread | (self) |
Requesting the same alias from separate threads should yield separate
instances.
|
Requesting the same alias from separate threads should yield separate
instances.
| def test_per_thread(self):
"""
Requesting the same alias from separate threads should yield separate
instances.
"""
c = []
def runner():
c.append(caches['default'])
for x in range(2):
t = threading.Thread(target=runner)
t.star... | [
"def",
"test_per_thread",
"(",
"self",
")",
":",
"c",
"=",
"[",
"]",
"def",
"runner",
"(",
")",
":",
"c",
".",
"append",
"(",
"caches",
"[",
"'default'",
"]",
")",
"for",
"x",
"in",
"range",
"(",
"2",
")",
":",
"t",
"=",
"threading",
".",
"Thre... | [
2107,
4
] | [
2122,
38
] | python | en | ['en', 'error', 'th'] | False |
compute_PSD_matrix | (audio, window_size) |
First, perform STFT.
Then, compute the PSD.
Last, normalize PSD.
|
First, perform STFT.
Then, compute the PSD.
Last, normalize PSD.
| def compute_PSD_matrix(audio, window_size):
"""
First, perform STFT.
Then, compute the PSD.
Last, normalize PSD.
"""
win = np.sqrt(8.0 / 3.0) * librosa.core.stft(audio, center=False)
z = abs(win / window_size)
psd_max = np.max(z * z)
psd = 10 * np.log10(z * z + 0.0000000000000000001... | [
"def",
"compute_PSD_matrix",
"(",
"audio",
",",
"window_size",
")",
":",
"win",
"=",
"np",
".",
"sqrt",
"(",
"8.0",
"/",
"3.0",
")",
"*",
"librosa",
".",
"core",
".",
"stft",
"(",
"audio",
",",
"center",
"=",
"False",
")",
"z",
"=",
"abs",
"(",
"... | [
9,
0
] | [
21,
23
] | python | en | ['en', 'error', 'th'] | False |
Bark | (f) | returns the bark-scale value for input frequency f (in Hz) | returns the bark-scale value for input frequency f (in Hz) | def Bark(f):
"""returns the bark-scale value for input frequency f (in Hz)"""
return 13 * np.arctan(0.00076 * f) + 3.5 * np.arctan(pow(f / 7500.0, 2)) | [
"def",
"Bark",
"(",
"f",
")",
":",
"return",
"13",
"*",
"np",
".",
"arctan",
"(",
"0.00076",
"*",
"f",
")",
"+",
"3.5",
"*",
"np",
".",
"arctan",
"(",
"pow",
"(",
"f",
"/",
"7500.0",
",",
"2",
")",
")"
] | [
24,
0
] | [
26,
76
] | python | en | ['en', 'en', 'en'] | True |
quiet | (f) | returns threshold in quiet measured in SPL at frequency f with an offset 12(in Hz) | returns threshold in quiet measured in SPL at frequency f with an offset 12(in Hz) | def quiet(f):
"""returns threshold in quiet measured in SPL at frequency f with an offset 12(in Hz)"""
thresh = (
3.64 * pow(f * 0.001, -0.8)
- 6.5 * np.exp(-0.6 * pow(0.001 * f - 3.3, 2))
+ 0.001 * pow(0.001 * f, 4)
- 12
)
return thresh | [
"def",
"quiet",
"(",
"f",
")",
":",
"thresh",
"=",
"(",
"3.64",
"*",
"pow",
"(",
"f",
"*",
"0.001",
",",
"-",
"0.8",
")",
"-",
"6.5",
"*",
"np",
".",
"exp",
"(",
"-",
"0.6",
"*",
"pow",
"(",
"0.001",
"*",
"f",
"-",
"3.3",
",",
"2",
")",
... | [
29,
0
] | [
37,
17
] | python | en | ['en', 'en', 'en'] | True |
two_slops | (bark_psd, delta_TM, bark_maskee) |
returns the masking threshold for each masker using two slopes as the spread function
|
returns the masking threshold for each masker using two slopes as the spread function
| def two_slops(bark_psd, delta_TM, bark_maskee):
"""
returns the masking threshold for each masker using two slopes as the spread function
"""
Ts = []
for tone_mask in range(bark_psd.shape[0]):
bark_masker = bark_psd[tone_mask, 0]
dz = bark_maskee - bark_masker
zero_index = np... | [
"def",
"two_slops",
"(",
"bark_psd",
",",
"delta_TM",
",",
"bark_maskee",
")",
":",
"Ts",
"=",
"[",
"]",
"for",
"tone_mask",
"in",
"range",
"(",
"bark_psd",
".",
"shape",
"[",
"0",
"]",
")",
":",
"bark_masker",
"=",
"bark_psd",
"[",
"tone_mask",
",",
... | [
40,
0
] | [
56,
13
] | python | en | ['en', 'error', 'th'] | False |
compute_th | (PSD, barks, ATH, freqs) | returns the global masking threshold | returns the global masking threshold | def compute_th(PSD, barks, ATH, freqs):
"""returns the global masking threshold"""
# Identification of tonal maskers
# find the index of maskers that are the local maxima
length = len(PSD)
masker_index = signal.argrelextrema(PSD, np.greater)[0]
# delete the boundary of maskers for smoothing
... | [
"def",
"compute_th",
"(",
"PSD",
",",
"barks",
",",
"ATH",
",",
"freqs",
")",
":",
"# Identification of tonal maskers",
"# find the index of maskers that are the local maxima",
"length",
"=",
"len",
"(",
"PSD",
")",
"masker_index",
"=",
"signal",
".",
"argrelextrema",... | [
59,
0
] | [
117,
18
] | python | en | ['en', 'no', 'en'] | True |
generate_th | (audio, fs, window_size=2048) |
returns the masking threshold theta_xs and the max psd of the audio
|
returns the masking threshold theta_xs and the max psd of the audio
| def generate_th(audio, fs, window_size=2048):
"""
returns the masking threshold theta_xs and the max psd of the audio
"""
PSD, psd_max = compute_PSD_matrix(audio, window_size)
freqs = librosa.core.fft_frequencies(fs, window_size)
barks = Bark(freqs)
# compute the quiet threshold
ATH = n... | [
"def",
"generate_th",
"(",
"audio",
",",
"fs",
",",
"window_size",
"=",
"2048",
")",
":",
"PSD",
",",
"psd_max",
"=",
"compute_PSD_matrix",
"(",
"audio",
",",
"window_size",
")",
"freqs",
"=",
"librosa",
".",
"core",
".",
"fft_frequencies",
"(",
"fs",
",... | [
120,
0
] | [
139,
28
] | python | en | ['en', 'error', 'th'] | False |
ReverseSelectRelatedTestCase.test_missing_reverse | (self) |
Ticket #13839: select_related() should NOT cache None
for missing objects on a reverse 1-1 relation.
|
Ticket #13839: select_related() should NOT cache None
for missing objects on a reverse 1-1 relation.
| def test_missing_reverse(self):
"""
Ticket #13839: select_related() should NOT cache None
for missing objects on a reverse 1-1 relation.
"""
with self.assertNumQueries(1):
user = User.objects.select_related('userprofile').get(username='bob')
with self.asse... | [
"def",
"test_missing_reverse",
"(",
"self",
")",
":",
"with",
"self",
".",
"assertNumQueries",
"(",
"1",
")",
":",
"user",
"=",
"User",
".",
"objects",
".",
"select_related",
"(",
"'userprofile'",
")",
".",
"get",
"(",
"username",
"=",
"'bob'",
")",
"wit... | [
99,
4
] | [
107,
32
] | python | en | ['en', 'error', 'th'] | False |
ReverseSelectRelatedTestCase.test_nullable_missing_reverse | (self) |
Ticket #13839: select_related() should NOT cache None
for missing objects on a reverse 0-1 relation.
|
Ticket #13839: select_related() should NOT cache None
for missing objects on a reverse 0-1 relation.
| def test_nullable_missing_reverse(self):
"""
Ticket #13839: select_related() should NOT cache None
for missing objects on a reverse 0-1 relation.
"""
Image.objects.create(name="imag1")
with self.assertNumQueries(1):
image = Image.objects.select_related('produ... | [
"def",
"test_nullable_missing_reverse",
"(",
"self",
")",
":",
"Image",
".",
"objects",
".",
"create",
"(",
"name",
"=",
"\"imag1\"",
")",
"with",
"self",
".",
"assertNumQueries",
"(",
"1",
")",
":",
"image",
"=",
"Image",
".",
"objects",
".",
"select_rela... | [
109,
4
] | [
119,
29
] | python | en | ['en', 'error', 'th'] | False |
GEOSGeometry.__init__ | (self, geo_input, srid=None) |
The base constructor for GEOS geometry objects, and may take the
following inputs:
* strings:
- WKT
- HEXEWKB (a PostGIS-specific canonical form)
- GeoJSON (requires GDAL)
* buffer:
- WKB
The `srid` keyword is used to specify t... |
The base constructor for GEOS geometry objects, and may take the
following inputs: | def __init__(self, geo_input, srid=None):
"""
The base constructor for GEOS geometry objects, and may take the
following inputs:
* strings:
- WKT
- HEXEWKB (a PostGIS-specific canonical form)
- GeoJSON (requires GDAL)
* buffer:
-... | [
"def",
"__init__",
"(",
"self",
",",
"geo_input",
",",
"srid",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"geo_input",
",",
"bytes",
")",
":",
"geo_input",
"=",
"force_text",
"(",
"geo_input",
")",
"if",
"isinstance",
"(",
"geo_input",
",",
"six",
... | [
46,
4
] | [
97,
29
] | python | en | ['en', 'error', 'th'] | False |
GEOSGeometry._post_init | (self, srid) | Helper routine for performing post-initialization setup. | Helper routine for performing post-initialization setup. | def _post_init(self, srid):
"Helper routine for performing post-initialization setup."
# Setting the SRID, if given.
if srid and isinstance(srid, int):
self.srid = srid
# Setting the class type (e.g., Point, Polygon, etc.)
self.__class__ = GEOS_CLASSES[self.geom_type... | [
"def",
"_post_init",
"(",
"self",
",",
"srid",
")",
":",
"# Setting the SRID, if given.",
"if",
"srid",
"and",
"isinstance",
"(",
"srid",
",",
"int",
")",
":",
"self",
".",
"srid",
"=",
"srid",
"# Setting the class type (e.g., Point, Polygon, etc.)",
"self",
".",
... | [
99,
4
] | [
110,
22
] | python | en | ['en', 'en', 'en'] | True |
GEOSGeometry.__del__ | (self) |
Destroys this Geometry; in other words, frees the memory used by the
GEOS C++ object.
|
Destroys this Geometry; in other words, frees the memory used by the
GEOS C++ object.
| def __del__(self):
"""
Destroys this Geometry; in other words, frees the memory used by the
GEOS C++ object.
"""
if self._ptr and capi:
capi.destroy_geom(self._ptr) | [
"def",
"__del__",
"(",
"self",
")",
":",
"if",
"self",
".",
"_ptr",
"and",
"capi",
":",
"capi",
".",
"destroy_geom",
"(",
"self",
".",
"_ptr",
")"
] | [
112,
4
] | [
118,
40
] | python | en | ['en', 'error', 'th'] | False |
GEOSGeometry.__copy__ | (self) |
Returns a clone because the copy of a GEOSGeometry may contain an
invalid pointer location if the original is garbage collected.
|
Returns a clone because the copy of a GEOSGeometry may contain an
invalid pointer location if the original is garbage collected.
| def __copy__(self):
"""
Returns a clone because the copy of a GEOSGeometry may contain an
invalid pointer location if the original is garbage collected.
"""
return self.clone() | [
"def",
"__copy__",
"(",
"self",
")",
":",
"return",
"self",
".",
"clone",
"(",
")"
] | [
120,
4
] | [
125,
27
] | python | en | ['en', 'error', 'th'] | False |
GEOSGeometry.__deepcopy__ | (self, memodict) |
The `deepcopy` routine is used by the `Node` class of django.utils.tree;
thus, the protocol routine needs to be implemented to return correct
copies (clones) of these GEOS objects, which use C pointers.
|
The `deepcopy` routine is used by the `Node` class of django.utils.tree;
thus, the protocol routine needs to be implemented to return correct
copies (clones) of these GEOS objects, which use C pointers.
| def __deepcopy__(self, memodict):
"""
The `deepcopy` routine is used by the `Node` class of django.utils.tree;
thus, the protocol routine needs to be implemented to return correct
copies (clones) of these GEOS objects, which use C pointers.
"""
return self.clone() | [
"def",
"__deepcopy__",
"(",
"self",
",",
"memodict",
")",
":",
"return",
"self",
".",
"clone",
"(",
")"
] | [
127,
4
] | [
133,
27
] | python | en | ['en', 'error', 'th'] | False |
GEOSGeometry.__str__ | (self) | WKT is used for the string representation. | WKT is used for the string representation. | def __str__(self):
"WKT is used for the string representation."
return self.wkt | [
"def",
"__str__",
"(",
"self",
")",
":",
"return",
"self",
".",
"wkt"
] | [
135,
4
] | [
137,
23
] | python | en | ['en', 'en', 'en'] | True |
GEOSGeometry.__repr__ | (self) | Short-hand representation because WKT may be very large. | Short-hand representation because WKT may be very large. | def __repr__(self):
"Short-hand representation because WKT may be very large."
return '<%s object at %s>' % (self.geom_type, hex(addressof(self.ptr))) | [
"def",
"__repr__",
"(",
"self",
")",
":",
"return",
"'<%s object at %s>'",
"%",
"(",
"self",
".",
"geom_type",
",",
"hex",
"(",
"addressof",
"(",
"self",
".",
"ptr",
")",
")",
")"
] | [
139,
4
] | [
141,
79
] | python | en | ['en', 'en', 'en'] | True |
GEOSGeometry.__eq__ | (self, other) |
Equivalence testing, a Geometry may be compared with another Geometry
or a WKT representation.
|
Equivalence testing, a Geometry may be compared with another Geometry
or a WKT representation.
| def __eq__(self, other):
"""
Equivalence testing, a Geometry may be compared with another Geometry
or a WKT representation.
"""
if isinstance(other, six.string_types):
return self.wkt == other
elif isinstance(other, GEOSGeometry):
return self.equal... | [
"def",
"__eq__",
"(",
"self",
",",
"other",
")",
":",
"if",
"isinstance",
"(",
"other",
",",
"six",
".",
"string_types",
")",
":",
"return",
"self",
".",
"wkt",
"==",
"other",
"elif",
"isinstance",
"(",
"other",
",",
"GEOSGeometry",
")",
":",
"return",... | [
159,
4
] | [
169,
24
] | python | en | ['en', 'error', 'th'] | False |
GEOSGeometry.__ne__ | (self, other) | The not equals operator. | The not equals operator. | def __ne__(self, other):
"The not equals operator."
return not (self == other) | [
"def",
"__ne__",
"(",
"self",
",",
"other",
")",
":",
"return",
"not",
"(",
"self",
"==",
"other",
")"
] | [
171,
4
] | [
173,
34
] | python | en | ['en', 'en', 'en'] | True |
GEOSGeometry.__or__ | (self, other) | Returns the union of this Geometry and the other. | Returns the union of this Geometry and the other. | def __or__(self, other):
"Returns the union of this Geometry and the other."
return self.union(other) | [
"def",
"__or__",
"(",
"self",
",",
"other",
")",
":",
"return",
"self",
".",
"union",
"(",
"other",
")"
] | [
179,
4
] | [
181,
32
] | python | en | ['en', 'en', 'en'] | True |
GEOSGeometry.__and__ | (self, other) | Returns the intersection of this Geometry and the other. | Returns the intersection of this Geometry and the other. | def __and__(self, other):
"Returns the intersection of this Geometry and the other."
return self.intersection(other) | [
"def",
"__and__",
"(",
"self",
",",
"other",
")",
":",
"return",
"self",
".",
"intersection",
"(",
"other",
")"
] | [
184,
4
] | [
186,
39
] | python | en | ['en', 'en', 'en'] | True |
GEOSGeometry.__sub__ | (self, other) | Return the difference this Geometry and the other. | Return the difference this Geometry and the other. | def __sub__(self, other):
"Return the difference this Geometry and the other."
return self.difference(other) | [
"def",
"__sub__",
"(",
"self",
",",
"other",
")",
":",
"return",
"self",
".",
"difference",
"(",
"other",
")"
] | [
189,
4
] | [
191,
37
] | python | en | ['en', 'en', 'en'] | True |
GEOSGeometry.__xor__ | (self, other) | Return the symmetric difference of this Geometry and the other. | Return the symmetric difference of this Geometry and the other. | def __xor__(self, other):
"Return the symmetric difference of this Geometry and the other."
return self.sym_difference(other) | [
"def",
"__xor__",
"(",
"self",
",",
"other",
")",
":",
"return",
"self",
".",
"sym_difference",
"(",
"other",
")"
] | [
194,
4
] | [
196,
41
] | python | en | ['en', 'en', 'en'] | True |
GEOSGeometry.has_cs | (self) | Returns True if this Geometry has a coordinate sequence, False if not. | Returns True if this Geometry has a coordinate sequence, False if not. | def has_cs(self):
"Returns True if this Geometry has a coordinate sequence, False if not."
# Only these geometries are allowed to have coordinate sequences.
if isinstance(self, (Point, LineString, LinearRing)):
return True
else:
return False | [
"def",
"has_cs",
"(",
"self",
")",
":",
"# Only these geometries are allowed to have coordinate sequences.",
"if",
"isinstance",
"(",
"self",
",",
"(",
"Point",
",",
"LineString",
",",
"LinearRing",
")",
")",
":",
"return",
"True",
"else",
":",
"return",
"False"
] | [
200,
4
] | [
206,
24
] | python | en | ['en', 'en', 'en'] | True |
GEOSGeometry._set_cs | (self) | Sets the coordinate sequence for this Geometry. | Sets the coordinate sequence for this Geometry. | def _set_cs(self):
"Sets the coordinate sequence for this Geometry."
if self.has_cs:
self._cs = GEOSCoordSeq(capi.get_cs(self.ptr), self.hasz)
else:
self._cs = None | [
"def",
"_set_cs",
"(",
"self",
")",
":",
"if",
"self",
".",
"has_cs",
":",
"self",
".",
"_cs",
"=",
"GEOSCoordSeq",
"(",
"capi",
".",
"get_cs",
"(",
"self",
".",
"ptr",
")",
",",
"self",
".",
"hasz",
")",
"else",
":",
"self",
".",
"_cs",
"=",
"... | [
208,
4
] | [
213,
27
] | python | en | ['en', 'en', 'en'] | True |
GEOSGeometry.coord_seq | (self) | Returns a clone of the coordinate sequence for this Geometry. | Returns a clone of the coordinate sequence for this Geometry. | def coord_seq(self):
"Returns a clone of the coordinate sequence for this Geometry."
if self.has_cs:
return self._cs.clone() | [
"def",
"coord_seq",
"(",
"self",
")",
":",
"if",
"self",
".",
"has_cs",
":",
"return",
"self",
".",
"_cs",
".",
"clone",
"(",
")"
] | [
216,
4
] | [
219,
35
] | python | en | ['en', 'en', 'en'] | True |
GEOSGeometry.geom_type | (self) | Returns a string representing the Geometry type, e.g. 'Polygon | Returns a string representing the Geometry type, e.g. 'Polygon | def geom_type(self):
"Returns a string representing the Geometry type, e.g. 'Polygon'"
return capi.geos_type(self.ptr).decode() | [
"def",
"geom_type",
"(",
"self",
")",
":",
"return",
"capi",
".",
"geos_type",
"(",
"self",
".",
"ptr",
")",
".",
"decode",
"(",
")"
] | [
223,
4
] | [
225,
48
] | python | en | ['en', 'en', 'en'] | True |
GEOSGeometry.geom_typeid | (self) | Returns an integer representing the Geometry type. | Returns an integer representing the Geometry type. | def geom_typeid(self):
"Returns an integer representing the Geometry type."
return capi.geos_typeid(self.ptr) | [
"def",
"geom_typeid",
"(",
"self",
")",
":",
"return",
"capi",
".",
"geos_typeid",
"(",
"self",
".",
"ptr",
")"
] | [
228,
4
] | [
230,
41
] | python | en | ['en', 'en', 'en'] | True |
GEOSGeometry.num_geom | (self) | Returns the number of geometries in the Geometry. | Returns the number of geometries in the Geometry. | def num_geom(self):
"Returns the number of geometries in the Geometry."
return capi.get_num_geoms(self.ptr) | [
"def",
"num_geom",
"(",
"self",
")",
":",
"return",
"capi",
".",
"get_num_geoms",
"(",
"self",
".",
"ptr",
")"
] | [
233,
4
] | [
235,
43
] | python | en | ['en', 'en', 'en'] | True |
GEOSGeometry.num_coords | (self) | Returns the number of coordinates in the Geometry. | Returns the number of coordinates in the Geometry. | def num_coords(self):
"Returns the number of coordinates in the Geometry."
return capi.get_num_coords(self.ptr) | [
"def",
"num_coords",
"(",
"self",
")",
":",
"return",
"capi",
".",
"get_num_coords",
"(",
"self",
".",
"ptr",
")"
] | [
238,
4
] | [
240,
44
] | python | en | ['en', 'en', 'en'] | True |
GEOSGeometry.num_points | (self) | Returns the number points, or coordinates, in the Geometry. | Returns the number points, or coordinates, in the Geometry. | def num_points(self):
"Returns the number points, or coordinates, in the Geometry."
return self.num_coords | [
"def",
"num_points",
"(",
"self",
")",
":",
"return",
"self",
".",
"num_coords"
] | [
243,
4
] | [
245,
30
] | python | en | ['en', 'en', 'en'] | True |
GEOSGeometry.dims | (self) | Returns the dimension of this Geometry (0=point, 1=line, 2=surface). | Returns the dimension of this Geometry (0=point, 1=line, 2=surface). | def dims(self):
"Returns the dimension of this Geometry (0=point, 1=line, 2=surface)."
return capi.get_dims(self.ptr) | [
"def",
"dims",
"(",
"self",
")",
":",
"return",
"capi",
".",
"get_dims",
"(",
"self",
".",
"ptr",
")"
] | [
248,
4
] | [
250,
38
] | python | en | ['en', 'en', 'en'] | True |
GEOSGeometry.normalize | (self) | Converts this Geometry to normal form (or canonical form). | Converts this Geometry to normal form (or canonical form). | def normalize(self):
"Converts this Geometry to normal form (or canonical form)."
return capi.geos_normalize(self.ptr) | [
"def",
"normalize",
"(",
"self",
")",
":",
"return",
"capi",
".",
"geos_normalize",
"(",
"self",
".",
"ptr",
")"
] | [
252,
4
] | [
254,
44
] | python | en | ['en', 'en', 'en'] | True |
GEOSGeometry.empty | (self) |
Returns a boolean indicating whether the set of points in this Geometry
are empty.
|
Returns a boolean indicating whether the set of points in this Geometry
are empty.
| def empty(self):
"""
Returns a boolean indicating whether the set of points in this Geometry
are empty.
"""
return capi.geos_isempty(self.ptr) | [
"def",
"empty",
"(",
"self",
")",
":",
"return",
"capi",
".",
"geos_isempty",
"(",
"self",
".",
"ptr",
")"
] | [
258,
4
] | [
263,
42
] | python | en | ['en', 'error', 'th'] | False |
GEOSGeometry.hasz | (self) | Returns whether the geometry has a 3D dimension. | Returns whether the geometry has a 3D dimension. | def hasz(self):
"Returns whether the geometry has a 3D dimension."
return capi.geos_hasz(self.ptr) | [
"def",
"hasz",
"(",
"self",
")",
":",
"return",
"capi",
".",
"geos_hasz",
"(",
"self",
".",
"ptr",
")"
] | [
266,
4
] | [
268,
39
] | python | en | ['en', 'en', 'en'] | True |
GEOSGeometry.ring | (self) | Returns whether or not the geometry is a ring. | Returns whether or not the geometry is a ring. | def ring(self):
"Returns whether or not the geometry is a ring."
return capi.geos_isring(self.ptr) | [
"def",
"ring",
"(",
"self",
")",
":",
"return",
"capi",
".",
"geos_isring",
"(",
"self",
".",
"ptr",
")"
] | [
271,
4
] | [
273,
41
] | python | en | ['en', 'en', 'en'] | True |
GEOSGeometry.simple | (self) | Returns false if the Geometry not simple. | Returns false if the Geometry not simple. | def simple(self):
"Returns false if the Geometry not simple."
return capi.geos_issimple(self.ptr) | [
"def",
"simple",
"(",
"self",
")",
":",
"return",
"capi",
".",
"geos_issimple",
"(",
"self",
".",
"ptr",
")"
] | [
276,
4
] | [
278,
43
] | python | en | ['en', 'en', 'en'] | True |
GEOSGeometry.valid | (self) | This property tests the validity of this Geometry. | This property tests the validity of this Geometry. | def valid(self):
"This property tests the validity of this Geometry."
return capi.geos_isvalid(self.ptr) | [
"def",
"valid",
"(",
"self",
")",
":",
"return",
"capi",
".",
"geos_isvalid",
"(",
"self",
".",
"ptr",
")"
] | [
281,
4
] | [
283,
42
] | python | en | ['en', 'en', 'en'] | True |
GEOSGeometry.valid_reason | (self) |
Returns a string containing the reason for any invalidity.
|
Returns a string containing the reason for any invalidity.
| def valid_reason(self):
"""
Returns a string containing the reason for any invalidity.
"""
return capi.geos_isvalidreason(self.ptr).decode() | [
"def",
"valid_reason",
"(",
"self",
")",
":",
"return",
"capi",
".",
"geos_isvalidreason",
"(",
"self",
".",
"ptr",
")",
".",
"decode",
"(",
")"
] | [
286,
4
] | [
290,
57
] | python | en | ['en', 'error', 'th'] | False |
GEOSGeometry.contains | (self, other) | Returns true if other.within(this) returns true. | Returns true if other.within(this) returns true. | def contains(self, other):
"Returns true if other.within(this) returns true."
return capi.geos_contains(self.ptr, other.ptr) | [
"def",
"contains",
"(",
"self",
",",
"other",
")",
":",
"return",
"capi",
".",
"geos_contains",
"(",
"self",
".",
"ptr",
",",
"other",
".",
"ptr",
")"
] | [
293,
4
] | [
295,
54
] | python | en | ['en', 'en', 'en'] | True |
GEOSGeometry.crosses | (self, other) |
Returns true if the DE-9IM intersection matrix for the two Geometries
is T*T****** (for a point and a curve,a point and an area or a line and
an area) 0******** (for two curves).
|
Returns true if the DE-9IM intersection matrix for the two Geometries
is T*T****** (for a point and a curve,a point and an area or a line and
an area) 0******** (for two curves).
| def crosses(self, other):
"""
Returns true if the DE-9IM intersection matrix for the two Geometries
is T*T****** (for a point and a curve,a point and an area or a line and
an area) 0******** (for two curves).
"""
return capi.geos_crosses(self.ptr, other.ptr) | [
"def",
"crosses",
"(",
"self",
",",
"other",
")",
":",
"return",
"capi",
".",
"geos_crosses",
"(",
"self",
".",
"ptr",
",",
"other",
".",
"ptr",
")"
] | [
297,
4
] | [
303,
53
] | python | en | ['en', 'error', 'th'] | False |
GEOSGeometry.disjoint | (self, other) |
Returns true if the DE-9IM intersection matrix for the two Geometries
is FF*FF****.
|
Returns true if the DE-9IM intersection matrix for the two Geometries
is FF*FF****.
| def disjoint(self, other):
"""
Returns true if the DE-9IM intersection matrix for the two Geometries
is FF*FF****.
"""
return capi.geos_disjoint(self.ptr, other.ptr) | [
"def",
"disjoint",
"(",
"self",
",",
"other",
")",
":",
"return",
"capi",
".",
"geos_disjoint",
"(",
"self",
".",
"ptr",
",",
"other",
".",
"ptr",
")"
] | [
305,
4
] | [
310,
54
] | python | en | ['en', 'error', 'th'] | False |
GEOSGeometry.equals | (self, other) |
Returns true if the DE-9IM intersection matrix for the two Geometries
is T*F**FFF*.
|
Returns true if the DE-9IM intersection matrix for the two Geometries
is T*F**FFF*.
| def equals(self, other):
"""
Returns true if the DE-9IM intersection matrix for the two Geometries
is T*F**FFF*.
"""
return capi.geos_equals(self.ptr, other.ptr) | [
"def",
"equals",
"(",
"self",
",",
"other",
")",
":",
"return",
"capi",
".",
"geos_equals",
"(",
"self",
".",
"ptr",
",",
"other",
".",
"ptr",
")"
] | [
312,
4
] | [
317,
52
] | python | en | ['en', 'error', 'th'] | False |
GEOSGeometry.equals_exact | (self, other, tolerance=0) |
Returns true if the two Geometries are exactly equal, up to a
specified tolerance.
|
Returns true if the two Geometries are exactly equal, up to a
specified tolerance.
| def equals_exact(self, other, tolerance=0):
"""
Returns true if the two Geometries are exactly equal, up to a
specified tolerance.
"""
return capi.geos_equalsexact(self.ptr, other.ptr, float(tolerance)) | [
"def",
"equals_exact",
"(",
"self",
",",
"other",
",",
"tolerance",
"=",
"0",
")",
":",
"return",
"capi",
".",
"geos_equalsexact",
"(",
"self",
".",
"ptr",
",",
"other",
".",
"ptr",
",",
"float",
"(",
"tolerance",
")",
")"
] | [
319,
4
] | [
324,
75
] | python | en | ['en', 'error', 'th'] | False |
GEOSGeometry.intersects | (self, other) | Returns true if disjoint returns false. | Returns true if disjoint returns false. | def intersects(self, other):
"Returns true if disjoint returns false."
return capi.geos_intersects(self.ptr, other.ptr) | [
"def",
"intersects",
"(",
"self",
",",
"other",
")",
":",
"return",
"capi",
".",
"geos_intersects",
"(",
"self",
".",
"ptr",
",",
"other",
".",
"ptr",
")"
] | [
326,
4
] | [
328,
56
] | python | en | ['nb', 'no', 'en'] | False |
GEOSGeometry.overlaps | (self, other) |
Returns true if the DE-9IM intersection matrix for the two Geometries
is T*T***T** (for two points or two surfaces) 1*T***T** (for two curves).
|
Returns true if the DE-9IM intersection matrix for the two Geometries
is T*T***T** (for two points or two surfaces) 1*T***T** (for two curves).
| def overlaps(self, other):
"""
Returns true if the DE-9IM intersection matrix for the two Geometries
is T*T***T** (for two points or two surfaces) 1*T***T** (for two curves).
"""
return capi.geos_overlaps(self.ptr, other.ptr) | [
"def",
"overlaps",
"(",
"self",
",",
"other",
")",
":",
"return",
"capi",
".",
"geos_overlaps",
"(",
"self",
".",
"ptr",
",",
"other",
".",
"ptr",
")"
] | [
330,
4
] | [
335,
54
] | python | en | ['en', 'error', 'th'] | False |
GEOSGeometry.relate_pattern | (self, other, pattern) |
Returns true if the elements in the DE-9IM intersection matrix for the
two Geometries match the elements in pattern.
|
Returns true if the elements in the DE-9IM intersection matrix for the
two Geometries match the elements in pattern.
| def relate_pattern(self, other, pattern):
"""
Returns true if the elements in the DE-9IM intersection matrix for the
two Geometries match the elements in pattern.
"""
if not isinstance(pattern, six.string_types) or len(pattern) > 9:
raise GEOSException('invalid inters... | [
"def",
"relate_pattern",
"(",
"self",
",",
"other",
",",
"pattern",
")",
":",
"if",
"not",
"isinstance",
"(",
"pattern",
",",
"six",
".",
"string_types",
")",
"or",
"len",
"(",
"pattern",
")",
">",
"9",
":",
"raise",
"GEOSException",
"(",
"'invalid inter... | [
337,
4
] | [
344,
81
] | python | en | ['en', 'error', 'th'] | False |
GEOSGeometry.touches | (self, other) |
Returns true if the DE-9IM intersection matrix for the two Geometries
is FT*******, F**T***** or F***T****.
|
Returns true if the DE-9IM intersection matrix for the two Geometries
is FT*******, F**T***** or F***T****.
| def touches(self, other):
"""
Returns true if the DE-9IM intersection matrix for the two Geometries
is FT*******, F**T***** or F***T****.
"""
return capi.geos_touches(self.ptr, other.ptr) | [
"def",
"touches",
"(",
"self",
",",
"other",
")",
":",
"return",
"capi",
".",
"geos_touches",
"(",
"self",
".",
"ptr",
",",
"other",
".",
"ptr",
")"
] | [
346,
4
] | [
351,
53
] | python | en | ['en', 'error', 'th'] | False |
GEOSGeometry.within | (self, other) |
Returns true if the DE-9IM intersection matrix for the two Geometries
is T*F**F***.
|
Returns true if the DE-9IM intersection matrix for the two Geometries
is T*F**F***.
| def within(self, other):
"""
Returns true if the DE-9IM intersection matrix for the two Geometries
is T*F**F***.
"""
return capi.geos_within(self.ptr, other.ptr) | [
"def",
"within",
"(",
"self",
",",
"other",
")",
":",
"return",
"capi",
".",
"geos_within",
"(",
"self",
".",
"ptr",
",",
"other",
".",
"ptr",
")"
] | [
353,
4
] | [
358,
52
] | python | en | ['en', 'error', 'th'] | False |
GEOSGeometry.get_srid | (self) | Gets the SRID for the geometry, returns None if no SRID is set. | Gets the SRID for the geometry, returns None if no SRID is set. | def get_srid(self):
"Gets the SRID for the geometry, returns None if no SRID is set."
s = capi.geos_get_srid(self.ptr)
if s == 0:
return None
else:
return s | [
"def",
"get_srid",
"(",
"self",
")",
":",
"s",
"=",
"capi",
".",
"geos_get_srid",
"(",
"self",
".",
"ptr",
")",
"if",
"s",
"==",
"0",
":",
"return",
"None",
"else",
":",
"return",
"s"
] | [
361,
4
] | [
367,
20
] | python | en | ['en', 'en', 'en'] | True |
GEOSGeometry.set_srid | (self, srid) | Sets the SRID for the geometry. | Sets the SRID for the geometry. | def set_srid(self, srid):
"Sets the SRID for the geometry."
capi.geos_set_srid(self.ptr, srid) | [
"def",
"set_srid",
"(",
"self",
",",
"srid",
")",
":",
"capi",
".",
"geos_set_srid",
"(",
"self",
".",
"ptr",
",",
"srid",
")"
] | [
369,
4
] | [
371,
42
] | python | en | ['en', 'en', 'en'] | True |
GEOSGeometry.ewkt | (self) |
Returns the EWKT (SRID + WKT) of the Geometry. Note that Z values
are only included in this representation if GEOS >= 3.3.0.
|
Returns the EWKT (SRID + WKT) of the Geometry. Note that Z values
are only included in this representation if GEOS >= 3.3.0.
| def ewkt(self):
"""
Returns the EWKT (SRID + WKT) of the Geometry. Note that Z values
are only included in this representation if GEOS >= 3.3.0.
"""
if self.get_srid():
return 'SRID=%s;%s' % (self.srid, self.wkt)
else:
return self.wkt | [
"def",
"ewkt",
"(",
"self",
")",
":",
"if",
"self",
".",
"get_srid",
"(",
")",
":",
"return",
"'SRID=%s;%s'",
"%",
"(",
"self",
".",
"srid",
",",
"self",
".",
"wkt",
")",
"else",
":",
"return",
"self",
".",
"wkt"
] | [
376,
4
] | [
384,
27
] | python | en | ['en', 'error', 'th'] | False |
GEOSGeometry.wkt | (self) | Returns the WKT (Well-Known Text) representation of this Geometry. | Returns the WKT (Well-Known Text) representation of this Geometry. | def wkt(self):
"Returns the WKT (Well-Known Text) representation of this Geometry."
return wkt_w(3 if self.hasz else 2).write(self).decode() | [
"def",
"wkt",
"(",
"self",
")",
":",
"return",
"wkt_w",
"(",
"3",
"if",
"self",
".",
"hasz",
"else",
"2",
")",
".",
"write",
"(",
"self",
")",
".",
"decode",
"(",
")"
] | [
387,
4
] | [
389,
64
] | python | en | ['en', 'en', 'en'] | True |
GEOSGeometry.hex | (self) |
Returns the WKB of this Geometry in hexadecimal form. Please note
that the SRID is not included in this representation because it is not
a part of the OGC specification (use the `hexewkb` property instead).
|
Returns the WKB of this Geometry in hexadecimal form. Please note
that the SRID is not included in this representation because it is not
a part of the OGC specification (use the `hexewkb` property instead).
| def hex(self):
"""
Returns the WKB of this Geometry in hexadecimal form. Please note
that the SRID is not included in this representation because it is not
a part of the OGC specification (use the `hexewkb` property instead).
"""
# A possible faster, all-python, implemen... | [
"def",
"hex",
"(",
"self",
")",
":",
"# A possible faster, all-python, implementation:",
"# str(self.wkb).encode('hex')",
"return",
"wkb_w",
"(",
"3",
"if",
"self",
".",
"hasz",
"else",
"2",
")",
".",
"write_hex",
"(",
"self",
")"
] | [
392,
4
] | [
400,
59
] | python | en | ['en', 'error', 'th'] | False |
GEOSGeometry.hexewkb | (self) |
Returns the EWKB of this Geometry in hexadecimal form. This is an
extension of the WKB specification that includes SRID value that are
a part of this geometry.
|
Returns the EWKB of this Geometry in hexadecimal form. This is an
extension of the WKB specification that includes SRID value that are
a part of this geometry.
| def hexewkb(self):
"""
Returns the EWKB of this Geometry in hexadecimal form. This is an
extension of the WKB specification that includes SRID value that are
a part of this geometry.
"""
return ewkb_w(3 if self.hasz else 2).write_hex(self) | [
"def",
"hexewkb",
"(",
"self",
")",
":",
"return",
"ewkb_w",
"(",
"3",
"if",
"self",
".",
"hasz",
"else",
"2",
")",
".",
"write_hex",
"(",
"self",
")"
] | [
403,
4
] | [
409,
60
] | python | en | ['en', 'error', 'th'] | False |
GEOSGeometry.json | (self) |
Returns GeoJSON representation of this Geometry if GDAL is installed.
|
Returns GeoJSON representation of this Geometry if GDAL is installed.
| def json(self):
"""
Returns GeoJSON representation of this Geometry if GDAL is installed.
"""
if gdal.HAS_GDAL:
return self.ogr.json
else:
raise GEOSException('GeoJSON output only supported when GDAL is installed.') | [
"def",
"json",
"(",
"self",
")",
":",
"if",
"gdal",
".",
"HAS_GDAL",
":",
"return",
"self",
".",
"ogr",
".",
"json",
"else",
":",
"raise",
"GEOSException",
"(",
"'GeoJSON output only supported when GDAL is installed.'",
")"
] | [
412,
4
] | [
419,
88
] | python | en | ['en', 'error', 'th'] | False |
GEOSGeometry.wkb | (self) |
Returns the WKB (Well-Known Binary) representation of this Geometry
as a Python buffer. SRID and Z values are not included, use the
`ewkb` property instead.
|
Returns the WKB (Well-Known Binary) representation of this Geometry
as a Python buffer. SRID and Z values are not included, use the
`ewkb` property instead.
| def wkb(self):
"""
Returns the WKB (Well-Known Binary) representation of this Geometry
as a Python buffer. SRID and Z values are not included, use the
`ewkb` property instead.
"""
return wkb_w(3 if self.hasz else 2).write(self) | [
"def",
"wkb",
"(",
"self",
")",
":",
"return",
"wkb_w",
"(",
"3",
"if",
"self",
".",
"hasz",
"else",
"2",
")",
".",
"write",
"(",
"self",
")"
] | [
423,
4
] | [
429,
55
] | python | en | ['en', 'error', 'th'] | False |
GEOSGeometry.ewkb | (self) |
Return the EWKB representation of this Geometry as a Python buffer.
This is an extension of the WKB specification that includes any SRID
value that are a part of this geometry.
|
Return the EWKB representation of this Geometry as a Python buffer.
This is an extension of the WKB specification that includes any SRID
value that are a part of this geometry.
| def ewkb(self):
"""
Return the EWKB representation of this Geometry as a Python buffer.
This is an extension of the WKB specification that includes any SRID
value that are a part of this geometry.
"""
return ewkb_w(3 if self.hasz else 2).write(self) | [
"def",
"ewkb",
"(",
"self",
")",
":",
"return",
"ewkb_w",
"(",
"3",
"if",
"self",
".",
"hasz",
"else",
"2",
")",
".",
"write",
"(",
"self",
")"
] | [
432,
4
] | [
438,
56
] | python | en | ['en', 'error', 'th'] | False |
GEOSGeometry.kml | (self) | Returns the KML representation of this Geometry. | Returns the KML representation of this Geometry. | def kml(self):
"Returns the KML representation of this Geometry."
gtype = self.geom_type
return '<%s>%s</%s>' % (gtype, self.coord_seq.kml, gtype) | [
"def",
"kml",
"(",
"self",
")",
":",
"gtype",
"=",
"self",
".",
"geom_type",
"return",
"'<%s>%s</%s>'",
"%",
"(",
"gtype",
",",
"self",
".",
"coord_seq",
".",
"kml",
",",
"gtype",
")"
] | [
441,
4
] | [
444,
65
] | python | en | ['en', 'en', 'en'] | True |
GEOSGeometry.prepared | (self) |
Returns a PreparedGeometry corresponding to this geometry -- it is
optimized for the contains, intersects, and covers operations.
|
Returns a PreparedGeometry corresponding to this geometry -- it is
optimized for the contains, intersects, and covers operations.
| def prepared(self):
"""
Returns a PreparedGeometry corresponding to this geometry -- it is
optimized for the contains, intersects, and covers operations.
"""
return PreparedGeometry(self) | [
"def",
"prepared",
"(",
"self",
")",
":",
"return",
"PreparedGeometry",
"(",
"self",
")"
] | [
447,
4
] | [
452,
37
] | python | en | ['en', 'error', 'th'] | False |
GEOSGeometry.ogr | (self) | Returns the OGR Geometry for this Geometry. | Returns the OGR Geometry for this Geometry. | def ogr(self):
"Returns the OGR Geometry for this Geometry."
if not gdal.HAS_GDAL:
raise GEOSException('GDAL required to convert to an OGRGeometry.')
if self.srid:
try:
return gdal.OGRGeometry(self.wkb, self.srid)
except SRSException:
... | [
"def",
"ogr",
"(",
"self",
")",
":",
"if",
"not",
"gdal",
".",
"HAS_GDAL",
":",
"raise",
"GEOSException",
"(",
"'GDAL required to convert to an OGRGeometry.'",
")",
"if",
"self",
".",
"srid",
":",
"try",
":",
"return",
"gdal",
".",
"OGRGeometry",
"(",
"self"... | [
456,
4
] | [
465,
41
] | python | en | ['en', 'en', 'en'] | True |
GEOSGeometry.srs | (self) | Returns the OSR SpatialReference for SRID of this Geometry. | Returns the OSR SpatialReference for SRID of this Geometry. | def srs(self):
"Returns the OSR SpatialReference for SRID of this Geometry."
if not gdal.HAS_GDAL:
raise GEOSException('GDAL required to return a SpatialReference object.')
if self.srid:
try:
return gdal.SpatialReference(self.srid)
except SRSEx... | [
"def",
"srs",
"(",
"self",
")",
":",
"if",
"not",
"gdal",
".",
"HAS_GDAL",
":",
"raise",
"GEOSException",
"(",
"'GDAL required to return a SpatialReference object.'",
")",
"if",
"self",
".",
"srid",
":",
"try",
":",
"return",
"gdal",
".",
"SpatialReference",
"... | [
468,
4
] | [
477,
19
] | python | en | ['en', 'en', 'en'] | True |
GEOSGeometry.crs | (self) | Alias for `srs` property. | Alias for `srs` property. | def crs(self):
"Alias for `srs` property."
return self.srs | [
"def",
"crs",
"(",
"self",
")",
":",
"return",
"self",
".",
"srs"
] | [
480,
4
] | [
482,
23
] | python | en | ['es', 'en', 'en'] | True |
GEOSGeometry.transform | (self, ct, clone=False) |
Requires GDAL. Transforms the geometry according to the given
transformation object, which may be an integer SRID, and WKT or
PROJ.4 string. By default, the geometry is transformed in-place and
nothing is returned. However if the `clone` keyword is set, then this
geometry will n... |
Requires GDAL. Transforms the geometry according to the given
transformation object, which may be an integer SRID, and WKT or
PROJ.4 string. By default, the geometry is transformed in-place and
nothing is returned. However if the `clone` keyword is set, then this
geometry will n... | def transform(self, ct, clone=False):
"""
Requires GDAL. Transforms the geometry according to the given
transformation object, which may be an integer SRID, and WKT or
PROJ.4 string. By default, the geometry is transformed in-place and
nothing is returned. However if the `clone` ... | [
"def",
"transform",
"(",
"self",
",",
"ct",
",",
"clone",
"=",
"False",
")",
":",
"srid",
"=",
"self",
".",
"srid",
"if",
"ct",
"==",
"srid",
":",
"# short-circuit where source & dest SRIDs match",
"if",
"clone",
":",
"return",
"self",
".",
"clone",
"(",
... | [
484,
4
] | [
523,
63
] | python | en | ['en', 'error', 'th'] | False |
GEOSGeometry._topology | (self, gptr) | Helper routine to return Geometry from the given pointer. | Helper routine to return Geometry from the given pointer. | def _topology(self, gptr):
"Helper routine to return Geometry from the given pointer."
return GEOSGeometry(gptr, srid=self.srid) | [
"def",
"_topology",
"(",
"self",
",",
"gptr",
")",
":",
"return",
"GEOSGeometry",
"(",
"gptr",
",",
"srid",
"=",
"self",
".",
"srid",
")"
] | [
526,
4
] | [
528,
49
] | python | en | ['en', 'en', 'en'] | True |
GEOSGeometry.boundary | (self) | Returns the boundary as a newly allocated Geometry object. | Returns the boundary as a newly allocated Geometry object. | def boundary(self):
"Returns the boundary as a newly allocated Geometry object."
return self._topology(capi.geos_boundary(self.ptr)) | [
"def",
"boundary",
"(",
"self",
")",
":",
"return",
"self",
".",
"_topology",
"(",
"capi",
".",
"geos_boundary",
"(",
"self",
".",
"ptr",
")",
")"
] | [
531,
4
] | [
533,
59
] | python | en | ['en', 'en', 'en'] | True |
GEOSGeometry.buffer | (self, width, quadsegs=8) |
Returns a geometry that represents all points whose distance from this
Geometry is less than or equal to distance. Calculations are in the
Spatial Reference System of this Geometry. The optional third parameter sets
the number of segment used to approximate a quarter circle (defaults to... |
Returns a geometry that represents all points whose distance from this
Geometry is less than or equal to distance. Calculations are in the
Spatial Reference System of this Geometry. The optional third parameter sets
the number of segment used to approximate a quarter circle (defaults to... | def buffer(self, width, quadsegs=8):
"""
Returns a geometry that represents all points whose distance from this
Geometry is less than or equal to distance. Calculations are in the
Spatial Reference System of this Geometry. The optional third parameter sets
the number of segment u... | [
"def",
"buffer",
"(",
"self",
",",
"width",
",",
"quadsegs",
"=",
"8",
")",
":",
"return",
"self",
".",
"_topology",
"(",
"capi",
".",
"geos_buffer",
"(",
"self",
".",
"ptr",
",",
"width",
",",
"quadsegs",
")",
")"
] | [
535,
4
] | [
543,
74
] | python | en | ['en', 'error', 'th'] | False |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.