Hi,
You need to assign the typeid in a 1D array. Currently, you are assigning it to a 2D array, which is causing an error. I have revised your code in HOOMD v4.1.0, and it is functioning properly now.
import itertools
import math
import hoomd
import numpy
import gsd.hoomd
N_particles = 300
spacing = 1.1
K = math.ceil(N_particles**(1 / 2))
L = 50
x = numpy.linspace(-L/2., L/2., K, endpoint=False)
position = list(itertools.product(x, repeat=2))
for i in range(len(position)):
position[i]=(position[i][0],position[i][1],0.)
snapshot = gsd.hoomd.Frame()
snapshot.configuration.box = [L, L, 0, 0, 0, 0]
snapshot.particles.N = N_particles
snapshot.particles.position = position[0:N_particles]
#snapshot.particles.typeid = [[0] * 100, [1] * 100, [2] * 100] #this line works
type_s = [0] * 100 + [1] * 90 + [2] * 110
print("types",type_s)
snapshot.particles.typeid = type_s # this line does not
snapshot.particles.types = ['A','B','C']
with gsd.hoomd.open(name='trial.gsd', mode='x') as f:
f.append(snapshot)
Regards,
Avishek