source: codes/icosagcm/devel/Python/dynamico/util.py @ 825

Last change on this file since 825 was 825, checked in by dubos, 5 years ago

devel/Python : moved Fortran bindings and *.pyx to dynamico/dev module + necessary changes to test/py/*.py

File size: 590 bytes
Line 
1def inverse_list(lst): return {j:i for i,j in enumerate(lst)}
2
3# list_stencil converts an adjacency graph from array format index[num_cells, MAX_EDGES] to compressed format
4def list_stencil(degree, stencil, cond=lambda x:True):
5    for i in range(degree.size):
6        for j in range(degree[i]):
7            s=stencil[i,j]
8            if cond(s): yield stencil[i,j]
9
10class BaseClass(object):
11    def set_members(self, loc, *names):
12        for name in names :
13            self.__dict__[name]=loc[name]
14    def members(self, *names):
15        return [ self.__dict__[name] for name in names ]
Note: See TracBrowser for help on using the repository browser.