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

Boa: magic functions are not working as expected #66

Closed
rickycao-qy opened this issue Apr 2, 2020 · 1 comment
Closed

Boa: magic functions are not working as expected #66

rickycao-qy opened this issue Apr 2, 2020 · 1 comment
Assignees
Labels
boa Python related issues bug Something isn't working

Comments

@rickycao-qy
Copy link
Collaborator

rickycao-qy commented Apr 2, 2020

This bug is likely related to #61
Now calling magic function directly is working file. But use system built-in function to call it is giving errors. For example

const boa = require('../packages/boa');
const torch = boa.import('torch');
const {len} = boa.builtins();

class customDataset extends torch.utils.data.Dataset {
  __len__() {
    return 5;
  }
  __getitem__(index) {
    return 2;
  }
}

const dataset =  new customDataset();
console.log(dataset.__len__());  # This is wokring fine
console.log(len(dataset));  # This gives errors

Accordingly in raw python, this is working:

import sys
import torch

class customDataset( torch.utils.data.Dataset ):
  def __len__(self): 
    return 5
  
  def __getitem__(self, index): 
    return 2
  

dataset = customDataset()

print(dataset.__len__())
print(len(dataset))
@rickycao-qy rickycao-qy added bug Something isn't working boa Python related issues labels Apr 2, 2020
@yorkie
Copy link
Member

yorkie commented Apr 2, 2020

It seems that some operations in class initialization are lost.

@yorkie yorkie closed this as completed Apr 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
boa Python related issues bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants