Skip to content

Commit 0c61267

Browse files
authored
Merge pull request #2542 from dhomeier/proper-assert-proper-roi
2 parents 9b86e18 + 127dd04 commit 0c61267

File tree

6 files changed

+15
-9
lines changed

6 files changed

+15
-9
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ ci:
44

55
repos:
66
- repo: https://github.com/pre-commit/pre-commit-hooks
7-
rev: v4.6.0
7+
rev: v5.0.0
88
hooks:
99
- id: check-added-large-files
1010
args: ["--enforce-all", "--maxkb=300"]
@@ -51,7 +51,7 @@ repos:
5151
# Forbid files which have a UTF-8 Unicode replacement character.
5252

5353
- repo: https://github.com/astral-sh/ruff-pre-commit
54-
rev: "v0.9.9"
54+
rev: "v0.11.12"
5555
hooks:
5656
- id: ruff
5757
args: ["--fix", "--show-fixes"]

.ruff.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
extend = "pyproject.toml"
22
lint.ignore = [
33
# NOTE: to find a good code to fix, run:
4-
# ruff --select="ALL" --statistics glue/<subpackage>
4+
# ruff check --select="ALL" --statistics glue/<subpackage>
55

66
# flake8-unused-arguments (ARG)
77
"ARG001", # unused-function-argument

glue/core/component.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
__all__ = ['Component', 'DerivedComponent', 'CategoricalComponent',
1717
'CoordinateComponent', 'DateTimeComponent', 'ExtendedComponent']
1818

19+
logger = logging.getLogger(__name__)
20+
1921

2022
class Component(object):
2123

@@ -80,7 +82,7 @@ def ndim(self):
8082
return len(self._data.shape)
8183

8284
def __getitem__(self, key):
83-
logging.debug("Using %s to index data of shape %s", key, self.shape)
85+
logger.debug("Using %s to index data of shape %s", key, self.shape)
8486
return self._data[key]
8587

8688
@property

glue/core/state.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ def load(rec, context)
9292
if MATPLOTLIB_GE_36:
9393
from matplotlib import colormaps
9494

95+
logger = logging.getLogger(__name__)
96+
9597
literals = tuple([type(None), float, int, bytes, bool])
9698
literals += tuple(s for s in np.ScalarType if s not in (np.datetime64, np.timedelta64))
9799

@@ -312,7 +314,7 @@ def id(self, obj):
312314
name = self._label(obj)
313315
assert name not in self._objs
314316

315-
logging.debug("Registering %r as %s", obj, name)
317+
logger.debug("Registering %r as %s", obj, name)
316318
self._objs[name] = obj
317319
self._names[oid] = name
318320

@@ -354,7 +356,7 @@ def do(self, obj):
354356
self._working.add(oid)
355357

356358
fun, version = self._dispatch(obj)
357-
logging.debug("Serializing %s with %s", obj, fun)
359+
logger.debug("Serializing %s with %s", obj, fun)
358360
result = fun(obj, self)
359361

360362
if isinstance(obj, types.FunctionType):

glue/core/tests/test_roi.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1216,7 +1216,7 @@ def _roi_factory(self):
12161216
return MplPolygonalROI(self.axes)
12171217

12181218
def test_proper_roi(self):
1219-
return isinstance(self.roi._roi, PolygonalROI)
1219+
assert isinstance(self.roi._roi, PolygonalROI)
12201220

12211221
def send_events(self):
12221222
ev0 = DummyEvent(5, 5, inaxes=self.axes)
@@ -1271,7 +1271,7 @@ def _roi_factory(self):
12711271
return MplPickROI(self.axes)
12721272

12731273
def test_proper_roi(self):
1274-
return isinstance(self.roi._roi, PointROI)
1274+
assert isinstance(self.roi._roi, PointROI)
12751275

12761276
def test_start_ignored_if_not_inaxes(self):
12771277
ev = DummyEvent(0, 0, inaxes=None)

glue/utils/matplotlib.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
MATPLOTLIB_GE_30 = Version(__version__) >= Version('3')
1919
MATPLOTLIB_GE_36 = Version(__version__) >= Version('3.6')
2020

21+
logger = logging.getLogger(__name__)
22+
2123

2224
__all__ = ['all_artists', 'new_artists', 'remove_artists',
2325
'get_extent', 'view_cascade', 'fast_limits', 'defer_draw',
@@ -97,7 +99,7 @@ def view_cascade(data, view):
9799
"""
98100
shp = data.shape
99101
v2 = list(view)
100-
logging.debug("image shape: %s, view: %s", shp, view)
102+
logger.debug("image shape: %s, view: %s", shp, view)
101103

102104
# choose stride length that roughly samples entire image
103105
# at roughly the same pixel count

0 commit comments

Comments
 (0)