Skip to content

Commit

Permalink
Fixing some more conventions
Browse files Browse the repository at this point in the history
  • Loading branch information
proy30 committed Aug 4, 2024
1 parent 12903a7 commit f52b0e1
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@


def line_plot_1d(selected_headers, filtered_data):
"""
Generates a 1D line plot using Plotly based on selected headers and filtered data.
"""

x_axis = selected_headers[1] if len(selected_headers) > 1 else None
y_axis = selected_headers[2:] if len(selected_headers) > 2 else None

Expand Down
8 changes: 4 additions & 4 deletions src/python/impactx/dashboard/Analyze/plotsMain.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def load_dataTable_data ():
# -----------------------------------------------------------------------------


def update_data_table():
def update_data_table ():
"""
Combines reducedBeam and refParticle files
and updates data table upon column selection by user
Expand All @@ -104,7 +104,7 @@ def update_data_table():
)


def update_plot():
def update_plot ():
"""
Performs actions to display correct information,
based on the plot optin selected by the user
Expand All @@ -125,14 +125,14 @@ def update_plot():


@state.change("selected_headers")
def on_header_selection_change(selected_headers, **kwargs):
def on_header_selection_change (selected_headers, **kwargs):
state.filtered_headers = analyzeFunctions.filter_headers(
state.all_headers, selected_headers
)
state.filtered_data = analyzeFunctions.filter_data(state.all_data, selected_headers)


@state.change("filtered_data", "active_plot")
@state.change ("filtered_data", "active_plot")
def on_filtered_data_change(**kwargs):
update_plot()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,17 @@

# Update plots on parameter change
@state.change("alpha_x", "beta_x", "epsilon_x")
def on_params_change_x(**kwargs):
def on_params_change_x (**kwargs):
VisualizeTwiss.update_plot_x()


@state.change("alpha_y", "beta_y", "epsilon_y")
def on_params_change_y(**kwargs):
def on_params_change_y (**kwargs):
VisualizeTwiss.update_plot_y()


@state.change("alpha_t", "beta_t", "epsilon_t")
def on_params_change_t(**kwargs):
def on_params_change_t (**kwargs):
VisualizeTwiss.update_plot_t()


Expand Down Expand Up @@ -126,7 +126,7 @@ def draw_phase_space_ellipse(
return fig

@staticmethod
def update_plot_x(**kwargs):
def update_plot_x (**kwargs):
alpha = state.alpha_x
beta = state.beta_x
epsilon = state.epsilon_x
Expand All @@ -142,7 +142,7 @@ def update_plot_x(**kwargs):
plt.close(fig)

@staticmethod
def update_plot_y(**kwargs):
def update_plot_y (**kwargs):
alpha = state.alpha_y
beta = state.beta_y
epsilon = state.epsilon_y
Expand All @@ -158,7 +158,7 @@ def update_plot_y(**kwargs):
plt.close(fig)

@staticmethod
def update_plot_t(**kwargs):
def update_plot_t (**kwargs):
alpha = state.alpha_t
beta = state.beta_t
epsilon = state.epsilon_t
Expand All @@ -174,7 +174,7 @@ def update_plot_t(**kwargs):
plt.close(fig)

@staticmethod
def card_x():
def card_x ():
with vuetify.VCard(style="width: 340px; height: 300px"):
with vuetify.VCardText():
with vuetify.VRow(classes="pl-1"):
Expand All @@ -189,7 +189,7 @@ def card_x():
ctrl.matplotlib_figure_update_x = matplotlib_figure.update

@staticmethod
def card_y():
def card_y ():
with vuetify.VCard(style="width: 340px; height: 300px"):
with vuetify.VCardText():
with vuetify.VRow(classes="pl-1"):
Expand All @@ -204,7 +204,7 @@ def card_y():
ctrl.matplotlib_figure_update_y = matplotlib_figure.update

@staticmethod
def card_t():
def card_t ():
with vuetify.VCard(style="width: 340px; height: 300px"):
with vuetify.VCardText():
with vuetify.VRow(classes="pl-1"):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
# -----------------------------------------------------------------------------


def populate_distribution_parameters(selectedDistribution):
def populate_distribution_parameters (selectedDistribution):
"""
Populates distribution parameters based on the selected distribution.
:param selectedDistribution (str): The name of the selected distribution
Expand Down Expand Up @@ -77,7 +77,7 @@ def populate_distribution_parameters(selectedDistribution):
return selectedDistributionParameters


def update_distribution_parameters(
def update_distribution_parameters (
parameterName, parameterValue, parameterErrorMessage
):
"""
Expand All @@ -103,7 +103,7 @@ def update_distribution_parameters(
# -----------------------------------------------------------------------------


def parameter_input_checker():
def parameter_input_checker ():
"""
Helper function to check if user input is valid.
:return: A dictionary with parameter names as keys and their validated values.
Expand All @@ -121,7 +121,7 @@ def parameter_input_checker():
return parameter_input


def save_distribution_parameters():
def save_distribution_parameters ():
"""
Writes user input for distribution parameters in suitable format for simulation code.
:return: An instance of the selected distribution class, initialized with user-provided parameters.
Expand All @@ -140,17 +140,17 @@ def save_distribution_parameters():


@state.change("selectedDistribution")
def on_distribution_name_change(selectedDistribution, **kwargs):
def on_distribution_name_change (selectedDistribution, **kwargs):
populate_distribution_parameters(selectedDistribution)


@state.change("selectedDistributionType")
def on_distribution_type_change(**kwargs):
def on_distribution_type_change (**kwargs):
populate_distribution_parameters(state.selectedDistribution)


@ctrl.add("updateDistributionParameters")
def on_distribution_parameter_change(parameter_name, parameter_value, parameter_type):
def on_distribution_parameter_change (parameter_name, parameter_value, parameter_type):
parameter_value, input_type = generalFunctions.determine_input_type(parameter_value)
error_message = generalFunctions.validate_against(parameter_value, parameter_type)

Expand Down
6 changes: 3 additions & 3 deletions src/python/impactx/dashboard/Input/generalFunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
class generalFunctions:

@staticmethod
def documentation(section_name):
def documentation (section_name):
"""
Opens a tab to the specified section link in the documentation.
:param section_name (str): The name of the documentation section to open.
Expand All @@ -48,7 +48,7 @@ def documentation(section_name):
# -----------------------------------------------------------------------------

@staticmethod
def determine_input_type(value):
def determine_input_type (value):
"""
Determines the type of the input value.
:param value: The input value whose type needs to be determined.
Expand All @@ -64,7 +64,7 @@ def determine_input_type(value):
return value, str

@staticmethod
def validate_against(input_value, value_type):
def validate_against (input_value, value_type):
"""
Returns an error message if the input value type does not match the desired type.
:param input_value: The value to validate.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class InputFunctions:
"""

@staticmethod
def value_of_kin_energy_MeV(kineticEnergyOnDisplayValue, OldUnit):
def value_of_kin_energy_MeV (kineticEnergyOnDisplayValue, OldUnit):
"""
Converts the kinetic energy to MeV.
:param kineticEnergyOnDisplayValue: The kinetic energy value that is displayed in the UI.
Expand All @@ -44,7 +44,7 @@ def value_of_kin_energy_MeV(kineticEnergyOnDisplayValue, OldUnit):
return state.kin_energy_MeV

@staticmethod
def update_kin_energy_on_display(old_unit, new_unit, kin_energy_value):
def update_kin_energy_on_display (old_unit, new_unit, kin_energy_value):
"""
Updates the kinetic energy value in the UI.
:param old_unit: The previous unit of kin_energy prior to change.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


@ctrl.add("on_input_change")
def validate_and_convert_to_correct_type(
def validate_and_convert_to_correct_type (
value, desired_type, state_name, validation_name
):
validation_result = generalFunctions.validate_against(value, desired_type)
Expand All @@ -39,7 +39,7 @@ def validate_and_convert_to_correct_type(


@ctrl.add("kin_energy_unit_change")
def on_convert_kin_energy_change(new_unit):
def on_convert_kin_energy_change (new_unit):
old_unit = state.old_kin_energy_unit
if old_unit != new_unit and float(state.kin_energy) > 0:
state.kin_energy = InputFunctions.update_kin_energy_on_display(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def add_lattice_element ():
return selectedLatticeElement


def update_latticeElement_parameters(
def update_latticeElement_parameters (
index, parameterName, parameterValue, parameterErrorMessage
):
"""
Expand All @@ -93,7 +93,7 @@ def update_latticeElement_parameters(
# -----------------------------------------------------------------------------


def parameter_input_checker_for_lattice(latticeElement):
def parameter_input_checker_for_lattice (latticeElement):
"""
Helper function to check if user input is valid.
:return: A dictionary with parameter names as keys and their validated values.
Expand All @@ -116,7 +116,7 @@ def parameter_input_checker_for_lattice(latticeElement):
return parameter_input


def save_lattice_elements():
def save_lattice_elements ():
"""
Writes user input for lattice element parameters parameters in suitable format for simulation code.
:return: A list in the suitable format.
Expand All @@ -139,7 +139,7 @@ def save_lattice_elements():


@state.change("selectedLatticeList")
def on_selectedLatticeList_change(selectedLatticeList, **kwargs):
def on_selectedLatticeList_change (selectedLatticeList, **kwargs):
if selectedLatticeList == []:
state.isSelectedLatticeListEmpty = "Please select a lattice element"
generalFunctions.update_simulation_validation_status()
Expand All @@ -148,13 +148,13 @@ def on_selectedLatticeList_change(selectedLatticeList, **kwargs):


@state.change("selectedLattice")
def on_lattice_element_name_change(selectedLattice, **kwargs):
def on_lattice_element_name_change (selectedLattice, **kwargs):
return
# print (f"Lattice Selection Changed to: {selectedLattice}")


@ctrl.add("add_latticeElement")
def on_add_lattice_element_click():
def on_add_lattice_element_click ():
selectedLattice = state.selectedLattice
if selectedLattice:
add_lattice_element()
Expand All @@ -165,7 +165,7 @@ def on_add_lattice_element_click():


@ctrl.add("updateLatticeElementParameters")
def on_lattice_element_parameter_change(
def on_lattice_element_parameter_change (
index, parameter_name, parameter_value, parameter_type
):
parameter_value, input_type = generalFunctions.determine_input_type(parameter_value)
Expand All @@ -180,20 +180,20 @@ def on_lattice_element_parameter_change(


@ctrl.add("clear_latticeElements")
def on_clear_lattice_element_click():
def on_clear_lattice_element_click ():
state.selectedLatticeList = []
save_lattice_elements()


@ctrl.add("deleteLatticeElement")
def on_delete_LatticeElement_click(index):
def on_delete_LatticeElement_click (index):
state.selectedLatticeList.pop(index)
state.dirty("selectedLatticeList")
save_lattice_elements()


@ctrl.add("move_latticeElementIndex_up")
def on_move_latticeElementIndex_up_click(index):
def on_move_latticeElementIndex_up_click (index):
if index > 0:
state.selectedLatticeList[index], state.selectedLatticeList[index - 1] = (
state.selectedLatticeList[index - 1],
Expand All @@ -204,7 +204,7 @@ def on_move_latticeElementIndex_up_click(index):


@ctrl.add("move_latticeElementIndex_down")
def on_move_latticeElementIndex_down_click(index):
def on_move_latticeElementIndex_down_click (index):
if index < len(state.selectedLatticeList) - 1:
state.selectedLatticeList[index], state.selectedLatticeList[index + 1] = (
state.selectedLatticeList[index + 1],
Expand Down
4 changes: 2 additions & 2 deletions src/python/impactx/dashboard/Input/trameFunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class TrameFunctions:
"""

@staticmethod
def create_route(route_title, mdi_icon):
def create_route (route_title, mdi_icon):
"""
Creates a route with a specified title and icon.
:param route_title: The title of the route.
Expand All @@ -45,7 +45,7 @@ def create_route(route_title, mdi_icon):
vuetify.VListItemTitle(route_title)

@staticmethod
def create_button(label):
def create_button (label):
"""
Creates a Vuetify button component with the specified label and styles.
:param label: The name of the button.
Expand Down

0 comments on commit f52b0e1

Please sign in to comment.