Skip to content

Commit

Permalink
Merge pull request #85 from PaNOSC-ViNYL/search_fix
Browse files Browse the repository at this point in the history
Fixing SEARCH system
  • Loading branch information
mads-bertelsen authored Sep 20, 2024
2 parents c544634 + 721e421 commit e47ce37
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion mcstasscript/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.0.71"
__version__ = "0.0.72"
6 changes: 5 additions & 1 deletion mcstasscript/helper/mcstas_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -1006,7 +1006,7 @@ def show_search(self):

print(self.search_statement_list)

def write_component(self, fo):
def write_component(self, fo, instrument_search=None):
"""
Method that writes component to file
Expand All @@ -1032,6 +1032,10 @@ def write_component(self, fo):
# Write search statements
self.search_statement_list.write(fo)

# Add search statement for instrument if supplied
if instrument_search is not None:
instrument_search.write(fo)

if self.SPLIT != 0:
fo.write("SPLIT " + str(self.SPLIT) + " ")

Expand Down
2 changes: 1 addition & 1 deletion mcstasscript/instrument_diagnostics/plot_overview.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def plot_all(self, figsize=None, same_scale=True):

if not major_label_set:
ylabel = ax.get_ylabel()
row_name = plotter.name.replace("_", "\ ")
row_name = plotter.name.replace("_", "\\ ")
new_label = r"$\bf{" + row_name + "}$" + "\n" + ylabel
ax.set_ylabel(new_label)

Expand Down
2 changes: 1 addition & 1 deletion mcstasscript/instrument_diagram/component_description.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class is used as a superclass for classes describing each
else:
if component.parameter_defaults[key] is None:
string += " $\\bf{" + parameter_name.replace("_", "\\_") + "}$"
string += " : $\\bf{Required\ parameter\ not\ yet\ specified}$\n"
string += " : $\\bf{Required\\ parameter\\ not\\ yet\\ specified}$\n"

if not component.WHEN == "":
string += component.WHEN + "\n"
Expand Down
6 changes: 4 additions & 2 deletions mcstasscript/interface/instr.py
Original file line number Diff line number Diff line change
Expand Up @@ -2096,7 +2096,6 @@ def write_full_instrument(self):
fo.write(")\n")
if self.dependency_statement != "":
fo.write("DEPENDENCY " + str(self.dependency_statement) + "\n")
self.search_statement_list.write(fo)
fo.write("\n")

# Write declare
Expand Down Expand Up @@ -2148,8 +2147,11 @@ def write_full_instrument(self):
# Write trace
fo.write("TRACE \n")

# Write all components, the first should get the instrument search list
search_object = copy.deepcopy(self.search_statement_list)
for component in self.make_component_subset():
component.write_component(fo)
component.write_component(fo, instrument_search=search_object)
search_object = None # Remove for remaining components

# Write finally
fo.write("FINALLY \n%{\n")
Expand Down
4 changes: 2 additions & 2 deletions mcstasscript/tests/test_Instr.py
Original file line number Diff line number Diff line change
Expand Up @@ -1911,8 +1911,6 @@ def test_write_full_instrument_search(self, mock_f):
my_call(""),
my_call("\n"),
my_call(")\n"),
my_call('SEARCH "first_search"\n'),
my_call('SEARCH SHELL "second search"\n'),
my_call("\n"),
my_call("DECLARE \n%{\n"),
my_call("double two_theta;"),
Expand All @@ -1923,6 +1921,8 @@ def test_write_full_instrument_search(self, mock_f):
+ "two_theta = 2.0*theta;\n"),
my_call("%}\n\n"),
my_call("TRACE \n"),
my_call('SEARCH "first_search"\n'),
my_call('SEARCH SHELL "second search"\n'),
my_call("COMPONENT first_component = test_for_reading("),
my_call(")\n"),
my_call("AT (0,0,0)"),
Expand Down

0 comments on commit e47ce37

Please sign in to comment.