def create_example_grooves()->List[IsoBaseGroove]: """ Create one example groove for each class """ groove_sub_classes = [cls for cls in IsoBaseGroove.__subclasses__()] groove_sub_class_names = [cls.__name__ for cls in groove_sub_classes] test_grooves = list(_create_test_grooves().values()) sub_class_examples = [[item[0] for item in test_grooves if item[0].__class__.__name__ == sub_class] for sub_class in groove_sub_class_names] sub_class_examples = [item[0] for item in sub_class_examples if len(item) > 0] return sub_class_examples
def base64_encode(): example_groove = list(_create_test_grooves().values())[0][0] seam_length = Q_(300, "mm") tree = { "workpiece": { "groove": example_groove, "length": Q_(seam_length, "mm") } } file_buffer = weldx.asdf.util._write_buffer(tree) base64_string = base64.b64encode(file_buffer.getvalue()).decode() return base64_string
from weldx_processors import * import asdf import weldx from weldx.welding.groove.iso_9692_1 import _create_test_grooves def run_pipeline(file: asdf.AsdfFile, steps): tmp_file = file for step in steps: tmp_file = step(tmp_file) return tmp_file if __name__ == "__main__": example_groove = list(_create_test_grooves().values())[0][0] tree = {"workpiece": {"groove": example_groove}} file = asdf.AsdfFile(tree) new_file = run_pipeline( file, steps=[add_seam_length, add_pulse_ui, add_process_spray]) print(new_file.tree)
"""Test all ASDF groove implementations.""" import matplotlib.pyplot as plt import pytest from weldx.asdf.utils import _write_read_buffer from weldx.constants import WELDX_QUANTITY as Q_ from weldx.geometry import Profile from weldx.welding.groove.iso_9692_1 import ( IsoBaseGroove, _create_test_grooves, get_groove, ) test_params = _create_test_grooves() @pytest.mark.parametrize( "groove, expected_dtype", test_params.values(), ids=test_params.keys() ) def test_asdf_groove(groove: IsoBaseGroove, expected_dtype): """Test ASDF functionality for all grooves. Parameters ---------- groove: Groove instance to be tested. expected_dtype: Expected type of the groove to be tested.