MCPcopy Create free account
hub / github.com/modAL-python/modAL / test_product

Method test_product

tests/core_tests.py:124–144  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

122 linear_combination(X_in)
123
124 def test_product(self):
125 for n_dim in range(1, 5):
126 shape = tuple([10] + [2 for _ in range(n_dim-1)])
127 X_in = 2*np.ones(shape=shape)
128 for n_functions in range(1, 10):
129 functions = [(lambda x: x) for _ in range(n_functions)]
130 # linear combination without weights
131 product = modAL.utils.combination.make_product(*functions)
132 np.testing.assert_almost_equal(
133 product(X_in),
134 X_in**n_functions
135 )
136
137 # linear combination with weights
138 exponents = np.random.rand(n_functions)
139 exp_product = modAL.utils.combination.make_product(
140 *functions, exponents=exponents)
141 np.testing.assert_almost_equal(
142 exp_product(X_in),
143 np.prod([X_in**exponent for exponent in exponents], axis=0)
144 )
145
146 def test_make_query_strategy(self):
147 query_strategy = modAL.utils.combination.make_query_strategy(

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected