Skip to content

Commit

Permalink
Use Sympy 1.5 (#79)
Browse files Browse the repository at this point in the history
The following changes have been made:

* All derivative operators return a scalar or an ImmutableDenseMatrix
* Allow sympy-1.5 in setup.py
  • Loading branch information
saidctb authored Sep 21, 2020
1 parent bf66f67 commit 7b5e484
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

# Dependencies
install_requires = [
'sympy>=1.2,<1.5',
'sympy>=1.2,<1.6',
'h5py',
'pytest',
'pyyaml',
Expand Down
32 changes: 16 additions & 16 deletions sympde/topology/derivatives.py
Original file line number Diff line number Diff line change
Expand Up @@ -577,10 +577,10 @@ def eval(cls, *_args):
line = [dx(u)[0,i], dy(u)[0,i]]
lines.append(line)

v = Matrix(lines)
v = ImmutableDenseMatrix(lines)

else:
v = Matrix((dx(u), dy(u)))
v = ImmutableDenseMatrix([[dx(u)], [dy(u)]])

return v

Expand All @@ -602,10 +602,10 @@ def eval(cls, *_args):
line = [dx(u)[0,i], dy(u)[0,i], dz(u)[0,i]]
lines.append(line)

v = Matrix(lines)
v = ImmutableDenseMatrix(lines)

else:
v = Matrix((dx(u), dy(u), dz(u)))
v = ImmutableDenseMatrix([[dx(u)], [dy(u)], [dz(u)]])

return v

Expand Down Expand Up @@ -657,9 +657,9 @@ def eval(cls, *_args):

u = _args[0]

return Matrix((dy(u[2]) - dz(u[1]),
dz(u[0]) - dx(u[2]),
dx(u[1]) - dy(u[0])))
return ImmutableDenseMatrix([[dy(u[2]) - dz(u[1])],
[dz(u[0]) - dx(u[2])],
[dx(u[1]) - dy(u[0])]])

#==============================================================================
class Rot_2d(CalculusFunction):
Expand Down Expand Up @@ -695,7 +695,7 @@ def eval(cls, *_args):

u = _args[0]

return Matrix([[dy(u),-dx(u)]]).T
return ImmutableDenseMatrix([[dy(u)],[-dx(u)]])

#==============================================================================
class DivBasic(CalculusFunction):
Expand Down Expand Up @@ -878,7 +878,7 @@ def eval(cls, *_args):
if isinstance(u, (VectorTestFunction, VectorField)):
raise NotImplementedError('TODO')

return Matrix([[dx(dx(u)), dx(dy(u))],
return ImmutableDenseMatrix([[dx(dx(u)), dx(dy(u))],
[dx(dy(u)), dy(dy(u))]])

class Hessian_3d(HessianBasic):
Expand All @@ -893,7 +893,7 @@ def eval(cls, *_args):
if isinstance(u, (VectorTestFunction, VectorField)):
raise NotImplementedError('TODO')

return Matrix([[dx(dx(u)), dx(dy(u)), dx(dz(u))],
return ImmutableDenseMatrix([[dx(dx(u)), dx(dy(u)), dx(dz(u))],
[dx(dy(u)), dy(dy(u)), dy(dz(u))],
[dx(dz(u)), dy(dz(u)), dz(dz(u))]])

Expand Down Expand Up @@ -962,7 +962,7 @@ def eval(cls, *_args):
v = ImmutableDenseMatrix(lines)

else:
v = ImmutableDenseMatrix((dx1(u), dx2(u)))
v = ImmutableDenseMatrix([[dx1(u)], [dx2(u)]])

return v

Expand All @@ -986,7 +986,7 @@ def eval(cls, *_args):
v = ImmutableDenseMatrix(lines)

else:
v = ImmutableDenseMatrix((dx1(u), dx2(u), dx3(u)))
v = ImmutableDenseMatrix([[dx1(u)], [dx2(u)], [dx3(u)]])

return v

Expand Down Expand Up @@ -1014,9 +1014,9 @@ def eval(cls, *_args):

u = _args[0]

return ImmutableDenseMatrix((dx2(u[2]) - dx3(u[1]),
dx3(u[0]) - dx1(u[2]),
dx1(u[1]) - dx2(u[0])))
return ImmutableDenseMatrix([[dx2(u[2]) - dx3(u[1])],
[dx3(u[0]) - dx1(u[2])],
[dx1(u[1]) - dx2(u[0])]])

#==============================================================================
class LogicalRot_2d(CalculusFunction):
Expand Down Expand Up @@ -1052,7 +1052,7 @@ def eval(cls, *_args):

u = _args[0]

return ImmutableDenseMatrix([[dx2(u),-dx1(u)]]).T
return ImmutableDenseMatrix([[dx2(u)],[-dx1(u)]])

#==============================================================================
class LogicalDiv_1d(DivBasic):
Expand Down

0 comments on commit 7b5e484

Please sign in to comment.