Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-common
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
Core Modules
dune-common
Commits
a1902413
Commit
a1902413
authored
3 years ago
by
Timo Koch
Browse files
Options
Downloads
Patches
Plain Diff
[python][cleanup][common] Mark internal helper functions as internal (won't be added to __all__)
parent
22aaa9ce
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!1050
Cleanup/python
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
python/dune/common/__init__.py
+34
-20
34 additions, 20 deletions
python/dune/common/__init__.py
with
34 additions
and
20 deletions
python/dune/common/__init__.py
+
34
−
20
View file @
a1902413
import
logging
import
os
import
numpy
as
np
logger
=
logging
.
getLogger
(
__name__
)
# default log level is INFO
loglevel
=
logging
.
INFO
try
:
loglevel
=
getattr
(
logging
,
os
.
environ
[
'
DUNE_LOG_LEVEL
'
].
upper
())
...
...
@@ -26,32 +28,44 @@ from ._common import *
from
.deprecated
import
DeprecatedObject
from
.externalmodule
import
registerExternalModule
import
numpy
def
fvgeti
tem
(
self
,
index
):
def
_fieldVectorGetI
tem
(
self
,
index
):
try
:
return
self
.
_getitem
(
index
)
except
TypeError
:
return
numpy
.
array
(
self
,
copy
=
False
)[
index
]
finished
=
False
nr
=
1
while
not
finished
:
try
:
cls
=
globals
()[
"
FieldVector_
"
+
str
(
nr
)]
setattr
(
cls
,
"
_getitem
"
,
cls
.
__getitem__
)
setattr
(
cls
,
"
__getitem__
"
,
fvgetitem
)
nr
+=
1
except
KeyError
:
finished
=
True
return
np
.
array
(
self
,
copy
=
False
)[
index
]
def
_initializeFieldVector
():
finished
=
False
nr
=
1
while
not
finished
:
try
:
cls
=
globals
()[
"
FieldVector_
"
+
str
(
nr
)]
setattr
(
cls
,
"
_getitem
"
,
cls
.
__getitem__
)
setattr
(
cls
,
"
__getitem__
"
,
_fieldVectorGetItem
)
nr
+=
1
except
KeyError
:
finished
=
True
def
loadvec
(
includes
,
typeName
,
constructors
=
None
,
methods
=
None
):
_initializeFieldVector
()
def
_loadVec
(
includes
,
typeName
,
constructors
=
None
,
methods
=
None
):
from
dune.generator.generator
import
SimpleGenerator
from
dune.common.hashit
import
hashIt
generator
vec
=
SimpleGenerator
(
"
FieldVector
"
,
"
Dune::Python
"
)
generator
=
SimpleGenerator
(
"
FieldVector
"
,
"
Dune::Python
"
)
includes
=
includes
+
[
"
dune/python/common/fvector.hh
"
]
typeHash
=
"
fieldvector_
"
+
hashIt
(
typeName
)
return
generatorvec
.
load
(
includes
,
typeName
,
typeHash
,
constructors
,
methods
,
bufferProtocol
=
True
)
return
generator
.
load
(
includes
,
typeName
,
typeHash
,
constructors
,
methods
,
bufferProtocol
=
True
)
def
FieldVector
(
values
):
"""
Construct a new FieldVector
"""
values
=
list
(
values
)
fv
=
"
FieldVector_
"
+
str
(
len
(
values
))
try
:
...
...
@@ -59,10 +73,10 @@ def FieldVector(values):
except
KeyError
:
typeName
=
"
Dune::FieldVector< double ,
"
+
str
(
len
(
values
))
+
"
>
"
includes
=
[]
cls
=
load
v
ec
(
includes
,
typeName
).
FieldVector
cls
=
_
load
V
ec
(
includes
,
typeName
).
FieldVector
setattr
(
cls
,
"
_getitem
"
,
cls
.
__getitem__
)
setattr
(
cls
,
"
__getitem__
"
,
fvgeti
tem
)
globals
().
update
({
fv
:
cls
})
setattr
(
cls
,
"
__getitem__
"
,
_fieldVectorGetI
tem
)
globals
().
update
({
fv
:
cls
})
return
globals
()[
fv
](
values
)
# implementation needs to be completed similar to the FV above
...
...
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