Skip to content

Commit

Permalink
Replace | typing operator with Union[]
Browse files Browse the repository at this point in the history
  • Loading branch information
robbietuk authored Feb 7, 2025
1 parent ba4e0fe commit 526ffae
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions examples/python/plot_projdata_profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import argparse
import sys
from typing import Union

import matplotlib.pyplot as plt
import numpy as np
Expand All @@ -32,7 +33,7 @@
}


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


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

def compress_and_extract_1d_from_nd_array(data: np.ndarray,
display_axis: int,
axes_indices: list[int | None] | None = None
axes_indices: Union[list[Union[int, None]], None] = None
) -> np.ndarray:
"""
Generate a 1D array from an n-dimensional NumPy array based on specified parameters.
Expand Down Expand Up @@ -125,9 +126,9 @@ def compress_and_extract_1d_from_nd_array(data: np.ndarray,
return data


def plot_projdata_profiles(projection_data_list: list[stir.ProjData] | list[str],
def plot_projdata_profiles(projection_data_list: Union[list[stir.ProjData], list[str]],
display_axis: int = 3,
data_indices: list[int | None] | None = None,
data_indices: Union[list[Union[int, None]], None] = None,
) -> None:
"""
Plots the profiles of the projection data.
Expand Down

0 comments on commit 526ffae

Please sign in to comment.