Constrains (Core)#

class QueryConstrain(count, shape, ranges)[source]#
Description
A QueryConstrain describes what kind of queries the given Queryable object accepts.
Queries can be constrained in 3 ways: count, shape, and value ranges.
Parameters:
  • count (int) – How many queries can be made

  • shape (Array Shape) – What shape the queries must have

  • ranges (Union of NDArrays) – A set of all permitted query values for discrete data sources OR of lower/upper bound per dimension for continuous data sources

Returns:

No return

Return type:

None

add_queries(queries) None[source]#
Description
Adds the list of queries to ranges and updates the query_count
Parameters:

shape – An iterable of queries

Returns:

No return

Return type:

None

all_queries() queries[source]#
Description
Returns all added queries.
Returns:

All added queries

Return type:

iterable of NDArray

constrains_met(queries) bool[source]#
Description
Checks whether the query matches the shape constrains of the Queryable object.
Parameters:

shape – An iterable of queries

Returns:

Confirmation or Rejection

Return type:

Boolean

last_queries() queries[source]#
Description
Returns the last added queries.
Returns:

Last added query

Return type:

NDArray

matches_shape(shape) bool[source]#
Description
Checks whether the query matches the shape constrains of the Queryable object.
Parameters:

shape – The shape of the query

Returns:

Confirmation or Rejection

Return type:

Boolean

queries_from_index(indexes) queries[source]#
Description
Returns the indexes-th added queries.
Parameters:

indexes (An iterable of int) – The indexes to look up

Returns:

The queries at the indexes

Return type:

iterable of NDArray

queries_from_norm_pos(self, norm_pos) queries[source]#
Description
Transforms the given normed query into the permitted value range given by its query constraints.
Example: Let ranges be [[[0,12], [0,12]] , [[2,14], [1,3]]] and norm_pos = [[1,0.5] , [0.25,0.5]]
Then this function returns the query [[0 + 1 * 12,0 + 0.5 * 12] , [2 + 0.25 * 12, 1 + 0.5 * 2]] = [[12, 6] , [5, 2]]
Parameters:

norm_pos – A query with values in range of [0,1]

Returns:

Return type:

NDArray

Raises:
  • LookupError – If the set of permitted query values is discrete and empty

  • RuntimeWarning – If infinite is a permitted value