Skip to content

Commit

Permalink
Improve linting and consistency (#1084)
Browse files Browse the repository at this point in the history
  • Loading branch information
manthey authored Dec 5, 2023
1 parent bbb91e2 commit 4b3391a
Show file tree
Hide file tree
Showing 117 changed files with 695 additions and 565 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ jobs:
name: Install dependencies
command: sudo apt-get update -yq && sudo apt install -yq pandoc
- tox:
env: docs,flake8
env: docs,lint
- store_artifacts:
path: docs/_build/html
- persist_to_workspace:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
pip install tox
- name: Run tox for lint and docs
run: |
tox -e flake8,docs
tox -e lint,docs
- uses: actions/upload-artifact@v3
with:
name: docs
Expand Down
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,10 @@ repos:
rev: 6.1.0
hooks:
- id: flake8
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.1.3
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
types_or: [python, pyi]
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@
man_pages = [
('index', 'HistomicsTK',
'HistomicsTK Documentation',
['Kitware, Inc.'], 1)
['Kitware, Inc.'], 1),
]

# If true, show URL addresses after external links.
Expand Down
20 changes: 10 additions & 10 deletions docs/examples/annotation_database_backup_and_sql_parser.ipynb

Large diffs are not rendered by default.

56 changes: 28 additions & 28 deletions docs/examples/annotations_to_object_segmentation_masks.ipynb

Large diffs are not rendered by default.

58 changes: 29 additions & 29 deletions docs/examples/annotations_to_semantic_segmentation_masks.ipynb

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions docs/examples/color_deconvolution.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,12 @@
"import histomicstk as htk\n",
"\n",
"import numpy as np\n",
"import scipy as sp\n",
"\n",
"import skimage.io\n",
"import skimage.measure\n",
"import skimage.color\n",
"\n",
"import matplotlib.pyplot as plt\n",
"import matplotlib.patches as mpatches\n",
"%matplotlib inline\n",
"\n",
"#Some nice default configuration for plots\n",
Expand Down Expand Up @@ -230,7 +228,7 @@
"\n",
"# perform sparse color deconvolution\n",
"imDeconvolved = htk.preprocessing.color_deconvolution.color_deconvolution(\n",
" imInput, \n",
" imInput,\n",
" htk.preprocessing.color_deconvolution.complement_stain_matrix(W_est),\n",
" I_0,\n",
")\n",
Expand Down
14 changes: 7 additions & 7 deletions docs/examples/color_normalization_and_augmentation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"outputs": [],
"source": [
"APIURL = 'http://candygram.neurology.emory.edu:8080/api/v1/'\n",
"SAMPLE_SLIDE_ID = \"5d817f5abd4404c6b1f744bb\"\n",
"SAMPLE_SLIDE_ID = '5d817f5abd4404c6b1f744bb'\n",
"\n",
"gc = girder_client.GirderClient(apiUrl=APIURL)\n",
"# gc.authenticate(interactive=True)\n",
Expand All @@ -75,7 +75,7 @@
"W_target = np.array([\n",
" [0.5807549, 0.08314027, 0.08213795],\n",
" [0.71681094, 0.90081588, 0.41999816],\n",
" [0.38588316, 0.42616716, -0.90380025]\n",
" [0.38588316, 0.42616716, -0.90380025],\n",
"])\n",
"\n",
"# visualization color map\n",
Expand Down Expand Up @@ -105,9 +105,9 @@
"source": [
"# get RGB image at a small magnification\n",
"slide_info = gc.get('item/%s/tiles' % SAMPLE_SLIDE_ID)\n",
"getStr = \"/item/%s/tiles/region?left=%d&right=%d&top=%d&bottom=%d\" % (\n",
" SAMPLE_SLIDE_ID, 0, slide_info['sizeX'], 0, slide_info['sizeY']\n",
" ) + \"&magnification=%.2f\" % MAG\n",
"getStr = '/item/%s/tiles/region?left=%d&right=%d&top=%d&bottom=%d' % (\n",
" SAMPLE_SLIDE_ID, 0, slide_info['sizeX'], 0, slide_info['sizeY'],\n",
" ) + '&magnification=%.2f' % MAG\n",
"tissue_rgb = get_image_from_htk_response(\n",
" gc.get(getStr, jsonResp=False))\n",
"\n",
Expand Down Expand Up @@ -317,7 +317,7 @@
" ax[0].imshow(tissue_rgb[ymin:ymax, xmin:xmax, :])\n",
" ax[1].imshow(tissue_rgb_normalized[ymin:ymax, xmin:xmax, :])\n",
" plt.show()\n",
" \n",
"\n",
"vis_result()"
]
},
Expand Down Expand Up @@ -854,7 +854,7 @@
" ax[0].imshow(rgb)\n",
" ax[1].imshow(augmented_rgb)\n",
" plt.show()\n",
" \n",
"\n",
"vis_augmentation()"
]
},
Expand Down
4 changes: 2 additions & 2 deletions docs/examples/creating_gallery_images_review.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@
"SAMPLE_FOLDER_ID = '5e2a2da8ddda5f83986d18a2'\n",
"\n",
"# This is the girder folder where galleries will be visualized\n",
"POST_FOLDERID = \"5e3ce440ddda5f839875b33e\"\n",
"POST_FOLDERID = '5e3ce440ddda5f839875b33e'\n",
"\n",
"# Connect to an authenticated girder API. You \n",
"# Connect to an authenticated girder API. You\n",
"gc = girder_client.GirderClient(apiUrl=APIURL)\n",
"gc.authenticate(interactive=True) # need this to post!\n",
"# gc.authenticate(apiKey='kri19nTIGOkWH01TbzRqfohaaDWb6kPecRqGmemb')\n",
Expand Down
18 changes: 9 additions & 9 deletions docs/examples/nuclei_segmentation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@
" 'hematoxylin': [0.65, 0.70, 0.29],\n",
" 'eosin': [0.07, 0.99, 0.11],\n",
" 'dab': [0.27, 0.57, 0.78],\n",
" 'null': [0.0, 0.0, 0.0]\n",
" 'null': [0.0, 0.0, 0.0],\n",
"}\n",
"\n",
"# specify stains of input image\n",
Expand All @@ -160,8 +160,8 @@
"stain_3 = 'null' # set to null of input contains only two stains\n",
"\n",
"# create stain matrix\n",
"W = np.array([stainColorMap[stain_1], \n",
" stainColorMap[stain_2], \n",
"W = np.array([stainColorMap[stain_1],\n",
" stainColorMap[stain_2],\n",
" stainColorMap[stain_3]]).T\n",
"\n",
"# perform standard color deconvolution\n",
Expand Down Expand Up @@ -226,7 +226,7 @@
"im_log_max, im_sigma_max = htk.filters.shape.cdog(\n",
" im_nuclei_stain, im_fgnd_mask,\n",
" sigma_min=min_radius * np.sqrt(2),\n",
" sigma_max=max_radius * np.sqrt(2)\n",
" sigma_max=max_radius * np.sqrt(2),\n",
")\n",
"\n",
"# detect and segment nuclei using local maximum clustering\n",
Expand Down Expand Up @@ -266,14 +266,14 @@
" height = objProps[i].bbox[2] - objProps[i].bbox[0] + 1\n",
"\n",
" cur_bbox = {\n",
" \"type\": \"rectangle\",\n",
" \"center\": c,\n",
" \"width\": width,\n",
" \"height\": height,\n",
" 'type': 'rectangle',\n",
" 'center': c,\n",
" 'width': width,\n",
" 'height': height,\n",
" }\n",
"\n",
" plt.plot(c[0], c[1], 'g+')\n",
" mrect = mpatches.Rectangle([c[0] - 0.5 * width, c[1] - 0.5 * height] , \n",
" mrect = mpatches.Rectangle([c[0] - 0.5 * width, c[1] - 0.5 * height] ,\n",
" width, height, fill=False, ec='g', linewidth=2)\n",
" plt.gca().add_patch(mrect)"
]
Expand Down
Loading

0 comments on commit 4b3391a

Please sign in to comment.