Apply Flake8, YamlLint and Black styling to entire repository
This is a big merge, but it is purely aesthetic! It simply applies Flake8 and Black styling to every file. It is compatible with the pre-commit hooks that we encourage people to use when git committing.
It passes all linting checks, build check, and pytest checks.
Merge request reports
Activity
assigned to @dmurnane
It is great! Thanks for putting them together.
One comment, maybe for the next merge request, but I want to express it now, is that some configuration parameters are optional, and some are mandatory. We use the
assert
statement pervasively to check that only when we want to use the parameters; therefore, such checks of a parameter come along with the function that wants to use the parameter. It can happen that the same parameter may be checked by a few functions. It looks tedious to me.I suggest we check the configuration at the class constructor,
__init__()
, possibly raise an error when the check fails, and document the list of parameters in the class docstring. Developers and users will know exactly what parameters are mandatory and what are optional for the class.Specifically, for optional parameters, we assign
None
or reasonable default values; for mandatory parameters, we assign reasonable default values or raise a RunTimeError only when needed. In this way, theself.hparams
always exists and contains all parameters needed in the class with reasonable default values, includingNone
. It will save us from checking the configuration in a function that does the actual work, like:if ( self.hparams is not None and "hard_cuts" in self.hparams.keys() and self.hparams["hard_cuts"] ): assert isinstance( self.hparams["hard_cuts"], dict ), "Hard cuts must be a dictionary" handle_hard_cuts(event, self.hparams["hard_cuts"])
mentioned in issue #29
mentioned in commit 5c7eaac0