Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
fslpy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
Michiel Cottaar
fslpy
Commits
0646aaf9
Commit
0646aaf9
authored
5 years ago
by
Paul McCarthy
Browse files
Options
Downloads
Patches
Plain Diff
ENH: New makeWriteable function
parent
fd0b848f
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
fsl/data/__init__.py
+2
-1
2 additions, 1 deletion
fsl/data/__init__.py
fsl/data/utils.py
+12
-1
12 additions, 1 deletion
fsl/data/utils.py
with
14 additions
and
2 deletions
fsl/data/__init__.py
+
2
−
1
View file @
0646aaf9
...
@@ -9,4 +9,5 @@ models, constants, and other data-like things used throughout ``fslpy``.
...
@@ -9,4 +9,5 @@ models, constants, and other data-like things used throughout ``fslpy``.
"""
"""
from
.utils
import
guessType
# noqa
from
.utils
import
(
guessType
,
# noqa
makeWriteable
)
This diff is collapsed.
Click to expand it.
fsl/data/utils.py
+
12
−
1
View file @
0646aaf9
...
@@ -10,7 +10,7 @@ with the data types defined in the :mod:`fsl.data` package.
...
@@ -10,7 +10,7 @@ with the data types defined in the :mod:`fsl.data` package.
import
os.path
as
op
import
os.path
as
op
import
numpy
as
np
def
guessType
(
path
):
def
guessType
(
path
):
"""
A convenience function which, given the name of a file or directory,
"""
A convenience function which, given the name of a file or directory,
...
@@ -77,3 +77,14 @@ def guessType(path):
...
@@ -77,3 +77,14 @@ def guessType(path):
# Otherwise, I don't
# Otherwise, I don't
# know what to do
# know what to do
return
None
,
path
return
None
,
path
def
makeWriteable
(
array
):
"""
Updates the given ``numpy.array`` so that it is writeable. If this
is not possible, a copy is created and returned.
"""
try
:
array
.
flags
[
'
WRITEABLE
'
]
=
True
except
ValueError
:
array
=
np
.
array
(
array
)
return
array
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