示例#1
0
文件: core.py 项目: candrayasa/anxcor
    def save_config(self, file):
        config = {}
        for task in self.TASKS:
            if task!='process':
                config[task] = self._get_task(task).get_kwargs()
            else:
                config[task] = {
                    'processing order' : self._process_order,
                }
                for key, process in self._get_task(task).items():
                    config[task][key]=process.get_kwargs()

        config['anxcor_configs'] = self._get_anxcor_config_dict()
        folder = utils.get_folderpath(file)
        if not utils.folder_exists(folder):
            print('given folder to save file does not exist. ignoring save call')
            return None
        with open(file, 'w') as configfile:
            json.dump(config,configfile, sort_keys=True, indent=4)
示例#2
0
 def set_folder(self, directory):
     self.enable()
     if not utils.folder_exists(directory):
         utils.make_dir(directory)
     self._file = directory
示例#3
0
 def _chkmkdir(self, dir):
     if not utils.folder_exists(dir):
         utils.make_dir(dir)
示例#4
0
 def set_folder(self, file):
     self.enable()
     if not utils.folder_exists(file):
         utils.make_dir(file)
     self._file = file
示例#5
0
import unittest
import os
from anxcor.utils import _clean_files_in_dir, _how_many_fmt
from anxcor.core import Anxcor
import anxcor.utils as utils
from anxcor.xarray_routines import XArrayTemporalNorm
import json
if os.path.isdir('tests'):
    basedir = 'tests/'
else:
    basedir = ''

save_dir = basedir + 'test_data/test_anxcor_database/test_save_config'
if not utils.folder_exists(save_dir):
    os.mkdir(save_dir)


class TestConfig(unittest.TestCase):
    def tearDown(self):
        _clean_files_in_dir(save_dir)

    def test_single_execution(self):
        anxcor = Anxcor(window_length=120.0)
        anxcor.save_config(save_dir + os.sep + 'config.ini')
        amnt = _how_many_fmt(save_dir, '.ini')
        assert amnt == 1

    def test_tau_is_correct(self):
        target_shift = 15.0
        anxcor = Anxcor(window_length=120.0)
        anxcor.set_task_kwargs('crosscorrelate',