pybmix.utils package¶
Submodules¶
pybmix.utils.combinatorials module¶
- class pybmix.utils.combinatorials.TriangularMemoizer(first_term_multiplier, second_term_multiplier)[source]¶
Bases:
objectSpecific class for triangular recurrence sequences of the kind s(0, 0) = s(1, 1) = 0, s(a, 0) = 0 for a > 0, s(a, b) = 0 for b > a, s(a, b) = f(a, b) * s(a - 1, b) + g(a, b) s(a - 1, b - 1).
For instance, Stirling numbers of the first kind are recovered setting f(a, b) = (a - 1) and g(a, b) = 1
- class pybmix.utils.combinatorials.generalized_factorial_memoizer(sigma)[source]¶
Bases:
pybmix.utils.combinatorials.TriangularMemoizerComputes the Generalized Factorial numbers and stores the results in a memoizer. The generalized factorial with parameter sigma in [0, 1) satisfy the triangular recurrence relation s(n, k) = (n - 1 - sigma * k) s(n - 1, k) + sigma * s(n - 1, k-1)
pybmix.utils.proto_utils module¶
- pybmix.utils.proto_utils.get_field(msg, field: str)[source]¶
Gets the field of an object, even if it is in a submessage
- Parameters
msg (google.protobuf.message) – a protobuf (object)
field (str) – a field of this proto. If it is a nested field, then we adopt the syntax a joining the subfields separated by ‘.’
- pybmix.utils.proto_utils.set_oneof_field(fieldname, msg, val)[source]¶
Sets a ‘oneof’ field inside of ‘msg’ :param fieldname: the oneof name of the field :type fieldname: str :param msg: the protobuf to modify :type msg: google.protobuf.Message :param val: the value to set :type val: google.protobuf.Message, numeric, string
Example
>>> protomsg = pybmix.proto.hierarchy_prior_pb2.NNIGPrior() >>> prior = pybmix.proto.hierarchy_prior_pb2.NNIGPrior.FixedValues(mean=1) >>> set_oneof_field("prior", protomsg, prior)