Best Python code snippet using pandera_python
resource_map.py
Source:resource_map.py
...614 # Idea credit goes to bostrt: https://github.com/kxr/o-must-gather/issues/34615 # This is just fall back and expensive to compute,616 # ideally these definitions should be added to the map dict for better lookup performance617 try:618 crds = from_yaml(619 "_all",620 "_all",621 "cluster-scoped-resources/apiextensions.k8s.io/customresourcedefinitions",622 False,623 )624 for c in crds:625 singular = c["res"]["spec"]["names"]["singular"]626 plural = c["res"]["spec"]["names"]["plural"]627 if "shortNames" in c["res"]["spec"]["names"]:628 short = c["res"]["spec"]["names"]["shortNames"]629 else:630 short = []631 aliases = [plural] + short632 if t.lower() == singular or t.lower() in aliases:...
setting_from_file.py
Source:setting_from_file.py
...4import datetime5from pathlib import Path6import yaml7import zivid8def _acquisitions_from_yaml(acquisitions_from_yaml):9 acquisitions = []10 for acquisition in acquisitions_from_yaml:11 acquisitions.append(12 zivid.Settings.Acquisition(13 brightness=acquisition["Acquisition"]["Brightness"],14 aperture=acquisition["Acquisition"]["Aperture"],15 exposure_time=datetime.timedelta(microseconds=acquisition["Acquisition"]["ExposureTime"]),16 gain=acquisition["Acquisition"]["Gain"],17 )18 )19 return acquisitions20def _contrast_distortion_from_yaml(from_yaml):21 contrast_distortion = zivid.Settings.Processing.Filters.Experimental.ContrastDistortion()22 contrast_distortion.correction.enabled = from_yaml["Correction"]["Enabled"]23 contrast_distortion.correction.strength = from_yaml["Correction"]["Strength"]24 contrast_distortion.removal.enabled = from_yaml["Removal"]["Enabled"]25 contrast_distortion.removal.threshold = from_yaml["Removal"]["Threshold"]26 return contrast_distortion27def _filter_from_yaml(from_yaml):28 filters = zivid.Settings.Processing.Filters()29 filters.noise.removal.enabled = from_yaml["Noise"]["Removal"]["Enabled"]30 filters.noise.removal.threshold = from_yaml["Noise"]["Removal"]["Threshold"]31 filters.smoothing.gaussian.enabled = from_yaml["Smoothing"]["Gaussian"]["Enabled"]32 filters.smoothing.gaussian.sigma = from_yaml["Smoothing"]["Gaussian"]["Sigma"]33 filters.outlier.removal.enabled = from_yaml["Outlier"]["Removal"]["Enabled"]34 filters.outlier.removal.threshold = from_yaml["Outlier"]["Removal"]["Threshold"]35 filters.experimental.contrast_distortion = _contrast_distortion_from_yaml(36 from_yaml["Experimental"]["ContrastDistortion"]37 )38 return filters39def _color_from_yaml(from_yaml):40 color = zivid.Settings.Processing.Color()41 color.balance.red = from_yaml["Balance"]["Red"]42 color.balance.blue = from_yaml["Balance"]["Blue"]43 color.balance.green = from_yaml["Balance"]["Green"]44 color.gamma = from_yaml["Gamma"]45 return color46def get_settings_from_yaml(path: str) -> zivid.Settings:47 """Get settings from .yml file.48 Args:49 path: Path to .yml file which contains settings50 Returns:51 settings: Zivid Settings52 """53 with open(path) as f:54 settings_from_yaml = yaml.load(f, Loader=yaml.Loader)["Settings"]55 settings = zivid.Settings(56 acquisitions=_acquisitions_from_yaml(settings_from_yaml["Acquisitions"]),57 processing=zivid.Settings.Processing(58 filters=_filter_from_yaml(settings_from_yaml["Processing"]["Filters"]),59 color=_color_from_yaml(settings_from_yaml["Processing"]["Color"]),60 ),61 )...
settings_from_file.py
Source:settings_from_file.py
...4import datetime5from pathlib import Path6import yaml7import zivid8def _acquisitions_from_yaml(acquisitions_from_yaml):9 acquisitions = []10 for acquisition in acquisitions_from_yaml:11 acquisitions.append(12 zivid.Settings.Acquisition(13 brightness=acquisition["Acquisition"]["Brightness"],14 aperture=acquisition["Acquisition"]["Aperture"],15 exposure_time=datetime.timedelta(microseconds=acquisition["Acquisition"]["ExposureTime"]),16 gain=acquisition["Acquisition"]["Gain"],17 )18 )19 return acquisitions20def _contrast_distortion_from_yaml(from_yaml):21 contrast_distortion = zivid.Settings.Processing.Filters.Experimental.ContrastDistortion()22 contrast_distortion.correction.enabled = from_yaml["Correction"]["Enabled"]23 contrast_distortion.correction.strength = from_yaml["Correction"]["Strength"]24 contrast_distortion.removal.enabled = from_yaml["Removal"]["Enabled"]25 contrast_distortion.removal.threshold = from_yaml["Removal"]["Threshold"]26 return contrast_distortion27def _filter_from_yaml(from_yaml):28 filters = zivid.Settings.Processing.Filters()29 filters.noise.removal.enabled = from_yaml["Noise"]["Removal"]["Enabled"]30 filters.noise.removal.threshold = from_yaml["Noise"]["Removal"]["Threshold"]31 filters.smoothing.gaussian.enabled = from_yaml["Smoothing"]["Gaussian"]["Enabled"]32 filters.smoothing.gaussian.sigma = from_yaml["Smoothing"]["Gaussian"]["Sigma"]33 filters.outlier.removal.enabled = from_yaml["Outlier"]["Removal"]["Enabled"]34 filters.outlier.removal.threshold = from_yaml["Outlier"]["Removal"]["Threshold"]35 filters.experimental.contrast_distortion = _contrast_distortion_from_yaml(36 from_yaml["Experimental"]["ContrastDistortion"]37 )38 return filters39def _color_from_yaml(from_yaml):40 color = zivid.Settings.Processing.Color()41 color.balance.red = from_yaml["Balance"]["Red"]42 color.balance.blue = from_yaml["Balance"]["Blue"]43 color.balance.green = from_yaml["Balance"]["Green"]44 color.gamma = from_yaml["Gamma"]45 return color46def get_settings_from_yaml(path: Path) -> zivid.Settings:47 """Get settings from .yml file.48 Args:49 path: Path to .yml file which contains settings50 Returns:51 settings: Zivid Settings52 """53 settings_from_yaml = yaml.load(path.read_text(), Loader=yaml.Loader)["Settings"]54 settings = zivid.Settings(55 acquisitions=_acquisitions_from_yaml(settings_from_yaml["Acquisitions"]),56 processing=zivid.Settings.Processing(57 filters=_filter_from_yaml(settings_from_yaml["Processing"]["Filters"]),58 color=_color_from_yaml(settings_from_yaml["Processing"]["Color"]),59 ),60 )...
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!!