From 24d012fcccd6307122f8807f57ec46e570c7b385 Mon Sep 17 00:00:00 2001 From: jan Date: Sun, 7 Apr 2019 17:18:57 -0700 Subject: [PATCH] Warnings should reference their caller --- gridlock/grid.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gridlock/grid.py b/gridlock/grid.py index f46f7a9..bf69c11 100644 --- a/gridlock/grid.py +++ b/gridlock/grid.py @@ -229,7 +229,7 @@ class Grid(object): self.exyz = [numpy.unique(pixel_edge_coordinates[i]) for i in range(3)] for i in range(3): if len(self.exyz[i]) != len(pixel_edge_coordinates[i]): - warnings.warn('Dimension {} had duplicate edge coordinates'.format(i)) + warnings.warn('Dimension {} had duplicate edge coordinates'.format(i), stacklevel=2) if is_scalar(periodic): periodic = [periodic] * 3 @@ -248,7 +248,7 @@ class Grid(object): if (self.shifts < 0).any(): # TODO: Test negative shifts - warnings.warn('Negative shifts are still experimental and mostly untested, be careful!') + warnings.warn('Negative shifts are still experimental and mostly untested, be careful!', stacklevel=2) num_shifts = self.shifts.shape[0] if num_grids is None: @@ -259,7 +259,7 @@ class Grid(object): grids_shape = hstack((num_grids, self.shape)) if is_scalar(initial): if isinstance(initial, int): - warnings.warn('Initial value is an int, grids will be integer-typed!') + warnings.warn('Initial value is an int, grids will be integer-typed!', stacklevel=2) self.grids = numpy.full(grids_shape, initial) else: if len(initial) < num_grids: @@ -270,7 +270,7 @@ class Grid(object): if is_scalar(initial[i]): if initial[i] is not None: if isinstance(initial[i], int): - warnings.warn('Initial value is an int, grid {} will be integer-typed!'.format(i)) + warnings.warn('Initial value is an int, grid {} will be integer-typed!'.format(i), stacklevel=2) self.grids[i] = numpy.full(self.shape, initial[i]) else: if not numpy.array_equal(initial[i].shape, self.shape):