Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fslpy
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Analyze
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
FSL
fslpy
Commits
3b170954
Commit
3b170954
authored
2 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
MNT: Use custom error type (sub-classed from ValueError, so not an API change)
parent
9dfb554f
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
fsl/data/mesh.py
+12
-6
12 additions, 6 deletions
fsl/data/mesh.py
with
12 additions
and
6 deletions
fsl/data/mesh.py
+
12
−
6
View file @
3b170954
...
...
@@ -41,6 +41,13 @@ import fsl.transform.affine as affine
log
=
logging
.
getLogger
(
__name__
)
class
IncompatibleVerticesError
(
ValueError
):
"""
``ValueError`` raised by the :meth:`Mesh.addVertices` method if
an attempt is made to add a vertex set with the wrong number of
vertices.
"""
class
Mesh
(
notifier
.
Notifier
,
meta
.
Meta
):
"""
The ``Mesh`` class represents a 3D model. A mesh is defined by a
collection of ``N`` vertices, and ``M`` triangles. The triangles are
...
...
@@ -412,8 +419,8 @@ class Mesh(notifier.Notifier, meta.Meta):
:returns: The vertices, possibly reshaped
:raises: ``
Value
Error`` if the provided
``vertices`` array
has the wrong number of vertices.
:raises: ``
IncompatibleVertices
Error`` if the provided
``vertices`` array
has the wrong number of vertices.
"""
if
self
.
__indices
is
None
:
...
...
@@ -434,10 +441,9 @@ class Mesh(notifier.Notifier, meta.Meta):
# reshape raised an error -
# wrong number of vertices
except
ValueError
:
raise
ValueError
(
'
{}: invalid number of vertices:
'
'
{} != ({}, 3)
'
.
format
(
key
,
vertices
.
shape
,
self
.
nvertices
))
raise
IncompatibleVerticesError
(
f
'
{
key
}
: invalid number of vertices:
'
f
'
{
vertices
.
shape
}
!= (
{
self
.
nvertices
}
, 3)
'
)
self
.
__vertices
[
key
]
=
vertices
self
.
__vindices
[
key
]
=
self
.
__indices
...
...
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