Skip to content

Commit

Permalink
black formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
freemansw1 committed Jan 9, 2025
1 parent 2b8c03e commit 1364012
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 49 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Tests for time padding of segmentation
"""

import datetime
import pytest
from typing import Optional
Expand Down
123 changes: 74 additions & 49 deletions tobac/utils/internal/general_internal.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Internal tobac utilities
"""Internal tobac utilities
"""

from __future__ import annotations

import numpy as np
Expand Down Expand Up @@ -136,19 +137,23 @@ 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
]
)
kwargs_new = dict(
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()
],
)
Expand All @@ -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
]
)
Expand Down Expand Up @@ -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
]
)
Expand All @@ -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()
],
)
Expand All @@ -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
]
)
Expand Down Expand Up @@ -292,23 +305,23 @@ 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
]
)
kwargs = dict(
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()
],
)
Expand All @@ -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
]
)
Expand Down Expand Up @@ -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
]
)
Expand All @@ -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()
],
)
Expand All @@ -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
]
)
Expand Down

0 comments on commit 1364012

Please sign in to comment.