@@ -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,19 @@ def set_layers(self) -> "Project":
454454 self .layers .data = []
455455 return self
456456
457+ @model_validator (mode = "after" )
458+ def set_resample (self ) -> "Project" :
459+ """If we are using a custom XY model, warn that the resample setting for each contrast must always be True."""
460+ if self .model == LayerModels .CustomXY :
461+ for contrast in self .contrasts :
462+ if "resample" in contrast .model_fields_set and contrast .resample is False :
463+ warnings .warn (
464+ 'For a custom XY calculation, "resample" must be True for each contrast - resetting to True.' ,
465+ stacklevel = 2 ,
466+ )
467+ contrast .resample = True
468+ return self
469+
457470 @model_validator (mode = "after" )
458471 def set_calculation (self ) -> "Project" :
459472 """Apply the calc setting to the project."""
0 commit comments