Skip to content
Snippets Groups Projects
Commit 6d8908e5 authored by Gregory Ashton's avatar Gregory Ashton
Browse files

Add helper to make the outdir if it does not already exist

parent 00de5b10
No related branches found
No related tags found
No related merge requests found
Pipeline #
......@@ -10,6 +10,7 @@ from chainconsumer import ChainConsumer
from .result import Result
from .prior import Prior
from . import utils
class Sampler(object):
......@@ -273,6 +274,8 @@ def run_sampler(likelihood, priors, label='label', outdir='outdir',
An object containing the results, and the sampler instance (useful
for creating plots etc)
"""
utils.check_directory_exists_and_if_not_mkdir(outdir)
implemented_samplers = get_implemented_samplers()
if implemented_samplers.__contains__(sampler.title()):
......
from __future__ import division
import logging
import os
import numpy as np
from astropy.time import Time
......@@ -272,3 +273,11 @@ def setup_logger(log_level='info'):
stream_handler.setLevel(LEVEL)
logger.addHandler(stream_handler)
def check_directory_exists_and_if_not_mkdir(directory):
if not os.path.exists(directory):
os.makedirs(directory)
logging.debug('Making directory {}'.format(directory))
else:
logging.debug('Directory {} exists'.format(directory))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment