Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
NIFTy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
13
Issues
13
List
Boards
Labels
Service Desk
Milestones
Merge Requests
9
Merge Requests
9
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ift
NIFTy
Commits
08e0ae66
Commit
08e0ae66
authored
Aug 02, 2018
by
Martin Reinecke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adjust a few demos
parent
409244a8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
7 deletions
+23
-7
demos/bernoulli_demo.py
demos/bernoulli_demo.py
+1
-1
demos/getting_started_2.py
demos/getting_started_2.py
+1
-1
nifty5/operators/operator.py
nifty5/operators/operator.py
+21
-5
No files found.
demos/bernoulli_demo.py
View file @
08e0ae66
...
...
@@ -53,7 +53,7 @@ if __name__ == '__main__':
A
=
pd
(
a
)
# Set up a sky model
sky
=
lambda
inp
:
HT
(
A
*
inp
).
positive_tanh
()
sky
=
HT
.
chain
(
ift
.
makeOp
(
A
)
).
positive_tanh
()
GR
=
ift
.
GeometryRemover
(
position_space
)
# Set up instrumental response
...
...
demos/getting_started_2.py
View file @
08e0ae66
...
...
@@ -70,7 +70,7 @@ if __name__ == '__main__':
A
=
pd
(
a
)
# Set up a sky model
sky
=
lambda
inp
:
(
HT
(
inp
*
A
)).
exp
()
sky
=
HT
.
chain
(
ift
.
makeOp
(
A
)).
exp
()
M
=
ift
.
DiagonalOperator
(
exposure
)
GR
=
ift
.
GeometryRemover
(
position_space
)
...
...
nifty5/operators/operator.py
View file @
08e0ae66
...
...
@@ -25,10 +25,7 @@ class Operator(NiftyMetaBase()):
def
__matmul__
(
self
,
x
):
if
not
isinstance
(
x
,
Operator
):
return
NotImplemented
return
OpChain
.
make
((
self
,
x
))
ops1
=
self
.
_ops
if
isinstance
(
self
,
OpChain
)
else
(
self
,)
ops2
=
x
.
_ops
if
isinstance
(
x
,
OpChain
)
else
(
x
,)
return
OpChain
(
ops1
+
ops2
)
return
_OpChain
.
make
((
self
,
x
))
def
chain
(
self
,
x
):
res
=
self
.
__matmul__
(
x
)
...
...
@@ -52,6 +49,25 @@ class Operator(NiftyMetaBase()):
raise
NotImplementedError
for
f
in
[
"sqrt"
,
"exp"
,
"log"
,
"tanh"
,
"positive_tanh"
]:
def
func
(
f
):
def
func2
(
self
):
fa
=
_FunctionApplier
(
self
.
_target
,
f
)
return
_OpChain
.
make
((
fa
,
self
))
return
func2
setattr
(
Operator
,
f
,
func
(
f
))
class
_FunctionApplier
(
Operator
):
def
__init__
(
self
,
domain
,
funcname
):
from
..sugar
import
makeDomain
self
.
_domain
=
self
.
_target
=
makeDomain
(
domain
)
self
.
_funcname
=
funcname
def
__call__
(
self
,
x
):
return
getattr
(
x
,
self
.
_funcname
)()
class
_CombinedOperator
(
Operator
):
def
__init__
(
self
,
ops
,
_callingfrommake
=
False
):
if
not
_callingfrommake
:
...
...
@@ -62,7 +78,7 @@ class _CombinedOperator(Operator):
def
unpack
(
cls
,
ops
,
res
):
for
op
in
ops
:
if
isinstance
(
op
,
cls
):
res
=
cls
.
unpack
(
op
,
res
)
res
=
cls
.
unpack
(
op
.
_ops
,
res
)
else
:
res
=
res
+
[
op
]
return
res
...
...
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