Skip to content

Commit

Permalink
ruff: remove unused imports and fix small typos.
Browse files Browse the repository at this point in the history
  • Loading branch information
pattonw committed Jan 2, 2024
1 parent d449036 commit d55c976
Show file tree
Hide file tree
Showing 37 changed files with 24 additions and 73 deletions.
2 changes: 0 additions & 2 deletions gunpowder/array.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from .freezable import Freezable
from copy import deepcopy
from gunpowder.coordinate import Coordinate
from gunpowder.roi import Roi
import logging
import numpy as np
import copy
Expand Down
3 changes: 1 addition & 2 deletions gunpowder/batch.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from copy import copy as shallow_copy
import logging
import multiprocessing
import warnings

from .freezable import Freezable
from .profiling import ProfilingStats
Expand Down Expand Up @@ -75,7 +74,7 @@ def __setitem__(self, key, value):
elif isinstance(value, Graph):
assert isinstance(
key, GraphKey
), f"Only a GraphKey is allowed as key for Graph value."
), "Only a GraphKey is allowed as key for Graph value."
self.graphs[key] = value

else:
Expand Down
2 changes: 1 addition & 1 deletion gunpowder/contrib/nodes/add_blobs_from_points.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def process(self, batch, request):
synapse_ids = []
for point_id, point in points.data.items():
# pdb.set_trace()
if not point.partner_ids[0] in partner_points.data.keys():
if point.partner_ids[0] not in partner_points.data.keys():
logger.warning(
"Point %s has no partner. Deleting..." % point_id
)
Expand Down
3 changes: 1 addition & 2 deletions gunpowder/contrib/nodes/add_boundary_distance_gradients.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from gunpowder.array import Array
from gunpowder.batch_request import BatchRequest
from gunpowder.nodes.batch_filter import BatchFilter
from numpy.lib.stride_tricks import as_strided
from scipy.ndimage.morphology import distance_transform_edt

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -83,7 +82,7 @@ def prepare(self, request):
return deps

def process(self, batch, request):
if not self.gradient_array_key in request:
if self.gradient_array_key not in request:
return

labels = batch.arrays[self.label_array_key].data
Expand Down
3 changes: 1 addition & 2 deletions gunpowder/contrib/nodes/add_gt_mask_exclusive_zone.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import copy
import logging
import numpy as np
from scipy import ndimage

from gunpowder.nodes.batch_filter import BatchFilter
from gunpowder.array import Array, ArrayKeys
from gunpowder.array import Array
from gunpowder.nodes.rasterize_graph import RasterizationSettings
from gunpowder.morphology import enlarge_binary_map

Expand Down
2 changes: 0 additions & 2 deletions gunpowder/contrib/nodes/add_nonsymmetric_affinities.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import copy
import logging
import numpy as np
import pdb

from gunpowder.array import Array
from gunpowder.nodes.batch_filter import BatchFilter
Expand Down
3 changes: 0 additions & 3 deletions gunpowder/contrib/nodes/hdf5_points_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@
from gunpowder.batch import Batch
from gunpowder.coordinate import Coordinate
from gunpowder.ext import h5py
from gunpowder.graph import GraphKey, Graph
from gunpowder.graph_spec import GraphSpec
from gunpowder.profiling import Timing
from gunpowder.roi import Roi
from gunpowder.nodes.batch_provider import BatchProvider

logger = logging.getLogger(__name__)
Expand Down
28 changes: 14 additions & 14 deletions gunpowder/ext/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,73 +21,73 @@ def __getattr__(self, item):

try:
import dvision
except ImportError as e:
except ImportError:
dvision = NoSuchModule("dvision")

try:
import h5py
except ImportError as e:
except ImportError:
h5py = NoSuchModule("h5py")

try:
import pyklb
except ImportError as e:
except ImportError:
pyklb = NoSuchModule("pyklb")

try:
import tensorflow
except ImportError as e:
except ImportError:
tensorflow = NoSuchModule("tensorflow")

try:
import torch
except ImportError as e:
except ImportError:
torch = NoSuchModule("torch")

try:
import tensorboardX
except ImportError as e:
except ImportError:
tensorboardX = NoSuchModule("tensorboardX")

try:
import malis
except ImportError as e:
except ImportError:
malis = NoSuchModule("malis")

try:
import augment
except ImportError as e:
except ImportError:
augment = NoSuchModule("augment")

ZarrFile: Optional[Any] = None
try:
import zarr
from .zarr_file import ZarrFile
except ImportError as e:
except ImportError:
zarr = NoSuchModule("zarr")
ZarrFile = None

try:
import daisy
except ImportError as e:
except ImportError:
daisy = NoSuchModule("daisy")

try:
import jax
except ImportError as e:
except ImportError:
jax = NoSuchModule("jax")

try:
import jax.numpy as jnp
except ImportError as e:
except ImportError:
jnp = NoSuchModule("jnp")

try:
import haiku
except ImportError as e:
except ImportError:
haiku = NoSuchModule("haiku")

try:
import optax
except ImportError as e:
except ImportError:
optax = NoSuchModule("optax")
3 changes: 1 addition & 2 deletions gunpowder/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from typing import Dict, Optional, Set, Iterator, Any
import logging
import itertools
import warnings


logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -485,7 +484,7 @@ def _roi_intercept(

offset = outside - inside
distance = np.linalg.norm(offset)
assert not np.isclose(distance, 0), f"Inside and Outside are the same location"
assert not np.isclose(distance, 0), "Inside and Outside are the same location"
direction = offset / distance

# `offset` can be 0 on some but not all axes leaving a 0 in the denominator.
Expand Down
1 change: 0 additions & 1 deletion gunpowder/nodes/crop.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import copy
import logging

from .batch_filter import BatchFilter
Expand Down
1 change: 0 additions & 1 deletion gunpowder/nodes/elastic_augment.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from gunpowder.coordinate import Coordinate
from gunpowder.ext import augment
from gunpowder.roi import Roi
from gunpowder.array import ArrayKey

import warnings

Expand Down
2 changes: 1 addition & 1 deletion gunpowder/nodes/exclude_labels.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def process(self, batch, request):
include_mask[gt.data == label] = 0

# if no ignore mask is provided or requested, we are done
if not self.ignore_mask or not self.ignore_mask in request:
if not self.ignore_mask or self.ignore_mask not in request:
return

voxel_size = self.spec[self.labels].voxel_size
Expand Down
1 change: 0 additions & 1 deletion gunpowder/nodes/grow_boundary.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from scipy import ndimage

from .batch_filter import BatchFilter
from gunpowder.array import Array


class GrowBoundary(BatchFilter):
Expand Down
1 change: 0 additions & 1 deletion gunpowder/nodes/klb_source.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import copy
import logging
import numpy as np
import glob
Expand Down
1 change: 0 additions & 1 deletion gunpowder/nodes/merge_provider.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from gunpowder.provider_spec import ProviderSpec
from gunpowder.batch import Batch
from gunpowder.batch_request import BatchRequest

Expand Down
1 change: 0 additions & 1 deletion gunpowder/nodes/pad.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from gunpowder.coordinate import Coordinate
from gunpowder.batch_request import BatchRequest

from itertools import product

logger = logging.getLogger(__name__)

Expand Down
3 changes: 0 additions & 3 deletions gunpowder/nodes/precache.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import logging
import multiprocessing
import time
import random

from .batch_filter import BatchFilter
from gunpowder.profiling import Timing
Expand Down
2 changes: 0 additions & 2 deletions gunpowder/nodes/rasterize_graph.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import copy
import logging
import numpy as np
from scipy.ndimage.filters import gaussian_filter
Expand All @@ -12,7 +11,6 @@
from gunpowder.freezable import Freezable
from gunpowder.morphology import enlarge_binary_map, create_ball_kernel
from gunpowder.ndarray import replace
from gunpowder.graph import GraphKey
from gunpowder.graph_spec import GraphSpec
from gunpowder.roi import Roi

Expand Down
1 change: 0 additions & 1 deletion gunpowder/nodes/shift_augment.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import random
from gunpowder.roi import Roi
from gunpowder.coordinate import Coordinate
from gunpowder.batch_request import BatchRequest

from .batch_filter import BatchFilter

Expand Down
2 changes: 0 additions & 2 deletions gunpowder/nodes/specified_location.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
from random import randrange
from random import choice, seed
import logging
import numpy as np

from gunpowder.coordinate import Coordinate
from gunpowder.batch_request import BatchRequest

from .batch_filter import BatchFilter

Expand Down
1 change: 0 additions & 1 deletion gunpowder/nodes/squeeze.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import copy
from typing import List
import logging

Expand Down
1 change: 0 additions & 1 deletion gunpowder/nodes/unsqueeze.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import copy
from typing import List
import logging

Expand Down
2 changes: 0 additions & 2 deletions gunpowder/producer_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
import multiprocessing
import os
import sys
import time
import traceback

import numpy as np

Expand Down
2 changes: 0 additions & 2 deletions gunpowder/provider_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@
from gunpowder.graph_spec import GraphSpec
from gunpowder.roi import Roi
from .freezable import Freezable
import time
import logging
import copy

logger = logging.getLogger(__name__)


import logging
import warnings

logger = logging.getLogger(__file__)

Expand Down
4 changes: 0 additions & 4 deletions tests/cases/add_affinities.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
from .provider_test import ProviderTest
from gunpowder import *
from itertools import product
from unittest import skipIf
import itertools
import numpy as np
import logging


class ExampleSource(BatchProvider):
Expand Down
1 change: 0 additions & 1 deletion tests/cases/dvid_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from unittest import skipIf
from gunpowder import *
from gunpowder.ext import dvision, NoSuchModule
import numpy as np
import socket
import logging

Expand Down
2 changes: 0 additions & 2 deletions tests/cases/elastic_augment_points.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import unittest
from gunpowder import (
BatchProvider,
Batch,
Expand All @@ -25,7 +24,6 @@
import numpy as np
import math
import time
import unittest


class PointTestSource3D(BatchProvider):
Expand Down
2 changes: 1 addition & 1 deletion tests/cases/expected_failures.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from gunpowder.nodes.batch_provider import BatchRequestError
from .helper_sources import ArraySource

from funlib.geometry import Roi, Coordinate
from funlib.geometry import Coordinate

import numpy as np
import pytest
Expand Down
1 change: 0 additions & 1 deletion tests/cases/intensity_scale_shift.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
IntensityScaleShift,
ArrayKey,
build,
Normalize,
Array,
ArraySpec,
Roi,
Expand Down
5 changes: 1 addition & 4 deletions tests/cases/jax_train.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,15 @@
BatchRequest,
ArraySpec,
Roi,
Coordinate,
ArrayKeys,
ArrayKey,
Array,
Batch,
Scan,
PreCache,
build,
)
from gunpowder.ext import jax, haiku, optax, NoSuchModule
from gunpowder.jax import Train, Predict, GenericJaxModel
from unittest import skipIf, expectedFailure
from unittest import skipIf
import numpy as np

import logging
Expand Down
1 change: 0 additions & 1 deletion tests/cases/noise_augment.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from .provider_test import ProviderTest
from gunpowder import IntensityAugment, ArrayKeys, build, Normalize, NoiseAugment

import numpy as np


class TestIntensityAugment(ProviderTest):
Expand Down
1 change: 0 additions & 1 deletion tests/cases/random_location.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
BatchProvider,
Roi,
Coordinate,
ArrayKeys,
ArrayKey,
ArraySpec,
Array,
Expand Down
Loading

0 comments on commit d55c976

Please sign in to comment.