Skip to content

Commit

Permalink
style: pre-commit fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pre-commit-ci[bot] committed Jan 29, 2024
1 parent 78a2ee6 commit bbc63df
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
9 changes: 6 additions & 3 deletions pybamm/solvers/processed_variable.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,9 @@ def _process_spatial_variable_names(self, spatial_variable):
f"Spatial variable name not recognized for {spatial_variable}"
)

def __call__(self, t=None, x=None, r=None, y=None, z=None, R=None, warn=True, **kwargs):
def __call__(
self, t=None, x=None, r=None, y=None, z=None, R=None, warn=True, **kwargs
):
"""
Evaluate the variable at arbitrary *dimensional* t (and x, r, y, z and/or R),
using interpolation
Expand All @@ -376,12 +378,13 @@ def __call__(self, t=None, x=None, r=None, y=None, z=None, R=None, warn=True, **
spatial_vars.update(kwargs)

# Remove any None arguments
spatial_vars = {key: value for key, value in spatial_vars.items() if value is not None}
spatial_vars = {
key: value for key, value in spatial_vars.items() if value is not None
}

# Use xarray interpolation, return numpy array
return self._xr_data_array.interp(**spatial_vars).values


@property
def data(self):
"""Same as entries, but different name"""
Expand Down
8 changes: 6 additions & 2 deletions pybamm/solvers/processed_variable_computed.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,9 @@ def initialise_2D_scikit_fem(self):
coords={"y": y_sol, "z": z_sol, "t": self.t_pts},
)

def __call__(self, t=None, x=None, r=None, y=None, z=None, R=None, warn=True, **kwargs):
def __call__(
self, t=None, x=None, r=None, y=None, z=None, R=None, warn=True, **kwargs
):
"""
Evaluate the variable at arbitrary *dimensional* t (and x, r, y, z and/or R),
using interpolation
Expand All @@ -421,7 +423,9 @@ def __call__(self, t=None, x=None, r=None, y=None, z=None, R=None, warn=True, **
spatial_vars.update(kwargs)

# Remove any None arguments
spatial_vars = {key: value for key, value in spatial_vars.items() if value is not None}
spatial_vars = {
key: value for key, value in spatial_vars.items() if value is not None
}

# Use xarray interpolation, return numpy array
return self._xr_data_array.interp(**spatial_vars).values
Expand Down
4 changes: 3 additions & 1 deletion tests/unit/test_solvers/test_processed_variable.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,11 @@ def process_and_check_2D_variable(
)
return y_sol, first_sol, second_sol, t_sol


def call_func(t=None, x=None, r=None, y=None, z=None, R=None, warn=True, **kwargs):
return np.random.rand(5, 5)


class TestProcessedVariable(TestCase):
def test_processed_variable_0D(self):
# without space
Expand Down Expand Up @@ -1162,7 +1164,7 @@ def test_call_with_R(self):
self.assertIsInstance(result, np.ndarray)

def test_call_with_kwargs(self):
result = call_func(foo='bar')
result = call_func(foo="bar")
self.assertIsInstance(result, np.ndarray)


Expand Down
5 changes: 4 additions & 1 deletion tests/unit/test_solvers/test_processed_variable_computed.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,11 @@ def process_and_check_2D_variable(
# ::test_output_variables
return y_sol, first_sol, second_sol, t_sol


def call_func(t=None, x=None, r=None, y=None, z=None, R=None, warn=True, **kwargs):
return np.random.rand(5, 5)


class TestProcessedVariableComputed(TestCase):
def test_processed_variable_0D(self):
# without space
Expand Down Expand Up @@ -472,9 +474,10 @@ def test_call_with_R(self):
self.assertIsInstance(result, np.ndarray)

def test_call_with_kwargs(self):
result = call_func(foo='bar')
result = call_func(foo="bar")
self.assertIsInstance(result, np.ndarray)


if __name__ == "__main__":
print("Add -v for more debug output")
import sys
Expand Down

0 comments on commit bbc63df

Please sign in to comment.