From 1364012b0f2e21e42abb64ab2e93d3817f52c384 Mon Sep 17 00:00:00 2001 From: Sean Freeman Date: Thu, 9 Jan 2025 09:09:17 -0600 Subject: [PATCH] black formatting --- .../test_segmentation_time_pad.py | 1 + tobac/utils/internal/general_internal.py | 123 +++++++++++------- 2 files changed, 75 insertions(+), 49 deletions(-) diff --git a/tobac/tests/segmentation_tests/test_segmentation_time_pad.py b/tobac/tests/segmentation_tests/test_segmentation_time_pad.py index 79409f10..bfdf7bd6 100644 --- a/tobac/tests/segmentation_tests/test_segmentation_time_pad.py +++ b/tobac/tests/segmentation_tests/test_segmentation_time_pad.py @@ -1,5 +1,6 @@ """Tests for time padding of segmentation """ + import datetime import pytest from typing import Optional diff --git a/tobac/utils/internal/general_internal.py b/tobac/utils/internal/general_internal.py index 295f20c6..7837dec3 100644 --- a/tobac/utils/internal/general_internal.py +++ b/tobac/utils/internal/general_internal.py @@ -1,5 +1,6 @@ -"""Internal tobac utilities +"""Internal tobac utilities """ + from __future__ import annotations import numpy as np @@ -136,9 +137,11 @@ def wrapper(*args, **kwargs): # print("converting iris to xarray and back") args = tuple( [ - xarray.DataArray.from_iris(arg) - if type(arg) == iris.cube.Cube - else arg + ( + xarray.DataArray.from_iris(arg) + if type(arg) == iris.cube.Cube + else arg + ) for arg in args ] ) @@ -146,9 +149,11 @@ def wrapper(*args, **kwargs): zip( kwargs.keys(), [ - xarray.DataArray.from_iris(arg) - if type(arg) == iris.cube.Cube - else arg + ( + xarray.DataArray.from_iris(arg) + if type(arg) == iris.cube.Cube + else arg + ) for arg in kwargs.values() ], ) @@ -159,9 +164,11 @@ def wrapper(*args, **kwargs): if type(output) == tuple: output = tuple( [ - xarray.DataArray.to_iris(output_item) - if type(output_item) == xarray.DataArray - else output_item + ( + xarray.DataArray.to_iris(output_item) + if type(output_item) == xarray.DataArray + else output_item + ) for output_item in output ] ) @@ -215,9 +222,11 @@ def wrapper(*args, **kwargs): # print("converting xarray to iris and back") args = tuple( [ - xarray.DataArray.to_iris(arg) - if type(arg) == xarray.DataArray - else arg + ( + xarray.DataArray.to_iris(arg) + if type(arg) == xarray.DataArray + else arg + ) for arg in args ] ) @@ -226,9 +235,11 @@ def wrapper(*args, **kwargs): zip( kwargs.keys(), [ - xarray.DataArray.to_iris(arg) - if type(arg) == xarray.DataArray - else arg + ( + xarray.DataArray.to_iris(arg) + if type(arg) == xarray.DataArray + else arg + ) for arg in kwargs.values() ], ) @@ -241,9 +252,11 @@ def wrapper(*args, **kwargs): if type(output) == tuple: output = tuple( [ - xarray.DataArray.from_iris(output_item) - if type(output_item) == iris.cube.Cube - else output_item + ( + xarray.DataArray.from_iris(output_item) + if type(output_item) == iris.cube.Cube + else output_item + ) for output_item in output ] ) @@ -292,11 +305,11 @@ def wrapper(*args, **kwargs): # print("converting iris to xarray and back") args = tuple( [ - xarray.DataArray.from_iris(arg) - if type(arg) == iris.cube.Cube - else arg.to_xarray() - if type(arg) == pd.DataFrame - else arg + ( + xarray.DataArray.from_iris(arg) + if type(arg) == iris.cube.Cube + else arg.to_xarray() if type(arg) == pd.DataFrame else arg + ) for arg in args ] ) @@ -304,11 +317,11 @@ def wrapper(*args, **kwargs): zip( kwargs.keys(), [ - xarray.DataArray.from_iris(arg) - if type(arg) == iris.cube.Cube - else arg.to_xarray() - if type(arg) == pd.DataFrame - else arg + ( + xarray.DataArray.from_iris(arg) + if type(arg) == iris.cube.Cube + else arg.to_xarray() if type(arg) == pd.DataFrame else arg + ) for arg in kwargs.values() ], ) @@ -318,11 +331,15 @@ def wrapper(*args, **kwargs): if type(output) == tuple: output = tuple( [ - xarray.DataArray.to_iris(output_item) - if type(output_item) == xarray.DataArray - else output_item.to_dataframe() - if type(output_item) == xarray.Dataset - else output_item + ( + xarray.DataArray.to_iris(output_item) + if type(output_item) == xarray.DataArray + else ( + output_item.to_dataframe() + if type(output_item) == xarray.Dataset + else output_item + ) + ) for output_item in output ] ) @@ -390,11 +407,11 @@ def wrapper(*args, **kwargs): # print("converting xarray to iris and back") args = tuple( [ - xarray.DataArray.to_iris(arg) - if type(arg) == xarray.DataArray - else arg.to_dataframe() - if type(arg) == xarray.Dataset - else arg + ( + xarray.DataArray.to_iris(arg) + if type(arg) == xarray.DataArray + else arg.to_dataframe() if type(arg) == xarray.Dataset else arg + ) for arg in args ] ) @@ -403,11 +420,15 @@ def wrapper(*args, **kwargs): zip( kwargs.keys(), [ - xarray.DataArray.to_iris(arg) - if type(arg) == xarray.DataArray - else arg.to_dataframe() - if type(arg) == xarray.Dataset - else arg + ( + xarray.DataArray.to_iris(arg) + if type(arg) == xarray.DataArray + else ( + arg.to_dataframe() + if type(arg) == xarray.Dataset + else arg + ) + ) for arg in kwargs.values() ], ) @@ -420,11 +441,15 @@ def wrapper(*args, **kwargs): if type(output) == tuple: output = tuple( [ - xarray.DataArray.from_iris(output_item) - if type(output_item) == iris.cube.Cube - else output_item.to_xarray() - if type(output_item) == pd.DataFrame - else output_item + ( + xarray.DataArray.from_iris(output_item) + if type(output_item) == iris.cube.Cube + else ( + output_item.to_xarray() + if type(output_item) == pd.DataFrame + else output_item + ) + ) for output_item in output ] )