Skip to content
Advertisement

Tag: arrays

Parametrizing fixtures and functions without combinations

Here’s the thing: I have an Array2D class that receives parameters ‘shape’ and ‘val’. The constructor is as follows: I would like to perform tests on this class. To do this I have declared a variable ARRAY_CONFIG, which lists parameters for different two-dimensional arrays. Here is an example: I have also defined other lists that store the expected values for

How do I get a specific element from a json string?

I have a JSON string (not in a file): [{‘x’: 403.5, ‘y’: 53.0, ‘width’: 117, ‘height’: 106, ‘class’: ‘fruitflies’, ‘confidence’: 0.626}, {‘x’: 446.0, ‘y’: 189.0, ‘width’: 124, ‘height’: 130, ‘class’: ‘fruitflies’, ‘confidence’: 0.528}], now as you can see, the entire string is in a list. Inside the list is the dictionary. There are 2 dictionaries in the list and I

Delete all zeros slices from 4d numpy array

I pretend to remove slices from the third dimension of a 4d numpy array if it’s contains only zeros. I have a 4d numpy array of dimensions [256,256,336,6] and I need to delete the slices in the third dimension that only contains zeros. So the result would have a shape like this , e.g. [256,256,300,6] if 36 slices are fully

What is the most efficient way to make a method that is able to process single and multi dimensional arrays in python?

I was using pytorch and realized that for a linear layer you could pass not only 1d tensors but multidmensional tensors as long as the last dimensions matched. Multi dimensional inputs in pytorch Linear method? I tried looping over each item, but is that what pytorch does? I’m having trouble thinking how you would program looping with more dimensions, maybe

A copy of image array not working in python

So I am working on Image Encryption and using a chaotic map for diffusion. So I have been trying to rearrange pixels of an image and made a rearranging code. It works fine for normal arrays but when I use it on image, without any rearranging, just a simple copy, the new array doesn’t make any image, in fact np.array_equal

Google Kickstart 2014 Round D Sort a scrambled itinerary – Do I need to bring the input in a ready-to-use array format?

Problem: Once upon a day, Mary bought a one-way ticket from somewhere to somewhere with some flight transfers. For example: SFO->DFW DFW->JFK JFK->MIA MIA->ORD. Obviously, transfer flights at a city twice or more doesn’t make any sense. So Mary will not do that. Unfortunately, after she received the tickets, she messed up the tickets and she forgot the order of

Advertisement