In an email (because the data are not published yet) you mentioned
- If you want to force your "compositional non-linearity slopes" (parameter
b
in Daëron, 2021) to be zero, you can use the constraints
argument of
D47data.standardize()
. I realize now that this is under-documented, but the
way it works, if you want to set b=0 for sessions foo
, bar
and baz
, is
to use constraints = dict(b_foo = 0, b_bar = 0, b_baz = 0)
. I haven't
extensively tested this option yet, however, so things may break somewhere
else as a result. As always, please open an issue if that is the case.
I've tried this out but I couldn't get it to work. My sessions were named '2018-02-23', '2020-01-03', and '2021-05-12' and when I tried:
mydata.standardize(
constraints = dict(b_2018-02-23 = 0,
b_2020-01-03 = 0,
b_2021-05-12 = 0))
I got the following errors
Traceback (most recent call last):
File "<string>", line 8, in __PYTHON_EL_eval
File "/usr/lib/python3.10/ast.py", line 50, in parse
return compile(source, filename, mode, flags,
File "<string>", line 1
dict(b_2018-02-23 = 0,
^
SyntaxError: leading zeros in decimal integer literals are not permitted; use an 0o prefix for octal integers
I then thought that they should be passed as characters, so I did it with bracketing '
's. ('b_2018-02-23') but this gave me the next error:
Traceback (most recent call last):
File "<string>", line 8, in __PYTHON_EL_eval
File "/usr/lib/python3.10/ast.py", line 50, in parse
return compile(source, filename, mode, flags,
File "<string>", line 1
dict('b_2018-02-23' = 0,
^^^^^^^^^^^^^^^^
SyntaxError: expression cannot contain assignment, perhaps you meant "=="?
which made me think that the issue may be with the names of the sessions, because typically -
is not allowed in a variable name (right?). So I renamed the sessions to session0
, session1
, and session2
(see, I'm getting the hang of Python's 0-indexing even though I'm an R user ;-))
Traceback (most recent call last):
File "<string>", line 17, in __PYTHON_EL_eval
File "<string>", line 3, in <module>
File "/tmp/babel-qGlEVX/python-7afIAv", line 1, in <module>
mydata.standardize(
File "/home/japhir/SurfDrive/PhD/programming/D47crunch/D47crunch/__init__.py", line 1006, in newfun
out = oldfun(*args, **kwargs)
File "/home/japhir/SurfDrive/PhD/programming/D47crunch/D47crunch/__init__.py", line 1628, in standardize
params[k].expr = constraints[k]
File "/usr/lib/python3.10/site-packages/lmfit/parameter.py", line 845, in expr
self.__set_expression(val)
File "/usr/lib/python3.10/site-packages/lmfit/parameter.py", line 860, in __set_expression
self._expr_ast = self._expr_eval.parse(val)
File "/usr/lib/python3.10/site-packages/asteval/asteval.py", line 257, in parse
if len(text) > self.max_statement_length:
TypeError: object of type 'int' has no len()
Note that calling mydata.standardize()
without any constraints does work as expected (and doesn't result in very different results after limiting the anchors to ETH-1, ETH-2, and ETH-3).
Any ideas?