text stringlengths 0 828 |
|---|
''' |
index = pd.Index(feedback_result.time * 1e-3, name='seconds') |
df_feedback = pd.DataFrame(np.column_stack([feedback_result.V_actuation() |
.filled(np.NaN), |
feedback_result.capacitance() |
.filled(np.NaN), |
feedback_result.Z_device() |
.filled(np.NaN)]), |
columns=['V_actuation', 'capacitance', |
'impedance'], |
index=index) |
df_feedback.insert(0, 'frequency', feedback_result.frequency) |
df_feedback.insert(1, 'voltage', feedback_result.voltage) |
return df_feedback" |
942,"def get_firmwares(): |
''' |
Return `dmf_control_board` compiled Arduino hex file paths. |
This function may be used to locate firmware binaries that are available |
for flashing to [Arduino Mega2560][1] boards. |
[1]: http://arduino.cc/en/Main/arduinoBoardMega2560 |
''' |
return OrderedDict([(board_dir.name, [f.abspath() for f in |
board_dir.walkfiles('*.hex')]) |
for board_dir in |
package_path().joinpath('firmware').dirs()])" |
943,"def safe_series_resistor_index_read(f, self, channel, resistor_index=None): |
''' |
This decorator checks the resistor-index from the current context _(i.e., |
the result of `self.series_resistor_index`)_. If the resistor-index |
specified by the `resistor_index` keyword argument is different than the |
current context value, the series-resistor-index is temporarily set to the |
value of `resistor_index` to execute the wrapped function before restoring |
back to the original value. |
''' |
if resistor_index is not None: |
original_resistor_index = self.series_resistor_index(channel) |
# Save state of resistor-index |
if resistor_index != original_resistor_index: |
self.set_series_resistor_index(channel, resistor_index) |
value = f(self, channel) |
if (resistor_index is not None and |
resistor_index != original_resistor_index): |
# Restore state of resistor-index |
self.set_series_resistor_index(channel, original_resistor_index) |
return value" |
944,"def remote_command(function, self, *args, **kwargs): |
''' |
Catch `RuntimeError` exceptions raised by remote control board firmware |
commands and re-raise as more specific `FirmwareError` exception type, |
which includes command code and return code. |
''' |
try: |
return function(self, *args, **kwargs) |
except RuntimeError, exception: |
error_message = str(exception) |
match = CRE_REMOTE_ERROR.match(error_message) |
if match: |
# Exception message matches format of remote firmware error. |
command_code = int(match.group('command_int')) |
return_code = int(match.group('return_code_int')) |
raise FirmwareError(command_code, return_code) |
match = CRE_REMOTE_COMMAND_ERROR.match(error_message) |
if match: |
# Exception message matches format of remote firmware error. |
command_code = int(match.group('command_int')) |
command_name = NAMES_BY_COMMAND_CODE[command_code] |
raise RuntimeError(CRE_REMOTE_COMMAND_ERROR.sub(command_name, |
error_message)) |
# Not a remote firmware error, so raise original exception. |
raise" |
945,"def _upgrade(self): |
"""""" |
Upgrade the serialized object if necessary. |
Raises: |
FutureVersionError: file was written by a future version of the |
software. |
"""""" |
logging.debug('[FeedbackResults]._upgrade()') |
if hasattr(self, 'version'): |
version = Version.fromstring(self.version) |
else: |
version = Version(0) |
logging.debug('[FeedbackResults] version=%s, class_version=%s' % |
(str(version), self.class_version)) |
if version > Version.fromstring(self.class_version): |
logging.debug('[FeedbackResults] version>class_version') |
raise FutureVersionError(Version.fromstring(self.class_version), |
version) |
elif version < Version.fromstring(self.class_version): |
if version < Version(0, 1): |
self.calibration = FeedbackCalibration() |
if version < Version(0, 2): |
# flag invalid data points |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.