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
parse_rst
(text, default_reference_context, thing_being_parsed=None)
Convert the string from reST to an XHTML fragment.
Convert the string from reST to an XHTML fragment.
def parse_rst(text, default_reference_context, thing_being_parsed=None): """ Convert the string from reST to an XHTML fragment. """ overrides = { 'doctitle_xform': True, 'initial_header_level': 3, "default_reference_context": default_reference_context, "link_base": revers...
[ "def", "parse_rst", "(", "text", ",", "default_reference_context", ",", "thing_being_parsed", "=", "None", ")", ":", "overrides", "=", "{", "'doctitle_xform'", ":", "True", ",", "'initial_header_level'", ":", "3", ",", "\"default_reference_context\"", ":", "default_...
[ 66, 0 ]
[ 93, 39 ]
python
en
['en', 'error', 'th']
False
replace_named_groups
(pattern)
r""" Find named groups in `pattern` and replace them with the group name. E.g., 1. ^(?P<a>\w+)/b/(\w+)$ ==> ^<a>/b/(\w+)$ 2. ^(?P<a>\w+)/b/(?P<c>\w+)/$ ==> ^<a>/b/<c>/$ 3. ^(?P<a>\w+)/b/(\w+) ==> ^<a>/b/(\w+) 4. ^(?P<a>\w+)/b/(?P<c>\w+) ==> ^<a>/b/<c>
r""" Find named groups in `pattern` and replace them with the group name. E.g., 1. ^(?P<a>\w+)/b/(\w+)$ ==> ^<a>/b/(\w+)$ 2. ^(?P<a>\w+)/b/(?P<c>\w+)/$ ==> ^<a>/b/<c>/$ 3. ^(?P<a>\w+)/b/(\w+) ==> ^<a>/b/(\w+) 4. ^(?P<a>\w+)/b/(?P<c>\w+) ==> ^<a>/b/<c>
def replace_named_groups(pattern): r""" Find named groups in `pattern` and replace them with the group name. E.g., 1. ^(?P<a>\w+)/b/(\w+)$ ==> ^<a>/b/(\w+)$ 2. ^(?P<a>\w+)/b/(?P<c>\w+)/$ ==> ^<a>/b/<c>/$ 3. ^(?P<a>\w+)/b/(\w+) ==> ^<a>/b/(\w+) 4. ^(?P<a>\w+)/b/(?P<c>\w+) ==> ^<a>/b/<c> """ ...
[ "def", "replace_named_groups", "(", "pattern", ")", ":", "named_group_indices", "=", "[", "(", "m", ".", "start", "(", "0", ")", ",", "m", ".", "end", "(", "0", ")", ",", "m", ".", "group", "(", "1", ")", ")", "for", "m", "in", "named_group_matcher...
[ 152, 0 ]
[ 187, 18 ]
python
cy
['en', 'cy', 'hi']
False
replace_unnamed_groups
(pattern)
r""" Find unnamed groups in `pattern` and replace them with '<var>'. E.g., 1. ^(?P<a>\w+)/b/(\w+)$ ==> ^(?P<a>\w+)/b/<var>$ 2. ^(?P<a>\w+)/b/((x|y)\w+)$ ==> ^(?P<a>\w+)/b/<var>$ 3. ^(?P<a>\w+)/b/(\w+) ==> ^(?P<a>\w+)/b/<var> 4. ^(?P<a>\w+)/b/((x|y)\w+) ==> ^(?P<a>\w+)/b/<var>
r""" Find unnamed groups in `pattern` and replace them with '<var>'. E.g., 1. ^(?P<a>\w+)/b/(\w+)$ ==> ^(?P<a>\w+)/b/<var>$ 2. ^(?P<a>\w+)/b/((x|y)\w+)$ ==> ^(?P<a>\w+)/b/<var>$ 3. ^(?P<a>\w+)/b/(\w+) ==> ^(?P<a>\w+)/b/<var> 4. ^(?P<a>\w+)/b/((x|y)\w+) ==> ^(?P<a>\w+)/b/<var>
def replace_unnamed_groups(pattern): r""" Find unnamed groups in `pattern` and replace them with '<var>'. E.g., 1. ^(?P<a>\w+)/b/(\w+)$ ==> ^(?P<a>\w+)/b/<var>$ 2. ^(?P<a>\w+)/b/((x|y)\w+)$ ==> ^(?P<a>\w+)/b/<var>$ 3. ^(?P<a>\w+)/b/(\w+) ==> ^(?P<a>\w+)/b/<var> 4. ^(?P<a>\w+)/b/((x|y)\w+) ==> ^(...
[ "def", "replace_unnamed_groups", "(", "pattern", ")", ":", "unnamed_group_indices", "=", "[", "m", ".", "start", "(", "0", ")", "for", "m", "in", "unnamed_group_matcher", ".", "finditer", "(", "pattern", ")", "]", "# Indices of the start of unnamed capture groups.",...
[ 190, 0 ]
[ 238, 22 ]
python
cy
['en', 'cy', 'hi']
False
backport_makefile
( self, mode="r", buffering=None, encoding=None, errors=None, newline=None )
Backport of ``socket.makefile`` from Python 3.5.
Backport of ``socket.makefile`` from Python 3.5.
def backport_makefile( self, mode="r", buffering=None, encoding=None, errors=None, newline=None ): """ Backport of ``socket.makefile`` from Python 3.5. """ if not set(mode) <= {"r", "w", "b"}: raise ValueError("invalid mode %r (only r, w, b allowed)" % (mode,)) writing = "w" in mode ...
[ "def", "backport_makefile", "(", "self", ",", "mode", "=", "\"r\"", ",", "buffering", "=", "None", ",", "encoding", "=", "None", ",", "errors", "=", "None", ",", "newline", "=", "None", ")", ":", "if", "not", "set", "(", "mode", ")", "<=", "{", "\"...
[ 13, 0 ]
[ 51, 15 ]
python
en
['en', 'error', 'th']
False
openapi_test_function
(endpoint: str)
This decorator is used to register an OpenAPI test function with its endpoint. Example usage: @openapi_test_function("/messages/render:post") def ...
This decorator is used to register an OpenAPI test function with its endpoint. Example usage:
def openapi_test_function(endpoint: str) -> Callable[[FuncT], FuncT]: """This decorator is used to register an OpenAPI test function with its endpoint. Example usage: @openapi_test_function("/messages/render:post") def ... """ def wrapper(test_func: FuncT) -> FuncT: @wraps(test_func) ...
[ "def", "openapi_test_function", "(", "endpoint", ":", "str", ")", "->", "Callable", "[", "[", "FuncT", "]", ",", "FuncT", "]", ":", "def", "wrapper", "(", "test_func", ":", "FuncT", ")", "->", "FuncT", ":", "@", "wraps", "(", "test_func", ")", "def", ...
[ 35, 0 ]
[ 54, 18 ]
python
en
['en', 'en', 'en']
True
as_crispy_form
(form, template_pack=TEMPLATE_PACK, label_class="", field_class="")
The original and still very useful way to generate a div elegant form/formset:: {% load crispy_forms_tags %} <form class="uniForm" method="post"> {% csrf_token %} {{ myform|crispy }} </form> or, if you want to explicitly set the template pack:: ...
The original and still very useful way to generate a div elegant form/formset:: {% load crispy_forms_tags %} <form class="uniForm" method="post"> {% csrf_token %} {{ myform|crispy }} </form> or, if you want to explicitly set the template pack:: ...
def as_crispy_form(form, template_pack=TEMPLATE_PACK, label_class="", field_class=""): """ The original and still very useful way to generate a div elegant form/formset:: {% load crispy_forms_tags %} <form class="uniForm" method="post"> {% csrf_token %} {{ myfor...
[ "def", "as_crispy_form", "(", "form", ",", "template_pack", "=", "TEMPLATE_PACK", ",", "label_class", "=", "\"\"", ",", "field_class", "=", "\"\"", ")", ":", "c", "=", "Context", "(", "{", "\"field_class\"", ":", "field_class", ",", "\"field_template\"", ":", ...
[ 27, 0 ]
[ 62, 29 ]
python
en
['en', 'ja', 'th']
False
as_crispy_errors
(form, template_pack=TEMPLATE_PACK)
Renders only form errors the same way as django-crispy-forms:: {% load crispy_forms_tags %} {{ form|as_crispy_errors }} or:: {{ form|as_crispy_errors:"bootstrap" }}
Renders only form errors the same way as django-crispy-forms:: {% load crispy_forms_tags %} {{ form|as_crispy_errors }} or:: {{ form|as_crispy_errors:"bootstrap" }}
def as_crispy_errors(form, template_pack=TEMPLATE_PACK): """ Renders only form errors the same way as django-crispy-forms:: {% load crispy_forms_tags %} {{ form|as_crispy_errors }} or:: {{ form|as_crispy_errors:"bootstrap" }} """ if isinstance(form, BaseFormSet)...
[ "def", "as_crispy_errors", "(", "form", ",", "template_pack", "=", "TEMPLATE_PACK", ")", ":", "if", "isinstance", "(", "form", ",", "BaseFormSet", ")", ":", "template", "=", "get_template", "(", "\"%s/errors_formset.html\"", "%", "template_pack", ")", "c", "=", ...
[ 66, 0 ]
[ 84, 29 ]
python
en
['en', 'ja', 'th']
False
as_crispy_field
(field, template_pack=TEMPLATE_PACK, label_class="", field_class="")
Renders a form field like a django-crispy-forms field:: {% load crispy_forms_tags %} {{ form.field|as_crispy_field }} or:: {{ form.field|as_crispy_field:"bootstrap" }}
Renders a form field like a django-crispy-forms field:: {% load crispy_forms_tags %} {{ form.field|as_crispy_field }} or:: {{ form.field|as_crispy_field:"bootstrap" }}
def as_crispy_field(field, template_pack=TEMPLATE_PACK, label_class="", field_class=""): """ Renders a form field like a django-crispy-forms field:: {% load crispy_forms_tags %} {{ form.field|as_crispy_field }} or:: {{ form.field|as_crispy_field:"bootstrap" }} """ ...
[ "def", "as_crispy_field", "(", "field", ",", "template_pack", "=", "TEMPLATE_PACK", ",", "label_class", "=", "\"\"", ",", "field_class", "=", "\"\"", ")", ":", "if", "not", "isinstance", "(", "field", ",", "boundfield", ".", "BoundField", ")", "and", "settin...
[ 88, 0 ]
[ 120, 29 ]
python
en
['en', 'ja', 'th']
False
get_module_constant
(module, symbol, default=-1, paths=None)
Find 'module' by searching 'paths', and extract 'symbol' Return 'None' if 'module' does not exist on 'paths', or it does not define 'symbol'. If the module defines 'symbol' as a constant, return the constant. Otherwise, return 'default'.
Find 'module' by searching 'paths', and extract 'symbol'
def get_module_constant(module, symbol, default=-1, paths=None): """Find 'module' by searching 'paths', and extract 'symbol' Return 'None' if 'module' does not exist on 'paths', or it does not define 'symbol'. If the module defines 'symbol' as a constant, return the constant. Otherwise, return 'defau...
[ "def", "get_module_constant", "(", "module", ",", "symbol", ",", "default", "=", "-", "1", ",", "paths", "=", "None", ")", ":", "try", ":", "f", ",", "path", ",", "(", "suffix", ",", "mode", ",", "kind", ")", "=", "info", "=", "find_module", "(", ...
[ 95, 0 ]
[ 121, 50 ]
python
en
['en', 'en', 'en']
True
extract_constant
(code, symbol, default=-1)
Extract the constant value of 'symbol' from 'code' If the name 'symbol' is bound to a constant value by the Python code object 'code', return that value. If 'symbol' is bound to an expression, return 'default'. Otherwise, return 'None'. Return value is based on the first assignment to 'symbol'. 'sy...
Extract the constant value of 'symbol' from 'code'
def extract_constant(code, symbol, default=-1): """Extract the constant value of 'symbol' from 'code' If the name 'symbol' is bound to a constant value by the Python code object 'code', return that value. If 'symbol' is bound to an expression, return 'default'. Otherwise, return 'None'. Return v...
[ "def", "extract_constant", "(", "code", ",", "symbol", ",", "default", "=", "-", "1", ")", ":", "if", "symbol", "not", "in", "code", ".", "co_names", ":", "# name's not there, can't possibly be an assignment", "return", "None", "name_idx", "=", "list", "(", "c...
[ 124, 0 ]
[ 157, 27 ]
python
en
['en', 'en', 'en']
True
_update_globals
()
Patch the globals to remove the objects not available on some platforms. XXX it'd be better to test assertions about bytecode instead.
Patch the globals to remove the objects not available on some platforms.
def _update_globals(): """ Patch the globals to remove the objects not available on some platforms. XXX it'd be better to test assertions about bytecode instead. """ if not sys.platform.startswith('java') and sys.platform != 'cli': return incompatible = 'extract_constant', 'get_module_...
[ "def", "_update_globals", "(", ")", ":", "if", "not", "sys", ".", "platform", ".", "startswith", "(", "'java'", ")", "and", "sys", ".", "platform", "!=", "'cli'", ":", "return", "incompatible", "=", "'extract_constant'", ",", "'get_module_constant'", "for", ...
[ 160, 0 ]
[ 172, 28 ]
python
en
['en', 'error', 'th']
False
Require.full_name
(self)
Return full package/distribution name, w/version
Return full package/distribution name, w/version
def full_name(self): """Return full package/distribution name, w/version""" if self.requested_version is not None: return '%s-%s' % (self.name, self.requested_version) return self.name
[ "def", "full_name", "(", "self", ")", ":", "if", "self", ".", "requested_version", "is", "not", "None", ":", "return", "'%s-%s'", "%", "(", "self", ".", "name", ",", "self", ".", "requested_version", ")", "return", "self", ".", "name" ]
[ 34, 4 ]
[ 38, 24 ]
python
en
['en', 'en', 'en']
True
Require.version_ok
(self, version)
Is 'version' sufficiently up-to-date?
Is 'version' sufficiently up-to-date?
def version_ok(self, version): """Is 'version' sufficiently up-to-date?""" return self.attribute is None or self.format is None or \ str(version) != "unknown" and version >= self.requested_version
[ "def", "version_ok", "(", "self", ",", "version", ")", ":", "return", "self", ".", "attribute", "is", "None", "or", "self", ".", "format", "is", "None", "or", "str", "(", "version", ")", "!=", "\"unknown\"", "and", "version", ">=", "self", ".", "reques...
[ 40, 4 ]
[ 43, 75 ]
python
en
['en', 'en', 'en']
True
Require.get_version
(self, paths=None, default="unknown")
Get version number of installed module, 'None', or 'default' Search 'paths' for module. If not found, return 'None'. If found, return the extracted version attribute, or 'default' if no version attribute was specified, or the value cannot be determined without importing the module. T...
Get version number of installed module, 'None', or 'default'
def get_version(self, paths=None, default="unknown"): """Get version number of installed module, 'None', or 'default' Search 'paths' for module. If not found, return 'None'. If found, return the extracted version attribute, or 'default' if no version attribute was specified, or the va...
[ "def", "get_version", "(", "self", ",", "paths", "=", "None", ",", "default", "=", "\"unknown\"", ")", ":", "if", "self", ".", "attribute", "is", "None", ":", "try", ":", "f", ",", "p", ",", "i", "=", "find_module", "(", "self", ".", "module", ",",...
[ 45, 4 ]
[ 70, 16 ]
python
en
['en', 'en', 'en']
True
Require.is_present
(self, paths=None)
Return true if dependency is present on 'paths
Return true if dependency is present on 'paths
def is_present(self, paths=None): """Return true if dependency is present on 'paths'""" return self.get_version(paths) is not None
[ "def", "is_present", "(", "self", ",", "paths", "=", "None", ")", ":", "return", "self", ".", "get_version", "(", "paths", ")", "is", "not", "None" ]
[ 72, 4 ]
[ 74, 50 ]
python
en
['en', 'af', 'en']
True
Require.is_current
(self, paths=None)
Return true if dependency is present and up-to-date on 'paths
Return true if dependency is present and up-to-date on 'paths
def is_current(self, paths=None): """Return true if dependency is present and up-to-date on 'paths'""" version = self.get_version(paths) if version is None: return False return self.version_ok(version)
[ "def", "is_current", "(", "self", ",", "paths", "=", "None", ")", ":", "version", "=", "self", ".", "get_version", "(", "paths", ")", "if", "version", "is", "None", ":", "return", "False", "return", "self", ".", "version_ok", "(", "version", ")" ]
[ 76, 4 ]
[ 81, 39 ]
python
en
['en', 'en', 'en']
True
get_current_request
()
Returns the current HttpRequest object; this should only be used by logging frameworks, which have no other access to the current request. All other codepaths should pass through the current request object, rather than rely on this thread-local global.
Returns the current HttpRequest object; this should only be used by logging frameworks, which have no other access to the current request. All other codepaths should pass through the current request object, rather than rely on this thread-local global.
def get_current_request() -> Optional[HttpRequest]: """Returns the current HttpRequest object; this should only be used by logging frameworks, which have no other access to the current request. All other codepaths should pass through the current request object, rather than rely on this thread-local glo...
[ "def", "get_current_request", "(", ")", "->", "Optional", "[", "HttpRequest", "]", ":", "return", "getattr", "(", "local", ",", "\"request\"", ",", "None", ")" ]
[ 397, 0 ]
[ 404, 42 ]
python
en
['en', 'en', 'en']
True
_REQ.__init__
( self, whence: Optional[str] = None, *, converter: Optional[Callable[[str], ResultT]] = None, default: Union[_NotSpecified, ResultT, None] = NotSpecified, json_validator: Optional[Validator[ResultT]] = None, str_validator: Optional[Validator[ResultT]] = None, ...
whence: the name of the request variable that should be used for this parameter. Defaults to a request variable of the same name as the parameter. converter: a function that takes a string and returns a new value. If specified, this will be called on the request variable value...
whence: the name of the request variable that should be used for this parameter. Defaults to a request variable of the same name as the parameter.
def __init__( self, whence: Optional[str] = None, *, converter: Optional[Callable[[str], ResultT]] = None, default: Union[_NotSpecified, ResultT, None] = NotSpecified, json_validator: Optional[Validator[ResultT]] = None, str_validator: Optional[Validator[ResultT]]...
[ "def", "__init__", "(", "self", ",", "whence", ":", "Optional", "[", "str", "]", "=", "None", ",", "*", ",", "converter", ":", "Optional", "[", "Callable", "[", "[", "str", "]", ",", "ResultT", "]", "]", "=", "None", ",", "default", ":", "Union", ...
[ 79, 4 ]
[ 138, 68 ]
python
en
['en', 'en', 'en']
True
create_requirements_index_file
(venv_path: str, requirements_file: str)
Creates a file, called package_index, in the virtual environment directory that contains all the PIP packages installed in the virtual environment. This file is used to determine the packages that can be copied to a new virtual environment.
Creates a file, called package_index, in the virtual environment directory that contains all the PIP packages installed in the virtual environment. This file is used to determine the packages that can be copied to a new virtual environment.
def create_requirements_index_file(venv_path: str, requirements_file: str) -> str: """ Creates a file, called package_index, in the virtual environment directory that contains all the PIP packages installed in the virtual environment. This file is used to determine the packages that can be copied to...
[ "def", "create_requirements_index_file", "(", "venv_path", ":", "str", ",", "requirements_file", ":", "str", ")", "->", "str", ":", "index_filename", "=", "get_index_filename", "(", "venv_path", ")", "packages", "=", "get_package_names", "(", "requirements_file", ")...
[ 134, 0 ]
[ 147, 25 ]
python
en
['en', 'error', 'th']
False
get_venv_packages
(venv_path: str)
Returns the packages installed in the virtual environment using the package index file.
Returns the packages installed in the virtual environment using the package index file.
def get_venv_packages(venv_path: str) -> Set[str]: """ Returns the packages installed in the virtual environment using the package index file. """ with open(get_index_filename(venv_path)) as reader: return {p.strip() for p in reader.read().split("\n") if p.strip()}
[ "def", "get_venv_packages", "(", "venv_path", ":", "str", ")", "->", "Set", "[", "str", "]", ":", "with", "open", "(", "get_index_filename", "(", "venv_path", ")", ")", "as", "reader", ":", "return", "{", "p", ".", "strip", "(", ")", "for", "p", "in"...
[ 150, 0 ]
[ 156, 74 ]
python
en
['en', 'error', 'th']
False
try_to_copy_venv
(venv_path: str, new_packages: Set[str])
Tries to copy packages from an old virtual environment in the cache to the new virtual environment. The algorithm works as follows: 1. Find a virtual environment, v, from the cache that has the highest overlap with the new requirements such that: a. The new requirements only add to ...
Tries to copy packages from an old virtual environment in the cache to the new virtual environment. The algorithm works as follows: 1. Find a virtual environment, v, from the cache that has the highest overlap with the new requirements such that: a. The new requirements only add to ...
def try_to_copy_venv(venv_path: str, new_packages: Set[str]) -> bool: """ Tries to copy packages from an old virtual environment in the cache to the new virtual environment. The algorithm works as follows: 1. Find a virtual environment, v, from the cache that has the highest overlap with the...
[ "def", "try_to_copy_venv", "(", "venv_path", ":", "str", ",", "new_packages", ":", "Set", "[", "str", "]", ")", "->", "bool", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "VENV_CACHE_PATH", ")", ":", "return", "False", "desired_python_version",...
[ 159, 0 ]
[ 240, 16 ]
python
en
['en', 'error', 'th']
False
do_patch_activate_script
(venv_path: str)
Patches the bin/activate script so that the value of the environment variable VIRTUAL_ENV is set to venv_path during the script's execution whenever it is sourced.
Patches the bin/activate script so that the value of the environment variable VIRTUAL_ENV is set to venv_path during the script's execution whenever it is sourced.
def do_patch_activate_script(venv_path: str) -> None: """ Patches the bin/activate script so that the value of the environment variable VIRTUAL_ENV is set to venv_path during the script's execution whenever it is sourced. """ # venv_path should be what we want to have in VIRTUAL_ENV after patching ...
[ "def", "do_patch_activate_script", "(", "venv_path", ":", "str", ")", "->", "None", ":", "# venv_path should be what we want to have in VIRTUAL_ENV after patching", "script_path", "=", "os", ".", "path", ".", "join", "(", "venv_path", ",", "\"bin\"", ",", "\"activate\""...
[ 272, 0 ]
[ 287, 31 ]
python
en
['en', 'error', 'th']
False
SQLCompiler.as_sql
(self, with_limits=True, with_col_aliases=False)
Creates the SQL for this query. Returns the SQL string and list of parameters. This is overridden from the original Query class to handle the additional SQL Oracle requires to emulate LIMIT and OFFSET. If 'with_limits' is False, any limit/offset information is not incl...
Creates the SQL for this query. Returns the SQL string and list of parameters. This is overridden from the original Query class to handle the additional SQL Oracle requires to emulate LIMIT and OFFSET.
def as_sql(self, with_limits=True, with_col_aliases=False): """ Creates the SQL for this query. Returns the SQL string and list of parameters. This is overridden from the original Query class to handle the additional SQL Oracle requires to emulate LIMIT and OFFSET. If '...
[ "def", "as_sql", "(", "self", ",", "with_limits", "=", "True", ",", "with_col_aliases", "=", "False", ")", ":", "if", "with_limits", "and", "self", ".", "query", ".", "low_mark", "==", "self", ".", "query", ".", "high_mark", ":", "return", "''", ",", "...
[ 4, 4 ]
[ 39, 26 ]
python
en
['en', 'error', 'th']
False
OGRGeometry.__init__
(self, geom_input, srs=None)
Initialize Geometry on either WKT or an OGR pointer as input.
Initialize Geometry on either WKT or an OGR pointer as input.
def __init__(self, geom_input, srs=None): """Initialize Geometry on either WKT or an OGR pointer as input.""" str_instance = isinstance(geom_input, str) # If HEX, unpack input to a binary buffer. if str_instance and hex_regex.match(geom_input): geom_input = memoryview(bytes....
[ "def", "__init__", "(", "self", ",", "geom_input", ",", "srs", "=", "None", ")", ":", "str_instance", "=", "isinstance", "(", "geom_input", ",", "str", ")", "# If HEX, unpack input to a binary buffer.", "if", "str_instance", "and", "hex_regex", ".", "match", "("...
[ 62, 4 ]
[ 116, 56 ]
python
en
['en', 'en', 'en']
True
OGRGeometry.from_bbox
(cls, bbox)
Construct a Polygon from a bounding box (4-tuple).
Construct a Polygon from a bounding box (4-tuple).
def from_bbox(cls, bbox): "Construct a Polygon from a bounding box (4-tuple)." x0, y0, x1, y1 = bbox return OGRGeometry('POLYGON((%s %s, %s %s, %s %s, %s %s, %s %s))' % ( x0, y0, x0, y1, x1, y1, x1, y0, x0, y0))
[ "def", "from_bbox", "(", "cls", ",", "bbox", ")", ":", "x0", ",", "y0", ",", "x1", ",", "y1", "=", "bbox", "return", "OGRGeometry", "(", "'POLYGON((%s %s, %s %s, %s %s, %s %s, %s %s))'", "%", "(", "x0", ",", "y0", ",", "x0", ",", "y1", ",", "x1", ",", ...
[ 144, 4 ]
[ 148, 52 ]
python
en
['en', 'en', 'en']
True
OGRGeometry.__or__
(self, other)
Return the union of the two geometries.
Return the union of the two geometries.
def __or__(self, other): "Return the union of the two geometries." return self.union(other)
[ "def", "__or__", "(", "self", ",", "other", ")", ":", "return", "self", ".", "union", "(", "other", ")" ]
[ 160, 4 ]
[ 162, 32 ]
python
en
['en', 'en', 'en']
True
OGRGeometry.__and__
(self, other)
Return the intersection of this Geometry and the other.
Return the intersection of this Geometry and the other.
def __and__(self, other): "Return the intersection of this Geometry and the other." return self.intersection(other)
[ "def", "__and__", "(", "self", ",", "other", ")", ":", "return", "self", ".", "intersection", "(", "other", ")" ]
[ 165, 4 ]
[ 167, 39 ]
python
en
['en', 'en', 'en']
True
OGRGeometry.__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", ")" ]
[ 170, 4 ]
[ 172, 37 ]
python
en
['en', 'en', 'en']
True
OGRGeometry.__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", ")" ]
[ 175, 4 ]
[ 177, 41 ]
python
en
['en', 'en', 'en']
True
OGRGeometry.__eq__
(self, other)
Is this Geometry equal to the other?
Is this Geometry equal to the other?
def __eq__(self, other): "Is this Geometry equal to the other?" return isinstance(other, OGRGeometry) and self.equals(other)
[ "def", "__eq__", "(", "self", ",", "other", ")", ":", "return", "isinstance", "(", "other", ",", "OGRGeometry", ")", "and", "self", ".", "equals", "(", "other", ")" ]
[ 179, 4 ]
[ 181, 68 ]
python
en
['en', 'en', 'en']
True
OGRGeometry.__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" ]
[ 183, 4 ]
[ 185, 23 ]
python
en
['en', 'en', 'en']
True
OGRGeometry.dimension
(self)
Return 0 for points, 1 for lines, and 2 for surfaces.
Return 0 for points, 1 for lines, and 2 for surfaces.
def dimension(self): "Return 0 for points, 1 for lines, and 2 for surfaces." return capi.get_dims(self.ptr)
[ "def", "dimension", "(", "self", ")", ":", "return", "capi", ".", "get_dims", "(", "self", ".", "ptr", ")" ]
[ 189, 4 ]
[ 191, 38 ]
python
en
['en', 'en', 'en']
True
OGRGeometry._get_coord_dim
(self)
Return the coordinate dimension of the Geometry.
Return the coordinate dimension of the Geometry.
def _get_coord_dim(self): "Return the coordinate dimension of the Geometry." return capi.get_coord_dim(self.ptr)
[ "def", "_get_coord_dim", "(", "self", ")", ":", "return", "capi", ".", "get_coord_dim", "(", "self", ".", "ptr", ")" ]
[ 193, 4 ]
[ 195, 43 ]
python
en
['en', 'en', 'en']
True
OGRGeometry._set_coord_dim
(self, dim)
Set the coordinate dimension of this Geometry.
Set the coordinate dimension of this Geometry.
def _set_coord_dim(self, dim): "Set the coordinate dimension of this Geometry." if dim not in (2, 3): raise ValueError('Geometry dimension must be either 2 or 3') capi.set_coord_dim(self.ptr, dim)
[ "def", "_set_coord_dim", "(", "self", ",", "dim", ")", ":", "if", "dim", "not", "in", "(", "2", ",", "3", ")", ":", "raise", "ValueError", "(", "'Geometry dimension must be either 2 or 3'", ")", "capi", ".", "set_coord_dim", "(", "self", ".", "ptr", ",", ...
[ 197, 4 ]
[ 201, 41 ]
python
en
['en', 'en', 'en']
True
OGRGeometry.geom_count
(self)
Return the number of elements in this Geometry.
Return the number of elements in this Geometry.
def geom_count(self): "Return the number of elements in this Geometry." return capi.get_geom_count(self.ptr)
[ "def", "geom_count", "(", "self", ")", ":", "return", "capi", ".", "get_geom_count", "(", "self", ".", "ptr", ")" ]
[ 206, 4 ]
[ 208, 44 ]
python
en
['en', 'en', 'en']
True
OGRGeometry.point_count
(self)
Return the number of Points in this Geometry.
Return the number of Points in this Geometry.
def point_count(self): "Return the number of Points in this Geometry." return capi.get_point_count(self.ptr)
[ "def", "point_count", "(", "self", ")", ":", "return", "capi", ".", "get_point_count", "(", "self", ".", "ptr", ")" ]
[ 211, 4 ]
[ 213, 45 ]
python
en
['en', 'en', 'en']
True
OGRGeometry.num_points
(self)
Alias for `point_count` (same name method in GEOS API.)
Alias for `point_count` (same name method in GEOS API.)
def num_points(self): "Alias for `point_count` (same name method in GEOS API.)" return self.point_count
[ "def", "num_points", "(", "self", ")", ":", "return", "self", ".", "point_count" ]
[ 216, 4 ]
[ 218, 31 ]
python
en
['en', 'en', 'en']
True
OGRGeometry.num_coords
(self)
Alias for `point_count`.
Alias for `point_count`.
def num_coords(self): "Alias for `point_count`." return self.point_count
[ "def", "num_coords", "(", "self", ")", ":", "return", "self", ".", "point_count" ]
[ 221, 4 ]
[ 223, 31 ]
python
en
['es', 'en', 'en']
True
OGRGeometry.geom_type
(self)
Return the Type for this Geometry.
Return the Type for this Geometry.
def geom_type(self): "Return the Type for this Geometry." return OGRGeomType(capi.get_geom_type(self.ptr))
[ "def", "geom_type", "(", "self", ")", ":", "return", "OGRGeomType", "(", "capi", ".", "get_geom_type", "(", "self", ".", "ptr", ")", ")" ]
[ 226, 4 ]
[ 228, 56 ]
python
en
['en', 'en', 'en']
True
OGRGeometry.geom_name
(self)
Return the Name of this Geometry.
Return the Name of this Geometry.
def geom_name(self): "Return the Name of this Geometry." return capi.get_geom_name(self.ptr)
[ "def", "geom_name", "(", "self", ")", ":", "return", "capi", ".", "get_geom_name", "(", "self", ".", "ptr", ")" ]
[ 231, 4 ]
[ 233, 43 ]
python
en
['en', 'en', 'en']
True
OGRGeometry.area
(self)
Return the area for a LinearRing, Polygon, or MultiPolygon; 0 otherwise.
Return the area for a LinearRing, Polygon, or MultiPolygon; 0 otherwise.
def area(self): "Return the area for a LinearRing, Polygon, or MultiPolygon; 0 otherwise." return capi.get_area(self.ptr)
[ "def", "area", "(", "self", ")", ":", "return", "capi", ".", "get_area", "(", "self", ".", "ptr", ")" ]
[ 236, 4 ]
[ 238, 38 ]
python
en
['en', 'en', 'en']
True
OGRGeometry.envelope
(self)
Return the envelope for this Geometry.
Return the envelope for this Geometry.
def envelope(self): "Return the envelope for this Geometry." # TODO: Fix Envelope() for Point geometries. return Envelope(capi.get_envelope(self.ptr, byref(OGREnvelope())))
[ "def", "envelope", "(", "self", ")", ":", "# TODO: Fix Envelope() for Point geometries.", "return", "Envelope", "(", "capi", ".", "get_envelope", "(", "self", ".", "ptr", ",", "byref", "(", "OGREnvelope", "(", ")", ")", ")", ")" ]
[ 241, 4 ]
[ 244, 74 ]
python
en
['en', 'en', 'en']
True
OGRGeometry.extent
(self)
Return the envelope as a 4-tuple, instead of as an Envelope object.
Return the envelope as a 4-tuple, instead of as an Envelope object.
def extent(self): "Return the envelope as a 4-tuple, instead of as an Envelope object." return self.envelope.tuple
[ "def", "extent", "(", "self", ")", ":", "return", "self", ".", "envelope", ".", "tuple" ]
[ 251, 4 ]
[ 253, 34 ]
python
en
['en', 'en', 'en']
True
OGRGeometry._get_srs
(self)
Return the Spatial Reference for this Geometry.
Return the Spatial Reference for this Geometry.
def _get_srs(self): "Return the Spatial Reference for this Geometry." try: srs_ptr = capi.get_geom_srs(self.ptr) return SpatialReference(srs_api.clone_srs(srs_ptr)) except SRSException: return None
[ "def", "_get_srs", "(", "self", ")", ":", "try", ":", "srs_ptr", "=", "capi", ".", "get_geom_srs", "(", "self", ".", "ptr", ")", "return", "SpatialReference", "(", "srs_api", ".", "clone_srs", "(", "srs_ptr", ")", ")", "except", "SRSException", ":", "ret...
[ 258, 4 ]
[ 264, 23 ]
python
en
['en', 'en', 'en']
True
OGRGeometry._set_srs
(self, srs)
Set the SpatialReference for this geometry.
Set the SpatialReference for this geometry.
def _set_srs(self, srs): "Set the SpatialReference for this geometry." # Do not have to clone the `SpatialReference` object pointer because # when it is assigned to this `OGRGeometry` it's internal OGR # reference count is incremented, and will likewise be released # (decremented...
[ "def", "_set_srs", "(", "self", ",", "srs", ")", ":", "# Do not have to clone the `SpatialReference` object pointer because", "# when it is assigned to this `OGRGeometry` it's internal OGR", "# reference count is incremented, and will likewise be released", "# (decremented) when this geometry'...
[ 266, 4 ]
[ 281, 42 ]
python
en
['en', 'en', 'en']
True
OGRGeometry.geos
(self)
Return a GEOSGeometry object from this OGRGeometry.
Return a GEOSGeometry object from this OGRGeometry.
def geos(self): "Return a GEOSGeometry object from this OGRGeometry." from django.contrib.gis.geos import GEOSGeometry return GEOSGeometry(self._geos_ptr(), self.srid)
[ "def", "geos", "(", "self", ")", ":", "from", "django", ".", "contrib", ".", "gis", ".", "geos", "import", "GEOSGeometry", "return", "GEOSGeometry", "(", "self", ".", "_geos_ptr", "(", ")", ",", "self", ".", "srid", ")" ]
[ 306, 4 ]
[ 309, 56 ]
python
en
['en', 'en', 'en']
True
OGRGeometry.gml
(self)
Return the GML representation of the Geometry.
Return the GML representation of the Geometry.
def gml(self): "Return the GML representation of the Geometry." return capi.to_gml(self.ptr)
[ "def", "gml", "(", "self", ")", ":", "return", "capi", ".", "to_gml", "(", "self", ".", "ptr", ")" ]
[ 312, 4 ]
[ 314, 36 ]
python
en
['en', 'en', 'en']
True
OGRGeometry.hex
(self)
Return the hexadecimal representation of the WKB (a string).
Return the hexadecimal representation of the WKB (a string).
def hex(self): "Return the hexadecimal representation of the WKB (a string)." return b2a_hex(self.wkb).upper()
[ "def", "hex", "(", "self", ")", ":", "return", "b2a_hex", "(", "self", ".", "wkb", ")", ".", "upper", "(", ")" ]
[ 317, 4 ]
[ 319, 40 ]
python
en
['en', 'en', 'en']
True
OGRGeometry.json
(self)
Return the GeoJSON representation of this Geometry.
Return the GeoJSON representation of this Geometry.
def json(self): """ Return the GeoJSON representation of this Geometry. """ return capi.to_json(self.ptr)
[ "def", "json", "(", "self", ")", ":", "return", "capi", ".", "to_json", "(", "self", ".", "ptr", ")" ]
[ 322, 4 ]
[ 326, 37 ]
python
en
['en', 'error', 'th']
False
OGRGeometry.kml
(self)
Return the KML representation of the Geometry.
Return the KML representation of the Geometry.
def kml(self): "Return the KML representation of the Geometry." return capi.to_kml(self.ptr, None)
[ "def", "kml", "(", "self", ")", ":", "return", "capi", ".", "to_kml", "(", "self", ".", "ptr", ",", "None", ")" ]
[ 330, 4 ]
[ 332, 42 ]
python
en
['en', 'en', 'en']
True
OGRGeometry.wkb_size
(self)
Return the size of the WKB buffer.
Return the size of the WKB buffer.
def wkb_size(self): "Return the size of the WKB buffer." return capi.get_wkbsize(self.ptr)
[ "def", "wkb_size", "(", "self", ")", ":", "return", "capi", ".", "get_wkbsize", "(", "self", ".", "ptr", ")" ]
[ 335, 4 ]
[ 337, 41 ]
python
en
['en', 'en', 'en']
True
OGRGeometry.wkb
(self)
Return the WKB representation of the Geometry.
Return the WKB representation of the Geometry.
def wkb(self): "Return the WKB representation of the Geometry." if sys.byteorder == 'little': byteorder = 1 # wkbNDR (from ogr_core.h) else: byteorder = 0 # wkbXDR sz = self.wkb_size # Creating the unsigned character buffer, and passing it in by referenc...
[ "def", "wkb", "(", "self", ")", ":", "if", "sys", ".", "byteorder", "==", "'little'", ":", "byteorder", "=", "1", "# wkbNDR (from ogr_core.h)", "else", ":", "byteorder", "=", "0", "# wkbXDR", "sz", "=", "self", ".", "wkb_size", "# Creating the unsigned charact...
[ 340, 4 ]
[ 351, 45 ]
python
en
['en', 'en', 'en']
True
OGRGeometry.wkt
(self)
Return the WKT representation of the Geometry.
Return the WKT representation of the Geometry.
def wkt(self): "Return the WKT representation of the Geometry." return capi.to_wkt(self.ptr, byref(c_char_p()))
[ "def", "wkt", "(", "self", ")", ":", "return", "capi", ".", "to_wkt", "(", "self", ".", "ptr", ",", "byref", "(", "c_char_p", "(", ")", ")", ")" ]
[ 354, 4 ]
[ 356, 55 ]
python
en
['en', 'en', 'en']
True
OGRGeometry.ewkt
(self)
Return the EWKT representation of the Geometry.
Return the EWKT representation of the Geometry.
def ewkt(self): "Return the EWKT representation of the Geometry." srs = self.srs if srs and srs.srid: return 'SRID=%s;%s' % (srs.srid, self.wkt) else: return self.wkt
[ "def", "ewkt", "(", "self", ")", ":", "srs", "=", "self", ".", "srs", "if", "srs", "and", "srs", ".", "srid", ":", "return", "'SRID=%s;%s'", "%", "(", "srs", ".", "srid", ",", "self", ".", "wkt", ")", "else", ":", "return", "self", ".", "wkt" ]
[ 359, 4 ]
[ 365, 27 ]
python
en
['en', 'en', 'en']
True
OGRGeometry.clone
(self)
Clone this OGR Geometry.
Clone this OGR Geometry.
def clone(self): "Clone this OGR Geometry." return OGRGeometry(capi.clone_geom(self.ptr), self.srs)
[ "def", "clone", "(", "self", ")", ":", "return", "OGRGeometry", "(", "capi", ".", "clone_geom", "(", "self", ".", "ptr", ")", ",", "self", ".", "srs", ")" ]
[ 368, 4 ]
[ 370, 63 ]
python
en
['en', 'en', 'en']
True
OGRGeometry.close_rings
(self)
If there are any rings within this geometry that have not been closed, this routine will do so by adding the starting point at the end.
If there are any rings within this geometry that have not been closed, this routine will do so by adding the starting point at the end.
def close_rings(self): """ If there are any rings within this geometry that have not been closed, this routine will do so by adding the starting point at the end. """ # Closing the open rings. capi.geom_close_rings(self.ptr)
[ "def", "close_rings", "(", "self", ")", ":", "# Closing the open rings.", "capi", ".", "geom_close_rings", "(", "self", ".", "ptr", ")" ]
[ 372, 4 ]
[ 379, 39 ]
python
en
['en', 'error', 'th']
False
OGRGeometry.transform
(self, coord_trans, clone=False)
Transform this geometry to a different spatial reference system. May take a CoordTransform object, a SpatialReference object, string WKT or PROJ.4, and/or an integer SRID. By default, return nothing and transform the geometry in-place. However, if the `clone` keyword is set, re...
Transform this geometry to a different spatial reference system. May take a CoordTransform object, a SpatialReference object, string WKT or PROJ.4, and/or an integer SRID. By default, return nothing and transform the geometry in-place. However, if the `clone` keyword is set, re...
def transform(self, coord_trans, clone=False): """ Transform this geometry to a different spatial reference system. May take a CoordTransform object, a SpatialReference object, string WKT or PROJ.4, and/or an integer SRID. By default, return nothing and transform the geometry in...
[ "def", "transform", "(", "self", ",", "coord_trans", ",", "clone", "=", "False", ")", ":", "if", "clone", ":", "klone", "=", "self", ".", "clone", "(", ")", "klone", ".", "transform", "(", "coord_trans", ")", "return", "klone", "# Depending on the input ty...
[ 381, 4 ]
[ 405, 77 ]
python
en
['en', 'error', 'th']
False
OGRGeometry._topology
(self, func, other)
A generalized function for topology operations, takes a GDAL function and the other geometry to perform the operation on.
A generalized function for topology operations, takes a GDAL function and the other geometry to perform the operation on.
def _topology(self, func, other): """A generalized function for topology operations, takes a GDAL function and the other geometry to perform the operation on.""" if not isinstance(other, OGRGeometry): raise TypeError('Must use another OGRGeometry object for topology operations!') ...
[ "def", "_topology", "(", "self", ",", "func", ",", "other", ")", ":", "if", "not", "isinstance", "(", "other", ",", "OGRGeometry", ")", ":", "raise", "TypeError", "(", "'Must use another OGRGeometry object for topology operations!'", ")", "# Returning the output of th...
[ 408, 4 ]
[ 416, 40 ]
python
en
['en', 'en', 'en']
True
OGRGeometry.intersects
(self, other)
Return True if this geometry intersects with the other.
Return True if this geometry intersects with the other.
def intersects(self, other): "Return True if this geometry intersects with the other." return self._topology(capi.ogr_intersects, other)
[ "def", "intersects", "(", "self", ",", "other", ")", ":", "return", "self", ".", "_topology", "(", "capi", ".", "ogr_intersects", ",", "other", ")" ]
[ 418, 4 ]
[ 420, 57 ]
python
en
['en', 'en', 'en']
True
OGRGeometry.equals
(self, other)
Return True if this geometry is equivalent to the other.
Return True if this geometry is equivalent to the other.
def equals(self, other): "Return True if this geometry is equivalent to the other." return self._topology(capi.ogr_equals, other)
[ "def", "equals", "(", "self", ",", "other", ")", ":", "return", "self", ".", "_topology", "(", "capi", ".", "ogr_equals", ",", "other", ")" ]
[ 422, 4 ]
[ 424, 53 ]
python
en
['en', 'en', 'en']
True
OGRGeometry.disjoint
(self, other)
Return True if this geometry and the other are spatially disjoint.
Return True if this geometry and the other are spatially disjoint.
def disjoint(self, other): "Return True if this geometry and the other are spatially disjoint." return self._topology(capi.ogr_disjoint, other)
[ "def", "disjoint", "(", "self", ",", "other", ")", ":", "return", "self", ".", "_topology", "(", "capi", ".", "ogr_disjoint", ",", "other", ")" ]
[ 426, 4 ]
[ 428, 55 ]
python
en
['en', 'en', 'en']
True
OGRGeometry.touches
(self, other)
Return True if this geometry touches the other.
Return True if this geometry touches the other.
def touches(self, other): "Return True if this geometry touches the other." return self._topology(capi.ogr_touches, other)
[ "def", "touches", "(", "self", ",", "other", ")", ":", "return", "self", ".", "_topology", "(", "capi", ".", "ogr_touches", ",", "other", ")" ]
[ 430, 4 ]
[ 432, 54 ]
python
en
['en', 'en', 'en']
True
OGRGeometry.crosses
(self, other)
Return True if this geometry crosses the other.
Return True if this geometry crosses the other.
def crosses(self, other): "Return True if this geometry crosses the other." return self._topology(capi.ogr_crosses, other)
[ "def", "crosses", "(", "self", ",", "other", ")", ":", "return", "self", ".", "_topology", "(", "capi", ".", "ogr_crosses", ",", "other", ")" ]
[ 434, 4 ]
[ 436, 54 ]
python
en
['en', 'en', 'en']
True
OGRGeometry.within
(self, other)
Return True if this geometry is within the other.
Return True if this geometry is within the other.
def within(self, other): "Return True if this geometry is within the other." return self._topology(capi.ogr_within, other)
[ "def", "within", "(", "self", ",", "other", ")", ":", "return", "self", ".", "_topology", "(", "capi", ".", "ogr_within", ",", "other", ")" ]
[ 438, 4 ]
[ 440, 53 ]
python
en
['en', 'en', 'en']
True
OGRGeometry.contains
(self, other)
Return True if this geometry contains the other.
Return True if this geometry contains the other.
def contains(self, other): "Return True if this geometry contains the other." return self._topology(capi.ogr_contains, other)
[ "def", "contains", "(", "self", ",", "other", ")", ":", "return", "self", ".", "_topology", "(", "capi", ".", "ogr_contains", ",", "other", ")" ]
[ 442, 4 ]
[ 444, 55 ]
python
en
['en', 'en', 'en']
True
OGRGeometry.overlaps
(self, other)
Return True if this geometry overlaps the other.
Return True if this geometry overlaps the other.
def overlaps(self, other): "Return True if this geometry overlaps the other." return self._topology(capi.ogr_overlaps, other)
[ "def", "overlaps", "(", "self", ",", "other", ")", ":", "return", "self", ".", "_topology", "(", "capi", ".", "ogr_overlaps", ",", "other", ")" ]
[ 446, 4 ]
[ 448, 55 ]
python
en
['en', 'en', 'en']
True
OGRGeometry._geomgen
(self, gen_func, other=None)
A helper routine for the OGR routines that generate geometries.
A helper routine for the OGR routines that generate geometries.
def _geomgen(self, gen_func, other=None): "A helper routine for the OGR routines that generate geometries." if isinstance(other, OGRGeometry): return OGRGeometry(gen_func(self.ptr, other.ptr), self.srs) else: return OGRGeometry(gen_func(self.ptr), self.srs)
[ "def", "_geomgen", "(", "self", ",", "gen_func", ",", "other", "=", "None", ")", ":", "if", "isinstance", "(", "other", ",", "OGRGeometry", ")", ":", "return", "OGRGeometry", "(", "gen_func", "(", "self", ".", "ptr", ",", "other", ".", "ptr", ")", ",...
[ 451, 4 ]
[ 456, 60 ]
python
en
['en', 'en', 'en']
True
OGRGeometry.boundary
(self)
Return the boundary of this geometry.
Return the boundary of this geometry.
def boundary(self): "Return the boundary of this geometry." return self._geomgen(capi.get_boundary)
[ "def", "boundary", "(", "self", ")", ":", "return", "self", ".", "_geomgen", "(", "capi", ".", "get_boundary", ")" ]
[ 459, 4 ]
[ 461, 47 ]
python
en
['en', 'en', 'en']
True
OGRGeometry.convex_hull
(self)
Return the smallest convex Polygon that contains all the points in this Geometry.
Return the smallest convex Polygon that contains all the points in this Geometry.
def convex_hull(self): """ Return the smallest convex Polygon that contains all the points in this Geometry. """ return self._geomgen(capi.geom_convex_hull)
[ "def", "convex_hull", "(", "self", ")", ":", "return", "self", ".", "_geomgen", "(", "capi", ".", "geom_convex_hull", ")" ]
[ 464, 4 ]
[ 469, 51 ]
python
en
['en', 'error', 'th']
False
OGRGeometry.difference
(self, other)
Return a new geometry consisting of the region which is the difference of this geometry and the other.
Return a new geometry consisting of the region which is the difference of this geometry and the other.
def difference(self, other): """ Return a new geometry consisting of the region which is the difference of this geometry and the other. """ return self._geomgen(capi.geom_diff, other)
[ "def", "difference", "(", "self", ",", "other", ")", ":", "return", "self", ".", "_geomgen", "(", "capi", ".", "geom_diff", ",", "other", ")" ]
[ 471, 4 ]
[ 476, 51 ]
python
en
['en', 'error', 'th']
False
OGRGeometry.intersection
(self, other)
Return a new geometry consisting of the region of intersection of this geometry and the other.
Return a new geometry consisting of the region of intersection of this geometry and the other.
def intersection(self, other): """ Return a new geometry consisting of the region of intersection of this geometry and the other. """ return self._geomgen(capi.geom_intersection, other)
[ "def", "intersection", "(", "self", ",", "other", ")", ":", "return", "self", ".", "_geomgen", "(", "capi", ".", "geom_intersection", ",", "other", ")" ]
[ 478, 4 ]
[ 483, 59 ]
python
en
['en', 'error', 'th']
False
OGRGeometry.sym_difference
(self, other)
Return a new geometry which is the symmetric difference of this geometry and the other.
Return a new geometry which is the symmetric difference of this geometry and the other.
def sym_difference(self, other): """ Return a new geometry which is the symmetric difference of this geometry and the other. """ return self._geomgen(capi.geom_sym_diff, other)
[ "def", "sym_difference", "(", "self", ",", "other", ")", ":", "return", "self", ".", "_geomgen", "(", "capi", ".", "geom_sym_diff", ",", "other", ")" ]
[ 485, 4 ]
[ 490, 55 ]
python
en
['en', 'error', 'th']
False
OGRGeometry.union
(self, other)
Return a new geometry consisting of the region which is the union of this geometry and the other.
Return a new geometry consisting of the region which is the union of this geometry and the other.
def union(self, other): """ Return a new geometry consisting of the region which is the union of this geometry and the other. """ return self._geomgen(capi.geom_union, other)
[ "def", "union", "(", "self", ",", "other", ")", ":", "return", "self", ".", "_geomgen", "(", "capi", ".", "geom_union", ",", "other", ")" ]
[ 492, 4 ]
[ 497, 52 ]
python
en
['en', 'error', 'th']
False
Point.x
(self)
Return the X coordinate for this Point.
Return the X coordinate for this Point.
def x(self): "Return the X coordinate for this Point." return capi.getx(self.ptr, 0)
[ "def", "x", "(", "self", ")", ":", "return", "capi", ".", "getx", "(", "self", ".", "ptr", ",", "0", ")" ]
[ 512, 4 ]
[ 514, 37 ]
python
en
['en', 'en', 'en']
True
Point.y
(self)
Return the Y coordinate for this Point.
Return the Y coordinate for this Point.
def y(self): "Return the Y coordinate for this Point." return capi.gety(self.ptr, 0)
[ "def", "y", "(", "self", ")", ":", "return", "capi", ".", "gety", "(", "self", ".", "ptr", ",", "0", ")" ]
[ 517, 4 ]
[ 519, 37 ]
python
en
['en', 'en', 'en']
True
Point.z
(self)
Return the Z coordinate for this Point.
Return the Z coordinate for this Point.
def z(self): "Return the Z coordinate for this Point." if self.coord_dim == 3: return capi.getz(self.ptr, 0)
[ "def", "z", "(", "self", ")", ":", "if", "self", ".", "coord_dim", "==", "3", ":", "return", "capi", ".", "getz", "(", "self", ".", "ptr", ",", "0", ")" ]
[ 522, 4 ]
[ 525, 41 ]
python
en
['en', 'en', 'en']
True
Point.tuple
(self)
Return the tuple of this point.
Return the tuple of this point.
def tuple(self): "Return the tuple of this point." if self.coord_dim == 2: return (self.x, self.y) elif self.coord_dim == 3: return (self.x, self.y, self.z)
[ "def", "tuple", "(", "self", ")", ":", "if", "self", ".", "coord_dim", "==", "2", ":", "return", "(", "self", ".", "x", ",", "self", ".", "y", ")", "elif", "self", ".", "coord_dim", "==", "3", ":", "return", "(", "self", ".", "x", ",", "self", ...
[ 528, 4 ]
[ 533, 43 ]
python
en
['en', 'en', 'en']
True
LineString.__getitem__
(self, index)
Return the Point at the given index.
Return the Point at the given index.
def __getitem__(self, index): "Return the Point at the given index." if 0 <= index < self.point_count: x, y, z = c_double(), c_double(), c_double() capi.get_point(self.ptr, index, byref(x), byref(y), byref(z)) dim = self.coord_dim if dim == 1: ...
[ "def", "__getitem__", "(", "self", ",", "index", ")", ":", "if", "0", "<=", "index", "<", "self", ".", "point_count", ":", "x", ",", "y", ",", "z", "=", "c_double", "(", ")", ",", "c_double", "(", ")", ",", "c_double", "(", ")", "capi", ".", "g...
[ 539, 4 ]
[ 552, 102 ]
python
en
['en', 'en', 'en']
True
LineString.__len__
(self)
Return the number of points in the LineString.
Return the number of points in the LineString.
def __len__(self): "Return the number of points in the LineString." return self.point_count
[ "def", "__len__", "(", "self", ")", ":", "return", "self", ".", "point_count" ]
[ 554, 4 ]
[ 556, 31 ]
python
en
['en', 'en', 'en']
True
LineString.tuple
(self)
Return the tuple representation of this LineString.
Return the tuple representation of this LineString.
def tuple(self): "Return the tuple representation of this LineString." return tuple(self[i] for i in range(len(self)))
[ "def", "tuple", "(", "self", ")", ":", "return", "tuple", "(", "self", "[", "i", "]", "for", "i", "in", "range", "(", "len", "(", "self", ")", ")", ")" ]
[ 559, 4 ]
[ 561, 55 ]
python
en
['en', 'en', 'en']
True
LineString._listarr
(self, func)
Internal routine that returns a sequence (list) corresponding with the given function.
Internal routine that returns a sequence (list) corresponding with the given function.
def _listarr(self, func): """ Internal routine that returns a sequence (list) corresponding with the given function. """ return [func(self.ptr, i) for i in range(len(self))]
[ "def", "_listarr", "(", "self", ",", "func", ")", ":", "return", "[", "func", "(", "self", ".", "ptr", ",", "i", ")", "for", "i", "in", "range", "(", "len", "(", "self", ")", ")", "]" ]
[ 564, 4 ]
[ 569, 60 ]
python
en
['en', 'error', 'th']
False
LineString.x
(self)
Return the X coordinates in a list.
Return the X coordinates in a list.
def x(self): "Return the X coordinates in a list." return self._listarr(capi.getx)
[ "def", "x", "(", "self", ")", ":", "return", "self", ".", "_listarr", "(", "capi", ".", "getx", ")" ]
[ 572, 4 ]
[ 574, 39 ]
python
en
['en', 'en', 'en']
True
LineString.y
(self)
Return the Y coordinates in a list.
Return the Y coordinates in a list.
def y(self): "Return the Y coordinates in a list." return self._listarr(capi.gety)
[ "def", "y", "(", "self", ")", ":", "return", "self", ".", "_listarr", "(", "capi", ".", "gety", ")" ]
[ 577, 4 ]
[ 579, 39 ]
python
en
['en', 'en', 'en']
True
LineString.z
(self)
Return the Z coordinates in a list.
Return the Z coordinates in a list.
def z(self): "Return the Z coordinates in a list." if self.coord_dim == 3: return self._listarr(capi.getz)
[ "def", "z", "(", "self", ")", ":", "if", "self", ".", "coord_dim", "==", "3", ":", "return", "self", ".", "_listarr", "(", "capi", ".", "getz", ")" ]
[ 582, 4 ]
[ 585, 43 ]
python
en
['en', 'en', 'en']
True
Polygon.__len__
(self)
Return the number of interior rings in this Polygon.
Return the number of interior rings in this Polygon.
def __len__(self): "Return the number of interior rings in this Polygon." return self.geom_count
[ "def", "__len__", "(", "self", ")", ":", "return", "self", ".", "geom_count" ]
[ 595, 4 ]
[ 597, 30 ]
python
en
['en', 'en', 'en']
True
Polygon.__getitem__
(self, index)
Get the ring at the specified index.
Get the ring at the specified index.
def __getitem__(self, index): "Get the ring at the specified index." if 0 <= index < self.geom_count: return OGRGeometry(capi.clone_geom(capi.get_geom_ref(self.ptr, index)), self.srs) else: raise IndexError('Index out of range when accessing rings of a polygon: %s.' % ind...
[ "def", "__getitem__", "(", "self", ",", "index", ")", ":", "if", "0", "<=", "index", "<", "self", ".", "geom_count", ":", "return", "OGRGeometry", "(", "capi", ".", "clone_geom", "(", "capi", ".", "get_geom_ref", "(", "self", ".", "ptr", ",", "index", ...
[ 599, 4 ]
[ 604, 97 ]
python
en
['en', 'en', 'en']
True
Polygon.shell
(self)
Return the shell of this Polygon.
Return the shell of this Polygon.
def shell(self): "Return the shell of this Polygon." return self[0] # First ring is the shell
[ "def", "shell", "(", "self", ")", ":", "return", "self", "[", "0", "]", "# First ring is the shell" ]
[ 608, 4 ]
[ 610, 49 ]
python
en
['en', 'en', 'en']
True
Polygon.tuple
(self)
Return a tuple of LinearRing coordinate tuples.
Return a tuple of LinearRing coordinate tuples.
def tuple(self): "Return a tuple of LinearRing coordinate tuples." return tuple(self[i].tuple for i in range(self.geom_count))
[ "def", "tuple", "(", "self", ")", ":", "return", "tuple", "(", "self", "[", "i", "]", ".", "tuple", "for", "i", "in", "range", "(", "self", ".", "geom_count", ")", ")" ]
[ 614, 4 ]
[ 616, 67 ]
python
en
['en', 'en', 'en']
True
Polygon.point_count
(self)
Return the number of Points in this Polygon.
Return the number of Points in this Polygon.
def point_count(self): "Return the number of Points in this Polygon." # Summing up the number of points in each ring of the Polygon. return sum(self[i].point_count for i in range(self.geom_count))
[ "def", "point_count", "(", "self", ")", ":", "# Summing up the number of points in each ring of the Polygon.", "return", "sum", "(", "self", "[", "i", "]", ".", "point_count", "for", "i", "in", "range", "(", "self", ".", "geom_count", ")", ")" ]
[ 620, 4 ]
[ 623, 71 ]
python
en
['en', 'en', 'en']
True
Polygon.centroid
(self)
Return the centroid (a Point) of this Polygon.
Return the centroid (a Point) of this Polygon.
def centroid(self): "Return the centroid (a Point) of this Polygon." # The centroid is a Point, create a geometry for this. p = OGRGeometry(OGRGeomType('Point')) capi.get_centroid(self.ptr, p.ptr) return p
[ "def", "centroid", "(", "self", ")", ":", "# The centroid is a Point, create a geometry for this.", "p", "=", "OGRGeometry", "(", "OGRGeomType", "(", "'Point'", ")", ")", "capi", ".", "get_centroid", "(", "self", ".", "ptr", ",", "p", ".", "ptr", ")", "return"...
[ 626, 4 ]
[ 631, 16 ]
python
en
['en', 'en', 'en']
True
GeometryCollection.__getitem__
(self, index)
Get the Geometry at the specified index.
Get the Geometry at the specified index.
def __getitem__(self, index): "Get the Geometry at the specified index." if 0 <= index < self.geom_count: return OGRGeometry(capi.clone_geom(capi.get_geom_ref(self.ptr, index)), self.srs) else: raise IndexError('Index out of range when accessing geometry in a collection: ...
[ "def", "__getitem__", "(", "self", ",", "index", ")", ":", "if", "0", "<=", "index", "<", "self", ".", "geom_count", ":", "return", "OGRGeometry", "(", "capi", ".", "clone_geom", "(", "capi", ".", "get_geom_ref", "(", "self", ".", "ptr", ",", "index", ...
[ 638, 4 ]
[ 643, 103 ]
python
en
['en', 'en', 'en']
True
GeometryCollection.__len__
(self)
Return the number of geometries in this Geometry Collection.
Return the number of geometries in this Geometry Collection.
def __len__(self): "Return the number of geometries in this Geometry Collection." return self.geom_count
[ "def", "__len__", "(", "self", ")", ":", "return", "self", ".", "geom_count" ]
[ 645, 4 ]
[ 647, 30 ]
python
en
['en', 'en', 'en']
True
GeometryCollection.add
(self, geom)
Add the geometry to this Geometry Collection.
Add the geometry to this Geometry Collection.
def add(self, geom): "Add the geometry to this Geometry Collection." if isinstance(geom, OGRGeometry): if isinstance(geom, self.__class__): for g in geom: capi.add_geom(self.ptr, g.ptr) else: capi.add_geom(self.ptr, geom.ptr) ...
[ "def", "add", "(", "self", ",", "geom", ")", ":", "if", "isinstance", "(", "geom", ",", "OGRGeometry", ")", ":", "if", "isinstance", "(", "geom", ",", "self", ".", "__class__", ")", ":", "for", "g", "in", "geom", ":", "capi", ".", "add_geom", "(", ...
[ 649, 4 ]
[ 661, 59 ]
python
en
['en', 'en', 'en']
True
GeometryCollection.point_count
(self)
Return the number of Points in this Geometry Collection.
Return the number of Points in this Geometry Collection.
def point_count(self): "Return the number of Points in this Geometry Collection." # Summing up the number of points in each geometry in this collection return sum(self[i].point_count for i in range(self.geom_count))
[ "def", "point_count", "(", "self", ")", ":", "# Summing up the number of points in each geometry in this collection", "return", "sum", "(", "self", "[", "i", "]", ".", "point_count", "for", "i", "in", "range", "(", "self", ".", "geom_count", ")", ")" ]
[ 664, 4 ]
[ 667, 71 ]
python
en
['en', 'en', 'en']
True
GeometryCollection.tuple
(self)
Return a tuple representation of this Geometry Collection.
Return a tuple representation of this Geometry Collection.
def tuple(self): "Return a tuple representation of this Geometry Collection." return tuple(self[i].tuple for i in range(self.geom_count))
[ "def", "tuple", "(", "self", ")", ":", "return", "tuple", "(", "self", "[", "i", "]", ".", "tuple", "for", "i", "in", "range", "(", "self", ".", "geom_count", ")", ")" ]
[ 670, 4 ]
[ 672, 67 ]
python
en
['en', 'en', 'en']
True
ExtraDataMixin.get_extra_fields
(self, includes, context)
Return a dictionary of extra serializer fields. includes is a list of requested extra data. Example: fields = {} if 'user' in includes: fields['user'] = UserSerializer(read_only=True, context=context) return fields
Return a dictionary of extra serializer fields. includes is a list of requested extra data.
def get_extra_fields(self, includes, context): """ Return a dictionary of extra serializer fields. includes is a list of requested extra data. Example: fields = {} if 'user' in includes: fields['user'] = UserSerializer(read_only=True, context=context) ...
[ "def", "get_extra_fields", "(", "self", ",", "includes", ",", "context", ")", ":", "return", "{", "}" ]
[ 102, 4 ]
[ 112, 17 ]
python
en
['en', 'en', 'en']
True
SingleObjectMixin.get_object
(self, queryset=None)
Returns the object the view is displaying. By default this requires `self.queryset` and a `pk` or `slug` argument in the URLconf, but subclasses can override this to return any object.
Returns the object the view is displaying.
def get_object(self, queryset=None): """ Returns the object the view is displaying. By default this requires `self.queryset` and a `pk` or `slug` argument in the URLconf, but subclasses can override this to return any object. """ # Use a custom queryset if provided; this...
[ "def", "get_object", "(", "self", ",", "queryset", "=", "None", ")", ":", "# Use a custom queryset if provided; this is required for subclasses", "# like DateDetailView", "if", "queryset", "is", "None", ":", "queryset", "=", "self", ".", "get_queryset", "(", ")", "# N...
[ 21, 4 ]
[ 56, 18 ]
python
en
['en', 'error', 'th']
False
SingleObjectMixin.get_queryset
(self)
Return the `QuerySet` that will be used to look up the object. Note that this method is called by the default implementation of `get_object` and may not be called if `get_object` is overridden.
Return the `QuerySet` that will be used to look up the object.
def get_queryset(self): """ Return the `QuerySet` that will be used to look up the object. Note that this method is called by the default implementation of `get_object` and may not be called if `get_object` is overridden. """ if self.queryset is None: if self...
[ "def", "get_queryset", "(", "self", ")", ":", "if", "self", ".", "queryset", "is", "None", ":", "if", "self", ".", "model", ":", "return", "self", ".", "model", ".", "_default_manager", ".", "all", "(", ")", "else", ":", "raise", "ImproperlyConfigured", ...
[ 58, 4 ]
[ 76, 34 ]
python
en
['en', 'error', 'th']
False
SingleObjectMixin.get_slug_field
(self)
Get the name of a slug field to be used to look up by slug.
Get the name of a slug field to be used to look up by slug.
def get_slug_field(self): """ Get the name of a slug field to be used to look up by slug. """ return self.slug_field
[ "def", "get_slug_field", "(", "self", ")", ":", "return", "self", ".", "slug_field" ]
[ 78, 4 ]
[ 82, 30 ]
python
en
['en', 'error', 'th']
False
SingleObjectMixin.get_context_object_name
(self, obj)
Get the name to use for the object.
Get the name to use for the object.
def get_context_object_name(self, obj): """ Get the name to use for the object. """ if self.context_object_name: return self.context_object_name elif isinstance(obj, models.Model): return obj._meta.model_name else: return None
[ "def", "get_context_object_name", "(", "self", ",", "obj", ")", ":", "if", "self", ".", "context_object_name", ":", "return", "self", ".", "context_object_name", "elif", "isinstance", "(", "obj", ",", "models", ".", "Model", ")", ":", "return", "obj", ".", ...
[ 84, 4 ]
[ 93, 23 ]
python
en
['en', 'error', 'th']
False