Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Daniel Boeckenhoff
tfields
Commits
7f95a14d
Commit
7f95a14d
authored
Jul 06, 2018
by
Daniel Boeckenhoff
Browse files
Makefile added coverage
parent
7727ee4e
Changes
10
Hide whitespace changes
Inline
Side-by-side
Makefile
View file @
7f95a14d
...
...
@@ -9,8 +9,8 @@ coverage:
coverage html
firefox htmlcov/index.html
html
:
echo
"Not implemented"
clear
:
coverage erase
publish
:
@
echo
"NOOOTE"
...
...
tfields/__main__.py
View file @
7f95a14d
...
...
@@ -35,7 +35,7 @@ def run_unittests():
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
# pragma: no cover
if
len
(
sys
.
argv
)
>
1
:
arg
=
sys
.
argv
.
pop
(
1
)
if
arg
==
'test'
:
...
...
tfields/core.py
View file @
7f95a14d
...
...
@@ -464,6 +464,7 @@ class Tensors(AbstractNdarray):
>>> merge2 = tfields.Tensors.merged(*obj_list, coordSys=tfields.bases.CARTESIAN)
>>> assert merge2.equal([[-0.41614684, 0.90929743, 3.],
... [3, 3, 3], [5, 1, 3]], atol=1e-8)
"""
''' get most frequent coordSys or predefined coordSys '''
...
...
tfields/lib/stats.py
View file @
7f95a14d
...
...
@@ -9,8 +9,6 @@ part of tfields library
import
numpy
as
np
import
scipy
import
scipy.stats
import
loggingTools
logger
=
loggingTools
.
Logger
(
__name__
)
def
mode
(
array
,
axis
=
0
,
bins
=
'auto'
,
range
=
None
):
...
...
tfields/lib/util.py
View file @
7f95a14d
...
...
@@ -53,3 +53,34 @@ def flatten(seq, container=None, keep_types=None):
else
:
container
.
append
(
s
)
return
container
def
multi_sort
(
array
,
*
others
,
**
kwargs
):
"""
Sort both lists with list 1
Args:
array
*others
**kwargs:
method (function): sorting function. Default is 'sorted'
...: further arguments are passed to method. Default rest is
'key=array[0]'
Examples:
>>> from tfields.lib.util import multi_sort
>>> multi_sort([1,2,3,6,4], [1,2,3,4,5])
[[1, 2, 3, 4, 6], [1, 2, 3, 5, 4]]
>>> a, b = multi_sort([1,2,3,6,4], [1,2,3,4,5])
>>> b
[1, 2, 3, 5, 4]
Expanded to sort as many objects as needed
>>> multi_sort([1,2,3,6,4], [1,2,3,4,5], [6,5,4,3,2])
[[1, 2, 3, 4, 6], [1, 2, 3, 5, 4], [6, 5, 4, 2, 3]]
"""
method
=
kwargs
.
pop
(
'method'
,
None
)
if
method
is
None
:
method
=
sorted
if
'key'
not
in
kwargs
:
kwargs
[
'key'
]
=
lambda
pair
:
pair
[
0
]
return
[
list
(
x
)
for
x
in
zip
(
*
method
(
zip
(
array
,
*
others
),
**
kwargs
))]
tfields/mesh3D.py
View file @
7f95a14d
...
...
@@ -723,7 +723,7 @@ class Mesh3D(tfields.TensorMaps):
return
obj
,
template
return
obj
def
plot
(
self
,
**
kwargs
):
def
plot
(
self
,
**
kwargs
):
# pragma: no cover
"""
Forwarding to plotTools.plotMesh
"""
...
...
@@ -751,7 +751,7 @@ class Mesh3D(tfields.TensorMaps):
return
tfields
.
plotting
.
plotMesh
(
self
,
self
.
faces
,
**
kwargs
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
# pragma: no cover
import
doctest
# doctest.run_docstring_examples(Mesh3D.cut, globals())
...
...
tfields/planes3D.py
View file @
7f95a14d
...
...
@@ -8,7 +8,6 @@ part of tfields library
"""
import
tfields
import
sympy
import
mplTools
as
mpt
class
Planes3D
(
tfields
.
TensorFields
):
...
...
@@ -24,15 +23,15 @@ class Planes3D(tfields.TensorFields):
return
[
sympy
.
Plane
(
point
,
normal_vector
=
vector
)
for
point
,
vector
in
zip
(
self
.
points
,
self
.
vectors
)]
def
plot
(
self
,
**
kwargs
):
def
plot
(
self
,
**
kwargs
):
# pragma: no cover
"""
forward to Mesh3D plotting
"""
artists
=
[]
for
i
in
range
(
len
(
self
)):
artists
.
append
(
mpt
.
plotPlane
(
self
[
i
],
self
.
vectors
[
0
],
**
kwargs
))
artists
.
append
(
tfields
.
plotting
.
plotPlane
(
self
[
i
],
self
.
vectors
[
0
],
**
kwargs
))
# symbolic = self.symbolic()
# planeMeshes = [tfields.Mesh3D([pl.arbitrary_point(t=(i + 1) * 1. / 2 * np.pi)
# for i in range(4)],
...
...
@@ -41,6 +40,6 @@ class Planes3D(tfields.TensorFields):
return
artists
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
# pragma: no cover
import
doctest
doctest
.
testmod
()
tfields/plotting/mpl.py
View file @
7f95a14d
...
...
@@ -64,22 +64,20 @@ def plotMesh(vertices, faces, **kwargs):
po
=
tfields
.
plotting
.
PlotOptions
(
kwargs
)
if
po
.
dim
==
2
:
full
=
True
import
npTools
as
npt
import
pyTools
mesh
=
npt
.
Mesh3D
(
vertices
,
faces
=
faces
)
mesh
=
tfields
.
Mesh3D
(
vertices
,
faces
=
faces
)
xAxis
,
yAxis
,
zAxis
=
po
.
getXYZAxis
()
facecolors
=
po
.
retrieveChain
(
'facecolors'
,
'color'
,
default
=
0
,
keep
=
False
)
if
full
:
# implementation that will sort the triangles by zAxis
centroids
=
mesh
.
getC
entroids
()
centroids
=
mesh
.
c
entroids
()
axesIndices
=
[
0
,
1
,
2
]
axesIndices
.
pop
(
axesIndices
.
index
(
xAxis
))
axesIndices
.
pop
(
axesIndices
.
index
(
yAxis
))
zAxis
=
axesIndices
[
0
]
zs
=
centroids
[:,
zAxis
]
zs
,
faces
,
facecolors
=
pyTools
.
array
.
getSortedBoth
(
zs
,
faces
,
zs
,
faces
,
facecolors
=
tfields
.
lib
.
util
.
multi_sort
(
zs
,
faces
,
facecolors
)
nFacesInitial
=
len
(
faces
)
else
:
...
...
@@ -87,7 +85,7 @@ def plotMesh(vertices, faces, **kwargs):
directionVector
=
np
.
array
([
1.
,
1.
,
1.
])
directionVector
[
xAxis
]
=
0.
directionVector
[
yAxis
]
=
0.
normVectors
=
mesh
.
triangles
.
getNormVector
s
()
normVectors
=
mesh
.
triangles
.
norm
s
()
dotProduct
=
np
.
dot
(
normVectors
,
directionVector
)
nFacesInitial
=
len
(
faces
)
faces
=
faces
[
dotProduct
>
0
]
...
...
tfields/points3D.py
View file @
7f95a14d
...
...
@@ -139,7 +139,7 @@ class Points3D(tfields.Tensors):
return
super
(
Points3D
,
cls
).
__new__
(
cls
,
tensors
,
**
kwargs
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
# pragma: no cover
import
doctest
doctest
.
testmod
()
# doctest.run_docstring_examples(Points3D, globals())
tfields/triangles3D.py
View file @
7f95a14d
...
...
@@ -627,6 +627,6 @@ class Triangles3D(tfields.TensorFields):
return
super
(
Triangles3D
,
self
).
_weights
(
weights
,
rigid
=
rigid
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
# pragma: no cover
import
doctest
doctest
.
testmod
()
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment