Skip to content

Commit e36cb33

Browse files
committed
Postpone k_vec imports; error msg w/o requests
1 parent acf93bf commit e36cb33

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

GSASII/GSASIIpwdGUI.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,11 @@
3939
from . import GSASIIsasd as G2sasd
4040
from . import G2shapes
4141
from . import SUBGROUPS as kSUB
42-
from . import k_vector_search as kvs
4342
from GSASII.imports.G2phase_CIF import CIFPhaseReader as CIFpr
4443
from . import GSASIIscriptable as G2sc
4544
from . import GSASIImiscGUI as G2IO
4645
try:
4746
from sympy import symbols, nsimplify, Rational as SRational
48-
from k_vec_solve import k_vec_solve as kvsolve
4947
except ImportError:
5048
G2fil.NeededPackage({'ISODISTORT k-vector search':['sympy']})
5149
symbols = None
@@ -4612,6 +4610,7 @@ def SeaResSelected(event=None):
46124610
46134611
Generates & plots reflections
46144612
'''
4613+
from . import k_vector_search as kvs
46154614
data = G2frame.GPXtree.GetItemPyData(UnitCellsId)
46164615
cells,dminx = data[2:4]
46174616
if event is None:
@@ -5206,6 +5205,7 @@ def _get_opt_val(opt_name, out):
52065205
def grab_all_kvecs(out_html):
52075206
"""Extract all k-vectors from the ISODISTORT output HTML."""
52085207
import re
5208+
from k_vec_solve import k_vec_solve as kvsolve
52095209

52105210
kvec1_pattern = r'<SELECT NAME="kvec1">(.*?)</SELECT>'
52115211
kvec1_match = re.search(kvec1_pattern, out_html, re.DOTALL)
@@ -5273,6 +5273,7 @@ def setup_kvec_input(k_vec, k_vec_dict, isocif_cif):
52735273
dict: New entries and those need to be corrected in the data
52745274
to be used in the post request.
52755275
"""
5276+
from k_vec_solve import k_vec_solve as kvsolve
52765277
k_forms = k_vec_dict.items()
52775278
all_keys = list(k_forms)
52785279

@@ -5298,9 +5299,14 @@ def setup_kvec_input(k_vec, k_vec_dict, isocif_cif):
52985299
G2G.G2MessageBox(G2frame,
52995300
'Unable to perform ISODISTORT kvec search without the sympy module. Use Help/Add packages... to address','No sympy')
53005301
return
5302+
try:
5303+
import requests
5304+
except:
5305+
G2G.G2MessageBox(G2frame,
5306+
'Unable to perform ISODISTORT kvec search without the requests module. Use Help/Add packages... to address','No requests')
5307+
return
53015308
import tempfile
53025309
import re
5303-
import requests
53045310
from GSASII.exports import G2export_CIF
53055311
from . import ISODISTORT as ISO
53065312
isoformsite = 'https://iso.byu.edu/isodistortform.php'
@@ -5422,7 +5428,7 @@ def setup_kvec_input(k_vec, k_vec_dict, isocif_cif):
54225428
isocif_out_cif = requests.post(isocifformsite, data=isocif_formDict).text
54235429

54245430
kvec_dict = grab_all_kvecs(out2)
5425-
lat_sym = Phase['General']['SGData']
5431+
#lat_sym = Phase['General']['SGData']
54265432
data_update = setup_kvec_input(kpoint, kvec_dict, isocif_out_cif)
54275433
for key, value in data_update.items():
54285434
data[key] = value
@@ -5461,13 +5467,13 @@ def setup_kvec_input(k_vec, k_vec_dict, isocif_cif):
54615467
resId = G2gd.GetGPXtreeItemId(G2frame, G2frame.root, 'Restraints')
54625468
Restraints = G2frame.GPXtree.GetItemPyData(resId)
54635469
resId = G2gd.GetGPXtreeItemId(G2frame, resId, phsnam)
5464-
savedRestraints = None
5470+
#savedRestraints = None
54655471
if phsnam in Restraints:
54665472
Restraints[phsnam]['Bond']['Bonds'] = []
54675473
Restraints[phsnam]['Angle']['Angles'] = []
5468-
savedRestraints = Restraints[phsnam]
5474+
#savedRestraints = Restraints[phsnam]
54695475
del Restraints[phsnam]
5470-
orgData = copy.deepcopy(data)
5476+
#orgData = copy.deepcopy(data)
54715477

54725478
for ir_opt, _ in ir_options:
54735479
print("Processing irrep:", ir_opt)
@@ -5697,6 +5703,7 @@ def kvecSizer():
56975703

56985704
def OnKvecSearch(event):
56995705
'Run the k-vector search'
5706+
from . import k_vector_search as kvs
57005707

57015708
try:
57025709
import seekpath

0 commit comments

Comments
 (0)