How to use load_by_file method in lisa

Best Python code snippet using lisa_python

locate_object.py

Source:locate_object.py Github

copy

Full Screen

...26 """27 if not np.isscalar(snapnum):28 raise TypeError('The input snapnum should be one number,' +29 ' process subhalos in different snapshots separately.')30 sim.load_by_file('SubLinkOffsets', snapnum, fields = ['SubhaloID'])31 subhaloid = sim.loaded['SubLinkOffsets'32 + str(snapnum)]['SubhaloID'][subfindid]33 return subhaloid34def chunk_num(subhaloid):35 """ Identifies the chunk of the SubLink tree for given subhalo(s). This36 information is available from the subhaloid alone and does not depend on37 the simulation box.38 Parameters39 ----------40 subhaloid : int or array_like41 The SubhaloID(s) of the subhalos to locate. SubhaloID is the SubLink42 index and is unique throughout all snapshots.43 Returns44 -------45 chunknum : int or array_like46 The SubLink chunk number of the given subhalos. Has same shape as the47 input subhaloid.48 samechunk : bool49 True if all the given subhalos are in the same tree file chunk, False50 otherwise.51 """52 if np.isscalar(subhaloid):53 if subhaloid == -1:54 raise ValueError('SubhaloID cannot be -1.')55 return subhaloid // _sl_chunk_const, True56 chunknum = np.array(subhaloid) // _sl_chunk_const57 if np.any(subhaloid == -1):58 raise ValueError('SubhaloID cannot be -1.')59 samechunk = len(np.unique(chunknum)) == 160 return chunknum, samechunk61def row_in_chunk(subhaloid, sim):62 """ Locates subhalo(s) within a tree file chunk.63 Parameters64 ----------65 subhaloid : int or array_like66 The SubhaloID(s) of the subhalos to locate. SubhaloID is the SubLink67 index and is unique throughout all snapshots.68 sim : class obj69 Instance of the simulation_box.SimulationBox class, which specifies the70 simulation box to work with.71 Returns72 -------73 rownum : int or array_like74 The row indices of the given subhalos in the tree chunk. Has same shape75 as the input subhaloid.76 chunknum : int77 The SubLink chunk number of the given subhalos. Subhalos required to be78 in the same chunk.79 """80 chunknum, samechunk = chunk_num(subhaloid)81 if not samechunk:82 raise ValueError('The subhalos should be in the same tree chunk,' +83 ' process subhalos in different chunks separately.' +84 ' Index of the first subhalo in a different chunk ' +85 'is {}.'.format(np.sort(np.unique(chunknum,86 return_index = True)[1])[1]))87 if not np.isscalar(chunknum):88 chunknum = chunknum[0]89 sim.load_by_file('SubLink', chunknum, fields = ['SubhaloID'])90 rownum = np.searchsorted(sim.loaded['SubLink' + str(chunknum)]\91 ['SubhaloID'],92 subhaloid)93 if np.any(subhaloid != sim.loaded['SubLink' + str(chunknum)]\94 ['SubhaloID'][rownum]):95 raise ValueError('Some of the SubhaloIDs do not exist.')96 return rownum, chunknum97def _chunk_num(subhaloid):98 if np.isscalar(subhaloid):99 return subhaloid // _sl_chunk_const100 return subhaloid[0] // _sl_chunk_const101def _row_in_chunk(subhaloid, sim):102 chunknum = _chunk_num(subhaloid)103 sim.load_by_file('SubLink', chunknum, fields = ['SubhaloID'])104 rownum = np.searchsorted(sim.loaded['SubLink' + str(chunknum)]\105 ['SubhaloID'],106 subhaloid)107 return rownum, chunknum108def subfind_id(subhaloid, sim, internal=False):109 """ Converts subhalo SubhaloID(s) to SubfindID(s) and SnapNum(s).110 Processes any number of subhalos in the same tree chunk.111 Parameters112 ----------113 subhaloid : int or array_like114 The SubhaloID(s) of the subhalos to convert. SubhaloID is the SubLink115 index and is unique throughout all snapshots.116 sim : class obj117 Instance of the simulation_box.SimulationBox class, which specifies the118 simulation box to work with.119 internal : bool120 Whether this function is called internally. User should always leave it121 as False.122 Returns123 -------124 subfindid : int or array_like125 The SubfindID(s) of the given subhalo(s). SubfindID is only unique126 within each snapshot and not throughout the history. Has same shape127 as the input subhaloid.128 snapnum : int or array_like129 The snapshot number(s) of the subhalo(s). Has same shape as the input130 subhaloid.131 """132 if internal:133 rownum, chunknum = _row_in_chunk(subhaloid, sim)134 else:135 rownum, chunknum = row_in_chunk(subhaloid, sim)136 sim.load_by_file('SubLink', chunknum,137 fields = ['SubfindID', 'SnapNum'])138 subfindid = sim.loaded['SubLink' + str(chunknum)]['SubfindID'][rownum]139 snapnum = sim.loaded['SubLink' + str(chunknum)]['SnapNum'][rownum]140 return subfindid, snapnum141def subfind_central(groupnum, snapnum, sim):142 """ Finds the SubfindID of the primary (most massive) subhalo in a143 given FOF group. Processes any number of groups in the same snapshot.144 Parameters145 ----------146 groupnum : int or array_like147 The group number(s) to find the primary subhalo(s) for. Group number148 is the index of the FOF group in the group catalog. The group number149 is only unique within each snapshot and not throughout the history.150 snapnum : int151 The snapshot number that contains the group(s). Should be one number.152 sim : class obj153 Instance of the simulation_box.SimulationBox class, which specifies154 the simulation box to work with.155 Returns156 -------157 central : int or array_like158 The SubfindID(s) of primary subhalo(s) of the given groups. Has same159 shape as the input groupnum. The SubfindID is only unique within160 each snapshot and not throughout the history.161 """162 if not np.isscalar(snapnum):163 raise TypeError('The input snapnum should be one number.')164 sim.load_by_file('Group', snapnum, fields = ['GroupFirstSub'])165 central = sim.loaded['Group'166 + str(snapnum)]['GroupFirstSub'][groupnum]167 return central168def group_num(subhaloid, sim, internal=False):169 """ Identifies the index(es) of the halo(s) hosting the input subhalo(s)170 given the SubhaloID(s) and snapshot. Processes any number of subhalos in171 the same tree chunk.172 Parameters173 ----------174 subhaloid : int or array_like175 The SubhaloID(s) of the subhalos to find group numbers for. SubhaloID176 is the ID assigned by SubLink and is unique throughout all snapshots.177 sim : class obj178 Instance of the simulation_box.SimulationBox class, which specifies179 the simulation box to work with.180 internal : bool181 Whether this function is called internally. User should always leave it182 as False.183 Returns184 -------185 groupnum : int or array_like186 The SubhaloGrNr(s) of the given subhalos. Has same shape as the input187 subhaloid. SubhaloGrNr is the index of the halo in the group catalog.188 snapnum : int189 The snapshot number that contains the subhalo(s). Should be one number.190 """191 if internal:192 rownum, chunknum = _row_in_chunk(subhaloid, sim)193 else:194 rownum, chunknum = row_in_chunk(subhaloid, sim)195 sim.load_by_file('SubLink', chunknum,196 fields = ['SubhaloGrNr', 'SnapNum'])197 groupnum = sim.loaded['SubLink' + str(chunknum)]['SubhaloGrNr'][rownum]198 snapnum = sim.loaded['SubLink' + str(chunknum)]['SnapNum'][rownum]199 return groupnum, snapnum200def is_subfind_central(subhaloid, sim):201 """202 """203 rownum, chunknum = row_in_chunk(subhaloid, sim)204 sim.load_by_file('SubLink', chunknum,205 fields = ['SubfindID', 'GroupFirstSub'])206 subfindid = sim.loaded['SubLink' + str(chunknum)]['SubfindID'][rownum]207 subfindcen = sim.loaded['SubLink' + str(chunknum)]['GroupFirstSub'][rownum]208 return subfindid == subfindcen209def is_sublink_central():210 """211 """212 rownum, chunknum = row_in_chunk(subhaloid, sim)213 sim.load_by_file('SubLink', chunknum,214 fields = ['SubhaloID', 'FirstSubhaloInFOFGroupID'])215 subhaloid = sim.loaded['SubLink' + str(chunknum)]['SubhaloID'][rownum]216 sublinkcen = sim.loaded['SubLink' + str(chunknum)]\217 ['FirstSubhaloInFOFGroupID'][rownum]...

Full Screen

Full Screen

datasetLoader.py

Source:datasetLoader.py Github

copy

Full Screen

...32 )33 )34 return df35 # データ読み込み処理36 def load_by_file(self, in_FilePath):37 """SQLファイルを実行し、dfに入れる38 Parameters39 ----------40 in_FilePath : ファイルパス41 Returns42 -------43 df : pandasのdataframeが返る44 Examples45 --------46 >>> import datasetLoader47 >>> dataset_loader = datasetLoader()48 >>> df = dataset_loader.load_by_file( "./test.sql" )49 """50 whole_dataset = []51 lines = self.__filePathToLines(in_FilePath)52 whole_dataset = self.__sqlToDataframe(lines)53 return whole_dataset54 # データ読み込み処理55 def load(self, lines):56 """SQLを実行し、dfに入れる57 Parameters58 ----------59 lines : SQL文60 Returns61 -------62 df : pandasのdataframeが返る...

Full Screen

Full Screen

collect_git.py

Source:collect_git.py Github

copy

Full Screen

...12 sys.exit(2)13 for opt, arg in opts:14 print((opt, arg))15 if opt == "-f":16 load_by_file(arg, update)17 sys.exit()18 elif opt == "-u":19 load_by_URL(arg, update)20 elif opt == "-g":21 load_by_org(arg, update)22def load_by_file(filePath, update=False):23 urls = open(filePath, "r")24 for url in urls:25 loader.get_repo(url, "remote", update)26def load_by_URL(url, update=False):27 loader.get_repo(url, "remote", update)28def load_by_org(org_name, update=False):29 loader.get_org_repos(org_name)30if __name__ == "__main__":...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run lisa automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful