Skip to content

Commit

Permalink
Fix shape bug when raising multivariate enclosures to a power.
Browse files Browse the repository at this point in the history
This fixes #10

Also bump version number in preparation for updating the pip package.
  • Loading branch information
mstreeter committed Aug 8, 2023
1 parent 1f82563 commit b3309d6
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
2 changes: 1 addition & 1 deletion autobound/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.

__version__ = "0.1.2"
__version__ = "0.1.3"
3 changes: 2 additions & 1 deletion autobound/enclosure_arithmetic.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,8 @@ def power(self, a: TaylorEnclosureLike, p: float) -> TaylorEnclosure:
term_power_coefficient = functools.partial(
_elementwise_term_power_coefficient, x_ndim=x_ndim,
np_like=self.np_like)
multiplicative_identity = self.np_like.ones_like(self.trust_region[0])
a0 = a[0][0] if isinstance(a[0], tuple) else a[0]
multiplicative_identity = self.np_like.ones_like(a0)
result = polynomials.integer_power( # pytype: disable=wrong-arg-types
a,
p,
Expand Down
21 changes: 21 additions & 0 deletions autobound/enclosure_arithmetic_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,27 @@ def test_pairwise_batched_multiply(self, u, v, p, q, expected):
0,
(np.ones((3,)),)
),
(
100,
(np.zeros((2,)), np.ones((2,))),
(np.ones((3,)), np.ones((3, 2))),
0,
(np.ones((3,)),)
),
(
100,
(np.zeros((2,)), np.ones((2,))),
(np.ones((3,)), np.ones((3, 2))),
1,
(np.ones((3,)), np.ones((3, 2))),
),
(
100,
(np.zeros((2,)), np.ones((2,))),
(np.ones((3,)), np.ones((3, 2))),
2,
(np.ones((3,)), 2*np.ones((3, 2)), np.ones((3, 2, 2))),
),
)
def test_power(self, max_degree, trust_region, enclosure, p, expected):
for np_like in self.backends:
Expand Down

0 comments on commit b3309d6

Please sign in to comment.