Added check for when material list is less than fractal bins/materials

这个提交包含在:
Craig Warren
2023-06-14 12:38:23 +01:00
父节点 9f4b3b5b99
当前提交 0e2a9c51cd

查看文件

@@ -21,6 +21,7 @@ import logging
import numpy as np
from ..fractals import FractalVolume
from ..materials import ListMaterial
from .cmds_geometry import UserObjectGeometry, rotate_2point_object
logger = logging.getLogger(__name__)
@@ -139,6 +140,12 @@ class FractalBox(UserObjectGeometry):
logger.exception(f'{self.__str__()} must be used with more than ' +
'one material from the mixing model.')
raise ValueError
if isinstance(mixingmodel, ListMaterial):
if nbins > len(mixingmodel.mat):
logger.exception(f'{self.__str__()} too many materials/bins ' +
'requested compared to materials in ' +
'mixing model.')
raise ValueError
# Create materials from mixing model as number of bins now known
# from fractal_box command.
mixingmodel.calculate_properties(nbins, grid)