From 85c963e223d7cf376ef5b888ce1225b241a635b5 Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Wed, 13 Dec 2023 08:11:32 -0600 Subject: [PATCH] Move 'import lxml' to third-party block of imports (#2803) --- openmc/cell.py | 2 +- openmc/data/library.py | 2 +- openmc/deplete/nuclide.py | 2 +- openmc/element.py | 1 + openmc/filter.py | 2 +- openmc/filter_expansion.py | 1 + openmc/lattice.py | 2 +- openmc/material.py | 2 +- openmc/model/model.py | 2 +- openmc/plots.py | 2 +- openmc/settings.py | 3 +-- openmc/source.py | 2 +- openmc/surface.py | 2 +- openmc/tally_derivative.py | 1 + openmc/trigger.py | 1 + openmc/universe.py | 6 +----- openmc/volume.py | 4 ++-- openmc/weight_windows.py | 1 - tests/unit_tests/test_cell.py | 2 -- tests/unit_tests/test_deplete_nuclide.py | 3 ++- tests/unit_tests/test_lattice.py | 2 +- tests/unit_tests/test_universe.py | 1 - 22 files changed, 21 insertions(+), 25 deletions(-) diff --git a/openmc/cell.py b/openmc/cell.py index 956d727d74..0af6ea2b45 100644 --- a/openmc/cell.py +++ b/openmc/cell.py @@ -1,8 +1,8 @@ from collections.abc import Iterable from math import cos, sin, pi from numbers import Real -import lxml.etree as ET +import lxml.etree as ET import numpy as np from uncertainties import UFloat diff --git a/openmc/data/library.py b/openmc/data/library.py index 397be3faf1..de9de27443 100644 --- a/openmc/data/library.py +++ b/openmc/data/library.py @@ -1,8 +1,8 @@ import os -import lxml.etree as ET import pathlib import h5py +import lxml.etree as ET import openmc from openmc._xml import clean_indentation, reorder_attributes diff --git a/openmc/deplete/nuclide.py b/openmc/deplete/nuclide.py index e2067a8e35..d055c2e375 100644 --- a/openmc/deplete/nuclide.py +++ b/openmc/deplete/nuclide.py @@ -8,8 +8,8 @@ from collections.abc import Mapping from collections import namedtuple, defaultdict from warnings import warn from numbers import Real -import lxml.etree as ET +import lxml.etree as ET import numpy as np from openmc.checkvalue import check_type diff --git a/openmc/element.py b/openmc/element.py index 01651bebb6..f9cf102f7c 100644 --- a/openmc/element.py +++ b/openmc/element.py @@ -1,4 +1,5 @@ import re + import lxml.etree as ET import openmc.checkvalue as cv diff --git a/openmc/filter.py b/openmc/filter.py index 8eb81432ff..f2bbf2f505 100644 --- a/openmc/filter.py +++ b/openmc/filter.py @@ -3,9 +3,9 @@ from collections.abc import Iterable import hashlib from itertools import product from numbers import Real, Integral -import lxml.etree as ET import warnings +import lxml.etree as ET import numpy as np import pandas as pd diff --git a/openmc/filter_expansion.py b/openmc/filter_expansion.py index f05f39fe9b..b9860846fd 100644 --- a/openmc/filter_expansion.py +++ b/openmc/filter_expansion.py @@ -1,4 +1,5 @@ from numbers import Integral, Real + import lxml.etree as ET import openmc.checkvalue as cv diff --git a/openmc/lattice.py b/openmc/lattice.py index 926a016efe..d281f6e769 100644 --- a/openmc/lattice.py +++ b/openmc/lattice.py @@ -4,8 +4,8 @@ from copy import deepcopy from math import sqrt, floor from numbers import Real import types -import lxml.etree as ET +import lxml.etree as ET import numpy as np import openmc diff --git a/openmc/material.py b/openmc/material.py index 6b71f56a8d..1f5496f15e 100644 --- a/openmc/material.py +++ b/openmc/material.py @@ -8,8 +8,8 @@ import re import typing # imported separately as py3.8 requires typing.Iterable import warnings from typing import Optional, List, Union, Dict -import lxml.etree as ET +import lxml.etree as ET import numpy as np import h5py diff --git a/openmc/model/model.py b/openmc/model/model.py index 9da834e139..a60960b2ba 100644 --- a/openmc/model/model.py +++ b/openmc/model/model.py @@ -7,10 +7,10 @@ from pathlib import Path from numbers import Integral from tempfile import NamedTemporaryFile import warnings -import lxml.etree as ET from typing import Optional, Dict import h5py +import lxml.etree as ET import openmc import openmc._xml as xml diff --git a/openmc/plots.py b/openmc/plots.py index 626056d79a..b38b51a59c 100644 --- a/openmc/plots.py +++ b/openmc/plots.py @@ -1,10 +1,10 @@ from collections.abc import Iterable, Mapping from numbers import Integral, Real from pathlib import Path -import lxml.etree as ET from typing import Optional import h5py +import lxml.etree as ET import numpy as np import openmc diff --git a/openmc/settings.py b/openmc/settings.py index 5d0800ac13..b4e615a2a1 100644 --- a/openmc/settings.py +++ b/openmc/settings.py @@ -1,4 +1,3 @@ -import os from collections.abc import Iterable, Mapping, MutableSequence from enum import Enum import itertools @@ -7,11 +6,11 @@ from numbers import Integral, Real from pathlib import Path import typing # required to prevent typing.Union namespace overwriting Union from typing import Optional + import lxml.etree as ET import openmc.checkvalue as cv from openmc.stats.multivariate import MeshSpatial - from . import (RegularMesh, SourceBase, MeshSource, IndependentSource, VolumeCalculation, WeightWindows, WeightWindowGenerator) from ._xml import clean_indentation, get_text, reorder_attributes diff --git a/openmc/source.py b/openmc/source.py index c339d6ed80..1ba90c9213 100644 --- a/openmc/source.py +++ b/openmc/source.py @@ -7,8 +7,8 @@ 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, Sequence -import lxml.etree as ET +import lxml.etree as ET import numpy as np import h5py diff --git a/openmc/surface.py b/openmc/surface.py index a684f83fea..a16b6712d6 100644 --- a/openmc/surface.py +++ b/openmc/surface.py @@ -3,9 +3,9 @@ from collections.abc import Iterable from copy import deepcopy import math from numbers import Real -import lxml.etree as ET from warnings import warn, catch_warnings, simplefilter +import lxml.etree as ET import numpy as np from .checkvalue import check_type, check_value, check_length, check_greater_than diff --git a/openmc/tally_derivative.py b/openmc/tally_derivative.py index 779ca619f2..ff918c1b3c 100644 --- a/openmc/tally_derivative.py +++ b/openmc/tally_derivative.py @@ -1,4 +1,5 @@ from numbers import Integral + import lxml.etree as ET import openmc.checkvalue as cv diff --git a/openmc/trigger.py b/openmc/trigger.py index 8a165526cf..c7d9e9240b 100644 --- a/openmc/trigger.py +++ b/openmc/trigger.py @@ -1,5 +1,6 @@ from collections.abc import Iterable from numbers import Real + import lxml.etree as ET import openmc.checkvalue as cv diff --git a/openmc/universe.py b/openmc/universe.py index bc122b03dc..2e86ab05a9 100644 --- a/openmc/universe.py +++ b/openmc/universe.py @@ -1,24 +1,20 @@ import math -import typing from abc import ABC, abstractmethod from collections.abc import Iterable -from copy import deepcopy from numbers import Integral, Real from pathlib import Path from tempfile import TemporaryDirectory -import lxml.etree as ET import warnings import h5py +import lxml.etree as ET import numpy as np import openmc import openmc.checkvalue as cv - from ._xml import get_text from .checkvalue import check_type, check_value from .mixin import IDManagerMixin -from .plots import _SVG_COLORS from .surface import _BOUNDARY_TYPES diff --git a/openmc/volume.py b/openmc/volume.py index 90882267d7..df19def1ea 100644 --- a/openmc/volume.py +++ b/openmc/volume.py @@ -1,11 +1,11 @@ from collections.abc import Iterable, Mapping from numbers import Real, Integral -import lxml.etree as ET import warnings +import h5py +import lxml.etree as ET import numpy as np import pandas as pd -import h5py from uncertainties import ufloat import openmc diff --git a/openmc/weight_windows.py b/openmc/weight_windows.py index 2b545a976e..f593643897 100644 --- a/openmc/weight_windows.py +++ b/openmc/weight_windows.py @@ -12,7 +12,6 @@ from openmc.filter import _PARTICLES from openmc.mesh import MeshBase, RectilinearMesh, CylindricalMesh, SphericalMesh, UnstructuredMesh import openmc.checkvalue as cv from openmc.checkvalue import PathLike - from ._xml import get_text, clean_indentation from .mixin import IDManagerMixin diff --git a/tests/unit_tests/test_cell.py b/tests/unit_tests/test_cell.py index 888a0ef88f..95c8249bb3 100644 --- a/tests/unit_tests/test_cell.py +++ b/tests/unit_tests/test_cell.py @@ -1,11 +1,9 @@ import lxml.etree as ET - import numpy as np from uncertainties import ufloat import openmc import pytest - from tests.unit_tests import assert_unbounded from openmc.data import atomic_mass, AVOGADRO diff --git a/tests/unit_tests/test_deplete_nuclide.py b/tests/unit_tests/test_deplete_nuclide.py index 07db57bd6d..6482d76a59 100644 --- a/tests/unit_tests/test_deplete_nuclide.py +++ b/tests/unit_tests/test_deplete_nuclide.py @@ -1,7 +1,8 @@ """Tests for the openmc.deplete.Nuclide class.""" -import lxml.etree as ET import copy + +import lxml.etree as ET import numpy as np import pytest from openmc.deplete import nuclide diff --git a/tests/unit_tests/test_lattice.py b/tests/unit_tests/test_lattice.py index 97cd898435..6fa32760e6 100644 --- a/tests/unit_tests/test_lattice.py +++ b/tests/unit_tests/test_lattice.py @@ -1,6 +1,6 @@ from math import sqrt -import lxml.etree as ET +import lxml.etree as ET import openmc import pytest diff --git a/tests/unit_tests/test_universe.py b/tests/unit_tests/test_universe.py index 630e66df3a..46d4ec3f73 100644 --- a/tests/unit_tests/test_universe.py +++ b/tests/unit_tests/test_universe.py @@ -1,5 +1,4 @@ import lxml.etree as ET - import numpy as np import openmc import pytest