Changeset 5251ec6 in sasview for src/sas/sasgui/plottools/convert_units.py
- Timestamp:
- Oct 11, 2018 12:20:56 PM (6 years ago)
- Branches:
- master, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1249
- Children:
- 98b9f32
- Parents:
- 67ed543
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/plottools/convert_units.py
ra1b8fee r5251ec6 13 13 """ 14 14 if power != 0: 15 if string.find(unit,"^") != -1: # if the unit contains a powerer ^16 toks = re.split( "\^", unit)17 if string.find(toks[0],"/") != -1 or \18 string.find(toks[0],"-") != -1:15 if unit.find("^") != -1: # if the unit contains a powerer ^ 16 toks = re.split(r"\^", unit) 17 if toks[0].find("/") != -1 or \ 18 toks[0].find("-") != -1: 19 19 if power == 1: 20 20 unit = unit … … 22 22 unit = "(" + unit + ")" + "^{" + str(power) + "}" 23 23 else: 24 if string.find(toks[1],"{") != -1: # if found a {24 if toks[1].find("{") != -1: # if found a { 25 25 find_power_toks = re.split("{", toks[1]) 26 if string.find(find_power_toks[1],"}") != -1: # found }26 if find_power_toks[1].find("}") != -1: # found } 27 27 unit_toks = re.split("}", find_power_toks[1]) 28 if string.find(unit_toks[0],".") != -1:28 if unit_toks[0].find(".") != -1: 29 29 powerer = float(unit_toks[0]) * power 30 elif string.find(unit_toks[0],"/") != -1:30 elif unit_toks[0].find("/") != -1: 31 31 power_toks = re.split("/", unit_toks[0]) 32 32 powerer = power * int(power_toks[0])\ … … 44 44 unit = toks[0] + "^{" + str(powerer) + "}" 45 45 else: 46 raise ValueError , "missing } in unit expression"46 raise ValueError("missing } in unit expression") 47 47 else: # no powerer 48 48 if power != 1: 49 49 unit = "(" + unit + ")" + "^{" + str(power) + "}" 50 50 else: 51 raise ValueError , "empty unit ,enter a powerer different from zero"51 raise ValueError("empty unit, enter a power different from zero") 52 52 return unit 53 53
Note: See TracChangeset
for help on using the changeset viewer.