Commit 341d8760 authored by Wout De Nolf's avatar Wout De Nolf
Browse files

numpy.float is deprecated. Replace with python's float.

parent c5a1b1ff
Pipeline #42976 passed with stages
in 140 minutes and 44 seconds
......@@ -2195,14 +2195,14 @@ class Axis(Scannable):
@lazy_init
def set_event_positions(self, positions):
dial_positions = self.user2dial(numpy.array(positions, dtype=numpy.float))
dial_positions = self.user2dial(numpy.array(positions, dtype=float))
step_positions = dial_positions * self.steps_per_unit
return self.__controller.set_event_positions(self, step_positions)
@lazy_init
def get_event_positions(self):
step_positions = numpy.array(
self.__controller.get_event_positions(self), dtype=numpy.float
self.__controller.get_event_positions(self), dtype=float
)
dial_positions = self.dial2user(step_positions)
return dial_positions / self.steps_per_unit
......
......@@ -171,8 +171,7 @@ class SimpleTimeStatistics:
def __init__(self, profile):
self._profile = {
key: numpy.array(values, dtype=numpy.float)
for key, values in profile.items()
key: numpy.array(values, dtype=float) for key, values in profile.items()
}
@property
......
......@@ -206,14 +206,13 @@ class Card(object):
@staticmethod
def _calc_delay(linear_nb, nb_segment, nb_val_per_segment):
flex_delay = Card.FLEX_DELAY
delay = numpy.arange(1, linear_nb + 1, dtype=numpy.float) * flex_delay
delay = numpy.arange(1, linear_nb + 1, dtype=float) * flex_delay
for i in range(nb_segment):
flex_delay += flex_delay
offset = delay[-1]
sub_delay = (
offset
+ numpy.arange(1, nb_val_per_segment + 1, dtype=numpy.float)
* flex_delay
+ numpy.arange(1, nb_val_per_segment + 1, dtype=float) * flex_delay
)
delay = numpy.append(delay, sub_delay)
return delay
......
......@@ -828,7 +828,7 @@ class CalcController(Controller):
for caxis in self.pseudos:
if caxis is calc_axis:
continue
cpos = numpy.zeros(len(calc_positions), dtype=numpy.float)
cpos = numpy.zeros(len(calc_positions), dtype=float)
cpos[:] = caxis.position
positions[self._axis_tag(caxis)] = cpos
......@@ -934,7 +934,7 @@ class CalcController(Controller):
axis_tag = ctrl._axis_tag(caxis)
if caxis is axis or axis_tag in local_real_positions:
continue
cpos = numpy.zeros(len(axis_position), dtype=numpy.float)
cpos = numpy.zeros(len(axis_position), dtype=float)
cpos[:] = caxis.position
local_real_positions[ctrl._axis_tag(caxis)] = cpos
......
......@@ -723,7 +723,7 @@ class Icepap(Controller):
_ackcommand(self._cnx, "%s:LISTDAT CLEAR" % address)
return
dial_positions = axis.user2dial(numpy.array(positions, dtype=numpy.float))
dial_positions = axis.user2dial(numpy.array(positions, dtype=float))
step_positions = numpy.array(
dial_positions * axis.steps_per_unit, dtype=numpy.int32
)
......
......@@ -4,18 +4,15 @@ from numpy import cos, sin
def euler2H(rx, ry, rz):
xRot = numpy.array(
[[1.0, 0.0, 0.0], [0.0, cos(rx), -sin(rx)], [0.0, sin(rx), cos(rx)]],
numpy.float,
[[1.0, 0.0, 0.0], [0.0, cos(rx), -sin(rx)], [0.0, sin(rx), cos(rx)]], float
)
yRot = numpy.array(
[[cos(ry), 0.0, sin(ry)], [0.0, 1.0, 0.0], [-sin(ry), 0.0, cos(ry)]],
numpy.float,
[[cos(ry), 0.0, sin(ry)], [0.0, 1.0, 0.0], [-sin(ry), 0.0, cos(ry)]], float
)
zRot = numpy.array(
[[cos(rz), -sin(rz), 0.0], [sin(rz), cos(rz), 0.0], [0.0, 0.0, 1.0]],
numpy.float,
[[cos(rz), -sin(rz), 0.0], [sin(rz), cos(rz), 0.0], [0.0, 0.0, 1.0]], float
)
H = numpy.zeros((4, 4), numpy.float)
H = numpy.zeros((4, 4), float)
H[:3, :3] = numpy.dot(zRot, numpy.dot(yRot, xRot))
H[3, 3] = 1.0
return H
......@@ -28,5 +25,5 @@ if __name__ == "__main__":
# print("Usage:")
# print("Euler2H rotX rotY rotZ")
sys.exit(0)
rotX, rotY, rotZ = [numpy.float(x) for x in sys.argv[1:]]
rotX, rotY, rotZ = [float(x) for x in sys.argv[1:]]
# print(euler2H(rotX, rotY, rotZ))
......@@ -33,9 +33,7 @@ def fwdKin(leg1, leg2, leg3):
l3.w = numpy.dot(R, l3.w)
# compute the forward kinematics
u = numpy.array(
[L1.u, L2.u, L3.u], dtype=numpy.float
) # get the z positions of the jacks
u = numpy.array([L1.u, L2.u, L3.u], dtype=float) # get the z positions of the jacks
du = u - u[0] # get the differential position of the jacks
# step1: compute the postion of the axis which has one additional dof
......@@ -93,25 +91,25 @@ def fwdKin(leg1, leg2, leg3):
# 0 = (a1 + dcC_1)^2 + (a2 + dcC_2)^2 + a3;
# 0 = (b1 + dcC_1)^2 + (b2 + dcC_2)^2 + b3;
# use the newton methode for solving this problem
x = numpy.zeros((2, 1), numpy.float) # starting value with x = [dcC_1; dcC_2]
x = numpy.zeros((2, 1), float) # starting value with x = [dcC_1; dcC_2]
for k in range(100):
J = numpy.array(
[
[2 * a1 + 2 * x[0, 0], 2 * a2 + 2 * x[1, 0]],
[2 * b1 + 2 * x[0, 0], 2 * b2 + 2 * x[1, 0]],
],
dtype=numpy.float,
dtype=float,
)
F = numpy.array(
[
(a1 + x[0, 0]) ** 2 + (a2 + x[1, 0]) ** 2 + a3,
(b1 + x[0, 0]) ** 2 + (b2 + x[1, 0]) ** 2 + b3,
],
dtype=numpy.float,
dtype=float,
).reshape(2, 1)
x = x - numpy.dot(numpy.linalg.inv(J), F)
daC = dac + numpy.array([x[0, 0], x[1, 0], dcC_3], dtype=numpy.float).reshape(3, 1)
daC = dac + numpy.array([x[0, 0], x[1, 0], dcC_3], dtype=float).reshape(3, 1)
# print("daC")
# print(daC)
......@@ -193,7 +191,7 @@ def fwdKin(leg1, leg2, leg3):
# print("rz = ", rz)
# print("rx = ", rx)
csry = numpy.array(
[[cos(rz), sin(rx) * sin(rz)], [sin(rx) * sin(rz), -cos(rz)]], dtype=numpy.float
[[cos(rz), sin(rx) * sin(rz)], [sin(rx) * sin(rz), -cos(rz)]], dtype=float
)
csry = numpy.dot(
numpy.linalg.inv(csry), numpy.concatenate((R[0:1], R[2:3]), axis=0)
......
......@@ -6,7 +6,7 @@ def htrans(p):
raise IndexError("3D vector expected")
v = p[:]
v.shape = -1
H = numpy.eye(4, dtype=numpy.float)
H = numpy.eye(4, dtype=float)
H[:3, 3] = v
return H
......@@ -18,7 +18,7 @@ if __name__ == "__main__":
# print("Usage:")
# print("htrans x y z")
sys.exit(0)
data = numpy.array([numpy.float(x) for x in sys.argv[1:]])
data = numpy.array([float(x) for x in sys.argv[1:]])
data.shape = 1, -1
# print(htrans(data))
data.shape = -1, 1
......
......@@ -534,7 +534,7 @@ class Rontec(object):
if calib:
x = self.calib_c[0] + self.calib_c[1] * x + self.calib_c[2] * x ** 2
return numpy.array([x, y], dtype=numpy.float)
return numpy.array([x, y], dtype=float)
def read_raw_data(self, chmin=0, chmax=4095, save_data=False):
"""Reads raw data
......
......@@ -231,9 +231,9 @@ MEASURE:VOLTAGE:DC?;:MEASURE:CURRENT:DC?
header = header["WFMOUTPRE"]
raw_data = numpy.frombuffer(datastring, dtype=numpy.int16)[-length:]
data = (raw_data.astype(numpy.float) - header["YOFF"]) * header[
"YMULT"
] + header["YZERO"]
data = (raw_data.astype(float) - header["YOFF"]) * header["YMULT"] + header[
"YZERO"
]
return OscAnalogChanData(length, raw_data, data, header)
......
......@@ -720,7 +720,7 @@ class VariableStepTriggerMaster(AcquisitionMaster):
if self.broadcast_len > 1:
self.channels.update_from_iterable(
[
numpy.ones(self.broadcast_len, numpy.float) * axis.position
numpy.ones(self.broadcast_len, float) * axis.position
for axis in self._monitor_axes
]
)
......
......@@ -24,7 +24,7 @@ class SoftwareTimerMaster(AcquisitionMaster):
AcquisitionChannel(f"{self.name}:elapsed_time", numpy.double, (), unit="s")
)
self.channels.append(
AcquisitionChannel(f"{self.name}:epoch", numpy.float, (), unit="s")
AcquisitionChannel(f"{self.name}:epoch", float, (), unit="s")
)
self._nb_point = 0
......
......@@ -79,7 +79,7 @@ def com(x: numpy.ndarray, y: numpy.ndarray, visual=True) -> float:
if visual:
x, y = _extract_unique(x, y)
y -= y.min()
return numpy.sum(x * _calc_weights(y), dtype=numpy.float)
return numpy.sum(x * _calc_weights(y), dtype=float)
return numpy.nan
......@@ -203,11 +203,11 @@ def _calc_weights(y):
"""
if (y < 0).any():
y -= y.min()
ysum = numpy.sum(y, dtype=numpy.float)
ysum = numpy.sum(y, dtype=float)
if ysum:
return y / ysum
else:
return numpy.float(1 / y.size) # no need to replicate
return float(1 / y.size) # no need to replicate
def _optimize_gradient(gradient, i, grad_down):
......
......@@ -129,13 +129,9 @@ def fullfield_tomo(session, nchunks=4, expo=1e-6):
return flatten([numpy.arange(npixels)] * len(spectra))
channelmap = {}
seq.add_custom_channel(
AcquisitionChannel("translation", numpy.float, (), unit="px")
)
seq.add_custom_channel(
AcquisitionChannel("rotation", numpy.float, (), unit="degree")
)
seq.add_custom_channel(AcquisitionChannel("sinogram", numpy.float, ()))
seq.add_custom_channel(AcquisitionChannel("translation", float, (), unit="px"))
seq.add_custom_channel(AcquisitionChannel("rotation", float, (), unit="degree"))
seq.add_custom_channel(AcquisitionChannel("sinogram", float, ()))
channelmap[f"axis:{rotmot.name}"] = [{"name": "rotation", "process": replicate}]
channelmap[detector.fullname] = [
{"name": "sinogram", "process": flatten},
......
......@@ -845,7 +845,7 @@ class AcqDevice(AcquisitionSlave):
self.counters = list()
def add_counter(self, counter):
channels = [AcquisitionChannel(self, f'{counter.name}:{k}', numpy.float, ())
channels = [AcquisitionChannel(self, f'{counter.name}:{k}', float, ())
for k in ['bid','ask']]
self.channels.extend(channels)
self.counters.append(counter)
......
......@@ -37,7 +37,7 @@ def simulate_scan(scan_info, data):
step = 2
seq = Sequence(scan_info=scan_info)
for channel_name, array in data.items():
seq.add_custom_channel(AcquisitionChannel(channel_name, numpy.float, ()))
seq.add_custom_channel(AcquisitionChannel(channel_name, float, ()))
with seq.sequence_context() as scan_seq:
array = list(data.values())[0]
for i in range(0, len(array) - 1, step):
......
......@@ -53,8 +53,8 @@ It is possible to publish additional channels that are not part of any of the sc
...: from bliss.scanning.chain import AcquisitionChannel
...: import numpy
...: seq=Sequence()
...: seq.add_custom_channel(AcquisitionChannel('mychannel',numpy.float,()))
...: seq.add_custom_channel(AcquisitionChannel('sum',numpy.float,()))
...: seq.add_custom_channel(AcquisitionChannel('mychannel',float,()))
...: seq.add_custom_channel(AcquisitionChannel('sum',float,()))
...: with seq.sequence_context() as scan_seq:
...: s1=loopscan(5,.1,diode,run=False)
...: s2=loopscan(5,.1,diode,run=False)
......
......@@ -47,8 +47,8 @@ def _test_nxw_scangroup(session=None, tmpdir=None, writer=None, **kwargs):
motor = session.env_dict["robx"]
seq = Sequence()
seq.add_custom_channel(AcquisitionChannel("customdata", numpy.float, ()))
seq.add_custom_channel(AcquisitionChannel("diode34", numpy.float, ()))
seq.add_custom_channel(AcquisitionChannel("customdata", float, ()))
seq.add_custom_channel(AcquisitionChannel("diode34", float, ()))
with gevent.Timeout(30):
with seq.sequence_context() as scan_seq:
scan1 = scans.loopscan(npoints, .1, detector1, run=False)
......
......@@ -131,7 +131,7 @@ def test_calc_channels_convert_func(default_session):
def func(sender, data_dict):
return {"position": data_dict["roby"] * 0.1}
# calc_chan_out = AcquisitionChannel("position", numpy.float, ())
# calc_chan_out = AcquisitionChannel("position", float, ())
calc_chan_acq = CalcChannelAcquisitionSlave(
"calc_chan_acq", [acq_master], func, ["position"]
)
......@@ -193,7 +193,7 @@ def test_calc_channels_mean_position(default_session):
self.last_data = stop
return {"mean_pos": numpy.array([mean])}
calc_chan_out = AcquisitionChannel("mean_pos", numpy.float, ())
calc_chan_out = AcquisitionChannel("mean_pos", float, ())
calc_chan_acq = CalcChannelAcquisitionSlave(
"calc_chan_acq", [acq_master], MyHook(), [calc_chan_out]
)
......
......@@ -86,7 +86,7 @@ def find_data_start(lines, fields):
def extract_data(lines, shape, col_sep="|"):
""" extract text data as numpy array """
_h, w = shape
arry = numpy.empty(shape, dtype=numpy.float)
arry = numpy.empty(shape, dtype=float)
incr = 0
for line in lines:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment