_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q228400 | BetweenClause.to_match | train | def to_match(self):
"""Return a unicode object with the MATCH representation of this BetweenClause."""
template = u'({field_name} BETWEEN {lower_bound} AND {upper_bound})'
return template.format(
field_name=self.field.to_match(),
lower_bound=self.lower_bound.to_match(),
... | python | {
"resource": ""
} |
q228401 | OptionalTraversalTree.insert | train | def insert(self, optional_root_locations_path):
"""Insert a path of optional Locations into the tree.
Each OptionalTraversalTree object contains child Location objects as keys mapping to
other OptionalTraversalTree objects.
Args:
optional_root_locations_path: list of option... | python | {
"resource": ""
} |
q228402 | emit_code_from_ir | train | def emit_code_from_ir(sql_query_tree, compiler_metadata):
"""Return a SQLAlchemy Query from a passed SqlQueryTree.
Args:
sql_query_tree: SqlQueryTree, tree representation of the query to emit.
compiler_metadata: SqlMetadata, SQLAlchemy specific metadata.
Returns:
SQLAlchemy Query
... | python | {
"resource": ""
} |
q228403 | _create_table_and_update_context | train | def _create_table_and_update_context(node, context):
"""Create an aliased table for a SqlNode.
Updates the relevant Selectable global context.
Args:
node: SqlNode, the current node.
context: CompilationContext, global compilation state and metadata.
Returns:
Table, the newly a... | python | {
"resource": ""
} |
q228404 | _create_query | train | def _create_query(node, context):
"""Create a query from a SqlNode.
Args:
node: SqlNode, the current node.
context: CompilationContext, global compilation state and metadata.
Returns:
Selectable, selectable of the generated query.
"""
visited_nodes = [node]
output_colum... | python | {
"resource": ""
} |
q228405 | _get_output_columns | train | def _get_output_columns(nodes, context):
"""Get the output columns for a list of SqlNodes.
Args:
nodes: List[SqlNode], the nodes to get output columns from.
context: CompilationContext, global compilation state and metadata.
Returns:
List[Column], list of SqlAlchemy Columns to outp... | python | {
"resource": ""
} |
q228406 | _get_filters | train | def _get_filters(nodes, context):
"""Get filters to apply to a list of SqlNodes.
Args:
nodes: List[SqlNode], the SqlNodes to get filters for.
context: CompilationContext, global compilation state and metadata.
Returns:
List[Expression], list of SQLAlchemy expressions.
"""
f... | python | {
"resource": ""
} |
q228407 | _transform_filter_to_sql | train | def _transform_filter_to_sql(filter_block, node, context):
"""Transform a Filter block to its corresponding SQLAlchemy expression.
Args:
filter_block: Filter, the Filter block to transform.
node: SqlNode, the node Filter block applies to.
context: CompilationContext, global compilation ... | python | {
"resource": ""
} |
q228408 | _expression_to_sql | train | def _expression_to_sql(expression, node, context):
"""Recursively transform a Filter block predicate to its SQLAlchemy expression representation.
Args:
expression: expression, the compiler expression to transform.
node: SqlNode, the SqlNode the expression applies to.
context: Compilatio... | python | {
"resource": ""
} |
q228409 | _transform_binary_composition_to_expression | train | def _transform_binary_composition_to_expression(expression, node, context):
"""Transform a BinaryComposition compiler expression into a SQLAlchemy expression.
Recursively calls _expression_to_sql to convert its left and right sub-expressions.
Args:
expression: expression, BinaryComposition compile... | python | {
"resource": ""
} |
q228410 | _transform_variable_to_expression | train | def _transform_variable_to_expression(expression, node, context):
"""Transform a Variable compiler expression into its SQLAlchemy expression representation.
Args:
expression: expression, Variable compiler expression.
node: SqlNode, the SqlNode the expression applies to.
context: Compila... | python | {
"resource": ""
} |
q228411 | _transform_local_field_to_expression | train | def _transform_local_field_to_expression(expression, node, context):
"""Transform a LocalField compiler expression into its SQLAlchemy expression representation.
Args:
expression: expression, LocalField compiler expression.
node: SqlNode, the SqlNode the expression applies to.
context: ... | python | {
"resource": ""
} |
q228412 | lower_context_field_existence | train | def lower_context_field_existence(ir_blocks, query_metadata_table):
"""Lower ContextFieldExistence expressions into lower-level expressions."""
def regular_visitor_fn(expression):
"""Expression visitor function that rewrites ContextFieldExistence expressions."""
if not isinstance(expression, Con... | python | {
"resource": ""
} |
q228413 | optimize_boolean_expression_comparisons | train | def optimize_boolean_expression_comparisons(ir_blocks):
"""Optimize comparisons of a boolean binary comparison expression against a boolean literal.
Rewriting example:
BinaryComposition(
'=',
BinaryComposition('!=', something, NullLiteral)
False)
The above is re... | python | {
"resource": ""
} |
q228414 | extract_simple_optional_location_info | train | def extract_simple_optional_location_info(
ir_blocks, complex_optional_roots, location_to_optional_roots):
"""Construct a map from simple optional locations to their inner location and traversed edge.
Args:
ir_blocks: list of IR blocks to extract optional data from
complex_optional_root... | python | {
"resource": ""
} |
q228415 | remove_end_optionals | train | def remove_end_optionals(ir_blocks):
"""Return a list of IR blocks as a copy of the original, with EndOptional blocks removed."""
new_ir_blocks = []
for block in ir_blocks:
if not isinstance(block, EndOptional):
new_ir_blocks.append(block)
return new_ir_blocks | python | {
"resource": ""
} |
q228416 | OutputContextVertex.validate | train | def validate(self):
"""Validate that the OutputContextVertex is correctly representable."""
super(OutputContextVertex, self).validate()
if self.location.field is not None:
raise ValueError(u'Expected location at a vertex, but got: {}'.format(self.location)) | python | {
"resource": ""
} |
q228417 | lower_has_substring_binary_compositions | train | def lower_has_substring_binary_compositions(ir_blocks):
"""Lower Filter blocks that use the "has_substring" operation into MATCH-representable form."""
def visitor_fn(expression):
"""Rewrite BinaryComposition expressions with "has_substring" into representable form."""
# The implementation of "h... | python | {
"resource": ""
} |
q228418 | truncate_repeated_single_step_traversals | train | def truncate_repeated_single_step_traversals(match_query):
"""Truncate one-step traversals that overlap a previous traversal location."""
# Such traversals frequently happen as side-effects of the lowering process
# of Backtrack blocks, and needlessly complicate the executed queries.
new_match_traversal... | python | {
"resource": ""
} |
q228419 | _flatten_location_translations | train | def _flatten_location_translations(location_translations):
"""If location A translates to B, and B to C, then make A translate directly to C.
Args:
location_translations: dict of Location -> Location, where the key translates to the value.
Mutated in place for efficiency ... | python | {
"resource": ""
} |
q228420 | _translate_equivalent_locations | train | def _translate_equivalent_locations(match_query, location_translations):
"""Translate Location objects into their equivalent locations, based on the given dict."""
new_match_traversals = []
def visitor_fn(expression):
"""Expression visitor function used to rewrite expressions with updated Location ... | python | {
"resource": ""
} |
q228421 | lower_folded_coerce_types_into_filter_blocks | train | def lower_folded_coerce_types_into_filter_blocks(folded_ir_blocks):
"""Lower CoerceType blocks into "INSTANCEOF" Filter blocks. Indended for folded IR blocks."""
new_folded_ir_blocks = []
for block in folded_ir_blocks:
if isinstance(block, CoerceType):
new_block = convert_coerce_type_to_... | python | {
"resource": ""
} |
q228422 | remove_backtrack_blocks_from_fold | train | def remove_backtrack_blocks_from_fold(folded_ir_blocks):
"""Return a list of IR blocks with all Backtrack blocks removed."""
new_folded_ir_blocks = []
for block in folded_ir_blocks:
if not isinstance(block, Backtrack):
new_folded_ir_blocks.append(block)
return new_folded_ir_blocks | python | {
"resource": ""
} |
q228423 | truncate_repeated_single_step_traversals_in_sub_queries | train | def truncate_repeated_single_step_traversals_in_sub_queries(compound_match_query):
"""For each sub-query, remove one-step traversals that overlap a previous traversal location."""
lowered_match_queries = []
for match_query in compound_match_query.match_queries:
new_match_query = truncate_repeated_si... | python | {
"resource": ""
} |
q228424 | _prune_traverse_using_omitted_locations | train | def _prune_traverse_using_omitted_locations(match_traversal, omitted_locations,
complex_optional_roots, location_to_optional_roots):
"""Return a prefix of the given traverse, excluding any blocks after an omitted optional.
Given a subset (omitted_locations) of comple... | python | {
"resource": ""
} |
q228425 | convert_optional_traversals_to_compound_match_query | train | def convert_optional_traversals_to_compound_match_query(
match_query, complex_optional_roots, location_to_optional_roots):
"""Return 2^n distinct MatchQuery objects in a CompoundMatchQuery.
Given a MatchQuery containing `n` optional traverses that expand vertex fields,
construct `2^n` different Mat... | python | {
"resource": ""
} |
q228426 | _get_present_locations | train | def _get_present_locations(match_traversals):
"""Return the set of locations and non-optional locations present in the given match traversals.
When enumerating the possibilities for optional traversals,
the resulting match traversals may have sections of the query omitted.
These locations will not be i... | python | {
"resource": ""
} |
q228427 | prune_non_existent_outputs | train | def prune_non_existent_outputs(compound_match_query):
"""Remove non-existent outputs from each MatchQuery in the given CompoundMatchQuery.
Each of the 2^n MatchQuery objects (except one) has been pruned to exclude some Traverse blocks,
For each of these, remove the outputs (that have been implicitly pruned... | python | {
"resource": ""
} |
q228428 | _construct_location_to_filter_list | train | def _construct_location_to_filter_list(match_query):
"""Return a dict mapping location -> list of filters applied at that location.
Args:
match_query: MatchQuery object from which to extract location -> filters dict
Returns:
dict mapping each location in match_query to a list of
... | python | {
"resource": ""
} |
q228429 | _filter_list_to_conjunction_expression | train | def _filter_list_to_conjunction_expression(filter_list):
"""Convert a list of filters to an Expression that is the conjunction of all of them."""
if not isinstance(filter_list, list):
raise AssertionError(u'Expected `list`, Received: {}.'.format(filter_list))
if any((not isinstance(filter_block, Fil... | python | {
"resource": ""
} |
q228430 | _apply_filters_to_first_location_occurrence | train | def _apply_filters_to_first_location_occurrence(match_traversal, location_to_filters,
already_filtered_locations):
"""Apply all filters for a specific location into its first occurrence in a given traversal.
For each location in the given match traversal,
con... | python | {
"resource": ""
} |
q228431 | collect_filters_to_first_location_occurrence | train | def collect_filters_to_first_location_occurrence(compound_match_query):
"""Collect all filters for a particular location to the first instance of the location.
Adding edge field non-exsistence filters in `_prune_traverse_using_omitted_locations` may
result in filters being applied to locations after their ... | python | {
"resource": ""
} |
q228432 | _update_context_field_binary_composition | train | def _update_context_field_binary_composition(present_locations, expression):
"""Lower BinaryCompositions involving non-existent ContextFields to True.
Args:
present_locations: set of all locations in the current MatchQuery that have not been pruned
expression: BinaryComposition with at least on... | python | {
"resource": ""
} |
q228433 | _simplify_non_context_field_binary_composition | train | def _simplify_non_context_field_binary_composition(expression):
"""Return a simplified BinaryComposition if either operand is a TrueLiteral.
Args:
expression: BinaryComposition without any ContextField operand(s)
Returns:
simplified expression if the given expression is a disjunction/conju... | python | {
"resource": ""
} |
q228434 | _update_context_field_expression | train | def _update_context_field_expression(present_locations, expression):
"""Lower Expressions involving non-existent ContextFields to TrueLiteral and simplify result."""
no_op_blocks = (ContextField, Literal, LocalField, UnaryTransformation, Variable)
if isinstance(expression, BinaryComposition):
if isi... | python | {
"resource": ""
} |
q228435 | _lower_non_existent_context_field_filters | train | def _lower_non_existent_context_field_filters(match_traversals, visitor_fn):
"""Return new match traversals, lowering filters involving non-existent ContextFields.
Expressions involving non-existent ContextFields are evaluated to TrueLiteral.
BinaryCompositions, where one of the operands is lowered to a Tr... | python | {
"resource": ""
} |
q228436 | lower_context_field_expressions | train | def lower_context_field_expressions(compound_match_query):
"""Lower Expressons involving non-existent ContextFields."""
if len(compound_match_query.match_queries) == 0:
raise AssertionError(u'Received CompoundMatchQuery {} with no MatchQuery objects.'
.format(compound_match_... | python | {
"resource": ""
} |
q228437 | _validate_edges_do_not_have_extra_links | train | def _validate_edges_do_not_have_extra_links(class_name, properties):
"""Validate that edges do not have properties of Link type that aren't the edge endpoints."""
for property_name, property_descriptor in six.iteritems(properties):
if property_name in {EDGE_SOURCE_PROPERTY_NAME, EDGE_DESTINATION_PROPERT... | python | {
"resource": ""
} |
q228438 | _validate_property_names | train | def _validate_property_names(class_name, properties):
"""Validate that properties do not have names that may cause problems in the GraphQL schema."""
for property_name in properties:
if not property_name or property_name.startswith(ILLEGAL_PROPERTY_NAME_PREFIXES):
raise IllegalSchemaStateErr... | python | {
"resource": ""
} |
q228439 | _validate_collections_have_default_values | train | def _validate_collections_have_default_values(class_name, property_name, property_descriptor):
"""Validate that if the property is of collection type, it has a specified default value."""
# We don't want properties of collection type having "null" values, since that may cause
# unexpected errors during Grap... | python | {
"resource": ""
} |
q228440 | get_superclasses_from_class_definition | train | def get_superclasses_from_class_definition(class_definition):
"""Extract a list of all superclass names from a class definition dict."""
# New-style superclasses definition, supporting multiple-inheritance.
superclasses = class_definition.get('superClasses', None)
if superclasses:
return list(s... | python | {
"resource": ""
} |
q228441 | SchemaElement.freeze | train | def freeze(self):
"""Make the SchemaElement's connections immutable."""
self.in_connections = frozenset(self.in_connections)
self.out_connections = frozenset(self.out_connections) | python | {
"resource": ""
} |
q228442 | SchemaGraph.get_default_property_values | train | def get_default_property_values(self, classname):
"""Return a dict with default values for all properties declared on this class."""
schema_element = self.get_element_by_class_name(classname)
result = {
property_name: property_descriptor.default
for property_name, proper... | python | {
"resource": ""
} |
q228443 | SchemaGraph._get_property_values_with_defaults | train | def _get_property_values_with_defaults(self, classname, property_values):
"""Return the property values for the class, with default values applied where needed."""
# To uphold OrientDB semantics, make a new dict with all property values set
# to their default values, which are None if no default... | python | {
"resource": ""
} |
q228444 | SchemaGraph.get_element_by_class_name_or_raise | train | def get_element_by_class_name_or_raise(self, class_name):
"""Return the SchemaElement for the specified class name, asserting that it exists."""
if class_name not in self._elements:
raise InvalidClassError(u'Class does not exist: {}'.format(class_name))
return self._elements[class_n... | python | {
"resource": ""
} |
q228445 | SchemaGraph.get_vertex_schema_element_or_raise | train | def get_vertex_schema_element_or_raise(self, vertex_classname):
"""Return the schema element with the given name, asserting that it's of vertex type."""
schema_element = self.get_element_by_class_name_or_raise(vertex_classname)
if not schema_element.is_vertex:
raise InvalidClassErro... | python | {
"resource": ""
} |
q228446 | SchemaGraph.get_edge_schema_element_or_raise | train | def get_edge_schema_element_or_raise(self, edge_classname):
"""Return the schema element with the given name, asserting that it's of edge type."""
schema_element = self.get_element_by_class_name_or_raise(edge_classname)
if not schema_element.is_edge:
raise InvalidClassError(u'Non-ed... | python | {
"resource": ""
} |
q228447 | SchemaGraph.validate_is_non_abstract_vertex_type | train | def validate_is_non_abstract_vertex_type(self, vertex_classname):
"""Validate that a vertex classname corresponds to a non-abstract vertex class."""
element = self.get_vertex_schema_element_or_raise(vertex_classname)
if element.abstract:
raise InvalidClassError(u'Expected a non-abst... | python | {
"resource": ""
} |
q228448 | SchemaGraph.validate_is_non_abstract_edge_type | train | def validate_is_non_abstract_edge_type(self, edge_classname):
"""Validate that a edge classname corresponds to a non-abstract edge class."""
element = self.get_edge_schema_element_or_raise(edge_classname)
if element.abstract:
raise InvalidClassError(u'Expected a non-abstract vertex ... | python | {
"resource": ""
} |
q228449 | SchemaGraph.validate_properties_exist | train | def validate_properties_exist(self, classname, property_names):
"""Validate that the specified property names are indeed defined on the given class."""
schema_element = self.get_element_by_class_name(classname)
requested_properties = set(property_names)
available_properties = set(schema... | python | {
"resource": ""
} |
q228450 | SchemaGraph._split_classes_by_kind | train | def _split_classes_by_kind(self, class_name_to_definition):
"""Assign each class to the vertex, edge or non-graph type sets based on its kind."""
for class_name in class_name_to_definition:
inheritance_set = self._inheritance_sets[class_name]
is_vertex = ORIENTDB_BASE_VERTEX_CLA... | python | {
"resource": ""
} |
q228451 | SchemaGraph._create_descriptor_from_property_definition | train | def _create_descriptor_from_property_definition(self, class_name, property_definition,
class_name_to_definition):
"""Return a PropertyDescriptor corresponding to the given OrientDB property definition."""
name = property_definition['name']
type... | python | {
"resource": ""
} |
q228452 | SchemaGraph._link_vertex_and_edge_types | train | def _link_vertex_and_edge_types(self):
"""For each edge, link it to the vertex types it connects to each other."""
for edge_class_name in self._edge_class_names:
edge_element = self._elements[edge_class_name]
if (EDGE_SOURCE_PROPERTY_NAME not in edge_element.properties or
... | python | {
"resource": ""
} |
q228453 | _is_local_filter | train | def _is_local_filter(filter_block):
"""Return True if the Filter block references no non-local fields, and False otherwise."""
# We need the "result" value of this function to be mutated within the "visitor_fn".
# Since we support both Python 2 and Python 3, we can't use the "nonlocal" keyword here:
# h... | python | {
"resource": ""
} |
q228454 | _calculate_type_bound_at_step | train | def _calculate_type_bound_at_step(match_step):
"""Return the GraphQL type bound at the given step, or None if no bound is given."""
current_type_bounds = []
if isinstance(match_step.root_block, QueryRoot):
# The QueryRoot start class is a type bound.
current_type_bounds.extend(match_step.ro... | python | {
"resource": ""
} |
q228455 | _assert_type_bounds_are_not_conflicting | train | def _assert_type_bounds_are_not_conflicting(current_type_bound, previous_type_bound,
location, match_query):
"""Ensure that the two bounds either are an exact match, or one of them is None."""
if all((current_type_bound is not None,
previous_type_bound is ... | python | {
"resource": ""
} |
q228456 | _expose_only_preferred_locations | train | def _expose_only_preferred_locations(match_query, location_types, coerced_locations,
preferred_locations, eligible_locations):
"""Return a MATCH query where only preferred locations are valid as query start locations."""
preferred_location_types = dict()
eligible_locatio... | python | {
"resource": ""
} |
q228457 | _expose_all_eligible_locations | train | def _expose_all_eligible_locations(match_query, location_types, eligible_locations):
"""Return a MATCH query where all eligible locations are valid as query start locations."""
eligible_location_types = dict()
new_match_traversals = []
for current_traversal in match_query.match_traversals:
new_... | python | {
"resource": ""
} |
q228458 | expose_ideal_query_execution_start_points | train | def expose_ideal_query_execution_start_points(compound_match_query, location_types,
coerced_locations):
"""Ensure that OrientDB only considers desirable query start points in query planning."""
new_queries = []
for match_query in compound_match_query.match_quer... | python | {
"resource": ""
} |
q228459 | _expression_list_to_conjunction | train | def _expression_list_to_conjunction(expression_list):
"""Return an Expression that is the `&&` of all the expressions in the given list."""
if not isinstance(expression_list, list):
raise AssertionError(u'Expected list. Received {}: '
u'{}'.format(type(expression_list).__nam... | python | {
"resource": ""
} |
q228460 | _extract_conjuction_elements_from_expression | train | def _extract_conjuction_elements_from_expression(expression):
"""Return a generator for expressions that are connected by `&&`s in the given expression."""
if isinstance(expression, BinaryComposition) and expression.operator == u'&&':
for element in _extract_conjuction_elements_from_expression(expressio... | python | {
"resource": ""
} |
q228461 | _construct_field_operator_expression_dict | train | def _construct_field_operator_expression_dict(expression_list):
"""Construct a mapping from local fields to specified operators, and corresponding expressions.
Args:
expression_list: list of expressions to analyze
Returns:
local_field_to_expressions:
dict mapping local field na... | python | {
"resource": ""
} |
q228462 | _lower_expressions_to_between | train | def _lower_expressions_to_between(base_expression):
"""Return a new expression, with any eligible comparisons lowered to `between` clauses."""
expression_list = list(_extract_conjuction_elements_from_expression(base_expression))
if len(expression_list) == 0:
raise AssertionError(u'Received empty exp... | python | {
"resource": ""
} |
q228463 | lower_comparisons_to_between | train | def lower_comparisons_to_between(match_query):
"""Return a new MatchQuery, with all eligible comparison filters lowered to between clauses."""
new_match_traversals = []
for current_match_traversal in match_query.match_traversals:
new_traversal = []
for step in current_match_traversal:
... | python | {
"resource": ""
} |
q228464 | _ensure_arguments_are_provided | train | def _ensure_arguments_are_provided(expected_types, arguments):
"""Ensure that all arguments expected by the query were actually provided."""
# This function only checks that the arguments were specified,
# and does not check types. Type checking is done as part of the actual formatting step.
expected_ar... | python | {
"resource": ""
} |
q228465 | insert_arguments_into_query | train | def insert_arguments_into_query(compilation_result, arguments):
"""Insert the arguments into the compiled GraphQL query to form a complete query.
Args:
compilation_result: a CompilationResult object derived from the GraphQL compiler
arguments: dict, mapping argument name to its value, for every... | python | {
"resource": ""
} |
q228466 | QueryRoot.validate | train | def validate(self):
"""Ensure that the QueryRoot block is valid."""
if not (isinstance(self.start_class, set) and
all(isinstance(x, six.string_types) for x in self.start_class)):
raise TypeError(u'Expected set of string start_class, got: {} {}'.format(
type(se... | python | {
"resource": ""
} |
q228467 | CoerceType.validate | train | def validate(self):
"""Ensure that the CoerceType block is valid."""
if not (isinstance(self.target_class, set) and
all(isinstance(x, six.string_types) for x in self.target_class)):
raise TypeError(u'Expected set of string target_class, got: {} {}'.format(
typ... | python | {
"resource": ""
} |
q228468 | ConstructResult.validate | train | def validate(self):
"""Ensure that the ConstructResult block is valid."""
if not isinstance(self.fields, dict):
raise TypeError(u'Expected dict fields, got: {} {}'.format(
type(self.fields).__name__, self.fields))
for key, value in six.iteritems(self.fields):
... | python | {
"resource": ""
} |
q228469 | Filter.validate | train | def validate(self):
"""Ensure that the Filter block is valid."""
if not isinstance(self.predicate, Expression):
raise TypeError(u'Expected Expression predicate, got: {} {}'.format(
type(self.predicate).__name__, self.predicate)) | python | {
"resource": ""
} |
q228470 | Backtrack.validate | train | def validate(self):
"""Ensure that the Backtrack block is valid."""
validate_marked_location(self.location)
if not isinstance(self.optional, bool):
raise TypeError(u'Expected bool optional, got: {} {}'.format(
type(self.optional).__name__, self.optional)) | python | {
"resource": ""
} |
q228471 | Backtrack.to_gremlin | train | def to_gremlin(self):
"""Return a unicode object with the Gremlin representation of this BasicBlock."""
self.validate()
if self.optional:
operation = u'optional'
else:
operation = u'back'
mark_name, _ = self.location.get_location_name()
return u'... | python | {
"resource": ""
} |
q228472 | Fold.validate | train | def validate(self):
"""Ensure the Fold block is valid."""
if not isinstance(self.fold_scope_location, FoldScopeLocation):
raise TypeError(u'Expected a FoldScopeLocation for fold_scope_location, got: {} '
u'{}'.format(type(self.fold_scope_location), self.fold_scope... | python | {
"resource": ""
} |
q228473 | lower_ir | train | def lower_ir(ir_blocks, query_metadata_table, type_equivalence_hints=None):
"""Lower the IR blocks into a form that can be represented by a SQL query.
Args:
ir_blocks: list of IR blocks to lower into SQL-compatible form
query_metadata_table: QueryMetadataTable object containing all metadata col... | python | {
"resource": ""
} |
q228474 | _validate_all_blocks_supported | train | def _validate_all_blocks_supported(ir_blocks, query_metadata_table):
"""Validate that all IR blocks and ConstructResult fields passed to the backend are supported.
Args:
ir_blocks: List[BasicBlock], IR blocks to validate.
query_metadata_table: QueryMetadataTable, object containing all metadata ... | python | {
"resource": ""
} |
q228475 | _get_construct_result | train | def _get_construct_result(ir_blocks):
"""Return the ConstructResult block from a list of IR blocks."""
last_block = ir_blocks[-1]
if not isinstance(last_block, blocks.ConstructResult):
raise AssertionError(
u'The last IR block {} for IR blocks {} was unexpectedly not '
u'a Co... | python | {
"resource": ""
} |
q228476 | _map_query_path_to_location_info | train | def _map_query_path_to_location_info(query_metadata_table):
"""Create a map from each query path to a LocationInfo at that path.
Args:
query_metadata_table: QueryMetadataTable, object containing all metadata collected during
query processing, including location metadata (e... | python | {
"resource": ""
} |
q228477 | _location_infos_equal | train | def _location_infos_equal(left, right):
"""Return True if LocationInfo objects are equivalent for the SQL backend, False otherwise.
LocationInfo objects are considered equal for the SQL backend iff the optional scopes depth,
recursive scopes depth, types and parent query paths are equal.
Args:
... | python | {
"resource": ""
} |
q228478 | _map_query_path_to_outputs | train | def _map_query_path_to_outputs(construct_result, query_path_to_location_info):
"""Assign the output fields of a ConstructResult block to their respective query_path."""
query_path_to_output_fields = {}
for output_name, field in six.iteritems(construct_result.fields):
field_name = field.location.fiel... | python | {
"resource": ""
} |
q228479 | _map_block_index_to_location | train | def _map_block_index_to_location(ir_blocks):
"""Associate each IR block with its corresponding location, by index."""
block_index_to_location = {}
# MarkLocation blocks occur after the blocks related to that location.
# The core approach here is to buffer blocks until their MarkLocation is encountered
... | python | {
"resource": ""
} |
q228480 | lower_unary_transformations | train | def lower_unary_transformations(ir_blocks):
"""Raise exception if any unary transformation block encountered."""
def visitor_fn(expression):
"""Raise error if current expression is a UnaryTransformation."""
if not isinstance(expression, expressions.UnaryTransformation):
return expres... | python | {
"resource": ""
} |
q228481 | lower_unsupported_metafield_expressions | train | def lower_unsupported_metafield_expressions(ir_blocks):
"""Raise exception if an unsupported metafield is encountered in any LocalField expression."""
def visitor_fn(expression):
"""Visitor function raising exception for any unsupported metafield."""
if not isinstance(expression, expressions.Loc... | python | {
"resource": ""
} |
q228482 | get_graphql_schema_from_orientdb_schema_data | train | def get_graphql_schema_from_orientdb_schema_data(schema_data, class_to_field_type_overrides=None,
hidden_classes=None):
"""Construct a GraphQL schema from an OrientDB schema.
Args:
schema_data: list of dicts describing the classes in the OrientDB schema.... | python | {
"resource": ""
} |
q228483 | SlackEventAdapter.start | train | def start(self, host='127.0.0.1', port=None, debug=False, **kwargs):
"""
Start the built in webserver, bound to the host and port you'd like.
Default host is `127.0.0.1` and port 8080.
:param host: The host you want to bind the build in webserver to
:param port: The port number ... | python | {
"resource": ""
} |
q228484 | login | train | def login(request):
'''
Logs in the user via given login and password.
'''
serializer_class = registration_settings.LOGIN_SERIALIZER_CLASS
serializer = serializer_class(data=request.data)
serializer.is_valid(raise_exception=True)
user = serializer.get_authenticated_user()
if not user:
... | python | {
"resource": ""
} |
q228485 | logout | train | def logout(request):
'''
Logs out the user. returns an error if the user is not
authenticated.
'''
user = request.user
serializer = LogoutSerializer(data=request.data)
serializer.is_valid(raise_exception=True)
data = serializer.validated_data
if should_authenticate_session():
... | python | {
"resource": ""
} |
q228486 | get_object_or_404 | train | def get_object_or_404(queryset, *filter_args, **filter_kwargs):
"""
Same as Django's standard shortcut, but make sure to also raise 404
if the filter_kwargs don't match the required types.
This function was copied from rest_framework.generics because of issue #36.
"""
try:
return _get_o... | python | {
"resource": ""
} |
q228487 | profile | train | def profile(request):
'''
Get or set user profile.
'''
serializer_class = registration_settings.PROFILE_SERIALIZER_CLASS
if request.method in ['POST', 'PUT', 'PATCH']:
partial = request.method == 'PATCH'
serializer = serializer_class(
instance=request.user,
da... | python | {
"resource": ""
} |
q228488 | register | train | def register(request):
'''
Register new user.
'''
serializer_class = registration_settings.REGISTER_SERIALIZER_CLASS
serializer = serializer_class(data=request.data)
serializer.is_valid(raise_exception=True)
kwargs = {}
if registration_settings.REGISTER_VERIFICATION_ENABLED:
ve... | python | {
"resource": ""
} |
q228489 | verify_registration | train | def verify_registration(request):
"""
Verify registration via signature.
"""
user = process_verify_registration_data(request.data)
extra_data = None
if registration_settings.REGISTER_VERIFICATION_AUTO_LOGIN:
extra_data = perform_login(request, user)
return get_ok_response('User verif... | python | {
"resource": ""
} |
q228490 | get_requirements | train | def get_requirements(requirements_filepath):
'''
Return list of this package requirements via local filepath.
'''
requirements = []
with open(os.path.join(ROOT_DIR, requirements_filepath), 'rt') as f:
for line in f:
if line.startswith('#'):
continue
li... | python | {
"resource": ""
} |
q228491 | send_reset_password_link | train | def send_reset_password_link(request):
'''
Send email with reset password link.
'''
if not registration_settings.RESET_PASSWORD_VERIFICATION_ENABLED:
raise Http404()
serializer = SendResetPasswordLinkSerializer(data=request.data)
serializer.is_valid(raise_exception=True)
login = seri... | python | {
"resource": ""
} |
q228492 | register_email | train | def register_email(request):
'''
Register new email.
'''
user = request.user
serializer = RegisterEmailSerializer(data=request.data)
serializer.is_valid(raise_exception=True)
email = serializer.validated_data['email']
template_config = (
registration_settings.REGISTER_EMAIL_VE... | python | {
"resource": ""
} |
q228493 | _is_colorbar_heuristic | train | def _is_colorbar_heuristic(obj):
"""Find out if the object is in fact a color bar.
"""
# TODO come up with something more accurate here
# Might help:
# TODO Are the colorbars exactly the l.collections.PolyCollection's?
try:
aspect = float(obj.get_aspect())
except ValueError:
... | python | {
"resource": ""
} |
q228494 | _mpl_cmap2pgf_cmap | train | def _mpl_cmap2pgf_cmap(cmap, data):
"""Converts a color map as given in matplotlib to a color map as
represented in PGFPlots.
"""
if isinstance(cmap, mpl.colors.LinearSegmentedColormap):
return _handle_linear_segmented_color_map(cmap, data)
assert isinstance(
cmap, mpl.colors.Listed... | python | {
"resource": ""
} |
q228495 | _scale_to_int | train | def _scale_to_int(X, max_val=None):
"""
Scales the array X such that it contains only integers.
"""
if max_val is None:
X = X / _gcd_array(X)
else:
X = X / max(1 / max_val, _gcd_array(X))
return [int(entry) for entry in X] | python | {
"resource": ""
} |
q228496 | _gcd_array | train | def _gcd_array(X):
"""
Return the largest real value h such that all elements in x are integer
multiples of h.
"""
greatest_common_divisor = 0.0
for x in X:
greatest_common_divisor = _gcd(greatest_common_divisor, x)
return greatest_common_divisor | python | {
"resource": ""
} |
q228497 | new_filename | train | def new_filename(data, file_kind, ext):
"""Returns an available filename.
:param file_kind: Name under which numbering is recorded, such as 'img' or
'table'.
:type file_kind: str
:param ext: Filename extension.
:type ext: str
:returns: (filename, rel_filepath) where file... | python | {
"resource": ""
} |
q228498 | mpl_linestyle2pgfplots_linestyle | train | def mpl_linestyle2pgfplots_linestyle(line_style, line=None):
"""Translates a line style of matplotlib to the corresponding style
in PGFPlots.
"""
# linestyle is a string or dash tuple. Legal string values are
# solid|dashed|dashdot|dotted. The dash tuple is (offset, onoffseq) where onoffseq
# i... | python | {
"resource": ""
} |
q228499 | draw_quadmesh | train | def draw_quadmesh(data, obj):
"""Returns the PGFPlots code for an graphics environment holding a
rendering of the object.
"""
content = []
# Generate file name for current object
filename, rel_filepath = files.new_filename(data, "img", ".png")
# Get the dpi for rendering and store the o... | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.