From 7046aa9c23d231c8478596d1ddc6e0506ff9a00e Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Tue, 15 Jun 2021 10:48:34 +0800 Subject: [PATCH] compiler: stop using deprecated numpy.float --- artiq/compiler/embedding.py | 4 ++-- artiq/test/coredevice/test_numpy.py | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/artiq/compiler/embedding.py b/artiq/compiler/embedding.py index b3f9c6d98..fe197d81b 100644 --- a/artiq/compiler/embedding.py +++ b/artiq/compiler/embedding.py @@ -167,10 +167,10 @@ class ASTSynthesizer: coerced = bool(value) return asttyped.NameConstantT(value=coerced, type=typ, loc=self._add(repr(coerced))) - elif value is numpy.float: + elif value is float: typ = builtins.fn_float() return asttyped.NameConstantT(value=None, type=typ, - loc=self._add("numpy.float")) + loc=self._add("float")) elif value is numpy.int32: typ = builtins.fn_int32() return asttyped.NameConstantT(value=None, type=typ, diff --git a/artiq/test/coredevice/test_numpy.py b/artiq/test/coredevice/test_numpy.py index 54c63fb83..7fe56f265 100644 --- a/artiq/test/coredevice/test_numpy.py +++ b/artiq/test/coredevice/test_numpy.py @@ -72,13 +72,13 @@ class CompareHostDeviceTest(ExperimentCase): # randomised tests instead. # TODO: Provoke overflows, division by zero, etc., and compare results. args = [(typ(a), typ(b)) for a, b in [(0, 1), (3, 2), (11, 6)] - for typ in [numpy.int32, numpy.int64, numpy.float]] + for typ in [numpy.int32, numpy.int64, numpy.float64]] for op in ELEM_WISE_BINOPS: for arg in args: self._test_binop("a" + op + "b", *arg) def test_scalar_matrix_binops(self): - for typ in [numpy.int32, numpy.int64, numpy.float]: + for typ in [numpy.int32, numpy.int64, numpy.float64]: scalar = typ(3) matrix = numpy.array([[4, 5, 6], [7, 8, 9]], dtype=typ) for op in ELEM_WISE_BINOPS: @@ -88,7 +88,7 @@ class CompareHostDeviceTest(ExperimentCase): self._test_binop(code, matrix, matrix) def test_matrix_mult(self): - for typ in [numpy.int32, numpy.int64, numpy.float]: + for typ in [numpy.int32, numpy.int64, numpy.float64]: mat_a = numpy.array([[1, 2, 3], [4, 5, 6]], dtype=typ) mat_b = numpy.array([[7, 8], [9, 10], [11, 12]], dtype=typ) self._test_binop("a @ b", mat_a, mat_b) @@ -139,7 +139,7 @@ class _MatrixMult(EnvExperiment): def build(self): self.setattr_device("core") self.imat = numpy.arange(4, dtype=numpy.int64).reshape((2, 2)) - self.fmat = numpy.arange(4, dtype=numpy.float).reshape((2, 2)) + self.fmat = numpy.arange(4, dtype=numpy.float64).reshape((2, 2)) @kernel def run(self):