-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add DC verifier python bindings and basic example
- Loading branch information
Showing
8 changed files
with
55 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import desbordante as db | ||
|
||
# # Given denial constraint tells us that if two persons | ||
# live in the same state, the one earning a lower | ||
# salary has a lower tax rate | ||
DC = "!(s.State == t.State and s.Salary < t.Salary and s.FedTaxRate > t.FedTaxRate)" | ||
|
||
TABLE = "test_input_data/TestDC1.csv" | ||
|
||
# Creating a verificator and loading data in algortihm | ||
verificator = db.dc_verification.algorithms.Default() | ||
verificator.load_data(table=(TABLE, ',', True)) | ||
|
||
# Algorithm execution | ||
verificator.execute(denial_constraint=DC) | ||
|
||
# Obtaining the result | ||
result: bool = verificator.dc_holds() | ||
|
||
print("DC " + DC + " holds: " + str(result)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#include "bind_dc_verification.h" | ||
|
||
#include "algorithms/dc/verifier/dc_verifier.h" | ||
#include "py_util/bind_primitive.h" | ||
|
||
namespace python_bindings { | ||
|
||
namespace py = pybind11; | ||
|
||
void BindDCVerification(py::module_& main_module) { | ||
auto dc_verification_module = main_module.def_submodule("dc_verification"); | ||
|
||
BindPrimitiveNoBase<algos::DCVerifier>(dc_verification_module, "DCVerification") | ||
.def("dc_holds", &algos::DCVerifier::DCHolds); | ||
} | ||
|
||
} // namespace python_bindings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#pragma once | ||
|
||
#include <pybind11/pybind11.h> | ||
|
||
namespace python_bindings { | ||
void BindDCVerification(pybind11::module_& main_module); | ||
} // namespace python_bindings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters