Skip to content

Commit

Permalink
Fix subassembly ID creation to not strip non-leading numerals (#144)
Browse files Browse the repository at this point in the history
* remove print debugging statement

* update the variable name creation method to operate as expected

* update changelog
  • Loading branch information
RHammond2 committed Apr 26, 2024
1 parent bd90ba4 commit 90aefbf
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- Replaces the `valid_reduction` attrs validator with `validate_0_1_inclusive` to reuse the logic in multiple places without duplicating checking methods.
- Adds a `replacement` flag for interruption methods, so that a failure or replacement comment can be added as a cause for `simpy.process.interrupt`. This update allows the failure and maintenance processes to check if an interruption should cause the process to exit completely. Additionally, the forced exit ensures that processes can't persist after a replacement event when a process is recreated, which was happening in isolated cases.
- Fixes a bug in `RepairManager.purge_subassemble_requests()` where the pending tows are cleared regardless of whether or not the focal subassembly is the cause of the tow, leading to a simulation failure.
- Fixes a bug in `utilities/utilities.py:create_variable_from_string()` to operate in a way that is expected. The original method was removing all numerics, but only leading punctuation and numerics should be replaced, with any punctuation being replaced with an underscore.

## v0.9.3 (15 February 2024)

Expand Down
1 change: 0 additions & 1 deletion wombat/core/service_equipment.py
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,6 @@ def register_repair_with_subassembly(
try:
subassembly.broken.succeed()
except RuntimeError as e:
print(subassembly.system.id, repair.details.description)
raise e
elif operation_reduction == 0:
subassembly.operating_level = starting_operating_level
Expand Down
12 changes: 6 additions & 6 deletions wombat/utilities/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from __future__ import annotations

import re
from string import digits, punctuation
from typing import Callable

import numpy as np
Expand Down Expand Up @@ -57,11 +57,11 @@ def create_variable_from_string(string: str) -> str:
'electrical_system'
"""
new_string = re.sub(
"[^0-9a-zA-Z]+",
"_",
re.sub(r"^\W+", "", re.sub("[^a-zA-Z]+$", "", string)), # noqa: disable=W605
).lower()
new_string = (
string.lstrip(punctuation + digits)
.translate(str.maketrans("", "", punctuation.replace("_", " ")))
.lower()
)
return new_string


Expand Down

0 comments on commit 90aefbf

Please sign in to comment.