MCPcopy Create free account
hub / github.com/anyoptimization/pymoo / new

Method new

pymoo/core/population.py:108–125  ·  view source on GitHub ↗
(cls, *args, **kwargs)

Source from the content-addressed store, hash-verified

106
107 @classmethod
108 def new(cls, *args, **kwargs) -> "Population":
109 kwargs = interleaving_args(*args, kwargs=kwargs)
110
111 if len(kwargs) > 0:
112 sizes = np.unique(np.array([len(v) for _, v in kwargs.items()]))
113 if len(sizes) == 1:
114 size = sizes[0]
115 else:
116 raise Exception(
117 f"Population.new needs to be called with same-sized inputs, but the sizes are {sizes}"
118 )
119 else:
120 size = 0
121
122 pop = Population.empty(size)
123 pop.set(**kwargs)
124
125 return pop
126
127
128def pop_from_array_or_individual(

Callers 2

pop_from_samplingFunction · 0.95

Calls 3

interleaving_argsFunction · 0.85
emptyMethod · 0.80
setMethod · 0.45

Tested by

no test coverage detected