Why do I get an "Expected body of lambda expression" in the NSMutableArray? - nsmutablearray

I got the below code and I am not sure why I am getting the "Expected body of lambda expression" error.
binImg is a UIImage and contours is a vector from openCV (std::vector > contours;).
NSMutableArray *returnArray = [binImg, contours];
Can I not put a vector into an array or is there a syntax issue. Please enlighten me - thanks

it is not possible to store a contour in an NSMutableArray.

Related

How to create and set compound structure for ceiling type?

I am trying to set compound structure for ceiling type and wall type for wall type it working good but when I tried to set for ceiling type then it gives me exception that
"Autodesk.Revit.Exceptions.ArgumentException: 'Input compound structure has wrong End Cap condition for this element type. Parameter name: src Structure'"
CompoundStructure cStructure = CompoundStructure.CreateSingleLayerCompoundStructure(materialFunctionAssignment, width, materialId1);
cStructure.SetLayers(clayer);
ceilingType.SetCompoundStructure(cStructure);
Is there any other way to set compound structure for ceiling type
Thanks .
I do some changes and using this two method my issue is solve
structure.SetLayers(clayer);
floorType.SetCompoundStructure(structure);

code produces a 2d histogram but the results dont match with hist2d

I am trying to write a histogram builder to construct a 2d histogram for my assignment work. This is [my code][1]:
def Build2DHistogramClassifier(X1,X2,T,B,x1min,x1max,x2min,x2max):
HF=np.zeros((B,B),dtype='int');#initialising a empty array of integer type
HM=np.zeros((B,B),dtype='int');
bin_row_indices=(np.round(((B-1)*(X1-x1min)/(x1max-x1min)))).astype('int32');"""this logic decides which bin the value goes into"""
bin_column_indices=(np.round(((B-1)*(X2-x2min)/(x2max-x2min)))).astype('int32');"""np.round-->applies the formula to all the values in the array"""
for i,(r,c) in enumerate(zip(bin_row_indices, bin_column_indices)):
"""enumerate-->if we put array or list into it gives output with index/count i """
if T[i]=='Female':
HF[r,c]+=1;
else:
HM[r,c]+=1;
return [HF, HM]
but the problem is that the results( count in each bin) i am getting is not matching the what i get from using hist2d function in numpy( i passed the same bin size)
i am sorry if my code is not in the right format. Please click on the hyperlink to a gist i created with the same code.
what is the mistake in my code?
how do i correct it?
thanks
By rounding when assigning to bins you are treating the bins as bin centers. The numpy convention is to use them as bin edges.
Remove the two calls to round() from your code and change B-1 to B. You should now get the same results with your function and with np.histogram2d.

index image with 2D array

I have an image of size (1080,1920,3) stored in a numpy array and am trying to index it using an index array of size (6,2). My code is below and it runs, however the output dimensions are (2,6,3), which is not what I expect.
A = inPix[np.arange(6), 2darray]
This method above is from the answers here. Can anyone help me understand whats wrong and how I can get a (6,3) output array?
I found out that if you split the indices into columns, it works.
A = inPix[2darray[:,0],2darray[:,1]]

iOS comparing NSDictionaries in Arrays

I'm trying to find the index of an NSDictionary in an Array with NSDictionaries, but having problems with the encoding of the two.
Array a: is downloaded from a webserver (as a csv-string) and then converted into an Array of dictionaries.
Array b: is loaded with [NSArray arrayWithContentsOfFile] from a plist.
The dictionaries and arrays look good, but [indexOfObject] doesn't give me any results.
By outputting the data to the console, I found out that German Umlauts are encoded differently.
Array a: shows the character «ä» as \U00c3\U00a4
Array b: shows the character «ä» as \U00e4
So I guess that's why the function returns a NSNotFound.
I tried to cast the strings in many different ways, with no result...
Interestingly, the function used to work...
Any Ideas?
[EDIT]
Well, it turns out I didn't process the data coming from the server correctly.
I had to change this
NSString *dataStr=[[NSString alloc] initWithData:self.receivedData encoding:NSASCIIStringEncoding];
into this:
NSString *dataStr=[[NSString alloc] initWithData:self.receivedData encoding:NSUTF8StringEncoding];

Why am I getting an array of NANs when trying to plot a map with D3.js?

I am tring to plot a map with d3.js using GeoJSON, but the paths generated look like this:
<path d="MNaN,NaNLNaN,NaNLNaN,NaNLNaN,NaNLNaN,NaNLNaN,NaNLNaN,NaNLNaN,NaNLNaN,NaNLNaN,‌​NaNLNaN,NaNLNaN,NaNLNaN,NaNLNaN,NaNLNaN,NaNLNaN,NaNLNaN,NaNLNaN,NaNLNaN,NaNLNaN,N‌​aNLNaN,NaNLNaN,NaNLNaN,NaNLNaN,NaNLNaN,NaNLNaN,NaNLNaN,NaNLNaN,NaNLNaN,NaNLNaN,Na‌​NLNaN,NaNLNaN,NaNLNaN,NaNLNaN,NaNLNaN,NaNLNaN,NaNLNaN,NaNLNaN,NaNLNaN,NaNLNaN,NaN‌​LNaN,NaNLNaN,NaNLNaN,NaNLNaN,NaNLNaN,NaNLNaN,NaNLNaN,NaNLNaN,NaNLNaN,NaNLNaN,NaNL‌​NaN,NaNLNaN,NaNLNaN,NaNLNaN,NaNLNaN,NaNLNaN,NaNLNaN,NaNLNaN,NaNLNaN,NaNLNaN,NaNLN‌​aN,NaNLNaN,NaNLNaN,NaNLNaN,NaNLNaN,NaNLNaN,NaNZ">
the code and data are in this Gist:
https://gist.github.com/4157853
I can load the data just fine on QGIS.
Does any one know what is causing this?
The way you have specified the offset in the Mercator projection doesn't seem right. The projection.translate method expects a two element array:
https://github.com/mbostock/d3/wiki/Geo-Projections#wiki-mercator_translate
So instead of:
proj.translate(-43.8,-23.2).scale(10);
you would need to say:
proj.translate([-43.8,-23.2]).scale(10);
-- edit --
See source of projection.translate: https://github.com/mbostock/d3/blob/3.0/src/geo/projection.js#L139
projection.translate = function(_) {
if (!arguments.length) return [x, y];
x = +_[0];
y = +_[1];
return reset();
};
If the argument _ is not an array then +_[0] will return a NaN and therefore the x and y will become NaNs. (This is because trying to get one element from a number (e.g. 213[0]) returns undefined and casting undefined to a number (e.g. +undefined) yields NaN.)
If the code you posted in the gist is everything you're trying to run, then the data you show in data.json is not being loaded anywhere. Anyway, your draw function is acting on the data defined by the variable map (line 16), which refers to a simulation variable which isn't set anywhere. And even if it did, line 34 then refers to a features property of the object passed in as json, which map does not have.
In summary, you need to pass the JSON you posted in the gist to your draw function. Then it might well work. If you don't pass in valid data to the d3 SVG helpers, you'll get a bunch of NaN out.

Resources