Last change
on this file since 1078 was
1078,
checked in by Maciej Komosinski, 2 years ago
|
Direct connection from python to Framsticks .so/.dll
|
File size:
955 bytes
|
Line | |
---|
1 | import frams
|
---|
2 |
|
---|
3 | framspath = "" # set to where Framsticks binaries and libraries exist
|
---|
4 | frams.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 |
|
---|
6 | print('Available objects:', dir(frams))
|
---|
7 | print()
|
---|
8 |
|
---|
9 |
|
---|
10 | def extValueDetails(v):
|
---|
11 | return '"' + str(v) + '" frams type=' + str(v._type()) + ' frams class=' + str(v._class()) + ' python type=' + str(type(v._value()))
|
---|
12 |
|
---|
13 |
|
---|
14 | v = frams.String.deserialize('[100,2.2,"abc",[null,[]],XYZ[9,8,7]]')
|
---|
15 | print(extValueDetails(v))
|
---|
16 | for e in v:
|
---|
17 | print(extValueDetails(e))
|
---|
18 |
|
---|
19 | g = frams.GenePools[0].add('X')
|
---|
20 | g.name = "py!"
|
---|
21 | g.data['custom'] = 123.456
|
---|
22 | g.data['a'] = 'b'
|
---|
23 |
|
---|
24 | for more in range(5):
|
---|
25 | frams.GenePools[0].add(frams.GenMan.mutate(g.geno))
|
---|
26 |
|
---|
27 | for 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.