def test_getmultigeo1(): '''Check strings are extracted from a "multi" laminate Frame, nplies >= 5.''' case = ut.laminator(['400-200-800']) for case_ in case.values(): for LM in case_.LMs: actual = ut.get_multi_geometry(LM.LMFrame) #expected = '400-[200]-800' # pre to_gen_convention() expected = '400.0-[200.0]-800.0' nt.assert_equal(actual, expected)
def extract_dataframe(df): """Parse corrected DataFrame from a csv file; legacy, automated or custom.""" df_expected = df.copy() # Mild cleanup if "d(mm)" in df_expected.columns: df_expected["d(m)"] = df_expected["d(mm)"] / 1000.0 del df_expected["d(mm)"] if "t(um)" not in df_expected.columns: # for custom controls from legacy scripts df_expected["t(um)"] = df_expected["h(m)"] / 1e-6 # Assign Nan to layer thickness of the discontinuity row df_expected.loc[df_expected["label"] == "discont.", "t(um)"] = np.nan # Twice the h in the middle df_expected.loc[df_expected["type"] == "middle", "t(um)"] = ( df_expected.loc[df_expected["type"] == "middle", "h(m)"].multiply(2) / 1e-6 ) # Parse data mainly for the Case nplies = len(df_expected["layer"].unique()) p = df_expected.groupby("layer").size().iloc[0] t_total = df_expected.iloc[-1]["d(m)"] # (in m) # Get a geometry string to feed the API if nplies < 5: geometry = ut.get_special_geometry(df_expected) elif nplies >= 5: geometry = ut.get_multi_geometry(df_expected) elif nplies < 1: raise Exception("Number of plies < 1. No plies detected.") # print(geometry) # Plugin holes; overwrite placeholder Nans at discontinuities # Primarily for custom controls geo = geometry.split("-") # print(geo) outer = float(geo[0]) if "[" in geo[1]: inners = geo[1][1:-1].split(",") """Why is float needed here and not int?""" """Getting 200L error for float.""" # print(inners) inner_i = [float(t) for t in inners] else: inner_i = float(geo[1]) # print(inner_i) df_expected.loc[(df_expected["label"] == "discont.") & (df_expected["type"] == "outer"), "t(um)"] = outer if ("discont." in df_expected["label"].values) and ("inner" in df_expected["type"].values): df_expected = fix_discontinuities(df_expected, inner_i) return df_expected, geometry, nplies, p, t_total
def test_getmultigeo2(): '''Check error is raised if not "multi", rather a special, nplies < 4.''' case = ut.laminator(['400-200-0']) for case_ in case.values(): for LM in case_.LMs: actual = ut.get_multi_geometry(LM.LMFrame)
def extract_dataframe(df): '''Parse corrected DataFrame from a csv file; legacy, automated or custom.''' df_expected = df.copy() # Mild cleanup if 'd(mm)' in df_expected.columns: df_expected['d(m)'] = df_expected['d(mm)'] / 1000. del df_expected['d(mm)'] if 't(um)' not in df_expected.columns: # for custom controls from legacy scripts df_expected['t(um)'] = df_expected['h(m)'] / 1e-6 # Assign Nan to layer thickness of the discontinuity row df_expected.loc[ df_expected['label'] == 'discont.', 't(um)' ] = np.nan # Twice the h in the middle df_expected.loc[ df_expected['type'] == 'middle', 't(um)'] = df_expected.loc[ df_expected['type'] == 'middle', 'h(m)' ].multiply(2) / 1e-6 # Parse data mainly for the Case nplies = len(df_expected['layer'].unique()) p = df_expected.groupby('layer').size().iloc[0] t_total = df_expected.iloc[-1]['d(m)'] # (in m) # Get a geometry string to feed the API if nplies < 5: geometry = ut.get_special_geometry(df_expected) elif nplies >= 5: geometry = ut.get_multi_geometry(df_expected) elif nplies < 1: raise Exception('Number of plies < 1. No plies detected.') #print(geometry) # Plugin holes; overwrite placeholder Nans at discontinuities # Primarily for custom controls geo = geometry.split('-') #print(geo) #### Look closely at affects of this commit 6f5f518fa42099fcbda37c1a15986a88a04e38c5 #### Check that files are not influenced; reverting should be commenting _to_gen_convention get_..._geometry # TODO: Refactor; this section is not needed with _to_gen_convention in get_multi_geometry and get_special_geometry outer = float(geo[0]) if '[' in geo[1]: inners = geo[1][1:-1].split(',') '''Why is float needed here and not int?''' '''Getting 200L error for float.''' #print(inners) inner_i = [float(t) for t in inners] else: inner_i = float(geo[1]) #print(inner_i) #### df_expected.loc[ (df_expected['label'] == 'discont.') & (df_expected['type'] == 'outer'), 't(um)'] = outer if ('discont.' in df_expected['label'].values) and ('inner' in df_expected['type'].values): df_expected = fix_discontinuities(df_expected, inner_i) return df_expected, geometry, nplies, p, t_total