muspan.query.query#

class query(domain, property, relation, comparison_value, bypass_checks=False)#

A helper class to standardise formatting of boolean queries - this does not return the result of the query, just stores the question.

A muspan query contains four key elements:

Parameters:
domainmuspan.domain

A muspan domain.

propertytuple or str

Tuple defining the object property to query against. Options include (‘label’, ‘label_name’), (‘object’, ‘type’), etc. If string, it will be expanded to (‘label’, property). See notes below for the full list of available options.

relationstr or function

An operation defining the type of comparison to perform. If a function, this should be a member of python’s standard operator library.

comparison_valuevarious

Value against which to test the object property.

bypass_checksbool, optional

If True, standard checks on whether this query can be interpreted are bypassed. May generate unexpected crashes if objects that can’t be interpreted as a query are passed in, but generates a substantial speed increase for large datasets when we’re confident the query is formatted correctly. Defaults to False.

Notes

Available options for the property argument of a query are:
  • ‘label_name’ - expanded to (‘label’,’label_name’)

  • (‘label’,’label_name’) - get object labels for the label ‘label_name’

  • (‘object’,’type’) - get the type of each object (‘point’,’line’, or ‘shape’)

  • (‘distance’, (‘centroid’, objects_1, objects_2)) - get the distance between the centroids of each objects_1 and the nearest object in objects_2 (these can be object IDs, or query-like)

  • (‘distance’, (‘boundary’, objects_1, objects_2)) - get the distance between the boundaries of each objects_1 and the nearest object in objects_2 (if an object is a point, the boundary is taken to be the coordinates of the point)

  • (‘collection’,) - get the collections associated with each object. Note the comma, which is required (no second argument is required here, but we need MuSpAn to recognise this as a tuple)

  • (‘contains’, (contained_objects, containing_objects)) - get a boolean (True or False) for each contained_object, which is true if it is inside an element of containing_objects.

__init__(domain, property, relation, comparison_value, bypass_checks=False)#

Methods