From 9fe8b746ef118757677d24e51d3b5a4a6d279a25 Mon Sep 17 00:00:00 2001 From: Tzu-Wei Huang Date: Sun, 23 Jan 2022 12:04:09 +0800 Subject: [PATCH] Remove Deprecation Warnings (#654) fixes #653 --- setup.cfg | 9 +++++++++ tensorboardX/summary.py | 4 ++-- test-requirements.txt | 1 + tests/test_caffe2.py | 4 ++-- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/setup.cfg b/setup.cfg index 5bb01114..311b439c 100644 --- a/setup.cfg +++ b/setup.cfg @@ -3,3 +3,12 @@ license_file = LICENSE [bdist_wheel] universal = 1 + +[tool:pytest] +filterwarnings = + ignore:Call to deprecated create function FieldDescriptor + ignore:Call to deprecated create function Descriptor + ignore:Call to deprecated create function EnumDescriptor + ignore:Call to deprecated create function EnumValueDescriptor + ignore:Call to deprecated create function FileDescriptor + ignore:Call to deprecated create function OneofDescriptor diff --git a/tensorboardX/summary.py b/tensorboardX/summary.py index 29658453..91b63794 100644 --- a/tensorboardX/summary.py +++ b/tensorboardX/summary.py @@ -231,7 +231,7 @@ def make_histogram(values, bins, max_bins=None): limits = new_limits # Find the first and the last bin defining the support of the histogram: - cum_counts = np.cumsum(np.greater(counts, 0, dtype=np.int32)) + cum_counts = np.cumsum(np.greater(counts, 0)) start, end = np.searchsorted(cum_counts, [0, cum_counts[-1] - 1], side="right") start = int(start) end = int(end) + 1 @@ -510,7 +510,7 @@ def compute_curve(labels, predictions, num_thresholds=None, weights=None): # Compute bins of true positives and false positives. bucket_indices = np.int32(np.floor(predictions * (num_thresholds - 1))) - float_labels = labels.astype(np.float) + float_labels = labels.astype(float) histogram_range = (0, num_thresholds - 1) tp_buckets, _ = np.histogram( bucket_indices, diff --git a/test-requirements.txt b/test-requirements.txt index 77fdf696..565931d9 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,3 +1,4 @@ +flake8 pytest torch six diff --git a/tests/test_caffe2.py b/tests/test_caffe2.py index ed8c3612..e3811470 100644 --- a/tests/test_caffe2.py +++ b/tests/test_caffe2.py @@ -215,7 +215,7 @@ def filter_fn(blob): def test_simple_cnnmodel(self): model = cnn.CNNModelHelper("NCHW", name="overfeat") workspace.FeedBlob("data", np.random.randn(1, 3, 64, 64).astype(np.float32)) - workspace.FeedBlob("label", np.random.randn(1, 1000).astype(np.int)) + workspace.FeedBlob("label", np.random.randn(1, 1000).astype(int)) with core.NameScope("conv1"): conv1 = model.Conv("data", "conv1", 3, 96, 11, stride=4) relu1 = model.Relu(conv1, conv1) @@ -243,7 +243,7 @@ def test_simple_model(self): model = model_helper.ModelHelper(name="mnist") # how come those inputs don't break the forward pass =.=a workspace.FeedBlob("data", np.random.randn(1, 3, 64, 64).astype(np.float32)) - workspace.FeedBlob("label", np.random.randn(1, 1000).astype(np.int)) + workspace.FeedBlob("label", np.random.randn(1, 1000).astype(int)) with core.NameScope("conv1"): conv1 = brew.conv(model, "data", 'conv1', dim_in=1, dim_out=20, kernel=5)