Categories
Mastering Development

I have a warning “passing argument 2 of ‘bins’ make integer from pointer without cast”, could anyone help me?

In a binary search, I have the warning I wrote in the title: #include <stdio.h> int bins(int, int, int, int);/*this function do a binary search*/ int main() { int n, low, high, v[]={0,1,2,3,4,5,6,7,8,9,10}; low=0;high=11; printf(“please enter the num you want to find\n:”); scanf(“%d”, &n); printf(“%d”, bins(n, v, low, high)); return 0; } int bins(int n, […]

Categories
Mastering Development

How can I smoothly detect the welding joint using OpenCV-Python?

I have tried to detect the welding joint (bead) using the codes attached below in the last part of this question. I aim to draw a contour on the joint as shown in the third image but my results are poor and don’t look similar to the expected results. here is the summary of what […]

Categories
Mastering Development

How can I compare numbers from a list only with the next number (neighbor)?

All I want to do is to compare the first number from a list with the second number from the same list, the second one with the third one, and so on. input: lst = [1,2,3,2,1] output: result = [“Lower”, “Lower”, “Higher”, “Higher”] (1 is lower than 2, 2 is lower than 3, 3 is […]

Categories
Mastering Development

swap key value pairs in a dictionary with values as lists

I have a dictionary with keys and values as lists. something like: d={1:[0,1,2,3,4],2:[1,3]} I was on the lookout for swapping key value pairs. The output I am trying to get is: o={0:[1],1:[1,2],2:[1],3:[1,2],4:[1]} Was wondering if there is a way to achieve this in the most efficient way

Categories
Mastering Development

3D bar plot with dates, strings and numbers in 3 axes with matplotlib in python

I have three lists as mentioned below. xx = [‘TT’, ‘AN’, ‘AP’, ‘AR’, ‘AS’, ‘BR’, ‘CH’, ‘CT’, ‘DN’, ‘DD’, ‘DL’, ‘GA’, ‘GJ’, ‘HR’, ‘HP’, ‘JK’, ‘JH’, ‘KA’, ‘KL’, ‘LA’, ‘LD’, ‘MP’, ‘MH’, ‘MN’, ‘ML’, ‘MZ’, ‘NL’, ‘OR’, ‘PY’, ‘PB’, ‘RJ’, ‘SK’, ‘TN’, ‘TG’, ‘TR’, ‘UP’, ‘UT’, ‘WB’] yy = [datetime.date(2020, 5, 27), datetime.date(2020, 5, 28), […]

Categories
Mastering Development

When to use padding in Conv2d() and when to do ReflectionPad2d() Pytorch

I have two pytorch models that are equivalent (I think), the only difference between them is the padding: import torch import torch.nn as nn i = torch.arange(9, dtype=torch.float).reshape(1,1,3,3) # First model: model1 = nn.Conv2d(1, 1, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), padding_mode=’reflection’) # tensor([[[[-0.6095, -0.0321, 2.2022], # [ 0.1018, 1.7650, 5.5392], # [ 1.7988, 3.9165, […]

Categories
Mastering Development

Getting the orginal value of variable after entering a for loop

I’m making a simple script that iterates through the files in the current directories, the $1 is for a size parameter and the others $1,$2 ….. are for the manipulated files and set for the file names. the problem is after using the for loop the variable are losing their value and start with integers […]

Categories
Mastering Development

Write a code that Calculates the average number of non-zero ratings per individual in our data set

So I’ve written my code below but I am having a hard time getting the code to not include the number of zeros. It runs but unfortunately not the way I want it to. Can anyone shed some light? the variable movies is basically a list of movies we were given The code will be […]

Categories
Mastering Development

nodejs+mongodb access node.js object with document’s _id field value in query

I am learning Mongodb to use with NodeJS. The below is my code: let configMap = { ‘1’: 10, ‘2’: 12, ‘3’: 13 } let myData = await mongo_groups_collection.find({ _id: { $in: [1,2,3] }, active: true }).project({ ‘_id’: 1, ‘name’: 1, ‘members’: 1, ‘messages’: { $slice: [-(configMap[_id]), (DEFAULT_PAGE_SIZE_FILL * PAGE_SIZE) + (PAGE_SIZE – ((configMap[_id]) % […]

Categories
Mastering Development

How to sort a pandas dataframe on two (or more) different columns, in a particular order

Note df2 is the only thing that can be used here – using df or df1 would be to use data that isn’t possible. The data is received as df2, it wants to be manipulated to the form of df1. Neither df1 or df can be used as part of of the solution (as df1 […]