Best Python code snippet using fMBT_python
KeysightB1511B.py
Source:KeysightB1511B.py
1from typing import Optional, TYPE_CHECKING, List, Any2from .KeysightB1517A import B1517A3from .constants import IMeasRange, IOutputRange4if TYPE_CHECKING:5 import qcodes.instrument_drivers.Keysight.keysightb15006class B1511B(B1517A):7 """8 Driver for Keysight B1511B Source/Monitor Unit module for B15009 Semiconductor Parameter Analyzer.10 Args:11 parent: mainframe B1500 instance that this module belongs to12 name: Name of the instrument instance to create. If `None`13 (Default), then the name is autogenerated from the instrument14 class.15 slot_nr: Slot number of this module (not channel number)16 asu_present: Flag to acknowledge ASU presence17 """18 def __init__(19 self,20 parent: "qcodes.instrument_drivers.Keysight.keysightb1500.KeysightB1500",21 name: Optional[str],22 slot_nr: int,23 **kwargs: Any24 ):25 super().__init__(parent, name, slot_nr, **kwargs)26 self._valid_i_measure_ranges: List[IMeasRange] = [IMeasRange.AUTO,27 IMeasRange.MIN_1nA,28 IMeasRange.MIN_10nA,29 IMeasRange.MIN_100nA,30 IMeasRange.MIN_1uA,31 IMeasRange.MIN_10uA,32 IMeasRange.MIN_100uA,33 IMeasRange.MIN_1mA,34 IMeasRange.MIN_10mA,35 IMeasRange.MIN_100mA,36 IMeasRange.FIX_1nA,37 IMeasRange.FIX_10nA,38 IMeasRange.FIX_100nA,39 IMeasRange.FIX_1uA,40 IMeasRange.FIX_10uA,41 IMeasRange.FIX_100uA,42 IMeasRange.FIX_1mA,43 IMeasRange.FIX_10mA,44 IMeasRange.FIX_100mA]45 self._asu_valid_i_measure_ranges: List[IMeasRange] = [46 IMeasRange.MIN_1pA, IMeasRange.MIN_10pA, IMeasRange.MIN_100pA,47 IMeasRange.FIX_1pA, IMeasRange.FIX_10pA, IMeasRange.FIX_100pA]48 self._valid_i_output_ranges: List[IOutputRange] = [49 IOutputRange.AUTO, IOutputRange.MIN_1nA, IOutputRange.MIN_10nA,50 IOutputRange.MIN_100nA, IOutputRange.MIN_1uA,51 IOutputRange.MIN_10uA, IOutputRange.MIN_100uA,52 IOutputRange.MIN_1mA, IOutputRange.MIN_10mA, IOutputRange.MIN_100mA]53 self._asu_valid_i_output_ranges: List[IOutputRange] = [54 IOutputRange.MIN_1pA, IOutputRange.MIN_10pA, IOutputRange.MIN_100pA]55 self.asu_present: bool = False56 @property57 def asu_present(self) -> bool:58 return self._asu_present59 @asu_present.setter60 def asu_present(self, val: bool) -> None:61 if not isinstance(val, bool):62 raise TypeError("Expected: True or False")63 self._asu_present = val64 if self.asu_present:65 self._valid_i_measure_ranges = self._valid_i_measure_ranges + \66 self._asu_valid_i_measure_ranges67 self._valid_i_output_ranges = self._valid_i_output_ranges + \68 self._asu_valid_i_output_ranges69 else:70 self._valid_i_measure_ranges = list(71 set(self._valid_i_measure_ranges) -72 set(self._asu_valid_i_measure_ranges)73 )74 self._valid_i_output_ranges = list(75 set(self._valid_i_output_ranges) -76 set(self._asu_valid_i_output_ranges)...
run_ann.py
Source:run_ann.py
1def _get_predict_fname(out_dir, ioutput, weight, pdf_sampling):2 if pdf_sampling:3 return "%s/fb_%05i_%s_ftidal_pdf_sampling.predict" % (out_dir, ioutput, weight)4 return "%s/fb_%05i_%s.predict" % (out_dir, ioutput, weight)5def _get_results_fname(out_dir, ioutput, weight, NN, pdf_sampling):6 if pdf_sampling:7 return "%s/fb_%05i_NN%i_%s_ftidal_pdf_sampling.results" % (out_dir, ioutput, NN, weight) 8 return "%s/fb_%05i_NN%i_%s.results" % (out_dir, ioutput, NN, weight)9def main(ioutputs, weights_fname, NN):10 import os11 from seren3.utils import which12 _BIN = which("neural-net")13 _CWD = os.getcwd()14 _WEIGHT = "mw"15 def _run(weights_fname, predict_fname, results_fname):16 exe = "%s -l %s -p %s -o %s" % (_BIN, weights_fname, predict_fname, results_fname)17 # print exe18 os.system(exe)19 for ioutput in ioutputs:20 dir_name = "./%i_final/" % (ioutput)21 # Run the standard and tidal force PDF sampled models22 predict_fname = _get_predict_fname(dir_name, ioutput, _WEIGHT, False)23 predict_pdf_sampled_fname = _get_predict_fname(dir_name, ioutput, _WEIGHT, True)24 results_fname = _get_results_fname(dir_name, ioutput, _WEIGHT, NN, False)25 results_pdf_sampled_fname = _get_results_fname(dir_name, ioutput, _WEIGHT, NN, True)26 for pf, rf in zip([predict_fname, predict_pdf_sampled_fname], [results_fname, results_pdf_sampled_fname]):27 _run(weights_fname, pf, rf)28if __name__ == "__main__":29 import sys, os30 ioutputs = [42, 48, 60, 70, 80, 90, 100, 106]31 NN = int(sys.argv[1])32 weights_fname = "/lustre/scratch/astro/ds381/simulations/baryfrac/bc03_fesc2_nohm/neural-net2/NN%i.weights" % NN33 # weights_fname = "/lustre/scratch/astro/ds381/simulations/baryfrac/bc03_fesc2_nohm/neural-net2/106_90_60_NN40_niter100_fb_scaled_ftidal_scaled_logall.weights"34 35 # ioutputs = [int(i) for i in sys.argv[1:-2]]36 # weights_fname = sys.argv[-2]37 # NN = int(sys.argv[-1])38 # paths = ["bc03_fesc1.5_nohm/", "bc03_fesc2_nohm/", "bc03_fesc5_nohm/"]39 # paths = ["bc03_fesc2_nohm/", "bc03_fesc5_nohm/"]40 paths = ["bc03_fesc2_nohm/"]41 lustre_path = "/lustre/scratch/astro/ds381/simulations/baryfrac/"42 full_paths = ["%s/%s/neural-net2/" % (lustre_path, p) for p in paths]43 print "NN = ", NN44 print "Using weights file: ", weights_fname45 print ioutputs46 for fp in full_paths:47 os.chdir(fp)48 print "**************************************************"49 print os.getcwd()50 print "**************************************************"51 main(ioutputs, weights_fname, NN)...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!