Skip to content

Commit

Permalink
Code style black (#1201)
Browse files Browse the repository at this point in the history
* add pyproject with black settings

* black codestyle for all except model, montecarlo

* Update tardis/io/atom_data/util.py

Co-authored-by: Jaladh Singhal <[email protected]>

* Update tardis/io/atom_data/util.py

Co-authored-by: Jaladh Singhal <[email protected]>

* Update tardis/io/config_reader.py

* Update tardis/io/config_reader.py

* Update tardis/io/decay.py

* Update tardis/io/util.py

Co-authored-by: Jaladh Singhal <[email protected]>

* Update tardis/plasma/properties/general.py

Co-authored-by: Wolfgang Kerzendorf <[email protected]>

* Update tardis/plasma/properties/general.py

Co-authored-by: Jaladh Singhal <[email protected]>

* Update tardis/plasma/properties/nlte.py

Co-authored-by: Jaladh Singhal <[email protected]>

* Update tardis/plasma/properties/partition_function.py

Co-authored-by: Jaladh Singhal <[email protected]>

* Update tardis/plasma/properties/partition_function.py

Co-authored-by: Wolfgang Kerzendorf <[email protected]>

* Delete properties.py

* Update tardis/plasma/standard_plasmas.py

Co-authored-by: Wolfgang Kerzendorf <[email protected]>

* Delete test_montecarlo.py

Co-authored-by: Jaladh Singhal <[email protected]>
  • Loading branch information
wkerzendorf and jaladh-singhal authored Jun 26, 2020
1 parent e8ab660 commit 3297d26
Show file tree
Hide file tree
Showing 78 changed files with 5,078 additions and 3,191 deletions.
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[tool.black]
line-length = 80
target-version = ['py36']
9 changes: 6 additions & 3 deletions tardis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,29 @@
import pyne.data

from tardis.util.colored_logger import ColoredFormatter, formatter_message

# Affiliated packages may add whatever they like to this file, but
# should keep this content at the top.
# ----------------------------------------------------------------------------
from ._astropy_init import *

# ----------------------------------------------------------------------------

from tardis.base import run_tardis
from tardis.io.util import yaml_load_config_file as yaml_load
warnings.filterwarnings('ignore', category=pyne.data.QAWarning)

warnings.filterwarnings("ignore", category=pyne.data.QAWarning)

FORMAT = "[$BOLD%(name)-20s$RESET][%(levelname)-18s] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)"
COLOR_FORMAT = formatter_message(FORMAT, True)

logging.captureWarnings(True)
logger = logging.getLogger('tardis')
logger = logging.getLogger("tardis")
logger.setLevel(logging.INFO)

console_handler = logging.StreamHandler(sys.stdout)
console_formatter = ColoredFormatter(COLOR_FORMAT)
console_handler.setFormatter(console_formatter)

logger.addHandler(console_handler)
logging.getLogger('py.warnings').addHandler(console_handler)
logging.getLogger("py.warnings").addHandler(console_handler)
65 changes: 49 additions & 16 deletions tardis/_astropy_init.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# Licensed under a 3-clause BSD style license - see LICENSE.rst

__all__ = ['__version__', '__githash__', 'test']
__all__ = ["__version__", "__githash__", "test"]

# this indicates whether or not we are in the package's setup.py
try:
_ASTROPY_SETUP_
except NameError:
from sys import version_info

if version_info[0] >= 3:
import builtins
else:
Expand All @@ -16,21 +17,34 @@
try:
from .version import version as __version__
except ImportError:
__version__ = ''
__version__ = ""
try:
from .version import githash as __githash__
except ImportError:
__githash__ = ''
__githash__ = ""

# set up the test command
def _get_test_runner():
import os
from astropy.tests.helper import TestRunner

return TestRunner(os.path.dirname(__file__))

def test(package=None, test_path=None, args=None, plugins=None,
verbose=False, pastebin=None, remote_data=False, pep8=False,
pdb=False, coverage=False, open_files=False, **kwargs):

def test(
package=None,
test_path=None,
args=None,
plugins=None,
verbose=False,
pastebin=None,
remote_data=False,
pep8=False,
pdb=False,
coverage=False,
open_files=False,
**kwargs,
):
"""
Run the tests using `py.test <http://pytest.org/latest>`__. A proper set
of arguments is constructed and passed to `pytest.main`_.
Expand Down Expand Up @@ -105,10 +119,20 @@ def test(package=None, test_path=None, args=None, plugins=None,
"""
test_runner = _get_test_runner()
return test_runner.run_tests(
package=package, test_path=test_path, args=args,
plugins=plugins, verbose=verbose, pastebin=pastebin,
remote_data=remote_data, pep8=pep8, pdb=pdb,
coverage=coverage, open_files=open_files, **kwargs)
package=package,
test_path=test_path,
args=args,
plugins=plugins,
verbose=verbose,
pastebin=pastebin,
remote_data=remote_data,
pep8=pep8,
pdb=pdb,
coverage=coverage,
open_files=open_files,
**kwargs,
)


if not _ASTROPY_SETUP_:
import os
Expand All @@ -118,21 +142,30 @@ def test(package=None, test_path=None, args=None, plugins=None,
# add these here so we only need to cleanup the namespace at the end
config_dir = None

if not os.environ.get('ASTROPY_SKIP_CONFIG_UPDATE', False):
if not os.environ.get("ASTROPY_SKIP_CONFIG_UPDATE", False):
config_dir = os.path.dirname(__file__)
config_template = os.path.join(config_dir, __package__ + ".cfg")
if os.path.isfile(config_template):
try:
config.configuration.update_default_config(
__package__, config_dir, version=__version__)
__package__, config_dir, version=__version__
)
except TypeError as orig_error:
try:
config.configuration.update_default_config(
__package__, config_dir)
__package__, config_dir
)
except config.configuration.ConfigurationDefaultMissingError as e:
wmsg = (e.args[0] + " Cannot install default profile. If you are "
"importing from source, this is expected.")
warn(config.configuration.ConfigurationDefaultMissingWarning(wmsg))
wmsg = (
e.args[0]
+ " Cannot install default profile. If you are "
"importing from source, this is expected."
)
warn(
config.configuration.ConfigurationDefaultMissingWarning(
wmsg
)
)
del e
except:
raise orig_error
Loading

0 comments on commit 3297d26

Please sign in to comment.