Skip to content

Commit

Permalink
pre-commit update
Browse files Browse the repository at this point in the history
  • Loading branch information
tdegeus committed Feb 23, 2023
1 parent 931414a commit 488c5e4
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 67 deletions.
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/psf/black
rev: 22.12.0
rev: 23.1.0
hooks:
- id: black
args: [--safe, --quiet, --line-length=100]
Expand All @@ -12,7 +12,7 @@ repos:
- id: check-yaml
- id: debug-statements
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
rev: v2.5.0
rev: v2.7.0
hooks:
- id: pretty-format-yaml
args: [--preserve-quotes, --autofix, --indent, '2']
Expand Down Expand Up @@ -40,7 +40,7 @@ repos:
hooks:
- id: setup-cfg-fmt
- repo: https://github.com/tdegeus/conda_envfile
rev: v0.4.1
rev: v0.4.2
hooks:
- id: conda_envfile_parse
files: environment.yaml
16 changes: 0 additions & 16 deletions enstat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,11 @@ class scalar:
"""

def __init__(self):

self.first = 0.0
self.second = 0.0
self.norm = 0.0

def __iter__(self):

yield "first", self.first
yield "second", self.second
yield "norm", self.norm
Expand All @@ -51,7 +49,6 @@ def restore(cls, first: float = 0, second: float = 0, norm: float = 0):
return ret

def __add__(self, datum: float):

self.add_sample(datum)
return self

Expand Down Expand Up @@ -143,7 +140,6 @@ def __init__(
shape: tuple[int] = None,
dtype: DTypeLike = np.float64,
):

self.compute_variance = compute_variance
self.norm = None
self.first = None
Expand All @@ -158,7 +154,6 @@ def __init__(
self.second = np.zeros(shape, dtype)

def __iter__(self):

yield "first", self.first
yield "second", self.second
yield "norm", self.norm
Expand All @@ -179,7 +174,6 @@ def restore(
"""

if norm is not None:

assert first is not None
assert first.shape == norm.shape

Expand All @@ -193,7 +187,6 @@ def restore(
return ret

def _allocate(self, shape, dtype):

self.norm = np.zeros(shape, np.int64)
self.first = np.zeros(shape, dtype)
if self.compute_variance:
Expand Down Expand Up @@ -234,7 +227,6 @@ def ravel(self) -> scalar:
)

def __add__(self, data: ArrayLike):

self.add_sample(data)
return self

Expand Down Expand Up @@ -340,7 +332,6 @@ def std(self, min_norm: int = 2) -> ArrayLike:


def _expand_array1d(data, size):

tmp = np.zeros((size), data.dtype)
tmp[: data.size] = data
return tmp
Expand Down Expand Up @@ -382,7 +373,6 @@ def __init__(
)

def _expand(self, size: int):

if size <= self.first.size:
return

Expand All @@ -393,12 +383,10 @@ def _expand(self, size: int):
self.second = _expand_array1d(self.second, size)

def __add__(self, data: ArrayLike):

self.add_sample(data)
return self

def add_sample(self, data: ArrayLike):

assert data.ndim == 1

if self.first is None:
Expand All @@ -413,7 +401,6 @@ def add_sample(self, data: ArrayLike):
self.second[: data.size] += data**2

def add_point(self, datum: float | int, index: int):

if self.first is None:
self._allocate(index + 1, type(datum))
else:
Expand Down Expand Up @@ -442,7 +429,6 @@ def __init__(
right: bool = False,
bound_error: str = "raise",
):

assert np.all(np.diff(bin_edges) > 0) or np.all(np.diff(bin_edges) < 0)

self.right = right
Expand All @@ -455,7 +441,6 @@ def __init__(
self.count = np.zeros((len(bin_edges) - 1), np.uint64)

def __iter__(self):

yield "bin_edges", self.bin_edges
yield "count", self.count
yield "count_left", self.count_left
Expand Down Expand Up @@ -709,7 +694,6 @@ def as_integer(self):
self.right = False

def __add__(self, data: ArrayLike):

self.add_sample(data)
return self

Expand Down
4 changes: 0 additions & 4 deletions enstat/detail.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ def histogram_bin_edges(data: ArrayLike, bins: int, mode: str, min_count: int =
return bin_edges

if mode == "uniform":

if min_count and bins is None:
if not isinstance(min_count, int):
raise OSError('"min_count" must be an integer number')
Expand All @@ -44,7 +43,6 @@ def histogram_bin_edges(data: ArrayLike, bins: int, mode: str, min_count: int =
return bin_edges

if mode == "voronoi":

mid_points = np.unique(data)
diff = np.diff(mid_points)
bin_edges = mid_points + np.hstack((0.5 * diff, 0.5 * diff[-1]))
Expand All @@ -63,7 +61,6 @@ def histogram_bin_edges_minwidth(bin_edges: ArrayLike, min_width: int) -> ArrayL
"""

while True:

idx = np.where(np.diff(bin_edges) < min_width)[0]

if len(idx) == 0:
Expand Down Expand Up @@ -94,7 +91,6 @@ def histogram_bin_edges_mincount(
assert isinstance(min_count, int)

while True:

count, _ = np.histogram(data, bins=bin_edges, density=False)

idx = np.where(count < min_count)[0]
Expand Down
6 changes: 0 additions & 6 deletions enstat/mean.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ class Scalar:
"""

def __init__(self, first=0, second=0, norm=0):

warnings.warn("Deprecated. Use: enstat.scalar.", DeprecationWarning)

self.m_first = first
Expand Down Expand Up @@ -136,7 +135,6 @@ def __init__(
second=None,
norm=None,
):

warnings.warn("Deprecated. Use: enstat.static.", DeprecationWarning)

self.m_compute_variance = compute_variance
Expand All @@ -147,7 +145,6 @@ def __init__(
self.m_dtype = dtype

def _allocate(self, data):

if self.m_first is not None:
assert data.shape == self.m_shape
return
Expand Down Expand Up @@ -267,7 +264,6 @@ def second(self):


def _expand_array1d(data, size):

tmp = np.zeros((size), data.dtype)
tmp[: data.size] = data
return tmp
Expand Down Expand Up @@ -308,7 +304,6 @@ def __init__(
second=None,
norm=None,
):

warnings.warn("Deprecated. Use: enstat.dynamic1d.", DeprecationWarning)

self.m_compute_variance = compute_variance
Expand Down Expand Up @@ -338,7 +333,6 @@ def _allocate(self, data):
self.m_second = np.zeros((self.m_size), self.m_dtype)

def _expand(self, data):

if data.size <= self.m_size:
return

Expand Down

0 comments on commit 488c5e4

Please sign in to comment.