Skip to content

Commit 526ffae

Browse files
authored
Replace | typing operator with Union[]
1 parent ba4e0fe commit 526ffae

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

examples/python/plot_projdata_profiles.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import argparse
1919
import sys
20+
from typing import Union
2021

2122
import matplotlib.pyplot as plt
2223
import numpy as np
@@ -32,7 +33,7 @@
3233
}
3334

3435

35-
def get_projdata_from_file_as_numpy(filename: str) -> np.ndarray | None:
36+
def get_projdata_from_file_as_numpy(filename: str) -> Union[np.ndarray, None]:
3637
"""
3738
Load a Projdata file and convert it to a NumPy array.
3839
Args:
@@ -53,7 +54,7 @@ def get_projdata_from_file_as_numpy(filename: str) -> np.ndarray | None:
5354
return None
5455

5556

56-
def get_projection_data_as_array(f: str | stir.ProjData) -> np.ndarray | None:
57+
def get_projection_data_as_array(f: Union[str, stir.ProjData]) -> Union[np.ndarray, None]:
5758
"""
5859
Get the projection data from a file or object.
5960
Args:
@@ -80,7 +81,7 @@ def get_projection_data_as_array(f: str | stir.ProjData) -> np.ndarray | None:
8081

8182
def compress_and_extract_1d_from_nd_array(data: np.ndarray,
8283
display_axis: int,
83-
axes_indices: list[int | None] | None = None
84+
axes_indices: Union[list[Union[int, None]], None] = None
8485
) -> np.ndarray:
8586
"""
8687
Generate a 1D array from an n-dimensional NumPy array based on specified parameters.
@@ -125,9 +126,9 @@ def compress_and_extract_1d_from_nd_array(data: np.ndarray,
125126
return data
126127

127128

128-
def plot_projdata_profiles(projection_data_list: list[stir.ProjData] | list[str],
129+
def plot_projdata_profiles(projection_data_list: Union[list[stir.ProjData], list[str]],
129130
display_axis: int = 3,
130-
data_indices: list[int | None] | None = None,
131+
data_indices: Union[list[Union[int, None]], None] = None,
131132
) -> None:
132133
"""
133134
Plots the profiles of the projection data.

0 commit comments

Comments
 (0)