2d

Show better representation of small values of 2D plot

Show better representation of small values of 2D plot Question: I am trying to make a 2D plot of a function 1/(xy) but the y values vary from 3 orders of magnitude which makes the graph look unreadable. On top of that, I am trying to emphasize the small values of 1/(xy) i.e. when x …

Total answers: 2

Problem with Pygame movement acceleration, platformer game

Problem with Pygame movement acceleration, platformer game Question: When i move right using the right key, i accelerate to a max speed. When i release it, i do decelerate to a stop so that is fine. However, when moving left using the left key, and after releasing it, i continue moving at a fixed speed …

Total answers: 1

How to define a 2D array of (x,y) coordinates

How to define a 2D array of (x,y) coordinates Question: I have a 2d space of (x,y) coordinates that I want to model in python and want to know a way to define the 2d space in python where I can assign multiple values to a point (x,y). Later values at coordinates will be changed …

Total answers: 3

Why are pyglet.image and texture so heavy?

Why are pyglet.image and texture so heavy? Question: Envrionment: python: 3.6.6 pyglet: 1.3.2 Here is my code and results: import pyglet images = [] textures = [] with_textures = True count = 10 for x in range(count): image = pyglet.image.load(“big.png”) # 2.1 Mb source 2400*2400px images.append(image) if with_textures: texture_grid = pyglet.image.ImageGrid(image, 10, 10).get_texture_sequence() textures.append(texture_grid) # …

Total answers: 1

Creating uniform random quaternion and multiplication of two quaternions

Creating uniform random quaternion and multiplication of two quaternions Question: I have a python (NumPy) function which creates a uniform random quaternion. I would like to get two quaternion multiplication as 2-dimensional returned array from the same or an another function. The formula of quaternion multiplication in my recent case is Q1*Q2 and Q2*Q1. Here, …

Total answers: 5

Creating 2D dictionary in Python

Creating 2D dictionary in Python Question: I have a list of details from an output for “set1” which are like “name”, “place”, “animal”, “thing” and a “set2” with the same details. I want to create a dictionary with dict_names[setx][‘name’]… etc On these lines. Is that the best way to do it? If not how do …

Total answers: 5

Most efficient way to find mode in numpy array

Most efficient way to find mode in numpy array Question: I have a 2D array containing integers (both positive or negative). Each row represents the values over time for a particular spatial site, whereas each column represents values for various spatial sites for a given time. So if the array is like: 1 3 4 …

Total answers: 11

checking diagonals in 2d list (Python)

checking diagonals in 2d list (Python) Question: The initial problem: for a given 3×3 tic tac toe board check if one of the players has won. The simplest solution I have come up so far is rotating the matrix and summing up each row: board [[0, 1, 2], [3, 4, 5], [6, 7, 8]] pr(board) …

Total answers: 6

2D list has weird behavor when trying to modify a single value

2D list has weird behavor when trying to modify a single value Question: When I try this code: data = [[None]*5]*5 data[0][0] = ‘Cell A1’ The value of data ends up like: [[‘Cell A1’, None, None, None, None], [‘Cell A1’, None, None, None, None], [‘Cell A1’, None, None, None, None], [‘Cell A1’, None, None, None, …

Total answers: 3