Categories
Mastering Development

In a group of objects Segment doesn’t move

I am a new commer to jsxgraph. I will have many questions. My first graph is the followingenter image description here Here is what I have been able to code. > <div id="box" class="jxgbox" style="width:500px; height:500px;"> > <script type="text/javascript"> var board = > JXG.JSXGraph.initBoard(‘box’, {boundingbox: [0, 10, 10, 0], > axis:false}); var grid = board.create(‘grid’, […]

Categories
Mastering Development

Apache beam processing sequential elements

I have a stream of GPS coordinates from different devices. Those coordinates could arrive out of order but they all have an event time. I want to calculate the total distance from GPS coordinates. From Beam Programming Guide: The combining function should be commutative and associative, as the function is not necessarily invoked exactly once […]

Categories
Mastering Development

PyTorch RuntimeError: Trying to backward through the graph a second time, but the saved intermediate results have already been freed

I’m a college student just getting into Deep Learning, trying to create my first backward propagated model. However, I keep getting the "Trying to backward through the graph a second time, but the saved intermediate results have already been freed." runtime error. I have seen many others asking the same question here, but their sample […]

Categories
Mastering Development

How can I retrieve programmatically from command line my SO rep and number of badges?

Orignal question My initial attempt was to run curl https://stackoverflow.com/users/5825294/enlico and pipe the result into sed/awk. However, as I’ve frequently read, sed and awk are not the best tools to parse HTML code. Furthermore, the above URL changes if I change my user name. Oh, this is my quick attempt with sed, written on multiple […]

Categories
Mastering Development

How to detect a rectangle (whiteboard) in an image using opencv?

I have the following image. I want to detect and perspective transform the rectangular whiteboard. I want to detect these 4 boundaries/corners and apply a perspective transformation to it. Have a look at the below image: I am not able to detect the boundaries of the rectangle. Here’s what I have tried: import cv2, os […]

Categories
Mastering Development

Constraints in DocCplex on Python don’t work

I’m trying to solve an optimization problem, but when I insert this constraint it doesn’t work: ”’ mdl.add_constraints(isinstance(w[i]/5, int) == True for i in range(0,5)) ”’ where w is defined as follow : ”’ w = mdl.integer_var_list(5,5,30, ‘W’) ”’ Python generates this error : Expecting sequence of constraints, got: False at position 0 I tried […]

Categories
Mastering Development

Why is the p5.js bezierPoint() function returning non-linear values when given a linear cubic bezier?

Okay, so I’ve been creating a UI framework and I added animations to it. I wanted to allow users to control the timing functions of their animations using cubicBeziers, so I decided to use p5.js’ bezierPoint() function. I spent hours making it work, and finally got it working in a way that I thought was […]

Categories
Mastering Development

How can I form matrix lines programmaticaly based on an element list?

I’m practicing some programming logic with a challenge that a friend shared with me. Here’s the problem: Write a script that takes an integer n as the numbers of rows and columns of a matrix and take the element list of the matrix. Example: n=3 matrix = [[11 2 4], [4 5 6], [10 8 […]

Categories
Mastering Development

SkFuzzy Giving “ValueError: Unexpected input: quality”

CODE SET BELOW WRITTEN IN PYTHON USING SKFUZZY FROM SCI-KIT LEARN: import skfuzzy as fuzz import numpy as np from skfuzzy import control as ctrl import matplotlib.pyplot as plt # New Antecedent/Consequent objects hold universe variables and membership # functions quality = ctrl.Antecedent(np.arange(0, 11, 1),’quality’) service = ctrl.Antecedent(np.arange(0, 11, 1), ‘service’) tip = ctrl.Consequent(np.arange(0, 26, […]

Categories
Mastering Development

Conversion of nested list to np.array for tensor model prediction is incorrect

I have an input array created from : initial window = ‘I have a bad feeling about this’ seq_tokens = t.texts_to_sequences(initial_window) # seq_tokens = [[4], [], [], [5], [590], [], [], [5], [], [998], [5], [], [], [], [], [], [], [4], [], [], [], [5], [998], [591], [], [], [], [], [], [4], []] […]