Skip to content

Commit 70bcb3f

Browse files
authored
BUG FIX - reverses changes to enum values made in #53 (#58)
1 parent 0a8fa3c commit 70bcb3f

File tree

3 files changed

+30
-30
lines changed

3 files changed

+30
-30
lines changed

RATapi/controls.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
fields = {
2020
"calculate": common_fields,
2121
"simplex": [*common_fields, "xTolerance", "funcTolerance", "maxFuncEvals", "maxIterations", *update_fields],
22-
"DE": [
22+
"de": [
2323
*common_fields,
2424
"populationSize",
2525
"fWeight",
@@ -29,8 +29,8 @@
2929
"numGenerations",
3030
*update_fields,
3131
],
32-
"NS": [*common_fields, "nLive", "nMCMC", "propScale", "nsTolerance"],
33-
"DREAM": [*common_fields, "nSamples", "nChains", "jumpProbability", "pUnitGamma", "boundHandling", "adaptPCR"],
32+
"ns": [*common_fields, "nLive", "nMCMC", "propScale", "nsTolerance"],
33+
"dream": [*common_fields, "nSamples", "nChains", "jumpProbability", "pUnitGamma", "boundHandling", "adaptPCR"],
3434
}
3535

3636

RATapi/utils/enums.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ class Procedures(RATEnum):
2626

2727
Calculate = "calculate"
2828
Simplex = "simplex"
29-
DE = "DE"
30-
NS = "NS"
31-
DREAM = "DREAM"
29+
DE = "de"
30+
NS = "ns"
31+
DREAM = "dream"
3232

3333

3434
class Parallel(RATEnum):
@@ -81,7 +81,7 @@ class BackgroundActions(RATEnum):
8181

8282

8383
class Languages(RATEnum):
84-
Cpp = "Cpp"
84+
Cpp = "cpp"
8585
Python = "python"
8686
Matlab = "matlab"
8787

tests/test_controls.py

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ def test_initialise_procedure_error() -> None:
1313
"""Tests for a ValidationError if the procedure property of the Controls class is initialised with an invalid
1414
value.
1515
"""
16-
with pytest.raises(pydantic.ValidationError, match="Input should be 'calculate', 'simplex', 'DE', 'NS' or 'DREAM'"):
16+
with pytest.raises(pydantic.ValidationError, match="Input should be 'calculate', 'simplex', 'de', 'ns' or 'dream'"):
1717
Controls(procedure="test")
1818

1919

2020
def test_set_procedure_error() -> None:
2121
"""Tests for a ValidationError if the procedure property of the Controls class is set to an invalid value."""
2222
controls = Controls()
23-
with pytest.raises(pydantic.ValidationError, match="Input should be 'calculate', 'simplex', 'DE', 'NS' or 'DREAM'"):
23+
with pytest.raises(pydantic.ValidationError, match="Input should be 'calculate', 'simplex', 'de', 'ns' or 'dream'"):
2424
controls.procedure = "test"
2525

2626

@@ -377,7 +377,7 @@ def table_str(self):
377377
"+----------------------+--------------------------------------+\n"
378378
"| Property | Value |\n"
379379
"+----------------------+--------------------------------------+\n"
380-
"| procedure | DE |\n"
380+
"| procedure | de |\n"
381381
"| parallel | single |\n"
382382
"| calcSldDuringFit | False |\n"
383383
"| resampleParams | [0.9, 50] |\n"
@@ -458,11 +458,11 @@ def test_initialise_non_de_properties(self, wrong_property: str, value: Any) ->
458458
incorrect_procedures = [key for (key, value) in fields.items() if wrong_property in value]
459459
with pytest.warns(
460460
UserWarning,
461-
match=f'\nThe current controls procedure is "DE", but the property'
461+
match=f'\nThe current controls procedure is "de", but the property'
462462
f' "{wrong_property}" applies instead to the'
463463
f' {", ".join(incorrect_procedures)} procedure.\n\n'
464-
f' The fields for the "DE" controls procedure are:\n'
465-
f' {", ".join(fields["DE"])}\n',
464+
f' The fields for the "de" controls procedure are:\n'
465+
f' {", ".join(fields["de"])}\n',
466466
):
467467
Controls(procedure=Procedures.DE, **{wrong_property: value})
468468

@@ -489,11 +489,11 @@ def test_set_non_de_properties(self, wrong_property: str, value: Any) -> None:
489489
incorrect_procedures = [key for (key, value) in fields.items() if wrong_property in value]
490490
with pytest.warns(
491491
UserWarning,
492-
match=f'\nThe current controls procedure is "DE", but the property'
492+
match=f'\nThe current controls procedure is "de", but the property'
493493
f' "{wrong_property}" applies instead to the'
494494
f' {", ".join(incorrect_procedures)} procedure.\n\n'
495-
f' The fields for the "DE" controls procedure are:\n'
496-
f' {", ".join(fields["DE"])}\n',
495+
f' The fields for the "de" controls procedure are:\n'
496+
f' {", ".join(fields["de"])}\n',
497497
):
498498
setattr(self.de, wrong_property, value)
499499

@@ -547,7 +547,7 @@ def table_str(self):
547547
"+------------------+-----------+\n"
548548
"| Property | Value |\n"
549549
"+------------------+-----------+\n"
550-
"| procedure | NS |\n"
550+
"| procedure | ns |\n"
551551
"| parallel | single |\n"
552552
"| calcSldDuringFit | False |\n"
553553
"| resampleParams | [0.9, 50] |\n"
@@ -624,11 +624,11 @@ def test_initialise_non_ns_properties(self, wrong_property: str, value: Any) ->
624624
incorrect_procedures = [key for (key, value) in fields.items() if wrong_property in value]
625625
with pytest.warns(
626626
UserWarning,
627-
match=f'\nThe current controls procedure is "NS", but the property'
627+
match=f'\nThe current controls procedure is "ns", but the property'
628628
f' "{wrong_property}" applies instead to the'
629629
f' {", ".join(incorrect_procedures)} procedure.\n\n'
630-
f' The fields for the "NS" controls procedure are:\n'
631-
f' {", ".join(fields["NS"])}\n',
630+
f' The fields for the "ns" controls procedure are:\n'
631+
f' {", ".join(fields["ns"])}\n',
632632
):
633633
Controls(procedure=Procedures.NS, **{wrong_property: value})
634634

@@ -659,11 +659,11 @@ def test_set_non_ns_properties(self, wrong_property: str, value: Any) -> None:
659659
incorrect_procedures = [key for (key, value) in fields.items() if wrong_property in value]
660660
with pytest.warns(
661661
UserWarning,
662-
match=f'\nThe current controls procedure is "NS", but the property'
662+
match=f'\nThe current controls procedure is "ns", but the property'
663663
f' "{wrong_property}" applies instead to the'
664664
f' {", ".join(incorrect_procedures)} procedure.\n\n'
665-
f' The fields for the "NS" controls procedure are:\n'
666-
f' {", ".join(fields["NS"])}\n',
665+
f' The fields for the "ns" controls procedure are:\n'
666+
f' {", ".join(fields["ns"])}\n',
667667
):
668668
setattr(self.ns, wrong_property, value)
669669

@@ -710,7 +710,7 @@ def table_str(self):
710710
"+------------------+-----------+\n"
711711
"| Property | Value |\n"
712712
"+------------------+-----------+\n"
713-
"| procedure | DREAM |\n"
713+
"| procedure | dream |\n"
714714
"| parallel | single |\n"
715715
"| calcSldDuringFit | False |\n"
716716
"| resampleParams | [0.9, 50] |\n"
@@ -791,11 +791,11 @@ def test_initialise_non_dream_properties(self, wrong_property: str, value: Any)
791791
incorrect_procedures = [key for (key, value) in fields.items() if wrong_property in value]
792792
with pytest.warns(
793793
UserWarning,
794-
match=f'\nThe current controls procedure is "DREAM", but the property'
794+
match=f'\nThe current controls procedure is "dream", but the property'
795795
f' "{wrong_property}" applies instead to the'
796796
f' {", ".join(incorrect_procedures)} procedure.\n\n'
797-
f' The fields for the "DREAM" controls procedure are:\n'
798-
f' {", ".join(fields["DREAM"])}\n',
797+
f' The fields for the "dream" controls procedure are:\n'
798+
f' {", ".join(fields["dream"])}\n',
799799
):
800800
Controls(procedure=Procedures.DREAM, **{wrong_property: value})
801801

@@ -824,11 +824,11 @@ def test_set_non_dream_properties(self, wrong_property: str, value: Any) -> None
824824
incorrect_procedures = [key for (key, value) in fields.items() if wrong_property in value]
825825
with pytest.warns(
826826
UserWarning,
827-
match=f'\nThe current controls procedure is "DREAM", but the property'
827+
match=f'\nThe current controls procedure is "dream", but the property'
828828
f' "{wrong_property}" applies instead to the'
829829
f' {", ".join(incorrect_procedures)} procedure.\n\n'
830-
f' The fields for the "DREAM" controls procedure are:\n'
831-
f' {", ".join(fields["DREAM"])}\n',
830+
f' The fields for the "dream" controls procedure are:\n'
831+
f' {", ".join(fields["dream"])}\n',
832832
):
833833
setattr(self.dream, wrong_property, value)
834834

0 commit comments

Comments
 (0)