Ignore:
Timestamp:
Mar 16, 2018 12:05:42 PM (6 years ago)
Author:
krzywon
Branches:
ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc
Children:
47bf906
Parents:
477c473 (diff), e4c475b7 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'ESS_GUI' into ESS_GUI_Pr

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/qtgui/Plotting/ConvertUnits.py

    re7a0b2f rd744767  
    44""" 
    55import re 
    6 import string 
    76 
    87def convertUnit(power, unit): 
     
    1110    """ 
    1211    if power != 0: 
    13         if string.find(unit, "^") != -1:  # if the unit contains a powerer ^ 
     12        if unit.find("^") != -1:  # if the unit contains a powerer ^ 
    1413            toks = re.split("\^", unit) 
    15             if string.find(toks[0], "/") != -1 or \ 
    16                 string.find(toks[0], "-") != -1: 
     14            if toks[0].find("/") != -1 or \ 
     15                toks[0].find("-") != -1: 
    1716                if power == 1: 
    1817                    unit = unit 
     
    2019                    unit = "(" + unit + ")" + "^{" + str(power) + "}" 
    2120            else: 
    22                 if string.find(toks[1], "{") != -1:  # if found a { 
     21                if toks[1].find("{") != -1:  # if found a { 
    2322                    find_power_toks = re.split("{", toks[1]) 
    24                     if string.find(find_power_toks[1], "}") != -1:  # found } 
     23                    if find_power_toks[1].find("}") != -1:  # found } 
    2524                        unit_toks = re.split("}", find_power_toks[1]) 
    26                         if string.find(unit_toks[0], ".") != -1: 
     25                        if unit_toks[0].find(".") != -1: 
    2726                            powerer = float(unit_toks[0]) * power 
    28                         elif string.find(unit_toks[0], "/") != -1: 
     27                        elif unit_toks[0].find("/") != -1: 
    2928                            power_toks = re.split("/", unit_toks[0]) 
    3029                            powerer = power * int(power_toks[0])\ 
     
    4241                            unit = toks[0] + "^{" + str(powerer) + "}" 
    4342                else: 
    44                     raise ValueError, "missing } in unit expression" 
     43                    raise ValueError("missing } in unit expression") 
    4544        else:  # no powerer 
    4645            if  power != 1: 
    4746                unit = "(" + unit + ")" + "^{" + str(power) + "}" 
    4847    else: 
    49         raise ValueError, "empty unit ,enter a powerer different from zero" 
     48        raise ValueError("empty unit ,enter a powerer different from zero") 
    5049    return unit 
    5150 
     
    6867    unit8 = "m/s^{4}"  #         x^2               (m/s^{4})^{2} 
    6968 
    70     print "this unit1 %s ,its powerer %s , and value %s" % (unit1, 1, convert_unit(1, unit1)) 
    71     print "this unit2 %s ,its powerer %s , and value %s" % (unit2, 1, convert_unit(1, unit2)) 
    72     print "this unit3 %s ,its powerer %s , and value %s" % (unit3, 2, convert_unit(2, unit3)) 
    73     print "this unit4 %s ,its powerer %s , and value %s" % (unit4, -1, convert_unit(-1, unit4)) 
    74     print "this unit5 %s ,its powerer %s , and value %s" % (unit5, 2, convert_unit(2, unit5)) 
    75     print "this unit6 %s ,its powerer %s , and value %s" % (unit6, 2, convert_unit(2, unit6)) 
    76     print "this unit7 %s ,its powerer %s , and value %s" % (unit7, -1, convert_unit(-1, unit7)) 
    77     print "this unit8 %s ,its powerer %s , and value %s" % (unit8, 2, convert_unit(2, unit8)) 
    78     print "this unit9 %s ,its powerer %s , and value %s" % (unit9, 2, convert_unit(2, unit9)) 
     69    print("this unit1 %s ,its powerer %s , and value %s" % (unit1, 1, convert_unit(1, unit1))) 
     70    print("this unit2 %s ,its powerer %s , and value %s" % (unit2, 1, convert_unit(1, unit2))) 
     71    print("this unit3 %s ,its powerer %s , and value %s" % (unit3, 2, convert_unit(2, unit3))) 
     72    print("this unit4 %s ,its powerer %s , and value %s" % (unit4, -1, convert_unit(-1, unit4))) 
     73    print("this unit5 %s ,its powerer %s , and value %s" % (unit5, 2, convert_unit(2, unit5))) 
     74    print("this unit6 %s ,its powerer %s , and value %s" % (unit6, 2, convert_unit(2, unit6))) 
     75    print("this unit7 %s ,its powerer %s , and value %s" % (unit7, -1, convert_unit(-1, unit7))) 
     76    print("this unit8 %s ,its powerer %s , and value %s" % (unit8, 2, convert_unit(2, unit8))) 
     77    print("this unit9 %s ,its powerer %s , and value %s" % (unit9, 2, convert_unit(2, unit9))) 
    7978 
    8079 
Note: See TracChangeset for help on using the changeset viewer.