Skip to content

Commit

Permalink
Clean up CompoundOptic cached properties when inserting/removing items
Browse files Browse the repository at this point in the history
  • Loading branch information
jmeyers314 committed Jan 5, 2024
1 parent b30d324 commit 6ed6747
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ Bug Fixes
---------
- Allow random seeds in applicable RayVector contructors.
- Trap divide-by-zero error in field_to_dircos
- Clean up CompoundOptic cached properties when inserting/removing items
2 changes: 1 addition & 1 deletion batoid/_version.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#https://stackoverflow.com/a/7071358/7530778

__version__ = "0.5.1"
__version__ = "0.5.2"
tmp = __version__
if "rc" in tmp: # pragma: no cover
tmp = tmp[:tmp.find("rc")]
Expand Down
6 changes: 4 additions & 2 deletions batoid/optic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1689,7 +1689,8 @@ def withInsertedOptic(self, before, item):
raise ValueError("Optic {} not found".format(before))
newItems = []
newDict = dict(self.__dict__)
del newDict['items']
for k in ['items', 'itemDict', '_names', 'R_inner', 'R_outer']:
newDict.pop(k, None)
for i, it in enumerate(self.items):
if self._names[it.name] == self._names[before]:
newItems.append(item)
Expand Down Expand Up @@ -1717,7 +1718,8 @@ def withRemovedOptic(self, item):
raise ValueError("Optic {} not found".format(item))
newItems = []
newDict = dict(self.__dict__)
del newDict['items']
for k in ['items', 'itemDict', '_names', 'R_inner', 'R_outer']:
newDict.pop(k, None)
for it in self.items:
if self._names[it.name] != self._names[item]:
newItems.append(it)
Expand Down

0 comments on commit 6ed6747

Please sign in to comment.