Esempio n. 1
0
def test_remove_tmp_files_and_container():
    """Test remove temp files and container"""
    cft.remove_tmp_files("/tmp/mltsp_test")
    assert(not os.path.exists("/tmp/mltsp_test"))
    for tmp_file in [pjoin(cfg.TMP_CUSTOM_FEATS_FOLDER,
                           "custom_feature_defs.py"),
                     pjoin(cfg.TMP_CUSTOM_FEATS_FOLDER,
                           "custom_feature_defs.pyc"),
                     pjoin(cfg.TMP_CUSTOM_FEATS_FOLDER,
                           "__init__.pyc")]:
        assert(not os.path.exists(tmp_file))
Esempio n. 2
0
def test_extract_feats_in_docker_container():
    """Test custom feature extraction in Docker container"""
    tmp_dir_path = cft.make_tmp_dir()
    feats_known_dict_list = [{"feat1": 0.215, "feat2": 0.311}]
    ts_datafile_paths = [pjoin(DATA_PATH, "dotastro_215153.dat")]
    cft.add_tsdata_to_feats_known_dict(feats_known_dict_list,
                                       ts_datafile_paths, None)
    cft.copy_data_to_tmp_dir(tmp_dir_path,
                             pjoin(DATA_PATH, "testfeature1.py"),
                             feats_known_dict_list)
    results = cft.extract_feats_in_docker_container("test", tmp_dir_path)
    shutil.rmtree(tmp_dir_path, ignore_errors=True)
    cft.remove_tmp_files(tmp_dir_path)
    npt.assert_equal(len(results), 1)
    assert(isinstance(results[0], dict))
    npt.assert_almost_equal(results[0]["avg_mag"], 10.347417647058824)
Esempio n. 3
0
def test_extract_feats_in_docker_container():
    """Test custom feature extraction in Docker container"""
    tmp_dir_path = cft.make_tmp_dir()
    feats_known_dict = {"feat1": 0.215, "feat2": 0.311}
    ts_datafile = pjoin(DATA_PATH, "dotastro_215153.dat")
    t, m, e = ctt.parse_ts_data(ts_datafile)
    feats_known_dict['t'] = t
    feats_known_dict['m'] = m
    feats_known_dict['e'] = e
    cft.copy_data_to_tmp_dir(tmp_dir_path,
                             pjoin(DATA_PATH, "testfeature1.py"),
                             feats_known_dict)
    results = cft.extract_feats_in_docker_container("test", tmp_dir_path)
    shutil.rmtree(tmp_dir_path, ignore_errors=True)
    cft.remove_tmp_files(tmp_dir_path)
    assert(isinstance(results, dict))
    npt.assert_almost_equal(results["avg_mag"], 10.347417647058824)