From d42f7b094bf8d594670e95cc563e28e0aebaeb8f Mon Sep 17 00:00:00 2001 From: pgleeson Date: Tue, 3 Sep 2024 10:57:25 +0100 Subject: [PATCH] More linting fixes --- c302/CompareMain.py | 4 ++-- c302/ConnectomeReader.py | 8 ++++---- c302/Cook2019DataReader.py | 3 --- c302/NeuroMLUtilities.py | 6 +----- c302/OpenWormReader.py | 8 ++++---- c302/SpreadsheetDataReader.py | 6 +++--- c302/UpdatedSpreadsheetDataReader.py | 4 ++-- c302/UpdatedSpreadsheetDataReader2.py | 4 ++-- c302/VarshneyDataReader.py | 6 +++--- c302/W_SpreadsheetDataReader.py | 1 - c302/WhiteDataReader.py | 1 - c302/WormNeuroAtlasReader.py | 9 ++++----- c302/__init__.py | 2 +- c302/c302_IClampMuscle.py | 1 - c302/c302_TargetMuscle.py | 1 - c302/c302_info.py | 19 +++++++------------ c302/c302_utils.py | 20 ++++++++------------ c302/parameters_C1.py | 2 +- c302/parameters_D.py | 3 --- c302/parameters_D1.py | 15 --------------- c302/parameters_X.py | 1 - 21 files changed, 42 insertions(+), 82 deletions(-) diff --git a/c302/CompareMain.py b/c302/CompareMain.py index bac3fce9..ab543130 100644 --- a/c302/CompareMain.py +++ b/c302/CompareMain.py @@ -118,13 +118,13 @@ def getColumnsXls(fileIn): # print(indexName[c]) while curr_row < num_rows: curr_row += 1 - row = worksheet.row(curr_row) + #row = worksheet.row(curr_row) # print('Row:', curr_row) curr_cell = -1 while curr_cell < num_cells: curr_cell += 1 # Cell Types: 0=Empty, 1=Text, 2=Number, 3=Date, 4=Boolean, 5=Error, 6=Blank - cell_type = worksheet.cell_type(curr_row, curr_cell) + #cell_type = worksheet.cell_type(curr_row, curr_cell) cell_value = str(worksheet.cell_value(curr_row, curr_cell)) # print(' ', cell_type, ':', cell_value) cols[indexName[curr_cell]] += [cell_value] diff --git a/c302/ConnectomeReader.py b/c302/ConnectomeReader.py index 9f059329..3e8e39b4 100644 --- a/c302/ConnectomeReader.py +++ b/c302/ConnectomeReader.py @@ -507,7 +507,7 @@ def check_neurons(cells): not_in_preferred = [] missing_preferred = [n for n in PREFERRED_NEURON_NAMES] for c in cells: - if not c in PREFERRED_NEURON_NAMES: + if c not in PREFERRED_NEURON_NAMES: not_in_preferred.append(c) else: preferred.append(c) @@ -539,7 +539,7 @@ def analyse_connections(cells, neuron_conns, neurons2muscles, muscles, muscle_co nts_tot = {} for c in neuron_conns: nt = c.synclass - if not nt in nts: + if nt not in nts: nts[nt] = 0 nts_tot[nt] = 0 nts[nt] += 1 @@ -558,7 +558,7 @@ def analyse_connections(cells, neuron_conns, neurons2muscles, muscles, muscle_co print_("Found %s muscles: %s\n" % (len(muscles), sorted(muscles))) not_in_preferred = [] for m in muscles: - if not m in PREFERRED_MUSCLE_NAMES: + if m not in PREFERRED_MUSCLE_NAMES: not_in_preferred.append(m) print_( @@ -586,7 +586,7 @@ def analyse_connections(cells, neuron_conns, neurons2muscles, muscles, muscle_co nts_tot = {} for c in muscle_conns: nt = c.synclass - if not nt in nts: + if nt not in nts: nts[nt] = 0 nts_tot[nt] = 0 nts[nt] += 1 diff --git a/c302/Cook2019DataReader.py b/c302/Cook2019DataReader.py index d04878cc..3d417dc8 100644 --- a/c302/Cook2019DataReader.py +++ b/c302/Cook2019DataReader.py @@ -9,12 +9,9 @@ ############################################################ -import csv from c302.ConnectomeReader import ConnectionInfo from c302.ConnectomeReader import analyse_connections -from c302.ConnectomeReader import convert_to_preferred_muscle_name -from c302.ConnectomeReader import is_neuron from c302.ConnectomeReader import is_body_wall_muscle from c302.ConnectomeReader import remove_leading_index_zero diff --git a/c302/NeuroMLUtilities.py b/c302/NeuroMLUtilities.py index cc399d9d..7c56e844 100644 --- a/c302/NeuroMLUtilities.py +++ b/c302/NeuroMLUtilities.py @@ -6,12 +6,8 @@ ############################################################ -from c302 import print_ -from c302.ConnectomeReader import PREFERRED_NEURON_NAMES -from c302.ConnectomeReader import PREFERRED_MUSCLE_NAMES -from c302.ConnectomeReader import ConnectionInfo from c302.ConnectomeReader import analyse_connections @@ -48,7 +44,7 @@ def fract(a, b, f): if __name__ == "__main__": - from SpreadsheetDataReader import read_data, read_muscle_data + #from SpreadsheetDataReader import read_data, read_muscle_data from WormNeuroAtlasReader import read_data, read_muscle_data cells, neuron_conns = read_data(include_nonconnected_cells=True) diff --git a/c302/OpenWormReader.py b/c302/OpenWormReader.py index 02e9feed..a34e6a18 100644 --- a/c302/OpenWormReader.py +++ b/c302/OpenWormReader.py @@ -1,8 +1,8 @@ import logging import re -from c302.NeuroMLUtilities import ConnectionInfo -from c302.NeuroMLUtilities import analyse_connections +from c302.ConnectomeReader import ConnectionInfo +from c302.ConnectomeReader import analyse_connections from c302 import print_, MUSCLE_RE try: @@ -11,7 +11,7 @@ from owmeta.neuron import Neuron from owmeta.muscle import BodyWallMuscle from owmeta.worm import Worm -except: +except Exception: print("owmeta not installed! Cannot run OpenWormReader") exit() @@ -158,7 +158,7 @@ def format_muscle_name(muscle_name): exit() conn_map_OWR = {} - for c in conns: + for c in muscle_conns: conn_map_OWR[c.short().lower()] = c from c302.UpdatedSpreadsheetDataReader import read_data as read_data_usr diff --git a/c302/SpreadsheetDataReader.py b/c302/SpreadsheetDataReader.py index e8ac18c8..6c362785 100644 --- a/c302/SpreadsheetDataReader.py +++ b/c302/SpreadsheetDataReader.py @@ -10,15 +10,15 @@ ############################################################ -from c302.NeuroMLUtilities import ConnectionInfo -from c302.NeuroMLUtilities import analyse_connections +from c302 import print_ +from c302.ConnectomeReader import ConnectionInfo +from c302.ConnectomeReader import analyse_connections from xlrd import open_workbook import os spreadsheet_location = os.path.dirname(os.path.abspath(__file__)) + "/data/" -from c302 import print_ READER_DESCRIPTION = ( """Data extracted from CElegansNeuronTables.xls for neuronal connectivity""" diff --git a/c302/UpdatedSpreadsheetDataReader.py b/c302/UpdatedSpreadsheetDataReader.py index 97f66086..0cf9d4a8 100644 --- a/c302/UpdatedSpreadsheetDataReader.py +++ b/c302/UpdatedSpreadsheetDataReader.py @@ -11,8 +11,8 @@ import csv -from c302.NeuroMLUtilities import ConnectionInfo -from c302.NeuroMLUtilities import analyse_connections +from c302.ConnectomeReader import ConnectionInfo +from c302.ConnectomeReader import analyse_connections import os from c302 import print_ diff --git a/c302/UpdatedSpreadsheetDataReader2.py b/c302/UpdatedSpreadsheetDataReader2.py index 234e283c..20286823 100644 --- a/c302/UpdatedSpreadsheetDataReader2.py +++ b/c302/UpdatedSpreadsheetDataReader2.py @@ -12,8 +12,8 @@ import csv -from c302.NeuroMLUtilities import ConnectionInfo -from c302.NeuroMLUtilities import analyse_connections +from c302.ConnectomeReader import ConnectionInfo +from c302.ConnectomeReader import analyse_connections import os from c302 import print_ diff --git a/c302/VarshneyDataReader.py b/c302/VarshneyDataReader.py index d01fe88e..1717bd71 100644 --- a/c302/VarshneyDataReader.py +++ b/c302/VarshneyDataReader.py @@ -1,5 +1,5 @@ -from c302.NeuroMLUtilities import ConnectionInfo -from c302.NeuroMLUtilities import analyse_connections +from c302.ConnectomeReader import ConnectionInfo +from c302.ConnectomeReader import analyse_connections from openpyxl import load_workbook import os @@ -70,7 +70,7 @@ def read_muscle_data(): conns.append(ConnectionInfo(pre, post, num, syntype, synclass)) if pre not in neurons: neurons.append(pre) - if not post in muscles: + if post not in muscles: muscles.append(post) return neurons, muscles, conns diff --git a/c302/W_SpreadsheetDataReader.py b/c302/W_SpreadsheetDataReader.py index dbd1dfb4..6f48ec47 100644 --- a/c302/W_SpreadsheetDataReader.py +++ b/c302/W_SpreadsheetDataReader.py @@ -2,7 +2,6 @@ from c302.ConnectomeReader import analyse_connections from c302.ConnectomeReader import convert_to_preferred_muscle_name from c302.ConnectomeReader import is_neuron -from c302.ConnectomeReader import is_body_wall_muscle from openpyxl import load_workbook import os diff --git a/c302/WhiteDataReader.py b/c302/WhiteDataReader.py index a4111d93..facde852 100644 --- a/c302/WhiteDataReader.py +++ b/c302/WhiteDataReader.py @@ -9,7 +9,6 @@ ############################################################ -import csv from c302.ConnectomeReader import ConnectionInfo from c302.ConnectomeReader import analyse_connections diff --git a/c302/WormNeuroAtlasReader.py b/c302/WormNeuroAtlasReader.py index a37c71a3..d0195fc6 100644 --- a/c302/WormNeuroAtlasReader.py +++ b/c302/WormNeuroAtlasReader.py @@ -1,8 +1,7 @@ import logging -import re -from c302.NeuroMLUtilities import ConnectionInfo -from c302.NeuroMLUtilities import analyse_connections +from c302.ConnectomeReader import ConnectionInfo +from c302.ConnectomeReader import analyse_connections from c302 import print_ import wormneuroatlas as wa @@ -93,9 +92,9 @@ def read_data(self, include_nonconnected_cells=False): connection = True if connection: - if not pre in connected_cells: + if pre not in connected_cells: connected_cells.append(pre) - if not post in connected_cells: + if post not in connected_cells: connected_cells.append(post) if include_nonconnected_cells: diff --git a/c302/__init__.py b/c302/__init__.py index 7fd9add6..b4ed2d00 100755 --- a/c302/__init__.py +++ b/c302/__init__.py @@ -44,7 +44,7 @@ try: from urllib2 import URLError # Python 2 -except: +except Exception: from urllib.error import URLError # Python 3 logging.basicConfig() diff --git a/c302/c302_IClampMuscle.py b/c302/c302_IClampMuscle.py index 7b92250d..f860c8d3 100644 --- a/c302/c302_IClampMuscle.py +++ b/c302/c302_IClampMuscle.py @@ -1,6 +1,5 @@ import c302 import sys -import neuroml.writers as writers def setup( diff --git a/c302/c302_TargetMuscle.py b/c302/c302_TargetMuscle.py index cdcf9ae6..927ce365 100644 --- a/c302/c302_TargetMuscle.py +++ b/c302/c302_TargetMuscle.py @@ -1,6 +1,5 @@ import c302 import sys -import neuroml.writers as writers def setup( diff --git a/c302/c302_info.py b/c302/c302_info.py index 550a78d7..d00f13fa 100644 --- a/c302/c302_info.py +++ b/c302/c302_info.py @@ -1,8 +1,3 @@ -import sys -import os -from pyneuroml import pynml -import matplotlib.pyplot as plt -import numpy as np import c302 @@ -15,14 +10,14 @@ def generate_c302_info(nml_doc, verbose=False): all_cells = [] for cp in net.continuous_projections: - if not cp.presynaptic_population in cc_exc_conns.keys(): + if cp.presynaptic_population not in cc_exc_conns.keys(): cc_exc_conns[cp.presynaptic_population] = {} - if not cp.presynaptic_population in cc_inh_conns.keys(): + if cp.presynaptic_population not in cc_inh_conns.keys(): cc_inh_conns[cp.presynaptic_population] = {} - if not cp.presynaptic_population in all_cells: + if cp.presynaptic_population not in all_cells: all_cells.append(cp.presynaptic_population) - if not cp.postsynaptic_population in all_cells: + if cp.postsynaptic_population not in all_cells: all_cells.append(cp.postsynaptic_population) for c in cp.continuous_connection_instance_ws: @@ -37,12 +32,12 @@ def generate_c302_info(nml_doc, verbose=False): gj_conns = {} for ep in net.electrical_projections: - if not ep.presynaptic_population in gj_conns.keys(): + if ep.presynaptic_population not in gj_conns.keys(): gj_conns[ep.presynaptic_population] = {} - if not ep.presynaptic_population in all_cells: + if ep.presynaptic_population not in all_cells: all_cells.append(ep.presynaptic_population) - if not ep.postsynaptic_population in all_cells: + if ep.postsynaptic_population not in all_cells: all_cells.append(ep.postsynaptic_population) for e in ep.electrical_connection_instance_ws: diff --git a/c302/c302_utils.py b/c302/c302_utils.py index bc2a0d4f..1a93638e 100644 --- a/c302/c302_utils.py +++ b/c302/c302_utils.py @@ -1,12 +1,9 @@ import sys import os import re -import collections -import traceback import matplotlib.pyplot as plt import numpy as np -from pyneuroml import pynml from pyneuroml import plot as pyneuroml_plot import c302 @@ -414,7 +411,6 @@ def _show_conn_matrix( title = "%s: %s" % (type, t) plt.title(title) fig.canvas.manager.set_window_title(title) - import matplotlib # cm = matplotlib.cm.get_cmap('gist_stern_r') if colormap == None: @@ -471,14 +467,14 @@ def generate_conn_matrix( all_cells = [] for cp in net.continuous_projections: - if not cp.presynaptic_population in cc_exc_conns.keys(): + if cp.presynaptic_population not in cc_exc_conns.keys(): cc_exc_conns[cp.presynaptic_population] = {} - if not cp.presynaptic_population in cc_inh_conns.keys(): + if cp.presynaptic_population not in cc_inh_conns.keys(): cc_inh_conns[cp.presynaptic_population] = {} - if not cp.presynaptic_population in all_cells: + if cp.presynaptic_population not in all_cells: all_cells.append(cp.presynaptic_population) - if not cp.postsynaptic_population in all_cells: + if cp.postsynaptic_population not in all_cells: all_cells.append(cp.postsynaptic_population) for c in cp.continuous_connection_instance_ws: @@ -493,12 +489,12 @@ def generate_conn_matrix( gj_conns = {} for ep in net.electrical_projections: - if not ep.presynaptic_population in gj_conns.keys(): + if ep.presynaptic_population not in gj_conns.keys(): gj_conns[ep.presynaptic_population] = {} - if not ep.presynaptic_population in all_cells: + if ep.presynaptic_population not in all_cells: all_cells.append(ep.presynaptic_population) - if not ep.postsynaptic_population in all_cells: + if ep.postsynaptic_population not in all_cells: all_cells.append(ep.postsynaptic_population) for e in ep.electrical_connection_instance_ws: @@ -767,5 +763,5 @@ def generate_conn_matrix( colormap=colormap, ) - if not "-nogui" in sys.argv: + if "-nogui" not in sys.argv: plt.show() diff --git a/c302/parameters_C1.py b/c302/parameters_C1.py index fac01f56..33463103 100644 --- a/c302/parameters_C1.py +++ b/c302/parameters_C1.py @@ -29,7 +29,7 @@ def set_default_bioparameters(self): param_C = ParameterisedModel_C() param_C.set_default_bioparameters() for b in param_C.bioparameters: - if not "syn" in b.name: + if "syn" not in b.name: self.add_bioparameter_obj(b) self.add_bioparameter( diff --git a/c302/parameters_D.py b/c302/parameters_D.py index bc46f45d..93a94738 100644 --- a/c302/parameters_D.py +++ b/c302/parameters_D.py @@ -20,9 +20,6 @@ from neuroml import Morphology from neuroml import Point3DWithDiam from neuroml import Segment -from neuroml import SegmentParent -from neuroml import Member -from neuroml import SegmentGroup from neuroml import BiophysicalProperties from neuroml import IntracellularProperties from neuroml import Resistivity diff --git a/c302/parameters_D1.py b/c302/parameters_D1.py index 208c5829..00d9ced8 100644 --- a/c302/parameters_D1.py +++ b/c302/parameters_D1.py @@ -13,23 +13,8 @@ """ -from neuroml import Cell -from neuroml import Morphology -from neuroml import Point3DWithDiam -from neuroml import Segment -from neuroml import BiophysicalProperties -from neuroml import IntracellularProperties -from neuroml import Resistivity -from neuroml import Species -from neuroml import MembraneProperties -from neuroml import InitMembPotential -from neuroml import SpecificCapacitance -from neuroml import ChannelDensity -from neuroml import SpikeThresh -from neuroml import FixedFactorConcentrationModel from neuroml import GapJunction -from neuroml import PulseGenerator from c302.parameters_D import ParameterisedModel as ParameterisedModel_D diff --git a/c302/parameters_X.py b/c302/parameters_X.py index cc004261..b64f889a 100644 --- a/c302/parameters_X.py +++ b/c302/parameters_X.py @@ -23,7 +23,6 @@ from neuroml import ChannelDensity from neuroml import SpikeThresh -from neuroml import GradedSynapse from neuroml import GapJunction from neuroml import PulseGenerator