diff --git a/.github/workflows/format_check.yml b/.github/workflows/format_check.yml index dca19a00f..f779ab252 100644 --- a/.github/workflows/format_check.yml +++ b/.github/workflows/format_check.yml @@ -8,3 +8,4 @@ jobs: - uses: chartboost/ruff-action@v1 with: args: 'format --check' + version: 0.6.1 diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 744b4e642..be42eccfe 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -6,3 +6,5 @@ jobs: steps: - uses: actions/checkout@v4 - uses: chartboost/ruff-action@v1 + with: + version: 0.6.1 diff --git a/.github/workflows/spell_check.yml b/.github/workflows/spell_check.yml index e21f80b37..c894573a1 100644 --- a/.github/workflows/spell_check.yml +++ b/.github/workflows/spell_check.yml @@ -10,16 +10,6 @@ jobs: - name: Checkout code uses: actions/checkout@v2 - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: '3.10' - - - name: Install codespell - run: | - python -m pip install --upgrade pip - pip install tomli codespell - - name: Run codespell - run: | - codespell . + uses: codespell-project/actions-codespell@v2 + diff --git a/modules/Workflow/createResponseCSV.py b/modules/Workflow/createResponseCSV.py index e553398c3..557b14c80 100644 --- a/modules/Workflow/createResponseCSV.py +++ b/modules/Workflow/createResponseCSV.py @@ -1,4 +1,4 @@ -# noqa: D100 +# noqa: D100, INP001 # # Code to write response.csv file given input and dakotaTab.out files @@ -14,9 +14,9 @@ import numpy as np import pandas as pd -def main(input_file, dakota_tab_file): # noqa: D103 - directory_inputs = os.path.dirname(input_file) # noqa: PTH120 +def main(input_file, dakota_tab_file): # noqa: D103 + directory_inputs = os.path.dirname(input_file) # noqa: PTH120 os.chdir(directory_inputs) try: @@ -26,11 +26,11 @@ def main(input_file, dakota_tab_file): # noqa: D103 except FileNotFoundError: # Handle the error if the file is not found - print(f"Error createResponseCSV.py: The file '{input_file}' was not found.") # noqa: T201 + print(f"Error createResponseCSV.py: The file '{input_file}' was not found.") # noqa: T201 return except OSError: # Handle other I/O errors - print(f"Error createResponseCSV.py: Error reading the file '{input_file}'.") # noqa: T201 + print(f"Error createResponseCSV.py: Error reading the file '{input_file}'.") # noqa: T201 return app_data = data.get('Applications', None) @@ -59,12 +59,12 @@ def main(input_file, dakota_tab_file): # noqa: D103 except FileNotFoundError: # Handle the error if the file is not found - print(f"Error createResponseCSV.py: The file '{dakota_tab_file}' not found.") # noqa: T201 + print(f"Error createResponseCSV.py: The file '{dakota_tab_file}' not found.") # noqa: T201 return except OSError: # Handle other I/O errors - print(f"Error createResponseCSV.py: Error reading '{dakota_tab_file}'.") # noqa: T201 + print(f"Error createResponseCSV.py: Error reading '{dakota_tab_file}'.") # noqa: T201 return diff --git a/modules/Workflow/whale/main.py b/modules/Workflow/whale/main.py index 759f8af73..86d0f26ab 100644 --- a/modules/Workflow/whale/main.py +++ b/modules/Workflow/whale/main.py @@ -2874,7 +2874,7 @@ def aggregate_results( # noqa: C901, PLR0912, PLR0915 bldg_dir = Path(os.path.dirname(asst_data[a_i]['file'])).resolve() # noqa: PTH120 main_dir = bldg_dir assetTypeHierarchy = [bldg_dir.name] # noqa: N806 - while main_dir.parent.name != 'Results': + while main_dir.parent.name != self.run_dir.name: main_dir = bldg_dir.parent assetTypeHierarchy = [main_dir.name] + assetTypeHierarchy # noqa: N806, RUF005 diff --git a/modules/createEVENT/multiplePEER/MultiplePEER_Events.cpp b/modules/createEVENT/multiplePEER/MultiplePEER_Events.cpp index fbe69c22a..e311ebab4 100644 --- a/modules/createEVENT/multiplePEER/MultiplePEER_Events.cpp +++ b/modules/createEVENT/multiplePEER/MultiplePEER_Events.cpp @@ -88,52 +88,52 @@ int main(int argc, char **argv) if (strcmp(eventType,"ExistingPEER_Events") != 0) { - json_array_append(newEventArray, value); // copy event for next event app to parse + json_array_append(newEventArray, value); // copy event for next event app to parse } else { - json_t *eventObj = json_object(); - json_object_set(eventObj,"type", json_string("Seismic")); - json_object_set(eventObj,"subtype", json_string("MultiplePEER_Event")); - - json_t *existingEventsArray = json_object_get(value,"Events"); - int numExisting = json_array_size(existingEventsArray); - - if (numExisting > 1) { - - json_t *randomVar = json_object(); - json_object_set(randomVar, "distribution",json_string("discrete_design_set_string")); - json_object_set(randomVar, "name",json_string("MultipleEvent")); - json_object_set(randomVar, "value",json_string("RV.MultipleEvent")); - json_t *theMultipleEvents = json_array(); - - json_t *existingEvent = 0; - json_array_foreach(existingEventsArray, index, existingEvent) { - createSimCenterEvent(existingEvent); - json_array_append(theMultipleEvents, json_object_get(existingEvent,"name")); - } - - json_object_set(randomVar, "elements", theMultipleEvents); - json_array_append(rvArray, randomVar); - json_object_set(eventObj, "index", json_string("RV.MultipleEvent")); - - } else { - - json_t *existingEvent = json_array_get(existingEventsArray,0); - createSimCenterEvent(existingEvent); - json_object_set(eventObj, "index", json_integer(0)); - - } - - //add first event to event - json_t *firstEvent = json_array_get(existingEventsArray, 0); - json_t *fileValue = json_object_get(firstEvent, "name"); - if (fileValue != NULL) { - const char *fileName = json_string_value(fileValue); - addEvent(fileName, eventObj); - } - - json_array_append(newEventArray, eventObj); + json_t *eventObj = json_object(); + json_object_set(eventObj,"type", json_string("Seismic")); + json_object_set(eventObj,"subtype", json_string("MultiplePEER_Event")); + + json_t *existingEventsArray = json_object_get(value,"Events"); + int numExisting = json_array_size(existingEventsArray); + + if (numExisting > 1) { + + json_t *randomVar = json_object(); + json_object_set(randomVar, "distribution",json_string("discrete_design_set_string")); + json_object_set(randomVar, "name",json_string("MultipleEvent")); + json_object_set(randomVar, "value",json_string("RV.MultipleEvent")); + json_t *theMultipleEvents = json_array(); + + json_t *existingEvent = 0; + json_array_foreach(existingEventsArray, index, existingEvent) { + createSimCenterEvent(existingEvent); + json_array_append(theMultipleEvents, json_object_get(existingEvent,"name")); + } + + json_object_set(randomVar, "elements", theMultipleEvents); + json_array_append(rvArray, randomVar); + json_object_set(eventObj, "index", json_string("RV.MultipleEvent")); + + } else { + + json_t *existingEvent = json_array_get(existingEventsArray,0); + createSimCenterEvent(existingEvent); + json_object_set(eventObj, "index", json_integer(0)); + + } + + //add first event to event + json_t *firstEvent = json_array_get(existingEventsArray, 0); + json_t *fileValue = json_object_get(firstEvent, "name"); + if (fileValue != NULL) { + const char *fileName = json_string_value(fileValue); + addEvent(fileName, eventObj); + } + + json_array_append(newEventArray, eventObj); } } diff --git a/modules/performRegionalEventSimulation/regionalGroundMotion/gmpe/openSHAGMPE.py b/modules/performRegionalEventSimulation/regionalGroundMotion/gmpe/openSHAGMPE.py index 3a6c527ec..69213803e 100644 --- a/modules/performRegionalEventSimulation/regionalGroundMotion/gmpe/openSHAGMPE.py +++ b/modules/performRegionalEventSimulation/regionalGroundMotion/gmpe/openSHAGMPE.py @@ -74,7 +74,16 @@ def __init__(self): def setIMT(self, imt): # noqa: N802, D102 if imt not in self.supportedImt: - sys.exit(f'The imt {imt} is not supported by Chiou and Young (2014)') + # supported_imt = [] + # for i in self.supportedImt: + # if i is float: + # supported_imt.append(i) + supported_imt = [ + f'SA{x}s' if isinstance(x, float) else x for x in self.supportedImt + ] + sys.exit( + f'The IM type {imt} is not supported by Chiou and Young (2014). \n The supported IM types are {supported_imt}' + ) return False self.c1 = self.coeff['c1'][imt] self.c1a = self.coeff['c1a'][imt] @@ -337,8 +346,11 @@ def __init__(self): def setIMT(self, imt): # noqa: N802, D102 if imt not in self.supportedImt: + supported_imt = [ + f'SA{x}s' if isinstance(x, float) else x for x in self.supportedImt + ] sys.exit( - f'The imt {imt} is not supported by Abrahamson, Silva, and Kamai (2014)' + f'The IM type {imt} is not supported by Abrahamson, Silva, and Kamai (2014). \n The supported IM types are {supported_imt}' ) return self.imt = imt @@ -636,8 +648,11 @@ def __init__(self): def setIMT(self, imt): # noqa: N802, D102 if imt not in self.supportedImt: + supported_imt = [ + f'SA{x}s' if isinstance(x, float) else x for x in self.supportedImt + ] sys.exit( - f'The imt {imt} is not supported by Boore, Stewart, Seyhan & Atkinson (2014)' + f'The IM type {imt} is not supported by Boore, Stewart, Seyhan & Atkinson (2014). \n The supported IM types are {supported_imt}' ) return self.imt = imt @@ -863,8 +878,11 @@ def __init__(self): def setIMT(self, imt): # noqa: N802, D102 if imt not in self.supportedImt: + supported_imt = [ + f'SA{x}s' if isinstance(x, float) else x for x in self.supportedImt + ] sys.exit( - f'The imt {imt} is not supported by Campbell & Bozorgnia (2014)' + f'The IM type {imt} is not supported by Campbell & Bozorgnia (2014). \n The supported IM types are {supported_imt}' ) return self.imt = imt