Skip to content

Commit

Permalink
Merge pull request #189 from jhlegarreta/ApplyIsortToPackageImports
Browse files Browse the repository at this point in the history
STYLE: Apply `isort` to package imports
  • Loading branch information
jhlegarreta authored Oct 21, 2023
2 parents adb6fc1 + 28a4bfa commit 4dbf568
Show file tree
Hide file tree
Showing 66 changed files with 208 additions and 134 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/check_format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: code format

on: [push]

jobs:
pre-commit:

runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
python-version: ['3.10']
requires: ['latest']

steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install and run pre-commit hooks
uses: pre-commit/[email protected]
2 changes: 2 additions & 0 deletions .github/workflows/test_package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ jobs:
if: matrix.requires == 'minimal'
run: |
python -c "req = open('requirements.txt').read().replace(' >= ', ' == ') ; open('requirements.txt', 'w').write(req)"
python -c "req = open('requirements_dev.txt').read().replace(' >= ', ' == ') ; open('requirements_dev.txt', 'w').write(req)"
python -c "req = open('setup.py').read().replace(' >= ', ' == ') ; open('setup.py', 'w').write(req)"
# - name: Cache pip
Expand All @@ -45,6 +46,7 @@ jobs:
# if: steps.cache.outputs.cache-hit != 'true'
run: |
python -m pip install --upgrade --user pip setuptools pytest-cov
pip install -r requirements_dev.txt
python --version
pip --version
pip list
Expand Down
10 changes: 10 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
default_language_version:
python: python3.10

repos:
- repo: https://github.com/timothycrosley/isort
rev: 5.11.5
hooks:
- id: isort
name: isort
types: [python]
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ whitematteranalysis

[![test, package](https://github.com/SlicerDMRI/whitematteranalysis/actions/workflows/test_package.yaml/badge.svg?branch=master)](https://github.com/SlicerDMRI/whitematteranalysis/actions/workflows/test_package.yaml?query=branch%3Amaster)
[![Documentation Status](https://readthedocs.org/projects/whitematteranalysis/badge/?version=latest)](https://whitematteranalysis.readthedocs.io/en/latest/?badge=latest)
[![Imports: isort](https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336)](https://pycqa.github.io/isort/)


# Synopsis

Expand Down
6 changes: 4 additions & 2 deletions bin/harden_transform_with_slicer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
# -*- coding: utf-8 -*-

import argparse
import slicer
import os
import glob
import os
import shutil

import slicer


def harden_transform(polydata, transform, inverse, outdir):

polydata_base_path, polydata_name = os.path.split(polydata)
Expand Down
3 changes: 2 additions & 1 deletion bin/wm_append_clusters.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import os
import argparse
import os

import vtk

import whitematteranalysis as wma
Expand Down
5 changes: 3 additions & 2 deletions bin/wm_append_clusters_to_anatomical_tracts.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import os
import argparse
import vtk
import glob
import os

import vtk

import whitematteranalysis as wma

Expand Down
7 changes: 4 additions & 3 deletions bin/wm_append_diffusion_measures_across_subjects.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import numpy
import argparse
import pandas
import os
import glob
import os

import numpy
import pandas


def _build_arg_parser():
Expand Down
11 changes: 6 additions & 5 deletions bin/wm_assess_cluster_location_by_hemisphere.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import argparse
import glob
import os
import shutil
import warnings

# If the cluster was created in bilateral clustering and is not commissural, separate into separate directories
# output should be a right_hem and a left_hem directory
# copy MRML files from toplevel directory into this one
Expand All @@ -12,12 +18,7 @@
# For running this per-subject, the alignment should be performed to handle the tracts near the midline better.
# That should be added as an option.
import numpy
import argparse
import os
import shutil
import vtk
import glob
import warnings

import whitematteranalysis as wma

Expand Down
5 changes: 3 additions & 2 deletions bin/wm_average_tract_measures.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import numpy
import argparse
import pandas
import os
import re

import numpy
import pandas


def _build_arg_parser():

Expand Down
8 changes: 4 additions & 4 deletions bin/wm_change_nrrd_dir.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import glob
import os
import argparse
import glob
import multiprocessing
import os

import numpy
import vtk
from joblib import Parallel, delayed

import whitematteranalysis as wma

from joblib import Parallel, delayed


def _build_arg_parser():

Expand Down
9 changes: 5 additions & 4 deletions bin/wm_cluster_atlas.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import numpy
import argparse
import os
import multiprocessing
import vtk
import os
import time

import matplotlib.pyplot as plt
import numpy
import vtk

import whitematteranalysis as wma

import matplotlib.pyplot as plt

def main():
#-----------------
Expand Down
5 changes: 3 additions & 2 deletions bin/wm_cluster_from_atlas.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import numpy
import argparse
import os
import multiprocessing
import os
import time

import numpy
import vtk

import whitematteranalysis as wma
Expand Down
4 changes: 2 additions & 2 deletions bin/wm_cluster_remove_outliers.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import numpy
import argparse
import os
import glob
import os
import shutil

import numpy
import vtk

import whitematteranalysis as wma
Expand Down
3 changes: 2 additions & 1 deletion bin/wm_cluster_volumetric_measurements.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@

import argparse
import os

import nibabel
import vtk
import numpy
import vtk
from nibabel.affines import apply_affine

import whitematteranalysis as wma
Expand Down
4 changes: 2 additions & 2 deletions bin/wm_compare_vtks.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@

import argparse
import os
import time

import numpy
import vtk
import time

import whitematteranalysis as wma



def _build_arg_parser():

parser = argparse.ArgumentParser(
Expand Down
4 changes: 2 additions & 2 deletions bin/wm_create_mrml_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@

import argparse
import os
import time

import numpy
import vtk
import time

import whitematteranalysis as wma



def _build_arg_parser():

parser = argparse.ArgumentParser(
Expand Down
1 change: 0 additions & 1 deletion bin/wm_diffusion_measurements.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import whitematteranalysis as wma



def _build_arg_parser():

parser = argparse.ArgumentParser(
Expand Down
11 changes: 6 additions & 5 deletions bin/wm_download_anatomically_curated_atlas.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import argparse
import enum
import os
import argparse
import urllib.request, urllib.error, urllib.parse
import zipfile
import sys
import ssl

import sys
import urllib.error
import urllib.parse
import urllib.request
import zipfile

ZENODO_RECORD_ROOT_URL = "https://zenodo.org/record/"
ZENODO_API_RECORD_ROOT_URL = "https://zenodo.org/api/records/"
Expand Down
2 changes: 1 addition & 1 deletion bin/wm_harden_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@

import argparse
import os

from joblib import Parallel, delayed

import whitematteranalysis as wma



def _build_arg_parser():

parser = argparse.ArgumentParser(
Expand Down
7 changes: 3 additions & 4 deletions bin/wm_preprocess_all.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import glob
import os
import argparse
import glob
import multiprocessing
import os
from pathlib import Path

import whitematteranalysis as wma

from joblib import Parallel, delayed

import whitematteranalysis as wma


def _build_arg_parser():
Expand Down
4 changes: 3 additions & 1 deletion bin/wm_quality_control_after_clustering.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@
# -*- coding: utf-8 -*-

import argparse
import glob
import os

import numpy
import glob

import whitematteranalysis as wma

HAVE_PLT = 1
try:
import matplotlib

# Force matplotlib to not use any Xwindows backend.
matplotlib.use('Agg')
import matplotlib.pyplot as plt
Expand Down
1 change: 1 addition & 0 deletions bin/wm_quality_control_cluster_measurements.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import argparse
import os

import numpy
import scipy.stats

Expand Down
4 changes: 2 additions & 2 deletions bin/wm_quality_control_tract_overlap.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

import argparse
import os
import time

import numpy
import vtk
import time

import whitematteranalysis as wma


HAVE_PLT = 1

try:
Expand Down
Loading

0 comments on commit 4dbf568

Please sign in to comment.