Skip to content

Commit

Permalink
Merged dev-5-1-1 branch
Browse files Browse the repository at this point in the history
  • Loading branch information
vyrjana committed Nov 20, 2024
1 parent e2b7068 commit 4f9d346
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 10 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 5.1.1 (2024/11/20)

- Added a docstring to the `Circuit.serialize` method.
- Fixed a bug that caused an exception to be raised when attempting to pass multiple methods and/or weights to the `fit_circuit` function.


# 5.1.0 (2024/11/02)

- Added support for analyzing the peaks in DRT results by fitting skew normal distributions:
Expand Down
2 changes: 1 addition & 1 deletion dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
build~=1.2
flake8~=7.1
setuptools~=75.3
setuptools~=75.5
sphinx~=8.1
sphinx-rtd-theme~=3.0
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
dev_dependencies = [
"build~=1.2",
"flake8~=7.1",
"setuptools~=75.3",
"setuptools~=75.5",
"sphinx~=8.1",
"sphinx-rtd-theme~=3.0",
]
Expand All @@ -40,7 +40,7 @@
"dev": dev_dependencies,
}

version = "5.1.0"
version = "5.1.1"

if __name__ == "__main__":
with open("requirements.txt", "w") as fp:
Expand Down
13 changes: 10 additions & 3 deletions src/pyimpspec/analysis/fitting.py
Original file line number Diff line number Diff line change
Expand Up @@ -1063,9 +1063,16 @@ def fit_circuit(
elif not all(map(lambda v: isinstance(v, dict), constraint_variables.values())):
raise TypeError(f"Expected all values to be dictionaries instead of {constraint_variables=}")

num_steps: int = (len(_METHODS) if method == "auto" else 1) * (
len(_WEIGHT_FUNCTIONS) if weight == "auto" else 1
)
num_steps: int = 0
if isinstance(method, str):
num_steps = len(_METHODS) if method == "auto" else 1
elif isinstance(method, list):
num_steps = len(method)

if isinstance(weight, str):
num_steps *= len(_WEIGHT_FUNCTIONS) if weight == "auto" else 1
elif isinstance(weight, list):
num_steps *= len(weight)

prog: Progress
with Progress("Preparing to fit", total=num_steps + 1) as prog:
Expand Down
16 changes: 16 additions & 0 deletions src/pyimpspec/circuit/circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,22 @@ def to_stack(self) -> List[Tuple[str, Union[Element, Connection]]]:
return stack

def serialize(self, decimals: int = 12) -> str:
"""
Generate a circuit description code (CDC) that represents this circuit.
This CDC is modified to also include the current version of the CDC syntax supported by pyimpspec.
Parameters
----------
decimals: int, optional
The number of decimals to include for the current element parameter values and limits.
Returns
-------
str
"""
if decimals < 1:
raise ValueError(f"Expected a value greater than or equal to 1 instead of {decimals=}")

return (
"!"
+ "/".join(
Expand Down
2 changes: 1 addition & 1 deletion src/pyimpspec/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
# The licenses of pyimpspec's dependencies and/or sources of portions of code are included in
# the LICENSES folder.

PACKAGE_VERSION: str = "5.1.0"
PACKAGE_VERSION: str = "5.1.1"
4 changes: 2 additions & 2 deletions tests/test_fitting.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def test_auto(self):
self.assertNotEqual(result.weight, "auto")

def test_methods_list(self):
methods: List[str] = ["powell"]
methods: List[str] = ["least_squares", "powell"]
result: FitResult = fit_circuit(
circuit=self.circuit,
data=DATA,
Expand All @@ -165,7 +165,7 @@ def test_methods_list(self):
self.assertEqual(result.weight, "boukamp")

def test_weights_list(self):
weights: List[str] = ["unity"]
weights: List[str] = ["unity", "boukamp"]
result: FitResult = fit_circuit(
circuit=self.circuit,
data=DATA,
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.1.0
5.1.1

0 comments on commit 4f9d346

Please sign in to comment.