Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot create sciline.Scope subclass instance from Scipp object returned by scipp.Variable.value #52

Open
SimonHeybrock opened this issue Sep 6, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@SimonHeybrock
Copy link
Member

SimonHeybrock commented Sep 6, 2023

import scipp as sc
import sciline as sl
from typing import TypeVar

Param = TypeVar('Param')

var = sc.scalar(sc.scalar(1.0))

class A(sl.Scope[Param, sc.Variable], sc.Variable):
    ...

A[Param](var.value)

raises TypeError: scipp._scipp.core.Variable.__init__() must be called when overriding __init__. Same problem with, e.g., sc.DataArray.

  • Changing to A[Param](var.value.copy()) fixes this.
  • Using other dtype such as int or float is fine.

This must be related to how we return references to scipp-objects from the value property in Scipp. I have no idea how this can interfere with what we are doing in sciline.Scope.

@SimonHeybrock SimonHeybrock added the bug Something isn't working label Sep 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant