Skip to content

Commit 4cc16ec

Browse files
authored
Merge pull request #367 from incf-nidash/prune-imports
Remove redundant imports
2 parents ab539e5 + 700dff2 commit 4cc16ec

7 files changed

+3
-30
lines changed

src/nidm/experiment/Query.py

-4
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,6 @@ def GetProjectLocation(nidm_file_list, project_uuid, output_file=None): # noqa:
200200

201201

202202
def testprojectmeta(nidm_file_list):
203-
import json
204-
205203
query = """
206204
prefix nidm: <http://purl.org/nidash/nidm#>
207205
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
@@ -229,8 +227,6 @@ def testprojectmeta(nidm_file_list):
229227

230228

231229
def GetProjectSessionsMetadata(nidm_file_list, project_uuid):
232-
import json
233-
234230
query = (
235231
"""
236232

src/nidm/experiment/tools/nidm_affinity_propagation.py

-4
Original file line numberDiff line numberDiff line change
@@ -393,10 +393,6 @@ def ap():
393393

394394
def opencsv(data):
395395
"""saves a list of lists as a csv and opens"""
396-
import csv
397-
import os
398-
import tempfile
399-
400396
handle, fn = tempfile.mkstemp(suffix=".csv")
401397
with os.fdopen(
402398
handle, "w", encoding="utf8", errors="surrogateescape", newline=""

src/nidm/experiment/tools/nidm_agglomerative_clustering.py

-4
Original file line numberDiff line numberDiff line change
@@ -381,10 +381,6 @@ def ac():
381381

382382
def opencsv(data):
383383
"""saves a list of lists as a csv and opens"""
384-
import csv
385-
import os
386-
import tempfile
387-
388384
handle, fn = tempfile.mkstemp(suffix=".csv")
389385
with os.fdopen(
390386
handle, "w", encoding="utf8", errors="surrogateescape", newline=""

src/nidm/experiment/tools/nidm_gmm.py

-4
Original file line numberDiff line numberDiff line change
@@ -558,10 +558,6 @@ def cluster_number():
558558

559559
def opencsv(data):
560560
"""saves a list of lists as a csv and opens"""
561-
import csv
562-
import os
563-
import tempfile
564-
565561
handle, fn = tempfile.mkstemp(suffix=".csv")
566562
with os.fdopen(
567563
handle, "w", encoding="utf8", errors="surrogateescape", newline=""

src/nidm/experiment/tools/nidm_kmeans.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import csv
22
import os
33
import tempfile
4+
import warnings
45
import click
56
import matplotlib.pyplot as plt
67
import numpy as np
@@ -548,8 +549,6 @@ def cluster_number():
548549
plt.show()
549550

550551
if "ca" in cm.lower():
551-
import warnings
552-
553552
warnings.filterwarnings(
554553
"ignore", category=FutureWarning
555554
) # it is a function for 0.24 but says it is deprecated in 0.23
@@ -646,10 +645,6 @@ def cluster_number():
646645

647646
def opencsv(data):
648647
"""saves a list of lists as a csv and opens"""
649-
import csv
650-
import os
651-
import tempfile
652-
653648
handle, fn = tempfile.mkstemp(suffix=".csv")
654649
with os.fdopen(
655650
handle, "w", encoding="utf8", errors="surrogateescape", newline=""

src/nidm/experiment/tools/nidm_linreg.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import os
3636
from statistics import mean
3737
import tempfile
38+
import warnings
3839
import click
3940
import numpy as np
4041
import pandas as pd
@@ -434,8 +435,6 @@ def dataparsing(): # The data is changed to a format that is usable by the line
434435
"\nYour data set has less than 20 points, which means the model calculated may not be accurate due to a lack of data. "
435436
)
436437
print("This means you cannot regularize the data either.")
437-
import warnings
438-
439438
warnings.filterwarnings("ignore")
440439
answer = input("Continue anyways? Y or N: ")
441440
if o is not None:
@@ -893,10 +892,6 @@ def regularizing():
893892

894893
def opencsv(data):
895894
"""saves a list of lists as a csv and opens"""
896-
import csv
897-
import os
898-
import tempfile
899-
900895
handle, fn = tempfile.mkstemp(suffix=".csv")
901896
with os.fdopen(
902897
handle, "w", encoding="utf8", errors="surrogateescape", newline=""

src/nidm/experiment/tools/rest_statistics.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import sys
22
from nidm.core import Constants
33
from nidm.experiment import Navigate
4-
import nidm.experiment.Navigate
54
import nidm.experiment.tools.rest
65

76

@@ -34,7 +33,7 @@ def GetProjectsComputedMetadata(nidm_file_list):
3433

3534
for a in activities:
3635
data = Navigate.getActivityData(tuple(nidm_file_list), a)
37-
if type(data) == nidm.experiment.Navigate.ActivityData:
36+
if type(data) == Navigate.ActivityData:
3837
for x in data.data:
3938
if x.isAbout == Constants.NIDM_IS_ABOUT_AGE:
4039
if (

0 commit comments

Comments
 (0)