numpy array of objects

You can vectorize the class’s __init__ function: import numpy as np class Site: def __init__(self, a): self.a = a def set_a(self, new_a): self.a = new_a vSite = np.vectorize(Site) init_arry = np.arange(9).reshape((3,3)) lattice = np.empty((3,3), dtype=object) lattice[:,:] = vSite(init_arry) This may look cleaner but has no performance advantage over your looping solution. The list comprehension answers … Read more

Experiences with Test Driven Development (TDD) for logic (chip) design in Verilog or VHDL

I write code for FPGAs, not ASICS… but TDD is my still my preferred approach. I like to have a full suite of tests for all the functional code I write, and I try (not always successfully) to write testcode first. Staring at waveforms always happens at some point when you’re debugging, but it’s not … Read more

How to make virtual organisms learn using neural networks? [closed]

This is similar to issues with trying to find a global minimum, where it’s easy to get stuck in a local minimum. Consider trying to find the global minimum for the profile below: you place the ball in different places and follow it as it rolls down the hill to the minimum, but depending on … Read more

Simulating low battery for iPhones

Unfortunately, there is no good way to simulate a low-battery environment. You actually will most likely need to physically charge your device’s battery until it is just above the “low battery” state and then debug your application. To address what others have said: There is no way to simulate low battery notifications. The project that … Read more

How do you simulate Stripe Subscription Renewal Failure? [closed]

EDIT 2023-02-02: The answer below was written in 2016. While it should still work, you can probably achieve this in a more straightforward manner by using test clocks instead. In order to test failed subscription payments, you can do something like this: Create the customer with a card token for a valid card (e.g. 4242 … Read more

Suggestions for Python debugging tools? [closed]

Winpdb (archived link / SourceForge.net / Google Code Archive) is a platform independent graphical GPL Python debugger with support for remote debugging over a network, multiple threads, namespace modification, embedded debugging, encrypted communication and is up to 20 times faster than pdb. Features: GPL license. Winpdb is Free Software. Compatible with CPython 2.3 through 2.6 … Read more