Relations Module

Copyright 2025 John Morris

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

File: relations.py
Author: John Morris
Purpose: A list of basic relations employable with edges in the
hypergraph.

Notes:

  • Generally imported as import relations as R

  • All relationship functions begin with a capital R, so that they are normally called as R.Rfunction

  • Each relationship should have *args, and **kwargs as its arguments and only arguments. Specific keywords referenced in kwargs should be s1, s2, … only.

constrainthg.relations.Rall(*args, **kwargs)

Returns true if all arguments are true.

constrainthg.relations.Rany(*args, **kwargs)

Returns true if any of the arguments are true.

constrainthg.relations.Rceiling(*args, **kwargs)

Returns the ceiling of the first argument

constrainthg.relations.Rcos(*args, **kwargs)

Returns the cosine of the mean of all arguments.

constrainthg.relations.Rdict(*args, **kwargs)

Returns a dictionary with either the keyed argument key or the first argument as the dict key.

constrainthg.relations.Rdivide(*args, **kwargs)

Divides s1 by all other arguments.

constrainthg.relations.Rfirst(*args, **kwargs)

Returns the first argument.

constrainthg.relations.Rfloor(*args, **kwargs)

Returns the floor of the first argument

constrainthg.relations.Rfloor_divide(*args, **kwargs)

Returns the largest integer smaller or equal to the division of s1 and s2.

constrainthg.relations.Rincrement(*args, **kwargs)

Increments the maximum source by 1.

constrainthg.relations.Rinvert(*args, **kwargs)

Inverts the first argument.

constrainthg.relations.Rmax(*args, **kwargs)

Returns the maximum of all arguments.

constrainthg.relations.Rmean(*args, **kwargs)

Returns the mean of all arguments.

constrainthg.relations.Rmin(*args, **kwargs)

Returns the minimum of all arguments.

constrainthg.relations.Rmultiply(*args, **kwargs)

Multiplies all arguments together.

constrainthg.relations.Rnegate(*args, **kwargs)

Returns the negative of the first argument.

constrainthg.relations.Rnot(*args, **kwargs)

Returns the logical negation of the first boolean argument.

constrainthg.relations.Rnot_any(*args, **kwargs)

Returns true if none of the arguments are true.

constrainthg.relations.Rnull(*args, **kwargs)

Returns zero.

constrainthg.relations.Rsame(*args, **kwargs)

Returns true if all arguments are equivalent.

constrainthg.relations.Rsin(*args, **kwargs)

Returns the sine of the mean of all arguments.

constrainthg.relations.Rsubtract(*args, **kwargs)

Subtracts from s1 all other arguments.

constrainthg.relations.Rsum(*args, **kwargs)

Sums all arguments.

constrainthg.relations.Rtan(*args, **kwargs)

Returns the tangent of the mean of all arguments.

constrainthg.relations.Rxor(*args, **kwargs)

Returns true if only one of the arguments is true.

constrainthg.relations.equal(identifier: str)

Returns a method that returns the argument with the same keyword as identifier.

constrainthg.relations.extend(args: list, kwargs: dict) list

Combines all arguments into a single list, with args leading.

constrainthg.relations.geq(identifier: str, val: int)

Returns a method that returns True if the identifier is greater than or equal to val.

constrainthg.relations.get_keyword_arguments(args: list, kwargs: dict, excluded_keys: list)

Combines all arguments except those with a given key. Returns the arguments or the given keys as a dictionary and the remaining arguments as a list.

Note that keys not found in kwargs are taken from args in the order of the excluded_keys list.

constrainthg.relations.mult_and_sum(mult_identifiers: list, sum_identifiers: list)

Convenient shorthand for multiplying the values identified in mult_identifiers and adding them to the values identified in sum_identifiers.

constrainthg.relations.to_list(order: list, *args, **kwargs)

Returns a list of all node values given in order.

constrainthg.relations.to_tuple(order: list, *args, **kwargs)

Returns a tuple of the node values given in order.

Home | Index | Search