source: framspy/frams-test.py @ 1085

Last change on this file since 1085 was 1085, checked in by sz, 3 years ago
  • more sophisticated frams.py init() so frams-test.py (and other python programs) don't have to bother with framsticks paths
  • './'+name for loading .so from the current directory in linux
File size: 1.1 KB
Line 
1import sys
2import frams
3
4frams.init(*(sys.argv[1:])) #pass whatever args we have, init() is the right place to deal with different scenrios:
5# frams.init() - should try to figure out everything (and might fail)
6# frams.init('path/to/frams') - load the library from the specified dir and configure framsticks path as "data" inside the dir
7# frams.init('path/to/frams','-d/tmp/workdir/data') - as above, but set the working (writable) directory somewhere else
8
9print('Available objects:', dir(frams))
10print()
11
12
13def extValueDetails(v):
14        return '"' + str(v) + '"    frams type=' + str(v._type()) + '    frams class=' + str(v._class()) + '    python type=' + str(type(v._value()))
15
16
17v = frams.String.deserialize('[100,2.2,"abc",[null,[]],XYZ[9,8,7]]')
18print(extValueDetails(v))
19for e in v:
20        print(extValueDetails(e))
21
22g = frams.GenePools[0].add('X')
23g.name = "py!"
24g.data['custom'] = 123.456
25g.data['a'] = 'b'
26
27for more in range(5):
28        frams.GenePools[0].add(frams.GenMan.mutate(g.geno))
29
30for g in frams.GenePools[0]:
31        print(str(g.index) + '. "' + str(g.name) + '"  ' + str(g.genotype) + '  data=' + str(g.data))
Note: See TracBrowser for help on using the repository browser.