text stringlengths 0 828 |
|---|
break |
current_id = next_id |
# Get the region delimited by the parent node |
region = parent_node.region[:] |
region[axis] = parent_node.region[axis][:] |
# Limit to the child's region |
limit = parent_node.point[axis] |
# Update reference to the new node |
if left: |
self.node_list[current_id] = parent_node._replace(left=self.size) |
region[axis][1] = limit |
else: |
self.node_list[current_id] = parent_node._replace(right=self.size) |
region[axis][0] = limit |
return self.new_node(point, region, (axis + 1) % self.k, data)" |
4594,"def find_nearest_point(self, query, dist_fun=euclidean_dist): |
""""""Find the point in the tree that minimizes the distance to the query. |
Args: |
query (:obj:`tuple` of float or int): Stores the position of the |
node. |
dist_fun (:obj:`function`, optional): The distance function, |
euclidean distance by default. |
Returns: |
:obj:`tuple`: Tuple of length 2, where the first element is the |
identifier of the nearest node, the second is the distance |
to the query. |
Example: |
>>> tree = Tree(2, 3) |
>>> tree.insert((0, 0)) |
>>> tree.insert((3, 5)) |
>>> tree.insert((-1, 7)) |
>>> query = (-1, 8) |
>>> nearest_node_id, dist = tree.find_nearest_point(query) |
>>> dist |
1 |
"""""" |
def get_properties(node_id): |
return self.node_list[node_id][:6] |
return nearest_point(query, 0, get_properties, dist_fun)" |
4595,"def set_to_public(self, request, queryset): |
"""""" Set one or several releases to public """""" |
queryset.update(is_public=True, modified=now())" |
4596,"def loads(cls, json_data): |
""""""description of load"""""" |
try: |
return cls(**cls.MARSHMALLOW_SCHEMA.loads(json_data)) |
except marshmallow.exceptions.ValidationError as exc: |
raise ValidationError(""Failed to load message"", extra=exc.args[0])" |
4597,"def format(self, response): |
"""""" Format the data. |
In derived classes, it is usually better idea to override |
``_format_data()`` than this method. |
:param response: devil's ``Response`` object or the data |
itself. May also be ``None``. |
:return: django's ``HttpResponse`` |
todo: this shouldn't change the given response. only return the |
formatted response. |
"""""" |
res = self._prepare_response(response) |
res.content = self._format_data(res.content, self.charset) |
return self._finalize_response(res)" |
4598,"def parse(self, data, charset=None): |
"""""" Parse the data. |
It is usually a better idea to override ``_parse_data()`` than |
this method in derived classes. |
:param charset: the charset of the data. Uses datamapper's |
default (``self.charset``) if not given. |
:returns: |
"""""" |
charset = charset or self.charset |
return self._parse_data(data, charset)" |
4599,"def _decode_data(self, data, charset): |
"""""" Decode string data. |
:returns: unicode string |
"""""" |
try: |
return smart_unicode(data, charset) |
except UnicodeDecodeError: |
raise errors.BadRequest('wrong charset')" |
4600,"def _parse_data(self, data, charset): |
"""""" Parse the data |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.