questions

Retrieve image name in python from form

Retrieve image name in python from form Question: on the contnue of the my prevous question : find answer i have fixed hmtl code and it is here : <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Select image</title> </head> <body> <form action="{{ url_for(‘image_shape’)}}"method="post"> <label for="img">Select image</label> <input type="file" id="img" name="img" accept="image/*" onchange="displayImage(this)"> <br> <img id="selectedImg" …

Total answers: 1

Incorrect Placement visited node set in Graph traversal DFS

Incorrect Placement visited node set in Graph traversal DFS Question: I am having trouble understanding why placing visited.append((i,j)) in the else case gives me the right output, while keeping it as shown below gives the incorrect output. I tried to debug with a simpler example [[0,1], [1,1]] But I am not able to figure out …

Total answers: 1

Getting Rid of the non-significant terms in symbolic equations in sympy

Getting Rid of the non-significant terms in symbolic equations in sympy Question: I am trying to obtain significant terms from a symbolic expression obtained using sympy. The expressions represent symbolic dynamics of a a manipulator arm. The expression has the numerical coefficient always in the zeroth argument. However, the coefficients can be both positive and …

Total answers: 1

change KeyboardInterrupt to 'enter'

change KeyboardInterrupt to 'enter' Question: I have the following code: import time def run_indefinitely(): while True: # code to run indefinitely goes here print("Running indefinitely…") time.sleep(1) try: # Run the code indefinitely until Enter key is pressed run_indefinitely() except KeyboardInterrupt: print("Loop interrupted by user") Is there a way to break out of the while loop …

Total answers: 2

Unexpected behaviour of log1p numpy

Unexpected behaviour of log1p numpy Question: I am using the function numpy.log1p to calculate the value of log(1 + x) for very small complex numbers, and I am getting unexpected results. I would expect that outputs should be practically equal to the function input. While this does not seem to be the case in the …

Total answers: 2

How to split an array using its minimum entry

How to split an array using its minimum entry Question: I am trying to split a dataset into two separate ones by finding its minimum point in the first column. I have used idxmin to firstly identify the location of the minimum entry and secondly iloc to slice the array from 0 to the minimum …

Total answers: 1

np.unique after np.round unrounds the data

np.unique after np.round unrounds the data Question: This code snippet describes a problem I have been having. For some reason rounded_data seems to be rounded, but once passed in np.unique and np.column_stack the result_array seems to be unrounded, meanwhile the rounded_data is still rounded. rounded_data = data_with_target_label.round(decimals=2) unique_values, counts = np.unique(rounded_data, return_counts=True) result_array = np.column_stack((unique_values, …

Total answers: 1

Polars: Replace parts of dataframe with other parts of dataframe

Polars: Replace parts of dataframe with other parts of dataframe Question: I’m looking for an efficient way to copy / replace parts of a dataframe with other parts of the same dataframe in Polars. For instance, in the following minimal example dataframe pl.DataFrame({ "year": [2020,2021,2020,2021], "district_id": [1,2,1,2], "distribution_id": [1, 1, 2, 2], "var_1": [1,2,0.1,0.3], "var_N": …

Total answers: 4

Multiple gaussian fit issue

Multiple gaussian fit issue Question: I have this code that aims to fit the data in here https://drive.google.com/file/d/1uBrHxuftALiQTcTeBl-s6AHGiC8DGBWV/view?usp=sharing. Where the function read_file is used to stract the information in a proper way. I do not what i am doing wrong that the gaussian fit is not right as you can see in the image (Gaussian …

Total answers: 1

Optimization of pytorch function to eliminate for loop

Optimization of pytorch function to eliminate for loop Question: lately I have been developing a function capable of dealing with tensors with dimension: torch.Size([51, 265, 23, 23]) where the first dim is time, the second is pattern and the last 2 are pattern size. Each individual pattern can have a maximum of 3 states: [-1,0,1], …

Total answers: 1