diff --git a/transport_analysis/viscosity.py b/transport_analysis/viscosity.py index f6e6988..cac1feb 100644 --- a/transport_analysis/viscosity.py +++ b/transport_analysis/viscosity.py @@ -78,8 +78,8 @@ def __init__( # args self.temp_avg = temp_avg - self.dim_type = dim_type - self._parse_dim_type() + self.dim_type = dim_type.lower() + self._dim, self.dim_fac = self._parse_dim_type(self.dim_type) # self.fft = fft # consider whether fft is possible later # local @@ -112,7 +112,8 @@ def _prepare(self): ) # self.results.timeseries not set here - def _parse_dim_type(self): + @staticmethod + def _parse_dim_type(dim_str): r"""Sets up the desired dimensionality of the calculation.""" keys = { "x": [0], @@ -124,17 +125,15 @@ def _parse_dim_type(self): "xyz": [0, 1, 2], } - self.dim_type = self.dim_type.lower() - try: - self._dim = keys[self.dim_type] + _dim = keys[dim_str] except KeyError: raise ValueError( "invalid dim_type: {} specified, please specify one of xyz, " - "xy, xz, yz, x, y, z".format(self.dim_type) + "xy, xz, yz, x, y, z".format(dim_str) ) - self.dim_fac = len(self._dim) + return _dim, len(_dim) def _single_frame(self): """