def test_gui_csv_02(self): """tests solid_bending_multi_node.txt""" csv_filename = os.path.join(MODEL_PATH, 'solid_bending', 'solid_bending_multi_node.txt') with self.assertRaises(ValueError): load_deflection_csv(csv_filename) # bad shape load_csv(csv_filename)
def _load_csv(self, result_type, out_filename): """ common method between: - on_add_nodal_results(filename) - on_add_elemental_results(filename) Parameters ---------- result_type : str ??? out_filename : str the CSV filename to load """ out_filename_short = os.path.relpath(out_filename) A, fmt_dict, headers = load_csv(out_filename) #nrows, ncols, fmts header0 = headers[0] result0 = A[header0] nrows = result0.size if result_type == 'Nodal': assert nrows == self.gui.nnodes, 'nrows=%s nnodes=%s' % ( nrows, self.gui.nnodes) result_type2 = 'node' #ids = self.node_ids elif result_type == 'Elemental': assert nrows == self.gui.nelements, 'nrows=%s nelements=%s' % ( nrows, self.gui.nelements) result_type2 = 'centroid' #ids = self.element_ids else: raise NotImplementedError('result_type=%r' % result_type) #num_ids = len(ids) #if num_ids != nrows: #A2 = {} #for key, matrix in A.items(): #fmt = fmt_dict[key] #assert fmt not in ['%i'], 'fmt=%r' % fmt #if len(matrix.shape) == 1: #matrix2 = np.full(num_ids, dtype=matrix.dtype) #iids = np.searchsorted(ids, ) #A = A2 self._add_cases_to_form(A, fmt_dict, headers, result_type2, out_filename_short, update=True, is_scalar=True)
def _load_csv(self, result_type, out_filename, stop_on_failure=False): """ common method between: - on_add_nodal_results(filename) - on_add_elemental_results(filename) Parameters ---------- result_type : str ??? out_filename : str the CSV filename to load """ out_filename_short = os.path.relpath(out_filename) A, fmt_dict, headers = load_csv(out_filename) #nrows, ncols, fmts header0 = headers[0] result0 = A[header0] nrows = result0.size if result_type == 'Nodal': nnodes = self.gui.nnodes if nrows != nnodes: self.log.warning( 'The fringe CSV has %i rows, but there are %i nodes in the ' 'model. Verify that the result is for the correct model and ' "that it's not an elemental result." % (nrows, nnodes)) A = _resize_array(A, A['index'], self.gui.node_ids, nrows, nnodes) result_type2 = 'node' elif result_type == 'Elemental': nelements = self.gui.nelements if nrows != nelements: self.log.warning( 'The fringe CSV has %i rows, but there are %i elements in the ' 'model. Verify that the result is for the correct model and ' "that it's not a nodal result." % (nrows, nelements)) A = _resize_array(A, A['index'], self.gui.element_ids, nrows, nelements) result_type2 = 'centroid' else: raise NotImplementedError('result_type=%r' % result_type) #num_ids = len(ids) #if num_ids != nrows: #A2 = {} #for key, matrix in A.items(): #fmt = fmt_dict[key] #assert fmt not in ['%i'], 'fmt=%r' % fmt #if len(matrix.shape) == 1: #matrix2 = np.full(num_ids, dtype=matrix.dtype) #iids = np.searchsorted(ids, ) #A = A2 self._add_cases_to_form(A, fmt_dict, headers, result_type2, out_filename_short, update=True, is_scalar=True)
def test_gui_csv_03b(self): """tests solid_bending_multi_node.csv""" csv_filename = os.path.join(MODEL_PATH, 'solid_bending', 'solid_bending_multi_node.csv') load_csv(csv_filename)