def test_all_inputs(): import os from EvoDAG.command_line import CommandLineParams fname = training_set() sys.argv = ['EvoDAG', '-C', '--parameters', 'cache.evodag.gz', '-p3', '-e2', '--all-inputs', '-r', '2', fname] c = CommandLineParams() c.parse_args() os.unlink('cache.evodag.gz')
def test_all_inputs(): import os import json from EvoDAG.command_line import CommandLineParams fname = training_set() sys.argv = [ 'EvoDAG', '-C', '--parameters', 'cache.evodag', '-p3', '-e2', '-r', '2', fname ] c = CommandLineParams() c.parse_args() with open('cache.evodag') as fpt: a = json.loads(fpt.read())[0] assert 'all_inputs' in a os.unlink('cache.evodag') default_nargs()
def test_word2id2(): import tempfile import os from EvoDAG.command_line import CommandLineParams fname = tempfile.mktemp() id2word = dict([[0, 'a'], [1, 'b'], [2, 'c']]) with open(fname, 'w') as fpt: for x, v in zip(X, cl): l = x.tolist() l.append(id2word[v]) fpt.write(','.join(map(str, l))) fpt.write('\n') sys.argv = ['EvoDAG', '-C', '--parameters', 'cache.evodag', '-p3', '-e1', '-r', '2', fname] c = CommandLineParams() c.parse_args() print(len(c.word2id)) assert len(c.word2id) == 0 os.unlink('cache.evodag') os.unlink(fname)
def test_word2id2(): import tempfile import os from EvoDAG.command_line import CommandLineParams fname = tempfile.mktemp() id2word = dict([[0, 'a'], [1, 'b'], [2, 'c']]) with open(fname, 'w') as fpt: for x, v in zip(X, cl): l = x.tolist() l.append(id2word[v]) fpt.write(','.join(map(str, l))) fpt.write('\n') sys.argv = [ 'EvoDAG', '-C', '--parameters', 'cache.evodag', '-p3', '-e1', '-r', '2', fname ] c = CommandLineParams() c.parse_args() print(len(c.word2id)) assert len(c.word2id) == 0 os.unlink('cache.evodag') os.unlink(fname) default_nargs()
def test_generational(): import os from EvoDAG.command_line import CommandLineParams import gzip import json fname = training_set() sys.argv = ['EvoDAG', '-C', '--parameters', 'cache.evodag.gz', '-p3', '-e2', '--evolution', 'Generational', '-r', '2', fname] c = CommandLineParams() c.parse_args() with gzip.open('cache.evodag.gz') as fpt: data = fpt.read() try: a = json.loads(str(data, encoding='utf-8')) except TypeError: a = json.loads(data) a = a[0] assert 'population_class' in a assert a['population_class'] == 'Generational' os.unlink('cache.evodag.gz') print(a)
def test_nan(): import numpy as np from EvoDAG.command_line import CommandLineParams c = CommandLineParams() assert np.isfinite(c.inputs.convert_label('NaN')) default_nargs()