Skip to content

Commit

Permalink
version bump and deprecation banners
Browse files Browse the repository at this point in the history
  • Loading branch information
JesusTorrado committed Apr 11, 2019
1 parent 68af19d commit 688bdd4
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 11 deletions.
6 changes: 2 additions & 4 deletions CHANGELOG.md
@@ -1,8 +1,6 @@
# CHANGELOG
## 1.0.4 – 2019-04-12

## 1.1beta – [no release date yet]

(Among many bugfixes...)
### Many bugfixes -- special thanks to Guadalupe Cañas-Herrera and Vivian Miranda!

### I/O

Expand Down
2 changes: 1 addition & 1 deletion LICENCE.txt
@@ -1,4 +1,4 @@
Copyright 2017-2018 Jesus Torrado and Antony Lewis
Copyright 2017-2019 Jesus Torrado and Antony Lewis

You are licensed to use this software free of charge within the terms of the LGPL (see below), with two additional conditions (from CAMB.info):

Expand Down
5 changes: 3 additions & 2 deletions cobaya/__init__.py
@@ -1,4 +1,5 @@
__author__ = "Jesus Torrado and Antony Lewis"
__version__ = "1.0.3"
__year__ = "2018"
__version__ = "1.0.4"
__obsolete__ = True
__year__ = "2019"
__url__ = "https://cobaya.readthedocs.io"
3 changes: 2 additions & 1 deletion cobaya/citation.py
Expand Up @@ -16,7 +16,7 @@
from collections import OrderedDict as odict

# Local
from cobaya.tools import get_folder, make_header
from cobaya.tools import get_folder, make_header, warn_deprecation
from cobaya.input import get_modules


Expand Down Expand Up @@ -53,6 +53,7 @@ def prettyprint_citation(blocks_text):
def citation_script():
from cobaya.mpi import am_single_or_primary_process
if am_single_or_primary_process():
warn_deprecation()
# Configure the logger ASAP
from cobaya.log import logger_setup
logger_setup()
Expand Down
1 change: 1 addition & 0 deletions cobaya/cosmo_input/gui.py
Expand Up @@ -200,6 +200,7 @@ def copy_clipb(self):


def gui_script():
warn_deprecation()
try:
app = QApplication(sys.argv)
except NameError:
Expand Down
3 changes: 2 additions & 1 deletion cobaya/install.py
Expand Up @@ -21,7 +21,7 @@

# Local
from cobaya.log import logger_setup, HandledException
from cobaya.tools import get_folder, make_header
from cobaya.tools import get_folder, make_header, warn_deprecation
from cobaya.input import get_modules
from cobaya.conventions import _package, _code, _data, _likelihood, _external
from cobaya.conventions import _modules_path_arg, _path_install
Expand Down Expand Up @@ -195,6 +195,7 @@ def pip_install(packages):
def install_script():
from cobaya.mpi import am_single_or_primary_process
if not am_single_or_primary_process():
warn_deprecation()
# Configure the logger ASAP
logger_setup()
log = logging.getLogger(__name__.split(".")[-1])
Expand Down
2 changes: 2 additions & 0 deletions cobaya/run.py
Expand Up @@ -25,6 +25,7 @@
from cobaya.yaml import yaml_dump
from cobaya.input import get_full_info
from cobaya.mpi import import_MPI, am_single_or_primary_process
from cobaya.tools import warn_deprecation


def run(info):
Expand Down Expand Up @@ -71,6 +72,7 @@ def run(info):

# Command-line script
def run_script():
warn_deprecation()
import os
import argparse
parser = argparse.ArgumentParser(description="Cobaya's run script.")
Expand Down
42 changes: 40 additions & 2 deletions cobaya/tools.py
Expand Up @@ -20,9 +20,9 @@
from collections import Mapping, OrderedDict as odict
from ast import parse
if six.PY3:
from inspect import getfullargspec as getargspec
from inspect import cleandoc, getfullargspec as getargspec
else:
from inspect import getargspec
from inspect import cleandoc, getargspec

# Local
from cobaya.conventions import _package, subfolders, _p_dist, _likelihood, _p_value
Expand Down Expand Up @@ -269,3 +269,41 @@ def KL_norm(m1=None, S1=np.array([]), m2=None, S2=np.array([])):
KL = 0.5 * (np.trace(S2inv.dot(S1)) + (m1 - m2).dot(S2inv).dot(m1 - m2) -
dim + np.log(np.linalg.det(S2) / np.linalg.det(S1)))
return KL


def create_banner(msg):
"""
Puts message into an attention-grabbing banner.
"""
msg_clean = cleandoc(msg)
longest_line_len = max([len(line) for line in msg_clean.split("\n")])
return ("*"*longest_line_len + "\n" + msg_clean + "\n" + "*"*longest_line_len)


def warn_deprecation_python2():
msg = """
*WARNING*: Python 2 support will eventually be dropped
(it is already unsupported by many scientific Python modules).
Please use Python 3!
In some systems, the Python 3 command may be python3 instead of python.
If that is the case, use pip3 instead of pip to install Cobaya.
"""
if not six.PY3:
print(create_banner(msg))


def warn_deprecation_version():
msg = """
*WARNING*: You are using an obsolete version of Cobaya, which is no loger maintained.
Please, update asap to the last version (e.g. with ``pip install cobaya --upgrade``).
"""
if __obsolete__:
print(create_banner(msg))


def warn_deprecation():
warn_deprecation_python2()
warn_deprecation_version()

0 comments on commit 688bdd4

Please sign in to comment.