Models

class fluxEngine.Model(handle, modelData)

Runtime Model

This class wraps a runtime model that has been loaded into fluxEngine.

If the user destroys the library handle while this object still exists, this object will be marked as invalid and no more operations may be performed on this object.

The user must supply fluxEngine with the raw bytes of a serialized runtime model, as a bytes-like object.

If an error occurs an exception will be thrown.

While the raw C API supports reading a model directly by specifying a file name, the Python API doesn’t, as it is extremely convenient to read a file in Python directly, and the error reporting of that is more in line with the rest of Python.

The following example loads a model from hard disk:

with open('model.fluxmdl', 'rb') as f:
    model = fluxEngine.Model(handle, f.read())
# At this point model may be used
Parameters
  • handle (Handle) – The fluxEngine handle to load the model into. This is required as the loaded license determines which specific features within a model are allowed

  • modelData (bytes) – The raw binary data of the model

class GroupInfo(name, color)

Group information

This structure contains the information about a group that is stored within a given runtime model.

name

The name of the group

Type

str

color

The color of the group, encoded in the format 0xffRRGGBB. To obtain the red, green and blue values of the color one may use the helper methods that are part of this class.

Type

int

blueComponent()

Obtain the blue color value of the group’s color

This helper method returns the blue color value of the group’s color, in a range of 0 to 255.

greenComponent()

Obtain the green color value of the group’s color

This helper method returns the green color value of the group’s color, in a range of 0 to 255.

redComponent()

Obtain the red color value of the group’s color

This helper method returns the red color value of the group’s color, in a range of 0 to 255.

groupInfos()

Get the information about all groups in a model

Returns the information about all groups in a model as a list. The index of the list is also the group id (that may be returned by a classifier).

Each group consists of a name and a color, and they are returned in form of a Model.GroupInfo structure.

For example, the following code lists all groups and their colors in a given model:

for groupInfo in model.groupInfos():
    r = groupInfo.redComponent()
    g = groupInfo.greenComponent()
    b = groupInfo.blueComponent()
    print("Group with name {0} has color rgb({1}, {2}, {3})".format(groupInfo.name, r, g, b))