kinfer 0.3.2__cp312-cp312-macosx_11_0_arm64.whl → 0.4.0__cp312-cp312-macosx_11_0_arm64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- kinfer/__init__.py +0 -1
- kinfer/common/__init__.py +0 -0
- kinfer/common/types.py +11 -0
- kinfer/export/__init__.py +0 -1
- kinfer/export/common.py +35 -0
- kinfer/export/jax.py +51 -0
- kinfer/export/pytorch.py +42 -110
- kinfer/export/serialize.py +86 -0
- kinfer/requirements.txt +3 -4
- kinfer/rust/Cargo.toml +8 -6
- kinfer/rust/src/lib.rs +2 -11
- kinfer/rust/src/model.rs +271 -121
- kinfer/rust/src/runtime.rs +104 -0
- kinfer/rust_bindings/Cargo.toml +8 -1
- kinfer/rust_bindings/rust_bindings.pyi +35 -0
- kinfer/rust_bindings/src/lib.rs +310 -1
- kinfer/rust_bindings.cpython-312-darwin.so +0 -0
- kinfer/rust_bindings.pyi +29 -1
- kinfer-0.4.0.dist-info/METADATA +55 -0
- kinfer-0.4.0.dist-info/RECORD +26 -0
- {kinfer-0.3.2.dist-info → kinfer-0.4.0.dist-info}/WHEEL +2 -1
- kinfer/inference/__init__.py +0 -1
- kinfer/inference/python.py +0 -92
- kinfer/proto/__init__.py +0 -40
- kinfer/proto/kinfer_pb2.py +0 -103
- kinfer/proto/kinfer_pb2.pyi +0 -1097
- kinfer/requirements-dev.txt +0 -8
- kinfer/rust/build.rs +0 -16
- kinfer/rust/src/kinfer_proto.rs +0 -14
- kinfer/rust/src/main.rs +0 -6
- kinfer/rust/src/onnx_serializer.rs +0 -804
- kinfer/rust/src/serializer.rs +0 -221
- kinfer/rust/src/tests/onnx_serializer_tests.rs +0 -212
- kinfer/serialize/__init__.py +0 -36
- kinfer/serialize/base.py +0 -536
- kinfer/serialize/json.py +0 -399
- kinfer/serialize/numpy.py +0 -426
- kinfer/serialize/pytorch.py +0 -402
- kinfer/serialize/schema.py +0 -125
- kinfer/serialize/types.py +0 -17
- kinfer/serialize/utils.py +0 -177
- kinfer-0.3.2.dist-info/METADATA +0 -57
- kinfer-0.3.2.dist-info/RECORD +0 -39
- {kinfer-0.3.2.dist-info → kinfer-0.4.0.dist-info/licenses}/LICENSE +0 -0
- {kinfer-0.3.2.dist-info → kinfer-0.4.0.dist-info}/top_level.txt +0 -0
kinfer/serialize/numpy.py
DELETED
@@ -1,426 +0,0 @@
|
|
1
|
-
"""Defines a serializer for Numpy arrays."""
|
2
|
-
|
3
|
-
from typing import cast
|
4
|
-
|
5
|
-
import numpy as np
|
6
|
-
|
7
|
-
from kinfer import proto as P
|
8
|
-
from kinfer.serialize.base import (
|
9
|
-
AudioFrameSerializer,
|
10
|
-
CameraFrameSerializer,
|
11
|
-
ImuSerializer,
|
12
|
-
JointCommandsSerializer,
|
13
|
-
JointPositionsSerializer,
|
14
|
-
JointTorquesSerializer,
|
15
|
-
JointVelocitiesSerializer,
|
16
|
-
MultiSerializer,
|
17
|
-
Serializer,
|
18
|
-
StateTensorSerializer,
|
19
|
-
TimestampSerializer,
|
20
|
-
VectorCommandSerializer,
|
21
|
-
)
|
22
|
-
from kinfer.serialize.utils import (
|
23
|
-
as_float,
|
24
|
-
check_names_match,
|
25
|
-
convert_angular_position,
|
26
|
-
convert_angular_velocity,
|
27
|
-
convert_torque,
|
28
|
-
dtype_num_bytes,
|
29
|
-
dtype_range,
|
30
|
-
numpy_dtype,
|
31
|
-
parse_bytes,
|
32
|
-
)
|
33
|
-
|
34
|
-
|
35
|
-
class NumpyBaseSerializer:
|
36
|
-
def __init__(self: "NumpyBaseSerializer", dtype: np.dtype | None = None) -> None:
|
37
|
-
self.dtype = dtype or np.float32
|
38
|
-
|
39
|
-
|
40
|
-
class NumpyJointPositionsSerializer(NumpyBaseSerializer, JointPositionsSerializer[np.ndarray]):
|
41
|
-
def serialize_joint_positions(
|
42
|
-
self: "NumpyJointPositionsSerializer",
|
43
|
-
schema: P.JointPositionsSchema,
|
44
|
-
value: P.JointPositionsValue,
|
45
|
-
) -> np.ndarray:
|
46
|
-
value_map = {v.joint_name: v for v in value.values}
|
47
|
-
check_names_match("schema", schema.joint_names, "value", list(value_map.keys()))
|
48
|
-
array = np.array(
|
49
|
-
[
|
50
|
-
convert_angular_position(value_map[name].value, value_map[name].unit, schema.unit)
|
51
|
-
for name in schema.joint_names
|
52
|
-
],
|
53
|
-
dtype=self.dtype,
|
54
|
-
)
|
55
|
-
|
56
|
-
return array
|
57
|
-
|
58
|
-
def deserialize_joint_positions(
|
59
|
-
self: "NumpyJointPositionsSerializer",
|
60
|
-
schema: P.JointPositionsSchema,
|
61
|
-
value: np.ndarray,
|
62
|
-
) -> P.JointPositionsValue:
|
63
|
-
if value.shape != (len(schema.joint_names),):
|
64
|
-
raise ValueError(
|
65
|
-
f"Shape of array must match number of joint names: {value.shape} != {len(schema.joint_names)}"
|
66
|
-
)
|
67
|
-
value_list = cast(list[float], value.astype(float).tolist())
|
68
|
-
return P.JointPositionsValue(
|
69
|
-
values=[
|
70
|
-
P.JointPositionValue(
|
71
|
-
joint_name=name,
|
72
|
-
value=float(value_list[i]),
|
73
|
-
unit=schema.unit,
|
74
|
-
)
|
75
|
-
for i, name in enumerate(schema.joint_names)
|
76
|
-
]
|
77
|
-
)
|
78
|
-
|
79
|
-
|
80
|
-
class NumpyJointVelocitiesSerializer(NumpyBaseSerializer, JointVelocitiesSerializer[np.ndarray]):
|
81
|
-
def serialize_joint_velocities(
|
82
|
-
self: "NumpyJointVelocitiesSerializer",
|
83
|
-
schema: P.JointVelocitiesSchema,
|
84
|
-
value: P.JointVelocitiesValue,
|
85
|
-
) -> np.ndarray:
|
86
|
-
value_map = {v.joint_name: v for v in value.values}
|
87
|
-
check_names_match("schema", schema.joint_names, "value", list(value_map.keys()))
|
88
|
-
array = np.array(
|
89
|
-
[
|
90
|
-
convert_angular_velocity(value_map[name].value, value_map[name].unit, schema.unit)
|
91
|
-
for name in schema.joint_names
|
92
|
-
],
|
93
|
-
dtype=self.dtype,
|
94
|
-
)
|
95
|
-
return array
|
96
|
-
|
97
|
-
def deserialize_joint_velocities(
|
98
|
-
self: "NumpyJointVelocitiesSerializer",
|
99
|
-
schema: P.JointVelocitiesSchema,
|
100
|
-
value: np.ndarray,
|
101
|
-
) -> P.JointVelocitiesValue:
|
102
|
-
if value.shape != (len(schema.joint_names),):
|
103
|
-
raise ValueError(
|
104
|
-
f"Shape of array must match number of joint names: {value.shape} != {len(schema.joint_names)}"
|
105
|
-
)
|
106
|
-
value_list = cast(list[float], value.astype(float).tolist())
|
107
|
-
return P.JointVelocitiesValue(
|
108
|
-
values=[
|
109
|
-
P.JointVelocityValue(joint_name=name, value=value_list[i], unit=schema.unit)
|
110
|
-
for i, name in enumerate(schema.joint_names)
|
111
|
-
]
|
112
|
-
)
|
113
|
-
|
114
|
-
|
115
|
-
class NumpyJointTorquesSerializer(NumpyBaseSerializer, JointTorquesSerializer[np.ndarray]):
|
116
|
-
def serialize_joint_torques(
|
117
|
-
self: "NumpyJointTorquesSerializer",
|
118
|
-
schema: P.JointTorquesSchema,
|
119
|
-
value: P.JointTorquesValue,
|
120
|
-
) -> np.ndarray:
|
121
|
-
value_map = {v.joint_name: v for v in value.values}
|
122
|
-
check_names_match("schema", schema.joint_names, "value", list(value_map.keys()))
|
123
|
-
array = np.array(
|
124
|
-
[convert_torque(value_map[name].value, value_map[name].unit, schema.unit) for name in schema.joint_names],
|
125
|
-
dtype=self.dtype,
|
126
|
-
)
|
127
|
-
return array
|
128
|
-
|
129
|
-
def deserialize_joint_torques(
|
130
|
-
self: "NumpyJointTorquesSerializer",
|
131
|
-
schema: P.JointTorquesSchema,
|
132
|
-
value: np.ndarray,
|
133
|
-
) -> P.JointTorquesValue:
|
134
|
-
if value.shape != (len(schema.joint_names),):
|
135
|
-
raise ValueError(
|
136
|
-
f"Shape of array must match number of joint names: {value.shape} != {len(schema.joint_names)}"
|
137
|
-
)
|
138
|
-
value_list = cast(list[float], value.astype(float).tolist())
|
139
|
-
return P.JointTorquesValue(
|
140
|
-
values=[
|
141
|
-
P.JointTorqueValue(joint_name=name, value=float(value_list[i]), unit=schema.unit)
|
142
|
-
for i, name in enumerate(schema.joint_names)
|
143
|
-
]
|
144
|
-
)
|
145
|
-
|
146
|
-
|
147
|
-
class NumpyJointCommandsSerializer(NumpyBaseSerializer, JointCommandsSerializer[np.ndarray]):
|
148
|
-
def _convert_value_to_array(
|
149
|
-
self: "NumpyJointCommandsSerializer",
|
150
|
-
value: P.JointCommandValue,
|
151
|
-
schema: P.JointCommandsSchema,
|
152
|
-
) -> np.ndarray:
|
153
|
-
return np.array(
|
154
|
-
[
|
155
|
-
convert_torque(value.torque, value.torque_unit, schema.torque_unit),
|
156
|
-
convert_angular_velocity(value.velocity, value.velocity_unit, schema.velocity_unit),
|
157
|
-
convert_angular_position(value.position, value.position_unit, schema.position_unit),
|
158
|
-
value.kp,
|
159
|
-
value.kd,
|
160
|
-
],
|
161
|
-
dtype=self.dtype,
|
162
|
-
)
|
163
|
-
|
164
|
-
def _convert_array_to_value(
|
165
|
-
self: "NumpyJointCommandsSerializer",
|
166
|
-
values: list[float],
|
167
|
-
schema: P.JointCommandsSchema,
|
168
|
-
name: str,
|
169
|
-
) -> P.JointCommandValue:
|
170
|
-
if len(values) != 5:
|
171
|
-
raise ValueError(f"Shape of array must match number of joint commands: {len(values)} != 5")
|
172
|
-
return P.JointCommandValue(
|
173
|
-
joint_name=name,
|
174
|
-
torque=values[0],
|
175
|
-
velocity=values[1],
|
176
|
-
position=values[2],
|
177
|
-
kp=values[3],
|
178
|
-
kd=values[4],
|
179
|
-
torque_unit=schema.torque_unit,
|
180
|
-
velocity_unit=schema.velocity_unit,
|
181
|
-
position_unit=schema.position_unit,
|
182
|
-
)
|
183
|
-
|
184
|
-
def serialize_joint_commands(
|
185
|
-
self: "NumpyJointCommandsSerializer",
|
186
|
-
schema: P.JointCommandsSchema,
|
187
|
-
value: P.JointCommandsValue,
|
188
|
-
) -> np.ndarray:
|
189
|
-
value_map = {v.joint_name: v for v in value.values}
|
190
|
-
check_names_match("schema", schema.joint_names, "value", list(value_map.keys()))
|
191
|
-
array = np.stack(
|
192
|
-
[self._convert_value_to_array(value_map[name], schema) for name in schema.joint_names],
|
193
|
-
axis=0,
|
194
|
-
)
|
195
|
-
return array
|
196
|
-
|
197
|
-
def deserialize_joint_commands(
|
198
|
-
self: "NumpyJointCommandsSerializer",
|
199
|
-
schema: P.JointCommandsSchema,
|
200
|
-
value: np.ndarray,
|
201
|
-
) -> P.JointCommandsValue:
|
202
|
-
if value.shape != (len(schema.joint_names), 5):
|
203
|
-
raise ValueError(
|
204
|
-
"Shape of array must match number of joint names and commands: "
|
205
|
-
f"{value.shape} != ({len(schema.joint_names)}, 5)"
|
206
|
-
)
|
207
|
-
value_list = cast(list[list[float]], value.astype(float).tolist())
|
208
|
-
return P.JointCommandsValue(
|
209
|
-
values=[
|
210
|
-
self._convert_array_to_value(value_list[i], schema, name) for i, name in enumerate(schema.joint_names)
|
211
|
-
]
|
212
|
-
)
|
213
|
-
|
214
|
-
|
215
|
-
class NumpyCameraFrameSerializer(NumpyBaseSerializer, CameraFrameSerializer[np.ndarray]):
|
216
|
-
def serialize_camera_frame(
|
217
|
-
self: "NumpyCameraFrameSerializer",
|
218
|
-
schema: P.CameraFrameSchema,
|
219
|
-
value: P.CameraFrameValue,
|
220
|
-
) -> np.ndarray:
|
221
|
-
np_arr = parse_bytes(value.data, P.DType.UINT8)
|
222
|
-
array = np_arr.astype(self.dtype) / 255.0
|
223
|
-
if array.size != schema.channels * schema.height * schema.width:
|
224
|
-
raise ValueError(
|
225
|
-
"Length of data must match number of channels, height, and width: "
|
226
|
-
f"{array.size} != {schema.channels} * {schema.height} * {schema.width}"
|
227
|
-
)
|
228
|
-
array = array.reshape(schema.channels, schema.height, schema.width)
|
229
|
-
return array
|
230
|
-
|
231
|
-
def deserialize_camera_frame(
|
232
|
-
self: "NumpyCameraFrameSerializer",
|
233
|
-
schema: P.CameraFrameSchema,
|
234
|
-
value: np.ndarray,
|
235
|
-
) -> P.CameraFrameValue:
|
236
|
-
np_arr = (value * 255.0).flatten().astype(np.uint8)
|
237
|
-
return P.CameraFrameValue(data=np_arr.tobytes())
|
238
|
-
|
239
|
-
|
240
|
-
class NumpyAudioFrameSerializer(NumpyBaseSerializer, AudioFrameSerializer[np.ndarray]):
|
241
|
-
def serialize_audio_frame(
|
242
|
-
self: "NumpyAudioFrameSerializer",
|
243
|
-
schema: P.AudioFrameSchema,
|
244
|
-
value: P.AudioFrameValue,
|
245
|
-
) -> np.ndarray:
|
246
|
-
value_bytes = value.data
|
247
|
-
if len(value_bytes) != schema.channels * schema.sample_rate * dtype_num_bytes(schema.dtype):
|
248
|
-
raise ValueError(
|
249
|
-
"Length of data must match number of channels, sample rate, and dtype: "
|
250
|
-
f"{len(value_bytes)} != {schema.channels} * {schema.sample_rate} * {dtype_num_bytes(schema.dtype)}"
|
251
|
-
)
|
252
|
-
_, max_value = dtype_range(schema.dtype)
|
253
|
-
np_arr = parse_bytes(value_bytes, schema.dtype)
|
254
|
-
array = np_arr.astype(self.dtype)
|
255
|
-
array = array.reshape(schema.channels, -1)
|
256
|
-
array = array / max_value
|
257
|
-
return array
|
258
|
-
|
259
|
-
def deserialize_audio_frame(
|
260
|
-
self: "NumpyAudioFrameSerializer",
|
261
|
-
schema: P.AudioFrameSchema,
|
262
|
-
value: np.ndarray,
|
263
|
-
) -> P.AudioFrameValue:
|
264
|
-
_, max_value = dtype_range(schema.dtype)
|
265
|
-
np_arr = (value * max_value).flatten().astype(numpy_dtype(schema.dtype))
|
266
|
-
return P.AudioFrameValue(data=np_arr.tobytes())
|
267
|
-
|
268
|
-
|
269
|
-
class NumpyImuSerializer(NumpyBaseSerializer, ImuSerializer[np.ndarray]):
|
270
|
-
def serialize_imu(
|
271
|
-
self: "NumpyImuSerializer",
|
272
|
-
schema: P.ImuSchema,
|
273
|
-
value: P.ImuValue,
|
274
|
-
) -> np.ndarray:
|
275
|
-
vectors = []
|
276
|
-
if schema.use_accelerometer:
|
277
|
-
vectors.append(
|
278
|
-
np.array(
|
279
|
-
[value.linear_acceleration.x, value.linear_acceleration.y, value.linear_acceleration.z],
|
280
|
-
dtype=self.dtype,
|
281
|
-
)
|
282
|
-
)
|
283
|
-
if schema.use_gyroscope:
|
284
|
-
vectors.append(
|
285
|
-
np.array(
|
286
|
-
[value.angular_velocity.x, value.angular_velocity.y, value.angular_velocity.z],
|
287
|
-
dtype=self.dtype,
|
288
|
-
)
|
289
|
-
)
|
290
|
-
if schema.use_magnetometer:
|
291
|
-
vectors.append(
|
292
|
-
np.array(
|
293
|
-
[value.magnetic_field.x, value.magnetic_field.y, value.magnetic_field.z],
|
294
|
-
dtype=self.dtype,
|
295
|
-
)
|
296
|
-
)
|
297
|
-
if not vectors:
|
298
|
-
raise ValueError("IMU has nothing to serialize")
|
299
|
-
return np.stack(vectors, axis=0)
|
300
|
-
|
301
|
-
def deserialize_imu(
|
302
|
-
self: "NumpyImuSerializer",
|
303
|
-
schema: P.ImuSchema,
|
304
|
-
value: np.ndarray,
|
305
|
-
) -> P.ImuValue:
|
306
|
-
num_vectors = sum([schema.use_accelerometer, schema.use_gyroscope, schema.use_magnetometer])
|
307
|
-
if value.shape != (num_vectors, 3):
|
308
|
-
raise ValueError(
|
309
|
-
f"Shape of array must match number of vectors and components: {value.shape} != ({num_vectors}, 3)"
|
310
|
-
)
|
311
|
-
vectors = cast(list[list[float]], value.astype(float).tolist())
|
312
|
-
imu_value = P.ImuValue()
|
313
|
-
if schema.use_accelerometer:
|
314
|
-
x, y, z = vectors.pop(0)
|
315
|
-
imu_value.linear_acceleration.x = as_float(x)
|
316
|
-
imu_value.linear_acceleration.y = as_float(y)
|
317
|
-
imu_value.linear_acceleration.z = as_float(z)
|
318
|
-
if schema.use_gyroscope:
|
319
|
-
x, y, z = vectors.pop(0)
|
320
|
-
imu_value.angular_velocity.x = as_float(x)
|
321
|
-
imu_value.angular_velocity.y = as_float(y)
|
322
|
-
imu_value.angular_velocity.z = as_float(z)
|
323
|
-
if schema.use_magnetometer:
|
324
|
-
x, y, z = vectors.pop(0)
|
325
|
-
imu_value.magnetic_field.x = as_float(x)
|
326
|
-
imu_value.magnetic_field.y = as_float(y)
|
327
|
-
imu_value.magnetic_field.z = as_float(z)
|
328
|
-
return imu_value
|
329
|
-
|
330
|
-
|
331
|
-
class NumpyTimestampSerializer(NumpyBaseSerializer, TimestampSerializer[np.ndarray]):
|
332
|
-
def serialize_timestamp(
|
333
|
-
self: "NumpyTimestampSerializer",
|
334
|
-
schema: P.TimestampSchema,
|
335
|
-
value: P.TimestampValue,
|
336
|
-
) -> np.ndarray:
|
337
|
-
elapsed_seconds = value.seconds - schema.start_seconds
|
338
|
-
elapsed_nanos = value.nanos - schema.start_nanos
|
339
|
-
if elapsed_nanos < 0:
|
340
|
-
elapsed_seconds -= 1
|
341
|
-
elapsed_nanos += 1_000_000_000
|
342
|
-
total_elapsed_seconds = elapsed_seconds + elapsed_nanos / 1_000_000_000
|
343
|
-
return np.array([total_elapsed_seconds], dtype=self.dtype)
|
344
|
-
|
345
|
-
def deserialize_timestamp(
|
346
|
-
self: "NumpyTimestampSerializer",
|
347
|
-
schema: P.TimestampSchema,
|
348
|
-
value: np.ndarray,
|
349
|
-
) -> P.TimestampValue:
|
350
|
-
total_elapsed_seconds = float(value.item())
|
351
|
-
elapsed_seconds = int(total_elapsed_seconds)
|
352
|
-
elapsed_nanos = int((total_elapsed_seconds - elapsed_seconds) * 1_000_000_000)
|
353
|
-
return P.TimestampValue(seconds=elapsed_seconds, nanos=elapsed_nanos)
|
354
|
-
|
355
|
-
|
356
|
-
class NumpyVectorCommandSerializer(NumpyBaseSerializer, VectorCommandSerializer[np.ndarray]):
|
357
|
-
def serialize_vector_command(
|
358
|
-
self: "NumpyVectorCommandSerializer",
|
359
|
-
schema: P.VectorCommandSchema,
|
360
|
-
value: P.VectorCommandValue,
|
361
|
-
) -> np.ndarray:
|
362
|
-
return np.array(value.values, dtype=self.dtype)
|
363
|
-
|
364
|
-
def deserialize_vector_command(
|
365
|
-
self: "NumpyVectorCommandSerializer",
|
366
|
-
schema: P.VectorCommandSchema,
|
367
|
-
value: np.ndarray,
|
368
|
-
) -> P.VectorCommandValue:
|
369
|
-
if value.shape != (schema.dimensions,):
|
370
|
-
raise ValueError(f"Shape of array must match number of dimensions: {value.shape} != {schema.dimensions}")
|
371
|
-
values = cast(list[float], value.astype(float).tolist())
|
372
|
-
return P.VectorCommandValue(values=values)
|
373
|
-
|
374
|
-
|
375
|
-
class NumpyStateTensorSerializer(NumpyBaseSerializer, StateTensorSerializer[np.ndarray]):
|
376
|
-
def serialize_state_tensor(
|
377
|
-
self: "NumpyStateTensorSerializer",
|
378
|
-
schema: P.StateTensorSchema,
|
379
|
-
value: P.StateTensorValue,
|
380
|
-
) -> np.ndarray:
|
381
|
-
value_bytes = value.data
|
382
|
-
if len(value_bytes) != np.prod(schema.shape) * dtype_num_bytes(schema.dtype):
|
383
|
-
raise ValueError(
|
384
|
-
"Length of data must match number of elements: "
|
385
|
-
f"{len(value_bytes)} != {np.prod(schema.shape)} * {dtype_num_bytes(schema.dtype)}"
|
386
|
-
)
|
387
|
-
np_arr = parse_bytes(value_bytes, schema.dtype)
|
388
|
-
array = np.ascontiguousarray(np_arr.astype(numpy_dtype(schema.dtype)))
|
389
|
-
array = array.reshape(tuple(schema.shape))
|
390
|
-
return array
|
391
|
-
|
392
|
-
def deserialize_state_tensor(
|
393
|
-
self: "NumpyStateTensorSerializer",
|
394
|
-
schema: P.StateTensorSchema,
|
395
|
-
value: np.ndarray,
|
396
|
-
) -> P.StateTensorValue:
|
397
|
-
contiguous_value = np.ascontiguousarray(value)
|
398
|
-
return P.StateTensorValue(data=contiguous_value.flatten().tobytes())
|
399
|
-
|
400
|
-
|
401
|
-
class NumpySerializer(
|
402
|
-
NumpyJointPositionsSerializer,
|
403
|
-
NumpyJointVelocitiesSerializer,
|
404
|
-
NumpyJointTorquesSerializer,
|
405
|
-
NumpyJointCommandsSerializer,
|
406
|
-
NumpyCameraFrameSerializer,
|
407
|
-
NumpyAudioFrameSerializer,
|
408
|
-
NumpyImuSerializer,
|
409
|
-
NumpyTimestampSerializer,
|
410
|
-
NumpyVectorCommandSerializer,
|
411
|
-
NumpyStateTensorSerializer,
|
412
|
-
Serializer[np.ndarray],
|
413
|
-
):
|
414
|
-
def __init__(
|
415
|
-
self: "NumpySerializer",
|
416
|
-
schema: P.ValueSchema,
|
417
|
-
*,
|
418
|
-
dtype: np.dtype | None = None,
|
419
|
-
) -> None:
|
420
|
-
NumpyBaseSerializer.__init__(self, dtype=dtype)
|
421
|
-
Serializer.__init__(self, schema=schema)
|
422
|
-
|
423
|
-
|
424
|
-
class NumpyMultiSerializer(MultiSerializer[np.ndarray]):
|
425
|
-
def __init__(self: "NumpyMultiSerializer", schema: P.IOSchema) -> None:
|
426
|
-
super().__init__([NumpySerializer(schema=s) for s in schema.values])
|