@@ -361,8 +361,8 @@ def model_post_init(self, __context: Any) -> None:
361361 """Set up the Class to protect against disallowed modification.
362362
363363 We initialise the class handle in the ClassLists for empty data fields, set protected parameters, get names of
364- all defined parameters, determine the contents of the "model" field in contrasts,
365- and wrap ClassList routines to control revalidation.
364+ all defined parameters, determine the contents of the "model" field in contrasts, and wrap ClassList routines
365+ to control revalidation.
366366 """
367367 # Ensure all ClassLists have the correct _class_handle defined
368368 for field in (fields := Project .model_fields ):
@@ -454,6 +454,33 @@ def set_layers(self) -> "Project":
454454 self .layers .data = []
455455 return self
456456
457+ @model_validator (mode = "after" )
458+ def set_repeat_layers (self ) -> "Project" :
459+ """If we are not using a standard layers model, warn that the repeat layers setting is not valid."""
460+ if self .model != LayerModels .StandardLayers :
461+ for contrast in self .contrasts :
462+ if "repeat_layers" in contrast .model_fields_set and contrast .repeat_layers != 1 :
463+ warnings .warn (
464+ 'For a custom layers or custom XY calculation, the "repeat_layers" setting for each '
465+ "contrast is not valid - resetting to 1." ,
466+ stacklevel = 2 ,
467+ )
468+ contrast .repeat_layers = 1
469+ return self
470+
471+ @model_validator (mode = "after" )
472+ def set_resample (self ) -> "Project" :
473+ """If we are using a custom XY model, warn that the resample setting for each contrast must always be True."""
474+ if self .model == LayerModels .CustomXY :
475+ for contrast in self .contrasts :
476+ if "resample" in contrast .model_fields_set and contrast .resample is False :
477+ warnings .warn (
478+ 'For a custom XY calculation, "resample" must be True for each contrast - resetting to True.' ,
479+ stacklevel = 2 ,
480+ )
481+ contrast .resample = True
482+ return self
483+
457484 @model_validator (mode = "after" )
458485 def set_calculation (self ) -> "Project" :
459486 """Apply the calc setting to the project."""
0 commit comments