source: framspy/frams-test.py @ 1078

Last change on this file since 1078 was 1078, checked in by Maciej Komosinski, 3 years ago

Direct connection from python to Framsticks .so/.dll

File size: 955 bytes
Line 
1import frams
2
3framspath = "" # set to where Framsticks binaries and libraries exist
4frams.init(framspath, "-Ddata")  # "-D"+os.path.join(framspath,"data")) # not possible (maybe python windows issue) because of the need for os.chdir(). So we assume "data" is where the dll/so is
5
6print('Available objects:', dir(frams))
7print()
8
9
10def extValueDetails(v):
11        return '"' + str(v) + '"    frams type=' + str(v._type()) + '    frams class=' + str(v._class()) + '    python type=' + str(type(v._value()))
12
13
14v = frams.String.deserialize('[100,2.2,"abc",[null,[]],XYZ[9,8,7]]')
15print(extValueDetails(v))
16for e in v:
17        print(extValueDetails(e))
18
19g = frams.GenePools[0].add('X')
20g.name = "py!"
21g.data['custom'] = 123.456
22g.data['a'] = 'b'
23
24for more in range(5):
25        frams.GenePools[0].add(frams.GenMan.mutate(g.geno))
26
27for g in frams.GenePools[0]:
28        print(str(g.index) + '. "' + str(g.name) + '"  ' + str(g.genotype) + '  data=' + str(g.data))
Note: See TracBrowser for help on using the repository browser.