def test__multi(): """ test conv.multi """ mcap = autoparse.find.first_capture(XYZ_LINE_PATTERN, XYZ_STRING) mval = autoparse.cast(mcap) assert mval == ('F', 1.584823, -0.748487, -0.427122) mcap = autoparse.find.first_capture(BAD_XYZ_LINE_PATTERN, XYZ_STRING) mval = autoparse.cast(mcap) assert mval is None
def test__single(): """ test conv.single """ bad_mult_pattern = autoparse.pattern.LINESPACES.join([ autoparse.pattern.escape('multiplicity:'), autoparse.pattern.capturing(autoparse.pattern.UNSIGNED_INTEGER), ]) mult_pattern = autoparse.pattern.LINESPACES.join([ autoparse.pattern.escape('mult:'), autoparse.pattern.capturing(autoparse.pattern.UNSIGNED_INTEGER), ]) cap = autoparse.find.first_capture(bad_mult_pattern, XYZ_STRING) val = autoparse.cast(cap) assert val is None mcap = autoparse.find.first_capture(mult_pattern, XYZ_STRING) mval = autoparse.cast(mcap) assert mval == 1
def test__singles(): """ test conv.singles """ pattern = autoparse.pattern.capturing(autoparse.pattern.FLOAT) caps = autoparse.find.all_captures(pattern, XYZ_STRING) vals = autoparse.cast(caps) assert vals == (1.584823, -0.748487, -0.427122, 0.61922, 0.190166, -0.271639, -0.635731, -0.183914, -0.180364, -1.602333, 0.736678, -0.026051, 0.916321, 1.229946, -0.227127, -0.8823, -1.224388, -0.229636)
def test__multis(): """ test conv.multis """ mcaps = autoparse.find.all_captures(XYZ_LINE_PATTERN, XYZ_STRING) mvals = autoparse.cast(mcaps) assert mvals == (('F', 1.584823, -0.748487, -0.427122), ('C', 0.61922, 0.190166, -0.271639), ('C', -0.635731, -0.183914, -0.180364), ('Cl', -1.602333, 0.736678, -0.026051), ('H', 0.916321, 1.229946, -0.227127), ('H', -0.8823, -1.224388, -0.229636))