Variables

pycertifspec.ArrayVar #

[view_source]

ArrayVar Objects #

class ArrayVar(Var,  collections.MutableSequence)

[view_source]

Represents a SPEC array and behaves like a regular python list. Values assigned to array indices will be pushed to SPEC.

The connection to SPEC decreases performance since the array gets fetched every time it is accessed. Therefore, for expensive computations, store the .value to a different variable and use that.

You usually don’t need to instantiate this class since it is easier to just use client.var(...) which will automatically detect the variable type and return a Var or ArrayVar accordingly.

shape #

 | @property
 | shape() -> Tuple[int]

[view_source]

Shape of the array like in numpy

is_2d #

 | @property
 | is_2d() -> bool

[view_source]

True if 2D array

pycertifspec.Var #

[view_source]

Var Objects #

class Var()

[view_source]

Represents a var/property.

You usually don’t need to instantiate this class since it is easier to just use client.var(...) which will automatically detect the variable type and return a Var or ArrayVar accordingly.

__init__ #

 | __init__(name: str, conn: Client, dtype: Type = str)

[view_source]

Create a variable object.

Arguments:

  • name str - The name of the variable
  • conn Client - An instance of Client connected to SPEC
  • dtype Type - The datatype of the variable (Only if not array)

value #

 | @property
 | value() -> Union[str, Exception, dict, np.ndarray]

[view_source]

The value of the variable

subscribe #

 | subscribe(callback: Callable, nowait: bool = False, timeout: float = 1.0) -> bool

[view_source]

Subscribe to changes in the value.

Arguments:

  • callback function - The function to be called when the event is received
  • nowait boolean - By default the function waits for the first event after registering to see if an error occurred. To skip that set True
  • timeout float - The timeout to wait for a response after subscribing. Function returns False when it runs out

Returns:

True if successful, False when an error occurred or timeout reached

unsubscribe #

 | unsubscribe(callback: Callable) -> bool

[view_source]

Unsubscribe from changes.

Arguments:

  • callback function - The callback function

Returns:

  • (boolean) - True if the callback was removed, False if it didn’t exist anyways