convert type 'ILNumerics.ILArray<float>' to 'float[*,*]' - ilnumerics

ILArray<float> W_wimgr = new float[256, 256];
float[,] ResultantImage = new float[256, 256];
When i Do this
ResultantImage = W_wimgr;
I got the Error :
Error 1 Cannot implicitly convert type 'ILNumerics.ILArray<float>' to 'float[*,*]'

Related

sum nested data with swift

I am trying to sum nested data without success.
This is my data:
{
"BON_PK" = 34;
"BON_EXTRA" = "100.00";
Line = ({ "LIG_PRICE" = "40.80";},
{ "LIG_PRICE" = "40.80";})
},
{
"BON_PK" = 35;
"BON_EXTRA" = "10.00";
Line = ({"LIG_PRICE" = "40.80";},
{"LIG_PRICE" = "40.80";})})
This is what I tried:
vPrice = vArr.map {$0?.Line!.map {(($0.LIG_PRICE as NSString).floatValue)}}.reduce(0, +)
This one is working but not the nested one:
vDelTotal = vArrBon.map { ($0?.BON_EXTRA!.toFloat)! }.reduce(0, +)
I created a 'toFloat' Function that is not working with the nested one.
I have this error message:
Cannot convert value of type '[Float]?' to closure result type 'Float'

Recieivng a 'NoneType' 'append' in python 3

I have this code and it keeps giving me the 'NoneType' object has no attribute 'append'. Can someone tells me what is wrong, please?
def extract():
extracted_data = pd.DataFrame(columns = ['Name','Last'])
for jsonfile in glob.glob('file_1.json'):
extracted_data = extracted_data.append(extract_from_json(jsonfile), ignore_index = True)
return extract

MlModel prediction returns nil

I converted an ONNX model to mlmodel and I'm unable to use the prediction function.
here is my model's input and output:
[enter image description here][1]
[1]: https://i.stack.imgur.com/6mY4H.png
i'm initializing the model and the input like this:
var model: dont_touch_model!
var modelInputVector = try! MLMultiArray(shape: [1,1,13], dataType: MLMultiArrayDataType.float32)
I fill the vector with motion data like this:
modelInputVector[[0, 0, 0] as [NSNumber]] = deviceMotion.userAcceleration.x as NSNumber
modelInputVector[[0, 0, 1] as [NSNumber]] = deviceMotion.userAcceleration.y as NSNumber
modelInputVector[[0, 0, 2] as [NSNumber]] = deviceMotion.userAcceleration.z as NSNumber
I try to execute a prediction:
let modelInput = dont_touch_modelInput(sequenceinput: modelInputVector)
var modelOutput = try! model.prediction(input: modelInput)
and I get this error message:
"Thread 1: Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value"
can someone please help?

How can I test an input condition after translating the source code using Coco/R?

I have a function that I want to test in Swift. It has been generated using Coco/R. I have an input statement which I want to test if it provides the desired output using the generated code (Parser.swift).
I haven't tried anything out yet since I don't know where to start.
func Addition {
var x = input.a
var y = input.b
let z: Int?
z = x + y
return z
}
Expected Result:
Input File: a = 10
b = 5
Output: 15
Open XCode , creat new PlayGround:
Then Try this:
import Foundation
struct InputFormat {
var a : Int
var b : Int
}
func addition(input: InputFormat) -> Int {
let x = input.a
let y = input.b
let z = x + y
return z
}
let input = InputFormat(a: 10, b: 5)
print(addition(input: input))
It was the nearest way to get your code into test.
Hope it helps.

Error: Cannot convert value of type 'UInt64' to expected argument type 'DispatchTime'

Im trying to create a timer in Swift4 that is controlled by a variable, the only issue is that I get a error:
Cannot convert value of type 'UInt64' to expected argument type 'DispatchTime'
Here is the code:
let maxNumber = maxNumberField.intValue
let amountOfNumbers = amountOfNumbersField.intValue
var delay = 5
var x: Int32 = amountOfNumbers
while(x > 0){
let when = (DispatchTime.now().uptimeNanoseconds + (5 * UInt64(x)))
DispatchQueue.main.asyncAfter(deadline: when) { // error
let number = arc4random_uniform(UInt32(maxNumber + 1))
let synth = NSSpeechSynthesizer()
synth.startSpeaking(String(number))
}
x = (x - 1)
}
From my understanding I need to convert the when variable which is an UInt64 to an DispatchTime.
How would I do this?
You should either:
Use DispatchTime.init(uptimeNanoseconds:) with your when variable.
Use this: let when = (DispatchTime.now() + (5 * Double(x))), for there is + overload for (DispatchTime, Double).