Skip to content

Commit

Permalink
Sort imports
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolossus committed Aug 9, 2023
1 parent 8b039cf commit 4d52bd9
Show file tree
Hide file tree
Showing 264 changed files with 473 additions and 405 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/nestbuildmatrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ jobs:
- name: "Run isort..."
uses: isort/isort-action@f14e57e1d457956c45a19c05a89cccdf087846e5 # 1.1.0
with:
configuration: --profile black --check-only --diff
configuration: --profile=black --thirdparty="nest" --check-only --diff

black:
runs-on: "ubuntu-20.04"
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ repos:
rev: 5.12.0
hooks:
- id: isort
args: ["--profile", "black", "--check-only", "--diff"]
args: ["--profile", "black", "--thirdparty", "nest", "--check-only", "--diff"]
- repo: https://github.com/psf/black
rev: 23.7.0
hooks:
Expand Down
24 changes: 11 additions & 13 deletions bin/nest-server-mpi
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,16 @@ Options:
from docopt import docopt
from mpi4py import MPI

if __name__ == '__main__':
if __name__ == "__main__":
opt = docopt(__doc__)

import time
import os
import sys
import time

import nest
import nest.server

import os

HOST = os.getenv("NEST_SERVER_HOST", "127.0.0.1")
PORT = os.getenv("NEST_SERVER_PORT", "52425")

Expand All @@ -35,34 +34,33 @@ rank = comm.Get_rank()


def log(call_name, msg):
msg = f'==> WORKER {rank}/{time.time():.7f} ({call_name}): {msg}'
msg = f"==> WORKER {rank}/{time.time():.7f} ({call_name}): {msg}"
print(msg, flush=True)


if rank == 0:
print("==> Starting NEST Server Master on rank 0", flush=True)
nest.server.set_mpi_comm(comm)
nest.server.run_mpi_app(host=opt.get('--host', HOST), port=opt.get('--port', PORT))
nest.server.run_mpi_app(host=opt.get("--host", HOST), port=opt.get("--port", PORT))

else:
print(f"==> Starting NEST Server Worker on rank {rank}", flush=True)
nest.server.set_mpi_comm(comm)
while True:

log('spinwait', 'waiting for call bcast')
log("spinwait", "waiting for call bcast")
call_name = comm.bcast(None, root=0)

log(call_name, 'received call bcast, waiting for data bcast')
log(call_name, "received call bcast, waiting for data bcast")
data = comm.bcast(None, root=0)

log(call_name, f'received data bcast, data={data}')
log(call_name, f"received data bcast, data={data}")
args, kwargs = data

if call_name == 'exec':
if call_name == "exec":
response = nest.server.do_exec(args, kwargs)
else:
call, args, kwargs = nest.server.nestify(call_name, args, kwargs)
log(call_name, f'local call, args={args}, kwargs={kwargs}')
log(call_name, f"local call, args={args}, kwargs={kwargs}")

# The following exception handler is useful if an error
# occurs simulataneously on all processes. If only a
Expand All @@ -74,5 +72,5 @@ else:
except Exception:
continue

log(call_name, f'sending reponse gather, data={response}')
log(call_name, f"sending reponse gather, data={response}")
comm.gather(nest.serializable(response), root=0)
2 changes: 1 addition & 1 deletion build_support/check_copyright_headers.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@


import os
import sys
import re
import sys


def eprint(*args, **kwargs):
Expand Down
2 changes: 1 addition & 1 deletion build_support/check_unused_names.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
"""

import os
import sys
import re
import sys
from subprocess import check_output


Expand Down
3 changes: 1 addition & 2 deletions build_support/generate_modelsmodule.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,9 @@
compiled by CMake.
"""

import argparse
import os
import sys
import argparse

from pathlib import Path
from textwrap import dedent

Expand Down
3 changes: 2 additions & 1 deletion doc/htmldoc/_ext/HoverXTooltip.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@
# You should have received a copy of the GNU General Public License
# along with NEST. If not, see <http://www.gnu.org/licenses/>.

import re
import os
import re
import sys

from docutils import nodes
from docutils.parsers.rst import Directive, directives

Expand Down
1 change: 1 addition & 0 deletions doc/htmldoc/_ext/VersionSyncRole.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import json
from pathlib import Path

from docutils import nodes


Expand Down
14 changes: 7 additions & 7 deletions doc/htmldoc/_ext/extractor_userdocs.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@
# You should have received a copy of the GNU General Public License
# along with NEST. If not, see <http://www.gnu.org/licenses/>.

import re
from tqdm import tqdm
from pprint import pformat
from math import comb

import os
import glob
import json
from itertools import chain, combinations
import logging
import os
import re
from collections import Counter
from itertools import chain, combinations
from math import comb
from pprint import pformat

from tqdm import tqdm

logging.basicConfig(level=logging.WARNING)
log = logging.getLogger()
Expand Down
2 changes: 1 addition & 1 deletion doc/htmldoc/clean_source_dirs.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
# You should have received a copy of the GNU General Public License
# along with NEST. If not, see <http://www.gnu.org/licenses/>.
import os
import shutil
import pathlib
import shutil
from glob import glob

for dir_ in ("auto_examples", "models"):
Expand Down
8 changes: 3 additions & 5 deletions doc/htmldoc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,13 @@
# along with NEST. If not, see <http://www.gnu.org/licenses/>.


import sys
import os
import json
import os
import subprocess

from urllib.request import urlretrieve

import sys
from pathlib import Path
from shutil import copyfile
from urllib.request import urlretrieve

# Add the extension modules to the path
extension_module_dir = os.path.abspath("./_ext")
Expand Down
2 changes: 1 addition & 1 deletion doc/htmldoc/networks/scripts/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@

# create connectivity figures for spatial manual

import nest
import matplotlib.pyplot as plt
import nest
import numpy as np

# seed NumPy RNG to ensure identical results for runs with random placement
Expand Down
2 changes: 1 addition & 1 deletion doc/htmldoc/resolve_includes.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@
"""

import glob
import os
import re
import sys
import glob
from fileinput import FileInput

pattern = re.compile("^.. include:: (.*)")
Expand Down
12 changes: 8 additions & 4 deletions doc/slihelp_generator/generate_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,21 @@
The helpindex is built during installation in a separate step.
"""

import os
import html
import io
import os
import re
import sys
import textwrap

from helpers_sli import (
check_ifdef,
create_helpdirs,
cut_it,
delete_helpdir,
help_generation_required,
)
from writers import coll_data
from helpers_sli import check_ifdef, create_helpdirs, cut_it
from helpers_sli import delete_helpdir
from helpers_sli import help_generation_required

if len(sys.argv) != 3:
print("Usage: python3 generate_help.py <source_dir> <build_dir>")
Expand Down
1 change: 1 addition & 0 deletions doc/slihelp_generator/generate_helpindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

import os
import sys

from writers import write_helpindex

if len(sys.argv) != 2:
Expand Down
4 changes: 2 additions & 2 deletions doc/slihelp_generator/helpers_sli.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
# You should have received a copy of the GNU General Public License
# along with NEST. If not, see <http://www.gnu.org/licenses/>.

import re
import errno
import os
import re
import shutil
import errno


def cut_it(separator, text):
Expand Down
3 changes: 2 additions & 1 deletion doc/slihelp_generator/writers.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@
import os
import re
import textwrap
from helpers_sli import cut_it
from string import Template

from helpers_sli import cut_it


def write_help_html(doc_dic, helpdir, fname, sli_command_list, keywords):
"""
Expand Down
5 changes: 3 additions & 2 deletions examples/nest/Potjans_2014/spike_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@

# Merges spike files, produces raster plots, calculates and plots firing rates

import numpy as np
import glob
import matplotlib.pyplot as plt
import os
import re

import matplotlib.pyplot as plt
import numpy as np

datapath = "."

# get simulation time and numbers of neurons recorded from sim_params.sli
Expand Down
2 changes: 1 addition & 1 deletion pynest/examples/BrodyHopfield.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@
#################################################################################
# First, we import all necessary modules for simulation, analysis, and plotting.

import matplotlib.pyplot as plt
import nest
import nest.raster_plot
import matplotlib.pyplot as plt

###############################################################################
# Second, the simulation parameters are assigned to variables.
Expand Down
8 changes: 3 additions & 5 deletions pynest/examples/CampbellSiegert.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,10 @@
# First, we import all necessary modules for simulation and analysis. Scipy
# should be imported before nest.

from scipy.special import erf
from scipy.optimize import fmin

import numpy as np

import nest
import numpy as np
from scipy.optimize import fmin
from scipy.special import erf

###############################################################################
# We first set the parameters of neurons, noise and the simulation. First
Expand Down
5 changes: 3 additions & 2 deletions pynest/examples/Potjans_2014/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@
"""

from matplotlib.patches import Polygon
import matplotlib.pyplot as plt
import os

import matplotlib.pyplot as plt
import numpy as np
from matplotlib.patches import Polygon

if "DISPLAY" not in os.environ:
import matplotlib
Expand Down
7 changes: 4 additions & 3 deletions pynest/examples/Potjans_2014/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@
"""

import os
import numpy as np
import nest
import helpers
import warnings

import helpers
import nest
import numpy as np


class Network:
"""Provides functions to setup NEST, to create and connect all nodes of
Expand Down
11 changes: 6 additions & 5 deletions pynest/examples/Potjans_2014/run_microcircuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@
###############################################################################
# Import the necessary modules and start the time measurements.

from stimulus_params import stim_dict
from network_params import net_dict
from sim_params import sim_dict
import network
import time

import nest
import network
import numpy as np
import time
from network_params import net_dict
from sim_params import sim_dict
from stimulus_params import stim_dict

time_start = time.time()

Expand Down
2 changes: 1 addition & 1 deletion pynest/examples/aeif_cond_beta_multisynapse.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
"""

import matplotlib.pyplot as plt
import nest
import numpy as np
import matplotlib.pyplot as plt

neuron = nest.Create("aeif_cond_beta_multisynapse")
nest.SetStatus(neuron, {"V_peak": 0.0, "a": 4.0, "b": 80.5})
Expand Down
5 changes: 2 additions & 3 deletions pynest/examples/balancedneuron.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,10 @@
# First, we import all necessary modules for simulation, analysis and
# plotting. Scipy should be imported before nest.

from scipy.optimize import bisect

import matplotlib.pyplot as plt
import nest
import nest.voltage_trace
import matplotlib.pyplot as plt
from scipy.optimize import bisect

###############################################################################
# Additionally, we set the verbosity using ``set_verbosity`` to
Expand Down
Loading

0 comments on commit 4d52bd9

Please sign in to comment.