有什么方法可以消除零尺寸数组归约错误?

时间:2019-11-23 18:59:38

标签: python numpy

scanSubscription = rxBleClient.scanBleDevices(
  ScanSettings.Builder()
  // .setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY) // change if needed
  // .setCallbackType(ScanSettings.CALLBACK_TYPE_ALL_MATCHES) // change if needed
  .build()
  // add filters if needed
 )
 .filter {
  scanResult -> scanResult.bleDevice.name == "MyDevice"
 } // Filter for devices named MyDevice
 .subscribe({
  scanResult ->
  // Print list of available devices
  println("Scan Result: ${scanResult.bleDevice.bluetoothDevice.name}")
  val charUUID = UUID.fromString("49535343-1e4d-4bd9-ba61-23c647249616")
  println("UUID: $charUUID")

  // Connect to MyDevice
  val macAddress = scanResult.bleDevice.bluetoothDevice.address //34:81:F4:55:04:9A
  println("MAC Address: $macAddress")
  val rxBleDevice = rxBleClient.getBleDevice(macAddress)

  val charset = Charsets.UTF_8
  val bytesToWrite = "cmdl000".toByteArray(charset)
  println("Bytes: $bytesToWrite")

  rxBleDevice.establishConnection(false)
  .flatMapSingle {
   rxBleConnection -> rxBleConnection.writeCharacteristic(charUUID, bytesToWrite)
  }

 }, {
  throwable ->
  // Handle an error here.
  println("Scan Error: $throwable")
 })

当我运行包含以下代码的程序时。我一次又一次收到零数组归约错误,但无法修复该错误。请帮我。相应的错误如下:

I/System.out: Scan Result: MyDevice
    UUID: 49535343-1e4d-4bd9-ba61-23c647249616
    MAC Address: 34:81:F4:55:04:9A
I/System.out: Bytes: [B@4973078

1 个答案:

答案 0 :(得分:1)

我认为,如果joints为空,则不应该执行任何计算……但是,如果您确实想这样做,可以将参数initial传递给np.max()。我建议将其设置为尽可能小的值,例如负无穷大。

x.max(axis=0, initial=-np.inf)