Skip to content

Commit

Permalink
Created filter prepper.
Browse files Browse the repository at this point in the history
  • Loading branch information
MicahGale committed Sep 12, 2024
1 parent 801360b commit c9fff24
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions montepy/data_inputs/material.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,32 @@ def append(self, obj):
self._check_valid_comp(obj)
self._components.append(obj)

def __prep_filter(filter_obj):
if callable(filter_obj):
return filter_obj

elif isinstance(filter_obj, slice):

def slicer(val):
if filter_obj.start:
start = filter_obj.start
if val < filter_obj.start:
return False
else:
start = 0
if filter_obj.stop:
if val >= filter_obj.stop:
return False
if filter_obj.step:
if (val - start) % filter_obj.step != 0:
return False
return True

return slicer

else:
return lambda val: val == filter_obj

def find(
self, fancy_name=None, element=None, A=None, meta_isomer=None, library=None
):
Expand Down

0 comments on commit c9fff24

Please sign in to comment.