mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 14:15:42 -04:00
avoid namespace overwrite of union
This commit is contained in:
parent
459b0f1fcf
commit
3623408bc5
5 changed files with 14 additions and 11 deletions
|
|
@ -1,12 +1,12 @@
|
|||
import copy
|
||||
import os
|
||||
from typing import Union
|
||||
import typing # required to prevent typing.Union namespace overwriting Union
|
||||
from collections.abc import Iterable
|
||||
|
||||
import numpy as np
|
||||
|
||||
# Type for arguments that accept file paths
|
||||
PathLike = Union[str, os.PathLike]
|
||||
PathLike = typing.Union[str, os.PathLike]
|
||||
|
||||
|
||||
def check_type(name, value, expected_type, expected_iter_type=None, *, none_ok=False):
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
import numbers
|
||||
import bisect
|
||||
import math
|
||||
from typing import Iterable, Optional, Tuple, Union
|
||||
import typing # required to prevent typing.Union namespace overwriting Union
|
||||
from typing import Iterable, Optional, Tuple
|
||||
from warnings import warn
|
||||
|
||||
import h5py
|
||||
|
|
@ -95,7 +96,7 @@ class Results(list):
|
|||
|
||||
def get_atoms(
|
||||
self,
|
||||
mat: Union[Material, str],
|
||||
mat: typing.Union[Material, str],
|
||||
nuc: str,
|
||||
nuc_units: str = "atoms",
|
||||
time_units: str = "s"
|
||||
|
|
@ -165,7 +166,7 @@ class Results(list):
|
|||
|
||||
def get_reaction_rate(
|
||||
self,
|
||||
mat: Union[Material, str],
|
||||
mat: typing.Union[Material, str],
|
||||
nuc: str,
|
||||
rx: str
|
||||
) -> Tuple[np.ndarray, np.ndarray]:
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ from pathlib import Path
|
|||
import re
|
||||
import typing # imported separately as py3.8 requires typing.Iterable
|
||||
import warnings
|
||||
from typing import Optional, Union
|
||||
from typing import Optional
|
||||
from xml.etree import ElementTree as ET
|
||||
|
||||
import h5py
|
||||
|
|
@ -968,7 +968,7 @@ class Material(IDManagerMixin):
|
|||
|
||||
Returns
|
||||
-------
|
||||
Union[dict, float]
|
||||
typing.Union[dict, float]
|
||||
If by_nuclide is True then a dictionary whose keys are nuclide
|
||||
names and values are activity is returned. Otherwise the activity
|
||||
of the material is returned as a float.
|
||||
|
|
|
|||
|
|
@ -6,7 +6,8 @@ import itertools
|
|||
from math import ceil
|
||||
from numbers import Integral, Real
|
||||
from pathlib import Path
|
||||
from typing import Optional, Union
|
||||
import typing # required to prevent typing.Union namespace overwriting Union
|
||||
from typing import Optional
|
||||
from xml.etree import ElementTree as ET
|
||||
|
||||
import openmc.checkvalue as cv
|
||||
|
|
@ -582,7 +583,7 @@ class Settings:
|
|||
self._max_order = max_order
|
||||
|
||||
@source.setter
|
||||
def source(self, source: Union[Source, typing.Iterable[Source]]):
|
||||
def source(self, source: typing.Union[Source, typing.Iterable[Source]]):
|
||||
if not isinstance(source, MutableSequence):
|
||||
source = [source]
|
||||
self._source = cv.CheckedList(Source, 'source distributions', source)
|
||||
|
|
@ -843,7 +844,7 @@ class Settings:
|
|||
|
||||
@volume_calculations.setter
|
||||
def volume_calculations(
|
||||
self, vol_calcs: Union[VolumeCalculation, typing.Iterable[VolumeCalculation]]
|
||||
self, vol_calcs: typing.Union[VolumeCalculation, typing.Iterable[VolumeCalculation]]
|
||||
):
|
||||
if not isinstance(vol_calcs, MutableSequence):
|
||||
vol_calcs = [vol_calcs]
|
||||
|
|
@ -889,7 +890,7 @@ class Settings:
|
|||
self._write_initial_source = value
|
||||
|
||||
@weight_windows.setter
|
||||
def weight_windows(self, value: Union[WeightWindows, typing.Iterable[WeightWindows]]):
|
||||
def weight_windows(self, value: typing.Union[WeightWindows, typing.Iterable[WeightWindows]]):
|
||||
if not isinstance(value, MutableSequence):
|
||||
value = [value]
|
||||
self._weight_windows = cv.CheckedList(WeightWindows, 'weight windows', value)
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ from enum import Enum
|
|||
from numbers import Real
|
||||
import warnings
|
||||
import typing # imported separately as py3.8 requires typing.Iterable
|
||||
# also required to prevent typing.Union namespace overwriting Union
|
||||
from typing import Optional
|
||||
from xml.etree import ElementTree as ET
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue