Skip to content

Commit a0c6bd3

Browse files
authored
Merge pull request #1927 from HEXRD/texture-fixes
Support material names containing `-`
2 parents 6a92f79 + 89120c2 commit a0c6bd3

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

hexrdgui/calibration/wppf_options_dialog.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1335,7 +1335,8 @@ def recursively_format_mat(mat, this_config, this_template):
13351335
texture_dict = tree_dict.setdefault('Texture', {})
13361336
for mat_name in self.textured_materials:
13371337
# Look for param names that match
1338-
prefix = f'{mat_name}_c_'
1338+
mat_name_sanitized = mat_name.replace('-', '_')
1339+
prefix = f'{mat_name_sanitized}_c_'
13391340
matching_names = [k for k in params if k.startswith(prefix)]
13401341
if not matching_names:
13411342
continue
@@ -1847,6 +1848,7 @@ def update_texture_model_gui(self):
18471848
self.ui.texture_ell_max.setValue(settings['ell_max'])
18481849

18491850
self.update_texture_model_enable_states()
1851+
self.update_texture_index_label()
18501852

18511853
def update_texture_model_enable_states(self):
18521854
# Determine whether we should disable the model texture
@@ -1984,7 +1986,7 @@ def polar_extent(self) -> list[float] | None:
19841986

19851987
@property
19861988
def varying_texture_params(self):
1987-
for mat_name in self.textured_materials:
1989+
for mat_name in self.textured_materials_sanitized:
19881990
prefix = f'{mat_name}_c_'
19891991
for param in self.params.values():
19901992
if param.name.startswith(prefix) and param.vary:
@@ -1997,7 +1999,10 @@ def varying_texture_and_non_texture_params(self):
19971999
if not self.varying_texture_params:
19982000
return False
19992001

2000-
prefixes = [f'{mat_name}_c_' for mat_name in self.textured_materials]
2002+
prefixes = [
2003+
f'{mat_name}_c_' for mat_name in
2004+
self.textured_materials_sanitized
2005+
]
20012006
for name, param in self.params.items():
20022007
if param.vary and not any(name.startswith(x) for x in prefixes):
20032008
return True
@@ -2236,6 +2241,10 @@ def textured_materials(self) -> list[str]:
22362241

22372242
return list(self.texture_model_kwargs)
22382243

2244+
@property
2245+
def textured_materials_sanitized(self) -> list[str]:
2246+
return [name.replace('-', '_') for name in self.textured_materials]
2247+
22392248
@property
22402249
def texture_model_kwargs(self) -> dict[str]:
22412250
return self.texture_settings['model_kwargs']

0 commit comments

Comments
 (0)