11import pytest
2- from pydp .distributions import (
3- LaplaceDistribution ,
4- GaussianDistribution ,
5- GeometricDistribution ,
6- )
2+ from pydp .distributions import LaplaceDistribution # type: ignore
3+ from pydp .distributions import GaussianDistribution # type: ignore
4+ from pydp .distributions import GeometricDistribution # type: ignore
75import pydp as dp
86import math
97from typing import List
@@ -24,7 +22,8 @@ def skew(samples: List[float], mu: float, sigma: float):
2422 Until then this should suffice. #FIXME: when possible we can fix this.
2523 """
2624 skew = list (
27- accumulate (samples , lambda lhs , rhs : lhs + (rhs - mu ) * (rhs - mu ) * (rhs - mu ))
25+ accumulate (samples , lambda lhs , rhs : lhs +
26+ (rhs - mu ) * (rhs - mu ) * (rhs - mu ))
2827 )[- 1 ]
2928 return skew / (len (samples ) * sigma * sigma * sigma )
3029
@@ -36,7 +35,8 @@ def kurtosis(samples: List[float], mu: float, var: float):
3635 Until then this should suffice. #FIXME: when possible we can fix this.
3736 """
3837 kurt = list (
39- accumulate (samples , lambda lhs , rhs : lhs + ((rhs - mu ) * (rhs - mu )) ** 2 )
38+ accumulate (samples , lambda lhs , rhs : lhs +
39+ ((rhs - mu ) * (rhs - mu )) ** 2 )
4040 )[- 1 ]
4141 n = len (samples )
4242 kurt = (n + 1 ) * kurt / (n * var * var )
@@ -48,7 +48,7 @@ def kurtosis(samples: List[float], mu: float, var: float):
4848# From what I understand @openmined/dp-research are going to look at validating correctness
4949# Until then we can use this to assert on floating point numbers.
5050# FIXME: When possible we should add 'correctness' tests.
51- expect_near = lambda expected , actual , tol : (
51+ def expect_near ( expected , actual , tol ): return (
5252 expected + tol >= actual and expected - tol <= actual
5353)
5454
@@ -62,7 +62,8 @@ def test_diversity_getter(self):
6262 def test_check_statistics_for_geo_unit_values (self ):
6363
6464 ld = LaplaceDistribution (epsilon = 1.0 , sensitivity = 1.0 )
65- samples = [ld .sample (scale = 1.0 ) for _ in range (k_num_geometric_samples )]
65+ samples = [ld .sample (scale = 1.0 )
66+ for _ in range (k_num_geometric_samples )]
6667 mean = dp .util .mean (samples )
6768 var = dp .util .variance (samples )
6869
0 commit comments