tulip-control / polytope

Geometric operations on polytopes of any dimension
https://pypi.org/project/polytope
Other
73 stars 19 forks source link

code to enforce immutable polytopes. #61

Closed navidmokh closed 3 years ago

navidmokh commented 3 years ago

Just a potential idea for the future.

TODO add similar protection for Regions.

johnyf commented 3 years ago

Immutability of the classes polytope.polytope.Polytope and polytope.polytope.Region has been discussed in #6 and was decided to keep these classes mutable. For example, commit 479e9ce4604adf9aec3ed0b41edc65e399f47494 on branch overhaul also makes A and b properties, but with setters.

johnyf commented 3 years ago

There are errors on Travis CI due to this change.

navidmokh commented 3 years ago

That overhaul commit does exactly what I had written originally in the setter. I am fully in favor of that change, hopefully it can be integrated. In the meantime, I am clearing the cached results myself every-time with a wrapper function. My only concern with allowing mutability of polytopes is the impact that decision would have within the region class and the memoization occuring there. Instead we could update the caching to confirm a hash of the A & b numpy arrays. This way, after checking None, we verify that the cached data still corresponds with the number and shapes of the polytopes in list_poly.