Commit e269754a authored by Philipp Arras's avatar Philipp Arras
Browse files

Sort all imports

parent 1fb9abd8
...@@ -14,9 +14,10 @@ ...@@ -14,9 +14,10 @@
# Copyright(C) 2021 Max-Planck-Society # Copyright(C) 2021 Max-Planck-Society
# Author: Philipp Arras # Author: Philipp Arras
import nifty7 as ift
import numpy as np import numpy as np
import nifty7 as ift
# In NIFTy, users can add hand-crafted point-wise nonlinearities that are then # In NIFTy, users can add hand-crafted point-wise nonlinearities that are then
# available for `Field`, `MultiField`, `Linearization` and `Operator`. This # available for `Field`, `MultiField`, `Linearization` and `Operator`. This
# guide illustrates how this is done. # guide illustrates how this is done.
......
...@@ -29,9 +29,9 @@ ...@@ -29,9 +29,9 @@
############################################################################### ###############################################################################
import numpy as np import numpy as np
from matplotlib import pyplot as plt
import nifty7 as ift import nifty7 as ift
from matplotlib import pyplot as plt
ift.random.push_sseq_from_seed(27) ift.random.push_sseq_from_seed(27)
......
...@@ -116,9 +116,11 @@ class LMSpace(StructuredDomain): ...@@ -116,9 +116,11 @@ class LMSpace(StructuredDomain):
colatitude in radians, and return the kernel amplitude at that colatitude in radians, and return the kernel amplitude at that
colatitude. colatitude.
""" """
from .gl_space import GLSpace
from ..operators.harmonic_operators import HarmonicTransformOperator
from ducc0.misc import GL_thetas from ducc0.misc import GL_thetas
from ..operators.harmonic_operators import HarmonicTransformOperator
from .gl_space import GLSpace
# define azimuthally symmetric spaces for kernel transform # define azimuthally symmetric spaces for kernel transform
gl = GLSpace(self.lmax + 1, 1) gl = GLSpace(self.lmax + 1, 1)
lm0 = gl.get_default_codomain() lm0 = gl.get_default_codomain()
......
...@@ -59,7 +59,7 @@ class Gridder(LinearOperator): ...@@ -59,7 +59,7 @@ class Gridder(LinearOperator):
self._eps = float(eps) self._eps = float(eps)
def apply(self, x, mode): def apply(self, x, mode):
from ducc0.wgridder import ms2dirty, dirty2ms from ducc0.wgridder import dirty2ms, ms2dirty
self._check_input(x, mode) self._check_input(x, mode)
freq = np.array([speed_of_light]) freq = np.array([speed_of_light])
x = x.val x = x.val
......
...@@ -356,8 +356,8 @@ class Linearization(Operator): ...@@ -356,8 +356,8 @@ class Linearization(Operator):
The Jacobian has an empty input domain, i.e. its matrix representation The Jacobian has an empty input domain, i.e. its matrix representation
has 0 columns. has 0 columns.
""" """
from .operators.simple_linear_operators import NullOperator
from .multi_domain import MultiDomain from .multi_domain import MultiDomain
from .operators.simple_linear_operators import NullOperator
return Linearization( return Linearization(
field, NullOperator(MultiDomain.make({}), field.domain), field, NullOperator(MultiDomain.make({}), field.domain),
want_metric=want_metric) want_metric=want_metric)
...@@ -387,8 +387,8 @@ class Linearization(Operator): ...@@ -387,8 +387,8 @@ class Linearization(Operator):
----- -----
The Jacobian is square. The Jacobian is square.
""" """
from .operators.scaling_operator import ScalingOperator
from .operators.block_diagonal_operator import BlockDiagonalOperator from .operators.block_diagonal_operator import BlockDiagonalOperator
from .operators.scaling_operator import ScalingOperator
if len(constants) == 0: if len(constants) == 0:
return Linearization.make_var(field, want_metric) return Linearization.make_var(field, want_metric)
else: else:
......
...@@ -18,12 +18,12 @@ ...@@ -18,12 +18,12 @@
import numpy as np import numpy as np
from .. import random from .. import random
from ..domain_tuple import DomainTuple
from ..linearization import Linearization from ..linearization import Linearization
from ..minimization.energy import Energy from ..minimization.energy import Energy
from ..utilities import myassert, allreduce_sum
from ..multi_domain import MultiDomain from ..multi_domain import MultiDomain
from ..sugar import from_random from ..sugar import from_random
from ..domain_tuple import DomainTuple from ..utilities import allreduce_sum, myassert
class EnergyAdapter(Energy): class EnergyAdapter(Energy):
......
...@@ -16,28 +16,28 @@ ...@@ -16,28 +16,28 @@
# #
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik. # NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik.
import numpy as np
from functools import reduce from functools import reduce
from .. import random import numpy as np
from .. import utilities
from .. import random, utilities
from ..domain_tuple import DomainTuple from ..domain_tuple import DomainTuple
from ..linearization import Linearization from ..linearization import Linearization
from ..multi_field import MultiField from ..multi_field import MultiField
from ..operators.inversion_enabler import InversionEnabler from ..operators.adder import Adder
from ..operators.endomorphic_operator import EndomorphicOperator from ..operators.endomorphic_operator import EndomorphicOperator
from ..operators.energy_operators import StandardHamiltonian, GaussianEnergy from ..operators.energy_operators import GaussianEnergy, StandardHamiltonian
from ..operators.sandwich_operator import SandwichOperator from ..operators.inversion_enabler import InversionEnabler
from ..operators.sampling_enabler import SamplingDtypeSetter from ..operators.sampling_enabler import SamplingDtypeSetter
from ..operators.sandwich_operator import SandwichOperator
from ..operators.scaling_operator import ScalingOperator from ..operators.scaling_operator import ScalingOperator
from .energy_adapter import EnergyAdapter
from .quadratic_energy import QuadraticEnergy
from ..probing import approximation2endo from ..probing import approximation2endo
from ..sugar import makeOp from ..sugar import makeOp
from ..operators.adder import Adder
from ..utilities import myassert from ..utilities import myassert
from .descent_minimizers import ConjugateGradient, DescentMinimizer
from .energy import Energy from .energy import Energy
from .descent_minimizers import DescentMinimizer, ConjugateGradient from .energy_adapter import EnergyAdapter
from .quadratic_energy import QuadraticEnergy
def _get_lo_hi(comm, n_samples): def _get_lo_hi(comm, n_samples):
...@@ -48,9 +48,9 @@ def _get_lo_hi(comm, n_samples): ...@@ -48,9 +48,9 @@ def _get_lo_hi(comm, n_samples):
def _modify_sample_domain(sample, domain): def _modify_sample_domain(sample, domain):
"""Takes only keys from sample which are also in domain and inserts zeros """Takes only keys from sample which are also in domain and inserts zeros
for keys which are not in sample.domain.""" for keys which are not in sample.domain."""
from ..multi_domain import MultiDomain
from ..field import Field
from ..domain_tuple import DomainTuple from ..domain_tuple import DomainTuple
from ..field import Field
from ..multi_domain import MultiDomain
from ..sugar import makeDomain from ..sugar import makeDomain
domain = makeDomain(domain) domain = makeDomain(domain)
if isinstance(domain, DomainTuple) and isinstance(sample, Field): if isinstance(domain, DomainTuple) and isinstance(sample, Field):
......
...@@ -155,7 +155,9 @@ class _ScipyCG(Minimizer): ...@@ -155,7 +155,9 @@ class _ScipyCG(Minimizer):
self._maxiter = maxiter self._maxiter = maxiter
def __call__(self, energy, preconditioner=None): def __call__(self, energy, preconditioner=None):
from scipy.sparse.linalg import LinearOperator as scipy_linop, cg from scipy.sparse.linalg import LinearOperator as scipy_linop
from scipy.sparse.linalg import cg
from .quadratic_energy import QuadraticEnergy from .quadratic_energy import QuadraticEnergy
if not isinstance(energy, QuadraticEnergy): if not isinstance(energy, QuadraticEnergy):
raise ValueError("need a quadratic energy for CG") raise ValueError("need a quadratic energy for CG")
......
...@@ -15,8 +15,8 @@ ...@@ -15,8 +15,8 @@
# #
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik. # NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik.
from .minimizer import Minimizer
from .energy import Energy from .energy import Energy
from .minimizer import Minimizer
class ADVIOptimizer(Minimizer): class ADVIOptimizer(Minimizer):
......
...@@ -25,13 +25,13 @@ from ..multi_domain import MultiDomain ...@@ -25,13 +25,13 @@ from ..multi_domain import MultiDomain
from ..multi_field import MultiField from ..multi_field import MultiField
from ..sugar import makeDomain, makeOp from ..sugar import makeDomain, makeOp
from ..utilities import myassert from ..utilities import myassert
from .adder import Adder
from .linear_operator import LinearOperator from .linear_operator import LinearOperator
from .operator import Operator from .operator import Operator
from .adder import Adder
from .sampling_enabler import SamplingDtypeSetter, SamplingEnabler from .sampling_enabler import SamplingDtypeSetter, SamplingEnabler
from .scaling_operator import ScalingOperator
from .sandwich_operator import SandwichOperator from .sandwich_operator import SandwichOperator
from .simple_linear_operators import VdotOperator, FieldAdapter from .scaling_operator import ScalingOperator
from .simple_linear_operators import FieldAdapter, VdotOperator
def _check_sampling_dtype(domain, dtypes): def _check_sampling_dtype(domain, dtypes):
......
...@@ -17,9 +17,9 @@ ...@@ -17,9 +17,9 @@
import numpy as np import numpy as np
from ..multi_domain import MultiDomain
from ..domain_tuple import DomainTuple from ..domain_tuple import DomainTuple
from ..domains.unstructured_domain import UnstructuredDomain from ..domains.unstructured_domain import UnstructuredDomain
from ..multi_domain import MultiDomain
from ..sugar import makeField from ..sugar import makeField
from .linear_operator import LinearOperator from .linear_operator import LinearOperator
......
...@@ -46,8 +46,8 @@ class SumOperator(LinearOperator): ...@@ -46,8 +46,8 @@ class SumOperator(LinearOperator):
@staticmethod @staticmethod
def simplify(ops, neg): def simplify(ops, neg):
from .scaling_operator import ScalingOperator
from .diagonal_operator import DiagonalOperator from .diagonal_operator import DiagonalOperator
from .scaling_operator import ScalingOperator
# unpack SumOperators # unpack SumOperators
opsnew = [] opsnew = []
......
...@@ -206,8 +206,8 @@ def _register_cmaps(): ...@@ -206,8 +206,8 @@ def _register_cmaps():
except AttributeError: except AttributeError:
_register_cmaps._cmaps_registered = True _register_cmaps._cmaps_registered = True
from matplotlib.colors import LinearSegmentedColormap
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
from matplotlib.colors import LinearSegmentedColormap
planckcmap = {'red': ((0., 0., 0.), (.4, 0., 0.), (.5, 1., 1.), planckcmap = {'red': ((0., 0., 0.), (.4, 0., 0.), (.5, 1., 1.),
(.7, 1., 1.), (.8, .83, .83), (.9, .67, .67), (.7, 1., 1.), (.8, .83, .83), (.9, .67, .67),
(1., .5, .5)), (1., .5, .5)),
......
...@@ -32,8 +32,8 @@ from .operators.diagonal_operator import DiagonalOperator ...@@ -32,8 +32,8 @@ from .operators.diagonal_operator import DiagonalOperator
from .operators.distributors import PowerDistributor from .operators.distributors import PowerDistributor
from .operators.operator import Operator from .operators.operator import Operator
from .operators.sampling_enabler import SamplingDtypeSetter from .operators.sampling_enabler import SamplingDtypeSetter
from .operators.selection_operators import SliceOperator
from .operators.scaling_operator import ScalingOperator from .operators.scaling_operator import ScalingOperator
from .operators.selection_operators import SliceOperator
from .plot import Plot from .plot import Plot
__all__ = ['PS_field', 'power_analyze', 'create_power_operator', __all__ = ['PS_field', 'power_analyze', 'create_power_operator',
...@@ -473,10 +473,10 @@ def get_default_codomain(domainoid, space=None): ...@@ -473,10 +473,10 @@ def get_default_codomain(domainoid, space=None):
Optional index of the subdomain to be replaced by its default Optional index of the subdomain to be replaced by its default
codomain. `domain[space]` must be of class `RGSpace`. codomain. `domain[space]` must be of class `RGSpace`.
""" """
from .domains.rg_space import RGSpace
from .domains.hp_space import HPSpace
from .domains.gl_space import GLSpace from .domains.gl_space import GLSpace
from .domains.hp_space import HPSpace
from .domains.lm_space import LMSpace from .domains.lm_space import LMSpace
from .domains.rg_space import RGSpace
if isinstance(domainoid, RGSpace): if isinstance(domainoid, RGSpace):
return domainoid.get_default_codomain() return domainoid.get_default_codomain()
if not isinstance(domainoid, DomainTuple): if not isinstance(domainoid, DomainTuple):
...@@ -558,8 +558,8 @@ def calculate_position(operator, output): ...@@ -558,8 +558,8 @@ def calculate_position(operator, output):
from .minimization.descent_minimizers import NewtonCG from .minimization.descent_minimizers import NewtonCG
from .minimization.iteration_controllers import GradientNormController from .minimization.iteration_controllers import GradientNormController
from .minimization.kl_energies import MetricGaussianKL from .minimization.kl_energies import MetricGaussianKL
from .operators.scaling_operator import ScalingOperator
from .operators.energy_operators import GaussianEnergy, StandardHamiltonian from .operators.energy_operators import GaussianEnergy, StandardHamiltonian
from .operators.scaling_operator import ScalingOperator
if not isinstance(operator, Operator): if not isinstance(operator, Operator):
raise TypeError raise TypeError
if output.domain != operator.target: if output.domain != operator.target:
......
...@@ -15,10 +15,11 @@ ...@@ -15,10 +15,11 @@
# #
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik. # NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik.
import nifty7 as ift
import numpy as np import numpy as np
import pytest import pytest
import nifty7 as ift
from .common import list2fixture, setup_function, teardown_function from .common import list2fixture, setup_function, teardown_function
spaces = [ift.GLSpace(5), spaces = [ift.GLSpace(5),
......
...@@ -14,15 +14,15 @@ ...@@ -14,15 +14,15 @@
# Copyright(C) 2021 Max-Planck-Society # Copyright(C) 2021 Max-Planck-Society
# Author: Philipp Arras # Author: Philipp Arras
from time import time
import numpy as np import numpy as np
import pytest import pytest
import nifty7 as ift import nifty7 as ift
from time import time
from .common import list2fixture, setup_function, teardown_function from .common import list2fixture, setup_function, teardown_function
pmp = pytest.mark.parametrize pmp = pytest.mark.parametrize
......
...@@ -15,10 +15,11 @@ ...@@ -15,10 +15,11 @@
# #
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik. # NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik.
import nifty7 as ift
import numpy as np import numpy as np
import pytest import pytest
import nifty7 as ift
from ..common import list2fixture, setup_function, teardown_function from ..common import list2fixture, setup_function, teardown_function
_h_RG_spaces = [ift.RGSpace(7, distances=0.2, harmonic=True), _h_RG_spaces = [ift.RGSpace(7, distances=0.2, harmonic=True),
......
...@@ -15,12 +15,13 @@ ...@@ -15,12 +15,13 @@
# #
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik. # NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik.
import nifty7 as ift
import numpy as np import numpy as np
import pytest import pytest
from nifty7.library.variational_models import DiagonalSelector
from numpy.testing import assert_allclose from numpy.testing import assert_allclose
import nifty7 as ift
from nifty7.library.variational_models import DiagonalSelector
from ..common import list2fixture, setup_function, teardown_function from ..common import list2fixture, setup_function, teardown_function
pmp = pytest.mark.parametrize pmp = pytest.mark.parametrize
......
...@@ -15,12 +15,13 @@ ...@@ -15,12 +15,13 @@
# #
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik. # NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik.
import nifty7 as ift
import numpy as np import numpy as np
import pytest import pytest
from nifty7.library.variational_models import GaussianEntropy
from numpy.testing import assert_allclose from numpy.testing import assert_allclose
import nifty7 as ift
from nifty7.library.variational_models import GaussianEntropy
from ..common import list2fixture, setup_function, teardown_function from ..common import list2fixture, setup_function, teardown_function
pmp = pytest.mark.parametrize pmp = pytest.mark.parametrize
......
...@@ -15,12 +15,13 @@ ...@@ -15,12 +15,13 @@
# #
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik. # NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik.
import nifty7 as ift
import numpy as np import numpy as np
import pytest import pytest
from nifty7.library.variational_models import LowerTriangularInserter
from numpy.testing import assert_allclose from numpy.testing import assert_allclose
import nifty7 as ift
from nifty7.library.variational_models import LowerTriangularInserter
from ..common import list2fixture, setup_function, teardown_function from ..common import list2fixture, setup_function, teardown_function
pmp = pytest.mark.parametrize pmp = pytest.mark.parametrize
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment