scruby 0.13.1__py3-none-any.whl → 0.14.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of scruby might be problematic. Click here for more details.

scruby/aggregation.py CHANGED
@@ -20,15 +20,47 @@ class Average:
20
20
  self.counter = 0.0
21
21
 
22
22
  def set(self, number: int | float) -> None:
23
- """Add value."""
23
+ """Add value.
24
+
25
+ Args:
26
+ number: Current value.
27
+ """
24
28
  self.value += float(number)
25
29
  self.counter += 1.0
26
30
 
27
31
  def get(self) -> float:
28
- """Get arithmetic average value."""
32
+ """Get arithmetic average value.
33
+
34
+ Returns:
35
+ Number (int|float) - Average value.
36
+ """
29
37
  return self.value / self.counter
30
38
 
31
39
 
40
+ class Counter:
41
+ """Aggregation class for calculating the number of documents.
42
+
43
+ Args:
44
+ max: The maximum counter value.
45
+ """
46
+
47
+ def __init__(self, max: int = 1000) -> None:
48
+ self.max = max
49
+ self.counter = 0
50
+
51
+ def check(self) -> bool:
52
+ """Check the condition of the counter.
53
+
54
+ Returns:
55
+ Boolean value. If `True`, the maximum value is achieved.
56
+ """
57
+ return self.counter >= self.max
58
+
59
+ def next(self) -> None:
60
+ """Increment the counter on one."""
61
+ self.counter += 1
62
+
63
+
32
64
  class Max:
33
65
  """Aggregation class for calculating the maximum value."""
34
66
 
@@ -36,12 +68,20 @@ class Max:
36
68
  self.value: Any = 0
37
69
 
38
70
  def set(self, number: int | float) -> None:
39
- """Add value."""
71
+ """Add value.
72
+
73
+ Args:
74
+ number: Current value.
75
+ """
40
76
  if number > self.value:
41
77
  self.value = number
42
78
 
43
79
  def get(self) -> Any:
44
- """Get maximum value."""
80
+ """Get maximum value.
81
+
82
+ Returns:
83
+ Number (int|float) - Maximum value.
84
+ """
45
85
  return self.value
46
86
 
47
87
 
@@ -52,12 +92,20 @@ class Min:
52
92
  self.value: Any = 0
53
93
 
54
94
  def set(self, number: int | float) -> None:
55
- """Add value."""
95
+ """Add value.
96
+
97
+ Args:
98
+ number: Current value.
99
+ """
56
100
  if self.value == 0 or number < self.value:
57
101
  self.value = number
58
102
 
59
103
  def get(self) -> Any:
60
- """Get minimum value."""
104
+ """Get minimum value.
105
+
106
+ Returns:
107
+ Number (int|float) - Minimum value.
108
+ """
61
109
  return self.value
62
110
 
63
111
 
@@ -68,9 +116,17 @@ class Sum:
68
116
  self.value: Any = 0
69
117
 
70
118
  def set(self, number: int | float) -> None:
71
- """Add value."""
119
+ """Add value.
120
+
121
+ Args:
122
+ number: Current value.
123
+ """
72
124
  self.value += number
73
125
 
74
126
  def get(self) -> Any:
75
- """Get sum of values."""
127
+ """Get sum of values.
128
+
129
+ Returns:
130
+ Number (int|float) - Sum of values.
131
+ """
76
132
  return self.value
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: scruby
3
- Version: 0.13.1
3
+ Version: 0.14.1
4
4
  Summary: A fast key-value storage library.
5
5
  Project-URL: Homepage, https://github.com/kebasyaty/scruby
6
6
  Project-URL: Repository, https://github.com/kebasyaty/scruby
@@ -1,10 +1,10 @@
1
1
  scruby/__init__.py,sha256=GOVcjXmcOEDBbJQJDJlQq-x3M-VGJaMSN278EXsl2po,884
2
- scruby/aggregation.py,sha256=AdVZNl9fV59pWMBQez5upQEuodAg3HIw0ixOnM8FrKg,1762
2
+ scruby/aggregation.py,sha256=fOsfMyCm28frKOFHmWzuGU81QPeJTJfs4EVIIroxOcQ,2909
3
3
  scruby/constants.py,sha256=3LZfcxcuRqwzoB0-iogLMjKBZRdxfWJmTbyPwVRhQgY,1007
4
4
  scruby/db.py,sha256=OXtMqq9y6RQkHHWOgFVXqI96v7g58SIoLUq-h09WxjI,20899
5
5
  scruby/errors.py,sha256=aHQri4LNcFVQrSHwjyzb1fL8O49SwjYEU4QgMOo4uyA,622
6
6
  scruby/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
- scruby-0.13.1.dist-info/METADATA,sha256=LlJPM_ZrH1yhQA7Yk0owqfigwt72Z2gRIVlDFdJ1cL4,10925
8
- scruby-0.13.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
9
- scruby-0.13.1.dist-info/licenses/LICENSE,sha256=2zZINd6m_jNYlowdQImlEizyhSui5cBAJZRhWQURcEc,1095
10
- scruby-0.13.1.dist-info/RECORD,,
7
+ scruby-0.14.1.dist-info/METADATA,sha256=cnKZxapHkg2CRAFX_M1AgMiZ5oDNvW0nSjaTnlnryLw,10925
8
+ scruby-0.14.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
9
+ scruby-0.14.1.dist-info/licenses/LICENSE,sha256=2zZINd6m_jNYlowdQImlEizyhSui5cBAJZRhWQURcEc,1095
10
+ scruby-0.14.1.dist-info/RECORD,,