Skip to content

Commit

Permalink
Fix representation of dotted variables (and other method calls) (#1074)
Browse files Browse the repository at this point in the history
* Add test of #1069

* Ensure function arguments are all in repr form

* Reverse order of pop'd arguments

Successive pops reverses, so reverse back

* Install miniconda on macos

Grrr.  Laggards on Azure/GHA team
[dropped miniconda on macos images](actions/runner-images#9262)
  • Loading branch information
guyer authored Oct 4, 2024
1 parent d8d9f88 commit fe5bf86
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
11 changes: 11 additions & 0 deletions .azure/templates/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@ parameters:
default: scipy

steps:
- bash: |
# laggards on Azure/GHA team dropped miniconda on macos images
# https://github.com/actions/runner-images/issues/9262
mkdir -p ~/miniconda3
curl https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -o ~/miniconda3/miniconda.sh
bash ~/miniconda3/miniconda.sh -b -u -p ~/miniconda3
rm ~/miniconda3/miniconda.sh
echo "##vso[task.setvariable variable=CONDA;]${HOME}/miniconda3"
displayName: Install miniconda
condition: startsWith(variables.image, 'macos')
- bash: echo "##vso[task.prependpath]$CONDA/bin"
displayName: Add conda to PATH
condition: or(startsWith(variables.image, 'macos'), startsWith(variables.image, 'ubuntu'))
Expand Down
12 changes: 9 additions & 3 deletions fipy/variables/operatorVariable.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ def _py3kInstructions(self, op, style, argDict, id, freshen):
stack.append(stack.pop() + "(" + ", ".join(args + kwargs) + ")")
elif ins.opname == 'LOAD_DEREF':
# Changed in Python 3.11
stack.append(op.__closure__[ins.arg-1].cell_contents)
stack.append(ins.argrepr)
elif ins.opname == 'RESUME':
# New in Python 3.11
pass
Expand All @@ -250,8 +250,8 @@ def _py3kInstructions(self, op, style, argDict, id, freshen):
pass
elif ins.opname == 'CALL':
# New in Python 3.11
kwargs = [kw + "=" + str(stack.pop()) for kw in kws]
positionals = [stack.pop() for _ in range(ins.argval - len(kws))]
kwargs = [kw + "=" + str(stack.pop()) for kw in kws][::-1]
positionals = [stack.pop() for _ in range(ins.argval - len(kws))][::-1]
callable = stack.pop()
if len(stack) > 0:
call_self = callable
Expand Down Expand Up @@ -1257,6 +1257,12 @@ def _testBinOp(self):
[[ 0 1 2 3 4 5 6 7 8]
[ 0 -1 -2 -3 -4 -5 -6 -7 -8]]
Test operator variable with unusual index argument
>>> vcv.dot(vcv) # doctest: +ELLIPSIS
(...MeshVariable._dot(CellVariable(value=array([[0, 1, 2],
[1, 2, 3]]), mesh=UniformGrid2D(dx=1.0, nx=3, dy=1.0, ny=1)), CellVariable(value=array([[0, 1, 2],
[1, 2, 3]]), mesh=UniformGrid2D(dx=1.0, nx=3, dy=1.0, ny=1)), index))
"""
pass

Expand Down

0 comments on commit fe5bf86

Please sign in to comment.