diff --git a/.github/workflows/black-check.yml b/.github/workflows/black-check.yml new file mode 100644 index 00000000000..7b8394ae7e1 --- /dev/null +++ b/.github/workflows/black-check.yml @@ -0,0 +1,26 @@ +# For more information on how to use this template please refer to: +# http://tardis-sn.github.io/tardis/development/continuous_integration.html + +name: black + +on: + pull_request: + branches: + - master + +jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: 3.x + + - name: Install Black + run: pip install black + + - name: Run Black + run: black --check tardis diff --git a/tardis/gui/datahandler.py b/tardis/gui/datahandler.py index 357c451314e..57de369e3cd 100644 --- a/tardis/gui/datahandler.py +++ b/tardis/gui/datahandler.py @@ -39,15 +39,15 @@ class Node(object): Attributes ---------- - parent : None/Node + parent : None/Node The parent of the node. children : list of Node The children of the node. - data : list of string + data : list of string The data stored on the node. Can be a key or a value. - siblings : dictionary - A dictionary of nodes that are siblings of this node. The - keys are the values of the nodes themselves. This is + siblings : dictionary + A dictionary of nodes that are siblings of this node. The + keys are the values of the nodes themselves. This is used to keep track of which value the user has selected if the parent of this node happens to be a key that can take values from a list. @@ -60,8 +60,8 @@ def __init__(self, data, parent=None): ---------- data : list of string The data that is intended to be stored on the node. - parent : Node - Another node which is the parent of this node. The + parent : Node + Another node which is the parent of this node. The root node has parent set to None. Note @@ -164,10 +164,10 @@ class TreeModel(QtCore.QAbstractItemModel): ---------- root : Node Root node of the tree. - disabledNodes : list of Node + disabledNodes : list of Node List of leaf nodes that are not editable currently. - typenodes : list of Node - List of nodes that correspond to keys that set container + typenodes : list of Node + List of nodes that correspond to keys that set container types. Look at tardis configuration template. These are the nodes that have values that can be set from a list. """ @@ -177,9 +177,9 @@ def __init__(self, dictionary, parent=None): Parameters ---------- - dictionary : dictionary + dictionary : dictionary The dictionary that needs to be converted to the tree. - parent : None + parent : None Used to instantiate the QAbstractItemModel """ QtCore.QAbstractItemModel.__init__(self, parent) @@ -347,7 +347,7 @@ def dict_to_tree(self, dictionary, root): ---------- dictionary : dictionary The dictionary that is to be converted to the tree. - root : Node + root : Node The root node of the tree. """ # Construct tree with all nodes diff --git a/tardis/gui/interface.py b/tardis/gui/interface.py index 591e6016a8f..cdfd6ae1361 100644 --- a/tardis/gui/interface.py +++ b/tardis/gui/interface.py @@ -36,7 +36,7 @@ def show(model): show method is called. Finally the eventloop is started using IPython functions (which start them - consistently) if they were imported. Otherwise it is started explicitly. + consistently) if they were imported. Otherwise it is started explicitly. """ if importFailed: app = QtWidgets.QApplication([]) diff --git a/tardis/gui/widgets.py b/tardis/gui/widgets.py index 62920d57e12..0c78fbd4c18 100644 --- a/tardis/gui/widgets.py +++ b/tardis/gui/widgets.py @@ -391,7 +391,7 @@ def match_dicts(self, dict1, dict2): # dict1<=dict2 The template dictionary with all default values set. This one may have some keys missing that are present in the `dict1`. Such keys will be appended. - + Raises ------ IOError diff --git a/tardis/io/config_reader.py b/tardis/io/config_reader.py index 3e89357f2f5..c63fc914469 100644 --- a/tardis/io/config_reader.py +++ b/tardis/io/config_reader.py @@ -340,7 +340,7 @@ def quantity_representer(dumper, data): def cns_representer(dumper, data): """ Represents Configuration as dict - + Parameters ---------- dumper : diff --git a/tardis/io/decay.py b/tardis/io/decay.py index 34cbcee86b1..a7959e5a7e1 100644 --- a/tardis/io/decay.py +++ b/tardis/io/decay.py @@ -106,7 +106,7 @@ def as_atoms(self): Returns ------- pandas.DataFrame - Merged isotope abundances + Merged isotope abundances """ return self.groupby("atomic_number").sum() @@ -117,7 +117,7 @@ def merge(self, other, normalize=True): Parameters ---------- - other : pd.DataFrame + other : pd.DataFrame normalize : bool If true, resultant dataframe will be normalized diff --git a/tardis/io/util.py b/tardis/io/util.py index 4fa4aed7dcc..a9373f8f1d9 100644 --- a/tardis/io/util.py +++ b/tardis/io/util.py @@ -205,13 +205,13 @@ def to_hdf_util( ): """ A function to uniformly store TARDIS data to an HDF file. - + Scalars will be stored in a Series under path/scalars 1D arrays will be stored under path/property_name as distinct Series 2D arrays will be stored under path/property_name as distinct DataFrames - + Units will be stored as their CGS value - + Parameters ---------- path_or_buf : str or pandas.io.pytables.HDFStore @@ -223,7 +223,7 @@ def to_hdf_util( stored. overwrite : bool If the HDF file path already exists, whether to overwrite it or not - + Notes ----- `overwrite` option doesn't have any effect when `path_or_buf` is an diff --git a/tardis/plasma/properties/atomic.py b/tardis/plasma/properties/atomic.py index 33770c7095d..9ab66b7585e 100644 --- a/tardis/plasma/properties/atomic.py +++ b/tardis/plasma/properties/atomic.py @@ -30,7 +30,7 @@ class Levels(BaseAtomicDataProperty): """ Attributes ---------- - levels : pandas.MultiIndex + levels : pandas.MultiIndex (atomic_number, ion_number, level_number) Index of filtered atomic data. Index used for all other attribute dataframes for this class excitation_energy : pandas.DataFrame, dtype float @@ -70,7 +70,7 @@ class Lines(BaseAtomicDataProperty): """ Attributes ---------- - lines : pandas.DataFrame + lines : pandas.DataFrame Atomic lines data. Columns are wavelength, atomic_number,ion_number, f_ul, f_lu, level_number_lower, level_number_upper, nu, B_lu, B_ul, A_ul, wavelength. Index is line_id. @@ -192,7 +192,7 @@ class IonizationData(BaseAtomicDataProperty): """ Attributes ---------- - ionization_data : pandas.Series + ionization_data : pandas.Series Holding ionization energies Indexed by atomic number, ion number. """ diff --git a/tardis/plasma/properties/ion_population.py b/tardis/plasma/properties/ion_population.py index 37924229875..020a161087f 100644 --- a/tardis/plasma/properties/ion_population.py +++ b/tardis/plasma/properties/ion_population.py @@ -270,7 +270,7 @@ class IonNumberDensity(ProcessingPlasmaProperty): for the electron densities are not similar to within the threshold value, a new guess for the value of the electron density is chosen and the process is repeated. - + Attributes ---------- ion_number_density : pandas.DataFrame, dtype float @@ -401,7 +401,7 @@ class IonNumberDensityHeNLTE(ProcessingPlasmaProperty): for the electron densities are not similar to within the threshold value, a new guess for the value of the electron density is chosen and the process is repeated. - + Attributes ---------- ion_number_density : pandas.DataFrame, dtype float diff --git a/tardis/widgets/tests/test_shell_info.py b/tardis/widgets/tests/test_shell_info.py index b34cd5e53b2..03cb156b2a3 100644 --- a/tardis/widgets/tests/test_shell_info.py +++ b/tardis/widgets/tests/test_shell_info.py @@ -29,7 +29,9 @@ def simulation_shell_info(simulation_verysimple): @pytest.fixture(scope="class") def hdf_shell_info(hdf_file_path, simulation_verysimple): - simulation_verysimple.to_hdf(hdf_file_path, overwrite=True) # save sim at hdf_file_path + simulation_verysimple.to_hdf( + hdf_file_path, overwrite=True + ) # save sim at hdf_file_path return HDFShellInfo(hdf_file_path)