Skip to content

Instantly share code, notes, and snippets.

@paugier
Created November 14, 2018 05:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paugier/7f9db3a3690758483108788d124e441a to your computer and use it in GitHub Desktop.
Save paugier/7f9db3a3690758483108788d124e441a to your computer and use it in GitHub Desktop.
pythran dataclass
from dataclasses import dataclass
@dataclass
class Base:
a: "float[:, :]"
b: "float[:, :]"
c: "float[:, :]"
def intermediate(self, d: int):
print("intermediate Base class")
return self.a ** d
def compute(self, e: int):
return self.intermediate(e) + self.b * self.c
import numpy as np
class Child(Base):
def __init__(self, myinput):
a = b = c = myinput * np.ones((2, 2))
super().__init__(a, b, c)
def intermediate(self, d):
print("intermediate Child class")
return self.b ** d
if __name__ == "__main__":
child = Child(1)
child.compute(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment