<reponame>jorgetavares/pygenome
from examples.gp_symbolic_regression import *

stdout = """0	46.5	156.4659622692552	183.61738555063005
1	46.5	132.9971535108812	30.718266130054925
2	32.5	128.5541883214168	54.31393951939565
3	32.5	120.6432016022899	54.4296163866599
4	32.5	112.05901424354084	34.25275505830754
5	32.5	108.69988522388344	48.21225456199498
6	0.0	106.13761318452147	52.95476292541651
7	0.0	103.21213720474007	66.94877798064552
8	0.0	101.00397496253747	61.29930195354359
9	0.0	94.84191895511894	51.188043754699315
10	0.0	97.43871518619832	84.23737266236267
11	0.0	103.65756445349886	104.62251784545246
12	0.0	102.80692416037579	218.1486786374937
13	0.0	95.94325216470521	104.76108149874408
14	0.0	102.49213635456861	156.2766645529315
15	0.0	111.87826823753666	411.059172261407
16	0.0	91.66089151082672	72.17293906498097
17	0.0	100.02009204358022	265.2424580943246
18	0.0	91.05697118808851	103.3961365429734
19	0.0	96.15183694459546	190.67018240424457
fitness: 0.0	genotype: [ 3  4 11  7 11  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0]
"""


def test_gp_with_elitism(capfd):
    gp_with_elitism()
    out, err = capfd.readouterr()
    assert out == stdout

from examples.gp_symbolic_regression import *

stdout = """0	46.5	156.4659622692552	183.61738555063005
1	46.5	132.9971535108812	30.718266130054925
2	32.5	128.5541883214168	54.31393951939565
3	32.5	120.6432016022899	54.4296163866599
4	32.5	112.05901424354084	34.25275505830754
5	32.5	108.69988522388344	48.21225456199498
6	0.0	106.13761318452147	52.95476292541651
7	0.0	103.21213720474007	66.94877798064552
8	0.0	101.00397496253747	61.29930195354359
9	0.0	94.84191895511894	51.188043754699315
10	0.0	97.43871518619832	84.23737266236267
11	0.0	103.65756445349886	104.62251784545246
12	0.0	102.80692416037579	218.1486786374937
13	0.0	95.94325216470521	104.76108149874408
14	0.0	102.49213635456861	156.2766645529315
15	0.0	111.87826823753666	411.059172261407
16	0.0	91.66089151082672	72.17293906498097
17	0.0	100.02009204358022	265.2424580943246
18	0.0	91.05697118808851	103.3961365429734
19	0.0	96.15183694459546	190.67018240424457
fitness: 0.0	genotype: [ 3  4 11  7 11  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0]
"""


def test_gp_with_elitism(capfd):
    gp_with_elitism()
    out, err = capfd.readouterr()
    assert out == stdout
0	46.5	156.4659622692552	183.61738555063005 1	46.5	132.9971535108812	30.718266130054925 2	32.5	128.5541883214168	54.31393951939565 3	32.5	120.6432016022899	54.4296163866599 4	32.5	112.05901424354084	34.25275505830754 5	32.5	108.69988522388344	48.21225456199498 6	0.0	106.13761318452147	52.95476292541651 7	0.0	103.21213720474007	66.94877798064552 8	0.0	101.00397496253747	61.29930195354359 9	0.0	94.84191895511894	51.188043754699315 10	0.0	97.43871518619832	84.23737266236267 11	0.0	103.65756445349886	104.62251784545246 12	0.0	102.80692416037579	218.1486786374937 13	0.0	95.94325216470521	104.76108149874408 14	0.0	102.49213635456861	156.2766645529315 15	0.0	111.87826823753666	411.059172261407 16	0.0	91.66089151082672	72.17293906498097 17	0.0	100.02009204358022	265.2424580943246 18	0.0	91.05697118808851	103.3961365429734 19	0.0	96.15183694459546	190.67018240424457 fitness: 0.0	genotype: [ 3  4 11  7 11  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0   0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0   0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0   0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0   0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0   0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0   0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0   0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0   0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0   0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0   0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0]