lendres 0.1.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.
- lendres/__init__.py +7 -0
- lendres/algorithms/Search.py +118 -0
- lendres/algorithms/__init__.py +0 -0
- lendres/computervision/ImageDataHelper.py +713 -0
- lendres/computervision/ImageHelper.py +443 -0
- lendres/computervision/__init__.py +0 -0
- lendres/data/BivariateAnalysis.py +508 -0
- lendres/data/DataComparison.py +324 -0
- lendres/data/DataHelper.py +1125 -0
- lendres/data/DataHelperBase.py +298 -0
- lendres/data/UnivariateAnalysis.py +393 -0
- lendres/data/__init__.py +0 -0
- lendres/datatypes/ListTools.py +203 -0
- lendres/datatypes/__init__.py +0 -0
- lendres/demonstration/FunctionGenerator.py +213 -0
- lendres/demonstration/__init__.py +0 -0
- lendres/io/ConsoleHelper.py +528 -0
- lendres/io/IO.py +18 -0
- lendres/io/__init__.py +0 -0
- lendres/mathematics/Precision.py +57 -0
- lendres/mathematics/__init__.py +0 -0
- lendres/modeling/LanguageHelper.py +668 -0
- lendres/path/File.py +167 -0
- lendres/path/Path.py +127 -0
- lendres/path/__init__.py +0 -0
- lendres/plotting/AnnotationHelper.py +197 -0
- lendres/plotting/AxesHelper.py +450 -0
- lendres/plotting/DisplayColors.py +130 -0
- lendres/plotting/FormatSettings.py +153 -0
- lendres/plotting/LegendHelper.py +45 -0
- lendres/plotting/LegendOptions.py +56 -0
- lendres/plotting/PlotHelper.py +948 -0
- lendres/plotting/PlotMaker.py +474 -0
- lendres/plotting/__init__.py +4 -0
- lendres/plotting/artistic.mplstyle +28 -0
- lendres/plotting/default.mplstyle +27 -0
- lendres/plotting/gridless.mplstyle +28 -0
- lendres/plotting/imagedefault.mplstyle +38 -0
- lendres/plotting/lightweightlines.mplstyle +27 -0
- lendres/plotting/manim.mplstyle +39 -0
- lendres/plotting/mediumsizefont.mplstyle +27 -0
- lendres/plotting/seaborn.mplstyle +52 -0
- lendres/plotting/transparentlegend.mplstyle +27 -0
- lendres/signalprocessing/SignalProcessing.py +70 -0
- lendres/utilities/PrintExecutable.py +7 -0
- lendres/utilities/__init__.py +0 -0
- lendres-0.1.1.dist-info/License.txt +20 -0
- lendres-0.1.1.dist-info/METADATA +46 -0
- lendres-0.1.1.dist-info/RECORD +51 -0
- lendres-0.1.1.dist-info/WHEEL +5 -0
- lendres-0.1.1.dist-info/top_level.txt +1 -0
lendres/__init__.py
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Created on February 16, 2022
|
|
3
|
+
@author: Lance A. Endres
|
|
4
|
+
"""
|
|
5
|
+
import numpy as np
|
|
6
|
+
|
|
7
|
+
class Search():
|
|
8
|
+
"""
|
|
9
|
+
Searching algorithms.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@classmethod
|
|
14
|
+
def BoundingBinarySearch(cls, item, points, returnedUnits="indices"):
|
|
15
|
+
"""
|
|
16
|
+
Finds the bounding values for item in a list of points.
|
|
17
|
+
|
|
18
|
+
The search algorithm is a binary search.
|
|
19
|
+
|
|
20
|
+
Parameters
|
|
21
|
+
----------
|
|
22
|
+
item : int or float
|
|
23
|
+
Item to bound.
|
|
24
|
+
points : int or float
|
|
25
|
+
A list of points to search through.
|
|
26
|
+
returnedUnits : string, optional
|
|
27
|
+
Specifies the context of the returned values. The default is "indices".
|
|
28
|
+
indices : Returns the indices of the "points" list.
|
|
29
|
+
values : Returns the bounding values, that is values = points[indices].
|
|
30
|
+
|
|
31
|
+
Returns
|
|
32
|
+
-------
|
|
33
|
+
list : int or float
|
|
34
|
+
A list of length two that has either the indices or the values that bound the
|
|
35
|
+
input "item." If "item" is in "points," the list will contain two entries that
|
|
36
|
+
are the same (the index/value).
|
|
37
|
+
|
|
38
|
+
If "item" is not in the list, [np.NaN, np.NaN] is returned.
|
|
39
|
+
"""
|
|
40
|
+
first = 0
|
|
41
|
+
last = len(points)-1
|
|
42
|
+
|
|
43
|
+
# Check for out of range.
|
|
44
|
+
if item < points[first] or item > points[last]:
|
|
45
|
+
return [np.nan, np.nan]
|
|
46
|
+
|
|
47
|
+
continueSearch = True
|
|
48
|
+
|
|
49
|
+
while (continueSearch):
|
|
50
|
+
|
|
51
|
+
# Find the midpoint index.
|
|
52
|
+
midpoint = (first + last) // 2
|
|
53
|
+
|
|
54
|
+
# Check to see if the value we are trying to bound is in the list.
|
|
55
|
+
if points[midpoint] == item:
|
|
56
|
+
first = midpoint
|
|
57
|
+
last = midpoint
|
|
58
|
+
continueSearch = False
|
|
59
|
+
|
|
60
|
+
# This catches when the point is bounded.
|
|
61
|
+
elif item > points[midpoint-1] and item < points[midpoint]:
|
|
62
|
+
first = midpoint-1
|
|
63
|
+
last = midpoint
|
|
64
|
+
continueSearch = False
|
|
65
|
+
|
|
66
|
+
else:
|
|
67
|
+
if item < points[midpoint]:
|
|
68
|
+
last = midpoint - 1
|
|
69
|
+
else:
|
|
70
|
+
first = midpoint + 1
|
|
71
|
+
|
|
72
|
+
# Return either the indices (position) of the array the bounded values are located at
|
|
73
|
+
# or return the values that bound the input item.
|
|
74
|
+
if returnedUnits == "indices":
|
|
75
|
+
return [first, last]
|
|
76
|
+
else:
|
|
77
|
+
return [points[first], points[last]]
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
@classmethod
|
|
81
|
+
def FindIndicesByValues(cls, data, searchValue, maxCount=None):
|
|
82
|
+
"""
|
|
83
|
+
Searches an array like object to find the indices of entries that match a specified value.
|
|
84
|
+
|
|
85
|
+
Parameters
|
|
86
|
+
----------
|
|
87
|
+
data : array like
|
|
88
|
+
Data to search through.
|
|
89
|
+
searchValue : string, numeric
|
|
90
|
+
Value to match in the data. Indices of entries that match this value are returned.
|
|
91
|
+
maxCount : integer
|
|
92
|
+
The maximum number of entries to returned. If maxCount is reached before the end of the data,
|
|
93
|
+
the function exits and returns the found values. This allows returning 10 items even though 100
|
|
94
|
+
are in the data, for example.
|
|
95
|
+
Returns
|
|
96
|
+
-------
|
|
97
|
+
indices : list of integers
|
|
98
|
+
The indices of all matched values.
|
|
99
|
+
"""
|
|
100
|
+
# If no maximum was provided, we can return up to the total number. We do it this way so we do not
|
|
101
|
+
# have to check every time in the loop if maxCount is none and then check the value of maxCount if
|
|
102
|
+
# it is not none.
|
|
103
|
+
if maxCount == None:
|
|
104
|
+
maxCount = len(data)
|
|
105
|
+
|
|
106
|
+
foundCount = 0
|
|
107
|
+
indices = []
|
|
108
|
+
|
|
109
|
+
for i, value in enumerate(data):
|
|
110
|
+
if value == searchValue:
|
|
111
|
+
indices.append(i)
|
|
112
|
+
foundCount += 1
|
|
113
|
+
|
|
114
|
+
# If we reach the maximum number of entries, exit loop and return.
|
|
115
|
+
if foundCount == maxCount:
|
|
116
|
+
break
|
|
117
|
+
|
|
118
|
+
return indices
|
|
File without changes
|