From 5837254ca73df2e5de432e7e409ddbbb3edf10da Mon Sep 17 00:00:00 2001 From: Gregory Ashton <gregory.ashton@ligo.org> Date: Wed, 9 Aug 2017 18:16:53 +0200 Subject: [PATCH] Adds from __future__ imports to an in Python3 compaitibility --- examples/follow_up.py | 5 +++-- examples/fully_coherent_search_using_MCMC.py | 6 +++--- pyfstat/core.py | 5 ++++- pyfstat/grid_based_searches.py | 8 +++++--- pyfstat/make_sfts.py | 5 +++-- pyfstat/mcmc_based_searches.py | 10 +++++----- pyfstat/optimal_setup_functions.py | 3 ++- 7 files changed, 25 insertions(+), 17 deletions(-) diff --git a/examples/follow_up.py b/examples/follow_up.py index d79b9a6..675c2e0 100644 --- a/examples/follow_up.py +++ b/examples/follow_up.py @@ -21,7 +21,7 @@ theta_prior = {'F0': {'type': 'unif', 'lower': F0*(1-1e-6), 'upper': F0*(1+1e-5) ntemps = 1 log10temperature_min = -1 nwalkers = 100 -run_setup = [(1000, 50), (1000, 25), (1000, 1, False), +run_setup = [(1000, 50), (1000, 25), (1000, 1, False), ((500, 500), 1, True)] mcmc = pyfstat.MCMCFollowUpSearch( @@ -29,6 +29,7 @@ mcmc = pyfstat.MCMCFollowUpSearch( sftfilepattern='data/*basic*sft', theta_prior=theta_prior, tref=tref, minStartTime=tstart, maxStartTime=tend, nwalkers=nwalkers, ntemps=ntemps, log10temperature_min=log10temperature_min) -mcmc.run(run_setup) +mcmc.run(run_setup, gen_tex_table=True) +#mcmc.run(Nsegs0=50) mcmc.plot_corner(add_prior=True) mcmc.print_summary() diff --git a/examples/fully_coherent_search_using_MCMC.py b/examples/fully_coherent_search_using_MCMC.py index 254f791..353ac61 100644 --- a/examples/fully_coherent_search_using_MCMC.py +++ b/examples/fully_coherent_search_using_MCMC.py @@ -48,14 +48,14 @@ theta_prior = {'F0': {'type': 'unif', ntemps = 1 log10temperature_min = -1 -nwalkers = 1000 -nsteps = [50, 50] +nwalkers = 100 +nsteps = [1000, 1000] mcmc = pyfstat.MCMCSearch( label='fully_coherent_search_using_MCMC', outdir='data', sftfilepattern='data/*'+data_label+'*sft', theta_prior=theta_prior, tref=tref, minStartTime=tstart, maxStartTime=tend, nsteps=nsteps, nwalkers=nwalkers, ntemps=ntemps, log10temperature_min=log10temperature_min) -mcmc.run(context='paper', subtractions=[30, -1e-10]) +mcmc.run(context='paper', subtractions=[30, -1e-10], c=2) mcmc.plot_corner(add_prior=True) mcmc.print_summary() diff --git a/pyfstat/core.py b/pyfstat/core.py index 2bf275a..9249248 100755 --- a/pyfstat/core.py +++ b/pyfstat/core.py @@ -1,8 +1,11 @@ """ The core tools used in pyfstat """ +from __future__ import division, absolute_import, print_function + import os import logging import copy + import glob import numpy as np import scipy.special @@ -10,7 +13,7 @@ import scipy.optimize import lal import lalpulsar -import helper_functions +import pyfstat.helper_functions as helper_functions # workaround for matplotlib on X-less remote logins if 'DISPLAY' in os.environ: diff --git a/pyfstat/grid_based_searches.py b/pyfstat/grid_based_searches.py index 2974c1b..dece311 100644 --- a/pyfstat/grid_based_searches.py +++ b/pyfstat/grid_based_searches.py @@ -1,4 +1,5 @@ """ Searches using grid-based methods """ +from __future__ import division, absolute_import, print_function import os import logging @@ -9,9 +10,10 @@ import numpy as np import matplotlib import matplotlib.pyplot as plt -import helper_functions -from core import BaseSearchClass, ComputeFstat, SemiCoherentGlitchSearch, SemiCoherentSearch -from core import tqdm, args, earth_ephem, sun_ephem, read_par +import pyfstat.helper_functions as helper_functions +from pyfstat.core import (BaseSearchClass, ComputeFstat, + SemiCoherentGlitchSearch, SemiCoherentSearch, tqdm, + args, earth_ephem, sun_ephem, read_par) class GridSearch(BaseSearchClass): diff --git a/pyfstat/make_sfts.py b/pyfstat/make_sfts.py index 84c6e3a..ea3028a 100644 --- a/pyfstat/make_sfts.py +++ b/pyfstat/make_sfts.py @@ -1,4 +1,5 @@ """ pyfstat tools to generate sfts """ +from __future__ import division, absolute_import, print_function import numpy as np import logging @@ -9,8 +10,8 @@ import pkgutil import lal import lalpulsar -from core import BaseSearchClass, tqdm, args -import helper_functions +from pyfstat.core import BaseSearchClass, tqdm, args +import pyfstat.helper_functions as helper_functions earth_ephem, sun_ephem = helper_functions.set_up_ephemeris_configuration() diff --git a/pyfstat/mcmc_based_searches.py b/pyfstat/mcmc_based_searches.py index fddf77f..e2836b1 100644 --- a/pyfstat/mcmc_based_searches.py +++ b/pyfstat/mcmc_based_searches.py @@ -1,4 +1,5 @@ """ Searches using MCMC-based methods """ +from __future__ import division, absolute_import, print_function import sys import os @@ -14,11 +15,10 @@ import emcee import corner import dill as pickle -import core -from core import tqdm, args, earth_ephem, sun_ephem, read_par -from optimal_setup_functions import get_V_estimate -from optimal_setup_functions import get_optimal_setup -import helper_functions +import pyfstat.core as core +from pyfstat.core import tqdm, args, earth_ephem, sun_ephem, read_par +from pyfstat.optimal_setup_functions import get_V_estimate, get_optimal_setup +import pyfstat.helper_functions as helper_functions class MCMCSearch(core.BaseSearchClass): diff --git a/pyfstat/optimal_setup_functions.py b/pyfstat/optimal_setup_functions.py index 543fed8..25017ce 100644 --- a/pyfstat/optimal_setup_functions.py +++ b/pyfstat/optimal_setup_functions.py @@ -4,13 +4,14 @@ Provides functions to aid in calculating the optimal setup based on the metric volume estimates. """ +from __future__ import division, absolute_import, print_function import logging import numpy as np import scipy.optimize import lal import lalpulsar -import helper_functions +import pyfstat.helper_functions as helper_functions def get_optimal_setup( -- GitLab