Skip to content
GitLab
  • Menu
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • T transonic
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 21
    • Issues 21
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 2
    • Merge requests 2
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • 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
  • fluiddyn
  • transonic
  • Issues
  • #35
Closed
Open
Created May 05, 2020 by Neal Becker@ndbecker

polymorphic methods supported?

The following simple test seems to indicate that polymorphic class members are not supported. It seems only the 2nd overload of call works.

Is there a workaround?

---- constellation.py ---

from transonic import boost

A = "complex[:]"
S = "int[:]"

@boost
class constellation:
    map: A

    def __init__(self, map: A):
        self.map = map
 
    @boost
    def __call__(self, s: int):
        return self.map[s]
    @boost
    def __call__(self, syms: S):
        out = np.empty(len(syms), dtype=complex)
        for i in range (len (syms)):
            out[i] = self.map[syms[i]]
        return out

--- test_constellation.py ---

from constellation import constellation
import numpy as np
A = np.array
u = A([1+0j, -1+0j])

c = constellation (u)

syms = A ([0,1])
xconst = c(syms)

x = c(0)
---> 11 x = c(0)

<string> in new_method(self, syms)

TypeError: Invalid call to pythranized function `__for_method__constellation____call__(complex128[:], int)'
Candidates are:

    - __for_method__constellation____call__(complex128[:], int[:])
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking