from COIM.operator import *
import pandas as pd

df=pd.DataFrame({"a":[1,2,3], "b":[4,3,2]})
print(df)

CO=ConstrainOperator()
MS=ConstantSum(variables=["a", "b"], reference_variable="a", constant_sum=5, labels=["new"])
CO.add_rule(MS)

encoded=CO.encode_dataframe(df)
print(df)
print(encoded)

errors=pd.DataFrame([[0.0005]], columns=["new"])
print(errors)

decoded, decoded_errors=CO.decode_dataframe(encoded, errors)
print(encoded)
print(decoded)
print(errors)
print(decoded_errors)
