half-sample 0.1.20__tar.gz → 0.1.23__tar.gz
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.
- {half_sample-0.1.20 → half_sample-0.1.23}/PKG-INFO +1 -1
- half_sample-0.1.23/cpp_build/sample.exe +0 -0
- {half_sample-0.1.20 → half_sample-0.1.23}/half_sample.egg-info/PKG-INFO +1 -1
- {half_sample-0.1.20 → half_sample-0.1.23}/sample/sample.py +82 -21
- {half_sample-0.1.20 → half_sample-0.1.23}/setup.py +1 -1
- half_sample-0.1.20/cpp_build/sample.exe +0 -0
- {half_sample-0.1.20 → half_sample-0.1.23}/README.md +0 -0
- {half_sample-0.1.20 → half_sample-0.1.23}/half_sample.egg-info/SOURCES.txt +0 -0
- {half_sample-0.1.20 → half_sample-0.1.23}/half_sample.egg-info/dependency_links.txt +0 -0
- {half_sample-0.1.20 → half_sample-0.1.23}/half_sample.egg-info/top_level.txt +0 -0
- {half_sample-0.1.20 → half_sample-0.1.23}/sample/__init__.py +0 -0
- {half_sample-0.1.20 → half_sample-0.1.23}/sample/process.py +0 -0
- {half_sample-0.1.20 → half_sample-0.1.23}/sample/result.py +0 -0
- {half_sample-0.1.20 → half_sample-0.1.23}/setup.cfg +0 -0
|
Binary file
|
|
@@ -1,30 +1,82 @@
|
|
|
1
1
|
import os
|
|
2
2
|
import shutil
|
|
3
|
+
import sys
|
|
4
|
+
import threading
|
|
5
|
+
from pathlib import Path
|
|
3
6
|
|
|
4
7
|
from . import Process
|
|
5
8
|
from . import Result
|
|
6
9
|
|
|
7
10
|
|
|
11
|
+
_SOURCE_ROOT = Path(os.path.realpath(os.path.abspath(__file__))).parent.parent
|
|
12
|
+
_SOURCE_BUILD_LOCK = threading.Lock()
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def _existing_file(*parts):
|
|
16
|
+
try:
|
|
17
|
+
candidate = Path(parts[0]).joinpath(*parts[1:])
|
|
18
|
+
except (TypeError, ValueError):
|
|
19
|
+
return None
|
|
20
|
+
try:
|
|
21
|
+
if candidate.is_file():
|
|
22
|
+
return str(candidate.resolve())
|
|
23
|
+
except OSError:
|
|
24
|
+
return None
|
|
25
|
+
return None
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def _is_source_checkout():
|
|
29
|
+
return all((
|
|
30
|
+
_existing_file(_SOURCE_ROOT, 'SConstruct'),
|
|
31
|
+
_existing_file(_SOURCE_ROOT, 'setup.py'),
|
|
32
|
+
_existing_file(_SOURCE_ROOT, 'sample', 'sample.py'),
|
|
33
|
+
))
|
|
34
|
+
|
|
35
|
+
|
|
8
36
|
class Sampler:
|
|
9
37
|
@property
|
|
10
38
|
def execution_path(self) -> str:
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
39
|
+
# keep the historical current-working-directory override first
|
|
40
|
+
execution_path = _existing_file('sample.exe')
|
|
41
|
+
if execution_path:
|
|
42
|
+
return execution_path
|
|
43
|
+
|
|
44
|
+
# try to use (or build) cpp_build/sample.exe in a source checkout
|
|
45
|
+
if _is_source_checkout():
|
|
46
|
+
execution_path = _existing_file(_SOURCE_ROOT, 'cpp_build', 'sample.exe')
|
|
47
|
+
if execution_path:
|
|
48
|
+
return execution_path
|
|
49
|
+
with _SOURCE_BUILD_LOCK:
|
|
50
|
+
execution_path = _existing_file(_SOURCE_ROOT, 'cpp_build', 'sample.exe')
|
|
51
|
+
if not execution_path:
|
|
52
|
+
if os.system('cd {} && scons'.format(_SOURCE_ROOT)) != 0:
|
|
53
|
+
raise self.Error("Compile C++ Driver Error")
|
|
54
|
+
execution_path = _existing_file(_SOURCE_ROOT, 'cpp_build', 'sample.exe')
|
|
55
|
+
if execution_path:
|
|
56
|
+
return execution_path
|
|
57
|
+
|
|
58
|
+
# try the Python/frozen executable directory
|
|
59
|
+
try:
|
|
60
|
+
executable_directory = Path(sys.executable).parent
|
|
61
|
+
except (TypeError, ValueError):
|
|
62
|
+
executable_directory = None
|
|
63
|
+
execution_path = _existing_file(executable_directory, 'sample.exe')
|
|
64
|
+
if execution_path:
|
|
65
|
+
return execution_path
|
|
66
|
+
|
|
67
|
+
# try the environment root used by venv/uv data-file installs
|
|
68
|
+
execution_path = _existing_file(sys.prefix, 'sample.exe')
|
|
69
|
+
if execution_path:
|
|
70
|
+
return execution_path
|
|
24
71
|
|
|
25
72
|
# try to find sample.exe in system path when release
|
|
26
|
-
|
|
27
|
-
|
|
73
|
+
try:
|
|
74
|
+
path_driver = shutil.which("sample.exe")
|
|
75
|
+
except (OSError, ValueError):
|
|
76
|
+
path_driver = None
|
|
77
|
+
execution_path = _existing_file(path_driver)
|
|
78
|
+
if execution_path:
|
|
79
|
+
return execution_path
|
|
28
80
|
|
|
29
81
|
raise self.Error('Sample Driver Not Found')
|
|
30
82
|
|
|
@@ -63,29 +115,38 @@ class Sampler:
|
|
|
63
115
|
def measure(self, number_of_waveforms: int, emitting_frequency: float, auto_mode: bool = False,
|
|
64
116
|
instant_ai_frequency_threshold: float = 0.0,
|
|
65
117
|
instant_ai_target_points_per_waveform: int = 100,
|
|
66
|
-
instant_ai_max_reliable_polling_hz: float = 10.0
|
|
118
|
+
instant_ai_max_reliable_polling_hz: float = 10.0,
|
|
119
|
+
waveform_processing_mode: str = "threshold_accumulation") -> Result:
|
|
67
120
|
command = "to_measure {} {:.12g} {}".format(number_of_waveforms, emitting_frequency, auto_mode)
|
|
68
121
|
if (instant_ai_frequency_threshold != 0.0 or instant_ai_target_points_per_waveform != 100 or
|
|
69
|
-
instant_ai_max_reliable_polling_hz != 10.0):
|
|
122
|
+
instant_ai_max_reliable_polling_hz != 10.0 or waveform_processing_mode != "threshold_accumulation"):
|
|
70
123
|
command += " {:.12g} {} {:.12g}".format(
|
|
71
124
|
instant_ai_frequency_threshold, instant_ai_target_points_per_waveform,
|
|
72
125
|
instant_ai_max_reliable_polling_hz)
|
|
126
|
+
if waveform_processing_mode != "threshold_accumulation":
|
|
127
|
+
command += " {}".format(waveform_processing_mode)
|
|
73
128
|
return self.communicate(command)
|
|
74
129
|
|
|
75
130
|
def dump(self, filename: str, number_of_waveforms: int, emitting_frequency: float,
|
|
76
131
|
auto_mode: bool = False, instant_ai_frequency_threshold: float = 0.0,
|
|
77
132
|
instant_ai_target_points_per_waveform: int = 100,
|
|
78
|
-
instant_ai_max_reliable_polling_hz: float = 10.0
|
|
133
|
+
instant_ai_max_reliable_polling_hz: float = 10.0,
|
|
134
|
+
waveform_processing_mode: str = "threshold_accumulation") -> Result:
|
|
79
135
|
command = "to_dump {} {} {:.12g} {}".format(filename, number_of_waveforms, emitting_frequency, auto_mode)
|
|
80
136
|
if (instant_ai_frequency_threshold != 0.0 or instant_ai_target_points_per_waveform != 100 or
|
|
81
|
-
instant_ai_max_reliable_polling_hz != 10.0):
|
|
137
|
+
instant_ai_max_reliable_polling_hz != 10.0 or waveform_processing_mode != "threshold_accumulation"):
|
|
82
138
|
command += " {:.12g} {} {:.12g}".format(
|
|
83
139
|
instant_ai_frequency_threshold, instant_ai_target_points_per_waveform,
|
|
84
140
|
instant_ai_max_reliable_polling_hz)
|
|
141
|
+
if waveform_processing_mode != "threshold_accumulation":
|
|
142
|
+
command += " {}".format(waveform_processing_mode)
|
|
85
143
|
return self.communicate(command)
|
|
86
144
|
|
|
87
|
-
def process(self, filename: str) -> Result:
|
|
88
|
-
|
|
145
|
+
def process(self, filename: str, waveform_processing_mode: str = None) -> Result:
|
|
146
|
+
command = "to_process {}".format(filename)
|
|
147
|
+
if waveform_processing_mode is not None:
|
|
148
|
+
command += " {}".format(waveform_processing_mode)
|
|
149
|
+
return self.communicate(command)
|
|
89
150
|
|
|
90
151
|
def sampling_progress(self) -> Result:
|
|
91
152
|
return self.communicate("to_sampling_progress")
|
|
Binary file
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|