Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
On Thursday, 7th July from 1 to 3 pm there will be a maintenance with a short downtime of GitLab.
Open sidebar
ift
NIFTy
Commits
680a22ee
Commit
680a22ee
authored
Oct 07, 2018
by
Philipp Arras
Browse files
Remove ValueInserter again since it is not needed
parent
15617c75
Changes
3
Hide whitespace changes
Inline
Side-by-side
nifty5/__init__.py
View file @
680a22ee
...
...
@@ -47,7 +47,6 @@ from .operators.outer_product_operator import OuterProduct
from
.operators.simple_linear_operators
import
(
VdotOperator
,
ConjugationOperator
,
Realizer
,
FieldAdapter
,
GeometryRemover
,
NullOperator
)
from
.operators.value_inserter
import
ValueInserter
from
.operators.energy_operators
import
(
EnergyOperator
,
GaussianEnergy
,
PoissonianEnergy
,
InverseGammaLikelihood
,
BernoulliEnergy
,
Hamiltonian
,
SampledKullbachLeiblerDivergence
)
...
...
nifty5/operators/value_inserter.py
deleted
100644 → 0
View file @
15617c75
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Copyright(C) 2013-2018 Max-Planck-Society
#
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik
# and financially supported by the Studienstiftung des deutschen Volkes.
from
__future__
import
absolute_import
,
division
,
print_function
import
numpy
as
np
from
..compat
import
*
from
..domain_tuple
import
DomainTuple
from
..domains.unstructured_domain
import
UnstructuredDomain
from
..field
import
Field
from
.linear_operator
import
LinearOperator
class
ValueInserter
(
LinearOperator
):
"""Operator which inserts one value into a field.
Parameters
----------
target : Domain, tuple of Domain or DomainTuple
index : tuple
The index of the target into which the value of the domain shall be
written.
"""
def
__init__
(
self
,
target
,
index
):
from
..sugar
import
makeDomain
self
.
_domain
=
makeDomain
(
UnstructuredDomain
(
1
))
self
.
_target
=
DomainTuple
.
make
(
target
)
if
not
isinstance
(
index
,
tuple
):
raise
TypeError
self
.
_index
=
index
self
.
_capability
=
self
.
TIMES
|
self
.
ADJOINT_TIMES
# Check if index is in bounds
np
.
empty
(
self
.
target
.
shape
)[
self
.
_index
]
def
apply
(
self
,
x
,
mode
):
self
.
_check_input
(
x
,
mode
)
x
=
x
.
to_global_data
()
if
mode
==
self
.
TIMES
:
res
=
np
.
zeros
(
self
.
target
.
shape
,
dtype
=
x
.
dtype
)
res
[
self
.
_index
]
=
x
else
:
res
=
np
.
full
((
1
,),
x
[
self
.
_index
])
return
Field
.
from_global_data
(
self
.
_tgt
(
mode
),
res
)
test/test_operators/test_adjoint.py
View file @
680a22ee
...
...
@@ -44,14 +44,6 @@ class Consistency_Tests(unittest.TestCase):
op
=
ift
.
LOSResponse
(
sp
,
starts
,
ends
,
sigma_low
,
sigma_ups
)
ift
.
extra
.
consistency_check
(
op
,
dtype
,
dtype
)
def
testValueInserter
(
self
):
op
=
ift
.
ValueInserter
(
ift
.
RGSpace
([
23
,
44
]),
(
2
,
43
))
ift
.
extra
.
consistency_check
(
op
)
self
.
assertRaises
(
IndexError
,
lambda
:
ift
.
ValueInserter
(
ift
.
RGSpace
(
3
),
(
7
,)))
self
.
assertRaises
(
TypeError
,
lambda
:
ift
.
ValueInserter
(
ift
.
RGSpace
(
3
),
2
))
@
expand
(
product
(
_h_spaces
+
_p_spaces
+
_pow_spaces
,
[
np
.
float64
,
np
.
complex128
]))
def
testOperatorCombinations
(
self
,
sp
,
dtype
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment