Skip to content

Commit 81aaab6

Browse files
committed
Fix scipy version just in case
1 parent 27a5b06 commit 81aaab6

2 files changed

Lines changed: 30 additions & 3 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ dependencies = [
1717
"numpy>=1.20",
1818
"prettytable>=3.9.0",
1919
"pydantic>=2.7.2",
20-
"scipy>=1.13.1",
20+
"scipy>=1.13.1, <=1.17.1",
2121
"strenum>=0.4.15 ; python_full_version < '3.11'",
2222
"tqdm>=4.66.5",
2323
]

ratapi/utils/convert.py

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,33 @@ def zip_if_several(*params) -> tuple | list[tuple]:
6666
return zip(*params, strict=False)
6767
return [params]
6868

69+
def __opaque_to_string(opaque):
70+
"""Extract java string from MATLABOpaque object.
71+
72+
Parameters
73+
----------
74+
opaque : MATLABOpaque
75+
object containing java string.
76+
77+
Returns
78+
-------
79+
str
80+
string extracted from object.
81+
82+
Raises
83+
------
84+
ValueError
85+
Raised if there is no java string array in the object.
86+
"""
87+
entries = opaque[0]
88+
for entry in entries:
89+
if isinstance(entry, ndarray):
90+
break
91+
else:
92+
raise ValueError("No array in MatlabOpaque")
93+
94+
return bytes(entry[7:]).decode("ascii")
95+
6996
def read_param(names, constrs, values, fits):
7097
"""Read in a parameter list from the relevant keys, and fix constraints for non-fit parameters.
7198
@@ -217,11 +244,11 @@ def fix_invalid_constraints(name: str, constrs: tuple[float, float], value: floa
217244
# which is given as the byte data of a Java string; this consists of 7 metadata bytes (ignored)
218245
# and then the actual string characters (index [7:]) in ascii format (.decode("ascii"))
219246
if len(mat_project["contrastNames"]) == 1 and isinstance(mat_project["contrastNames"], MatlabOpaque):
220-
mat_project["contrastNames"] = bytes(mat_project["contrastNames"][0][3][7:]).decode("ascii")
247+
mat_project["contrastNames"] = __opaque_to_string(mat_project["contrastNames"])
221248
else:
222249
for i, contrast_name in enumerate(mat_project["contrastNames"]):
223250
if isinstance(contrast_name, MatlabOpaque):
224-
mat_project["contrastNames"][i] = bytes(contrast_name[0][3][7:]).decode("ascii")
251+
mat_project["contrastNames"][i] = __opaque_to_string(contrast_name)
225252

226253
# if just one contrast, resolNames is a string; fix that here
227254
if isinstance(mat_project["resolNames"], str):

0 commit comments

Comments
 (0)