def on_area_pick_callback(self, eids, nids, name): """prints the message when area_pick succeeds""" msg = '' if eids is not None and len(eids): msg += write_patran_syntax_dict({'Elem': eids}) if nids is not None and len(nids): msg += '\n' + write_patran_syntax_dict({'Node': nids}) if msg: self.gui.log_info('\n%s' % msg.lstrip())
def test_bdf_utils_02(self): """tests parse_patran_syntax_dict""" msg = 'n 1:10 14:20:2 50:40:-1 e 10 20' expected_nodes = np.array( [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 14, 16, 18, 20, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50] ) expected_elements = np.array([10, 20]) output_dict = parse_patran_syntax_dict(msg, pound_dict=None) assert np.array_equal(output_dict['n'], expected_nodes) assert np.array_equal(output_dict['e'], expected_elements) # messing with the order a bit msg = 'n 1:# e 2:#:4 junk 1 7 12:#:2 3' expected_nodes = np.array([1, 2, 3, 4, 5]) expected_elements = np.array([2, 6, 10, 14]) expected_junk = np.array([1, 3, 7, 12, 14, 16, 18, 20]) pound_dict = { 'n' : 5, 'e' : 14, 'junk' : 20., } output_dict = parse_patran_syntax_dict(msg, pound_dict=pound_dict) assert np.array_equal(output_dict['n'], expected_nodes) assert np.array_equal(output_dict['e'], expected_elements) error_msg = 'expected equal; A-B=%s; B-A=%s' % ( np.setdiff1d(expected_junk, output_dict['junk']), np.setdiff1d(output_dict['junk'], expected_junk)) assert np.array_equal(output_dict['junk'], expected_junk), error_msg msg = write_patran_syntax_dict({'e' : [2, 6, 10, 14]}) assert msg == 'e 2:14:4', 'msg=%r' % msg msg = write_patran_syntax_dict({'e' : [1, 2, 6, 10, 14]}) assert msg == 'e 1 2 6:14:4', 'msg=%r' % msg msg = write_patran_syntax_dict( { 'n' : [1, 2, 6, 10, 14], 'e' : [1, 2, 6, 10, 14], }, ) assert msg == 'e 1 2 6:14:4 n 1 2 6:14:4', 'msg=%r' % msg out = parse_patran_syntax_dict('') assert len(out) == 0, 'out=%s' % out
def test_bdf_utils_02(self): msg = 'n 1:10 14:20:2 50:40:-1 e 10 20' expected_nodes = np.array( [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 14, 16, 18, 20, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50] ) expected_elements = np.array([10, 20]) output_dict = parse_patran_syntax_dict(msg, pound_dict=None) assert np.array_equal(output_dict['n'], expected_nodes) assert np.array_equal(output_dict['e'], expected_elements) # messing with the order a bit msg = 'n 1:# e 2:#:4 junk 1 7 12:#:2 3' expected_nodes = np.array([1, 2, 3, 4, 5]) expected_elements = np.array([2, 6, 10, 14]) expected_junk = np.array([1, 3, 7, 12, 14, 16, 18, 20]) pound_dict = { 'n' : 5, 'e' : 14, 'junk' : 20., } output_dict = parse_patran_syntax_dict(msg, pound_dict=pound_dict) assert np.array_equal(output_dict['n'], expected_nodes) assert np.array_equal(output_dict['e'], expected_elements) error_msg = 'expected equal; A-B=%s; B-A=%s' % ( np.setdiff1d(expected_junk, output_dict['junk']), np.setdiff1d(output_dict['junk'], expected_junk)) assert np.array_equal(output_dict['junk'], expected_junk), error_msg msg = write_patran_syntax_dict({'e' : [2, 6, 10, 14]}) assert msg == 'e 2:14:4', 'msg=%r' % msg msg = write_patran_syntax_dict({'e' : [1, 2, 6, 10, 14]}) assert msg == 'e 1 2 6:14:4', 'msg=%r' % msg msg = write_patran_syntax_dict( { 'n' : [1, 2, 6, 10, 14], 'e' : [1, 2, 6, 10, 14], }, ) assert msg == 'e 1 2 6:14:4 n 1 2 6:14:4', 'msg=%r' % msg out = parse_patran_syntax_dict('') assert len(out) == 0, 'out=%s' % out
def on_focus_callback(self, eids, nids, name): """the callback method for ``on_focus``""" if nids is None: return if len(nids) == 1: self.setText(str(nids[0])) return nids_str = write_patran_syntax_dict({'': nids}) self.setText(nids_str)
def on_focus_callback(self, eids, nids): """the callback method for ``on_focus``""" eids_str = write_patran_syntax_dict({'': eids}) self.setText(eids_str)
def on_focus_callback(self, eids, nids, name): """the callback method for ``on_focus``""" if eids is None: return eids_str = write_patran_syntax_dict({'' : eids}) self.setText(eids_str)