Skip to content

Commit

Permalink
More linting fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pgleeson committed Sep 3, 2024
1 parent 0f008ab commit d42f7b0
Show file tree
Hide file tree
Showing 21 changed files with 42 additions and 82 deletions.
4 changes: 2 additions & 2 deletions c302/CompareMain.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
8 changes: 4 additions & 4 deletions c302/ConnectomeReader.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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_(
Expand Down Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions c302/Cook2019DataReader.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 1 addition & 5 deletions c302/NeuroMLUtilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions c302/OpenWormReader.py
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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()

Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions c302/SpreadsheetDataReader.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down
4 changes: 2 additions & 2 deletions c302/UpdatedSpreadsheetDataReader.py
Original file line number Diff line number Diff line change
Expand Up @@ -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_
Expand Down
4 changes: 2 additions & 2 deletions c302/UpdatedSpreadsheetDataReader2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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_
Expand Down
6 changes: 3 additions & 3 deletions c302/VarshneyDataReader.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion c302/W_SpreadsheetDataReader.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion c302/WhiteDataReader.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

############################################################

import csv

from c302.ConnectomeReader import ConnectionInfo
from c302.ConnectomeReader import analyse_connections
Expand Down
9 changes: 4 additions & 5 deletions c302/WormNeuroAtlasReader.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion c302/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

try:
from urllib2 import URLError # Python 2
except:
except Exception:
from urllib.error import URLError # Python 3

logging.basicConfig()
Expand Down
1 change: 0 additions & 1 deletion c302/c302_IClampMuscle.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import c302
import sys
import neuroml.writers as writers


def setup(
Expand Down
1 change: 0 additions & 1 deletion c302/c302_TargetMuscle.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import c302
import sys
import neuroml.writers as writers


def setup(
Expand Down
19 changes: 7 additions & 12 deletions c302/c302_info.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
import sys
import os
from pyneuroml import pynml
import matplotlib.pyplot as plt
import numpy as np

import c302

Expand All @@ -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:
Expand All @@ -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:
Expand Down
20 changes: 8 additions & 12 deletions c302/c302_utils.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -767,5 +763,5 @@ def generate_conn_matrix(
colormap=colormap,
)

if not "-nogui" in sys.argv:
if "-nogui" not in sys.argv:
plt.show()
2 changes: 1 addition & 1 deletion c302/parameters_C1.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
3 changes: 0 additions & 3 deletions c302/parameters_D.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 0 additions & 15 deletions c302/parameters_D1.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 0 additions & 1 deletion c302/parameters_X.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
from neuroml import ChannelDensity
from neuroml import SpikeThresh

from neuroml import GradedSynapse
from neuroml import GapJunction
from neuroml import PulseGenerator

Expand Down

0 comments on commit d42f7b0

Please sign in to comment.