Skip to content

Commit 0237b5e

Browse files
authored
Removing unused code (OpenMined#400)
* clean-ups * tiny fix * format * format c++
1 parent 8d349c1 commit 0237b5e

File tree

11 files changed

+6
-106
lines changed

11 files changed

+6
-106
lines changed

src/bindings/PyDP/algorithms/bounded_functions.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#include "algorithms/bounded-variance.h"
1313

1414
#include "../pydp_lib/algorithm_builder.hpp"
15-
#include "../pydp_lib/casting.hpp" // our caster helper library
1615

1716
using namespace std;
1817

src/bindings/PyDP/algorithms/rand.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// Provides bindings for rand
22
#include "algorithms/rand.h"
3-
#include "../pydp_lib/casting.hpp"
43
#include "pybind11/pybind11.h"
54

65
namespace py = pybind11;

src/bindings/PyDP/base/logging.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55

66
#include "pybind11/pybind11.h"
77

8-
#include "../pydp_lib/casting.hpp" // our caster helper library
9-
#include "base/logging.h" // the header file associated with logging.cc
8+
#include "base/logging.h" // the header file associated with logging.cc
109

1110
namespace py = pybind11;
1211
namespace dpb = differential_privacy::base;

src/bindings/PyDP/base/status.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,12 @@
22

33
#include <string>
44

5-
#include "../pydp_lib/casting.hpp" // our caster helper library
6-
#include "pybind11/operators.h" // for overloading the operators
5+
#include "pybind11/operators.h" // for overloading the operators
76
#include "pybind11/pybind11.h"
87
#include "pybind11/stl.h"
98

109
#include "base/status.h" // the header file associated with status.cc
1110
#include "base/statusor.h" //header file associated with statusor.cc
12-
// #include "differential_privacy/proto/data.pb.h" // for Output type
1311

1412
using namespace std;
1513

src/bindings/PyDP/mechanisms/mechanism.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@
33
#include "pybind11/functional.h"
44
#include "pybind11/stl.h"
55

6-
#include "algorithms/distributions.h"
76
#include "algorithms/numerical-mechanisms.h"
87

98
#include "../pydp_lib/algorithm_builder.hpp"
10-
#include "../pydp_lib/casting.hpp"
119

1210
using namespace std;
1311

@@ -107,11 +105,6 @@ class LaplaceMechanismBinder {
107105
builder.Build().value());
108106
}
109107

110-
static std::unique_ptr<dp::NumericalMechanismBuilder> clone() {
111-
dp::LaplaceMechanism::Builder cloner;
112-
return std::move(cloner.Clone());
113-
}
114-
115108
static void DeclareIn(py::module& m) {
116109
py::class_<dp::LaplaceMechanism, dp::NumericalMechanism> lap_mech(
117110
m, "LaplaceMechanism");
@@ -140,11 +133,6 @@ class GaussianMechanismBinder {
140133
builder.Build().value());
141134
};
142135

143-
static std::unique_ptr<dp::NumericalMechanismBuilder> clone() {
144-
dp::GaussianMechanism::Builder cloner;
145-
return std::move(cloner.Clone());
146-
};
147-
148136
static void DeclareIn(py::module& m) {
149137
py::class_<dp::GaussianMechanism, dp::NumericalMechanism> gaus_mech(
150138
m, "GaussianMechanism");

src/bindings/PyDP/proto/proto.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
#include <fstream>
22
#include <string>
33

4-
#include "../pydp_lib/casting.hpp" // our caster helper library
54
#include "pybind11/pybind11.h"
65

76
#include "proto/summary.pb.h"
8-
#include "proto/util.h" // the header file associated with status.cc
97

108
using namespace std;
119

src/bindings/PyDP/pydp_lib/casting.hpp

Lines changed: 0 additions & 13 deletions
This file was deleted.

tests/algorithms/conftest.py

Lines changed: 0 additions & 60 deletions
This file was deleted.

tests/algorithms/test_bounded_mean/test_bounded_mean_int64_data.bin

Lines changed: 0 additions & 2 deletions
This file was deleted.

tests/algorithms/test_order_statistics.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
1-
# stdlib
2-
import math
3-
41
# verify with actual value
52
import statistics
63

74
# third party
8-
from conftest import expect_near
9-
from conftest import percentile
105
import pytest
116

127
# pydp absolute
@@ -32,8 +27,8 @@ def test_min(data, dtype):
3227
minn = dp.algorithms.laplacian.Min(
3328
dtype=dtype, epsilon=1.0, lower_bound=0, upper_bound=200
3429
)
35-
assert expect_near(min(data), minn.quick_result(data), 10)
36-
assert expect_near(0, minn.quick_result(data), 10)
30+
assert minn.quick_result(data) == pytest.approx(min(data), abs=10)
31+
assert minn.quick_result(data) == pytest.approx(0, abs=10)
3732

3833

3934
@pytest.mark.parametrize("dtype, data", [("int", data_ints), ("float", data_floats)])
@@ -43,7 +38,7 @@ def test_max(data, dtype):
4338
)
4439
assert 190 < maxx.quick_result(data) < 210
4540

46-
assert expect_near(max(data), maxx.quick_result(data), 10)
41+
assert maxx.quick_result(data) == pytest.approx(max(data), abs=10)
4742

4843

4944
@pytest.mark.parametrize("dtype, data", [("int", data_ints), ("float", data_floats)])
@@ -53,7 +48,7 @@ def test_median(data, dtype):
5348
dtype=dtype, epsilon=1.0, lower_bound=0, upper_bound=200
5449
)
5550

56-
assert expect_near(statistics.median(data), median.quick_result(data), 20)
51+
assert median.quick_result(data) == pytest.approx(statistics.median(data), abs=20)
5752

5853

5954
@pytest.mark.parametrize("dtype", ["int", "float"])

0 commit comments

Comments
 (0)