Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
NIFTy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ift
NIFTy
Commits
1763f1ca
Commit
1763f1ca
authored
5 years ago
by
Lukas Platz
Browse files
Options
Downloads
Patches
Plain Diff
move total_volume functionality to DomainTuple
parent
4a05f59b
No related branches found
No related tags found
1 merge request
!359
Add total_volume property to DomainTuple
Pipeline
#62676
passed
5 years ago
Stage: build_docker
Stage: test
Stage: demo_runs
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
nifty5/domain_tuple.py
+23
-4
23 additions, 4 deletions
nifty5/domain_tuple.py
nifty5/field.py
+4
-14
4 additions, 14 deletions
nifty5/field.py
with
27 additions
and
18 deletions
nifty5/domain_tuple.py
+
23
−
4
View file @
1763f1ca
...
@@ -19,6 +19,8 @@ from functools import reduce
...
@@ -19,6 +19,8 @@ from functools import reduce
from
.
import
utilities
from
.
import
utilities
from
.domains.domain
import
Domain
from
.domains.domain
import
Domain
import
numpy
as
np
class
DomainTuple
(
object
):
class
DomainTuple
(
object
):
"""
Ordered sequence of Domain objects.
"""
Ordered sequence of Domain objects.
...
@@ -125,11 +127,28 @@ class DomainTuple(object):
...
@@ -125,11 +127,28 @@ class DomainTuple(object):
"""
"""
return
self
.
_size
return
self
.
_size
@property
def
total_volume
(
self
,
spaces
=
None
):
def
total_volume
(
self
):
"""
Returns the total volume of `self` or of a subspace of it.
Parameters
----------
spaces : int, tuple of int or None
Indices of the sub-domains of the domain to be considered.
If `None`, the total volume of the whole domain is returned.
Returns
-------
float
the total volume of the requested (sub-)domain.
"""
if
np
.
isscalar
(
spaces
):
return
self
.
_dom
[
spaces
].
total_volume
if
spaces
is
None
:
spaces
=
range
(
len
(
self
.
_dom
))
res
=
1.
res
=
1.
for
d
in
s
elf
.
_dom
:
for
i
in
s
paces
:
res
*=
d
.
total_volume
res
*=
self
.
_dom
[
i
]
.
total_volume
return
res
return
res
@property
@property
...
...
This diff is collapsed.
Click to expand it.
nifty5/field.py
+
4
−
14
View file @
1763f1ca
...
@@ -260,30 +260,20 @@ class Field(object):
...
@@ -260,30 +260,20 @@ class Field(object):
return
res
return
res
def
total_volume
(
self
,
spaces
=
None
):
def
total_volume
(
self
,
spaces
=
None
):
"""
Returns the total volume of
a sub-
domain of
`self`
.
"""
Returns the total volume of
the field
'
s
domain
or
of
a subspace of it
.
Parameters
Parameters
----------
----------
spaces : int, tuple of int or None
spaces : int, tuple of int or None
Indices of the sub-domains of the field
'
s domain to be considered.
Indices of the sub-domains of the field
'
s domain to be considered.
If `None`, the
entir
e domain is
us
ed.
If `None`, the
total volume of the whol
e domain is
return
ed.
Returns
Returns
-------
-------
float
float
the total volume of the requested sub-domain.
the total volume of the requested
(
sub-
)
domain.
"""
"""
if
spaces
is
None
:
return
self
.
_domain
.
total_volume
(
spaces
)
return
self
.
_domain
.
total_volume
if
np
.
isscalar
(
spaces
):
return
self
.
_domain
[
spaces
].
total_volume
# tuple of spaces given
res
=
1.
for
i
in
spaces
:
res
*=
self
.
_domain
[
i
].
total_volume
return
res
def
weight
(
self
,
power
=
1
,
spaces
=
None
):
def
weight
(
self
,
power
=
1
,
spaces
=
None
):
"""
Weights the pixels of `self` with their invidual pixel volumes.
"""
Weights the pixels of `self` with their invidual pixel volumes.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment