- Timestamp:
- Mar 7, 2019, 7:53:54 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/generic_tools.py
r2373 r2380 193 193 # str_list_k: Function to obtain a list of types of values from a string giving a split character 194 194 # str_list_rep: Function to obtain a list from a string givin a split character and a total number of values 195 # stringS_dictvar: Function to provide a dictionary from a Srting which list of DVs separated [key] [value] couples 195 # stringS_dictvar: Function to provide a dictionary from a String which list of DVs separated 196 # [key] [value] couples 197 # stringS_dictvark: Function to provide a dictionary from a String which list of DVs separated 198 # [key] [value] couples and assigning a variable-type to the value 196 199 # stringList_dictKeysVals: Function to provide a dictionary with keys which contain values of lists from a string 197 200 # subbasin_point: Function to provide sub-basins given a grid point following a matrix of trips … … 9744 9747 9745 9748 def stringS_dictvar(stringv, Dc=',', DVs=':'): 9746 """ Function to provide a dictionary from a Srting which list of DVs separated [key] [value] couples 9749 """ Function to provide a dictionary from a String which list of DVs separated 9750 [key] [value] couples 9747 9751 stringv: String with a dictionary content as [key1][DVs][val1][Dc][key2][DVs][Val2][Dc]... 9748 9752 Sc: character to separate key values … … 9757 9761 valn = Svals.split(DVs)[1] 9758 9762 dictv[keyn] = valn 9763 9764 return dictv 9765 9766 def stringS_dictvark(stringv, Dc=',', DVs=':', kind='np.float'): 9767 """ Function to provide a dictionary from a String which list of DVs separated 9768 [key] [value] couples and assigning a variable-type to the value 9769 stringv: String with a dictionary content as [key1][DVs][val1][Dc][key2][DVs][Val2][Dc]... 9770 Sc: character to separate key values 9771 DVs: character to separate key-value couples 9772 kind: ind of value to assign to all the values 9773 >>> stringS_dictvark('i:1,iv:4,vii:7',',',':') 9774 {'i': 1.0, 'vii': 7.0, 'iv': 4.0} 9775 """ 9776 fname = 'stringS_dictvark' 9777 dictv = {} 9778 for Svals in stringv.split(Dc): 9779 keyn = Svals.split(DVs)[0] 9780 valn = Svals.split(DVs)[1] 9781 dictv[keyn] = typemod(valn, kind) 9759 9782 9760 9783 return dictv
Note: See TracChangeset
for help on using the changeset viewer.