Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • pystencils pystencils
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 18
    • Issues 18
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 6
    • Merge requests 6
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • pycodegen
  • pystencilspystencils
  • Issues
  • #23
Closed
Open
Issue created Jul 06, 2020 by Michael Kuron@kuronMaintainer

Cannot simplify piecewise function with field access in condition

This fails:

from pystencils.session import *
dh = ps.create_data_handling((20,20))
ρ = dh.add_array('rho')
pw = sp.Piecewise((0, 1 < sp.Max(-0.5, ρ.center+0.5)), (1, True))
sp.simplify(pw)

with the following error:

./pystencils/pystencils/field.py in __iter__(self)
    760             """This is necessary to work with parts of sympy that test if an object is iterable (e.g. simplify).
    761             The __getitem__ would make it iterable"""
--> 762             raise TypeError("Field access is not iterable")
    763 
    764         @property

TypeError: Field access is not iterable

Here are two similar examples that do not produce such an error:

s = sp.Symbol("s")
pw = sp.Piecewise((0, 1 < sp.Max(-0.5, s+0.5)), (1, True))
sp.simplify(pw)

pw = sp.Piecewise((0, 1 < ρ.center+0.5), (1, True))
sp.simplify(pw)
Assignee
Assign to
Time tracking