Skip to content
Snippets Groups Projects
Commit 1d928851 authored by Kostas Vilkelis's avatar Kostas Vilkelis :flamingo:
Browse files

use argspec instead to obtain args

parent 8f411318
No related branches found
No related tags found
1 merge request!8Builder fixes
Pipeline #180710 passed
This commit is part of merge request !8. Comments created here will be created in the context of that merge request.
from itertools import product
from typing import Callable
import inspect
import numpy as np
from scipy.sparse import coo_array
......@@ -8,6 +9,7 @@ from kwant.builder import Site
import kwant.lattice
import kwant.builder
from meanfi.tb.tb import _tb_type
......@@ -49,7 +51,7 @@ def builder_to_tb(
row, col = np.array([*product(tb_idx, tb_idx)]).T
if callable(val):
param_keys = val.__code__.co_varnames[1:]
param_keys = inspect.getfullargspec(val).args[1:]
try:
val = val(site, *[params[key] for key in param_keys])
except KeyError as key:
......@@ -74,7 +76,7 @@ def builder_to_tb(
row, col = np.array([*product(tb_idx1, tb_idx2)]).T
if callable(val):
param_keys = val.__code__.co_varnames[2:]
param_keys = inspect.getfullargspec(val).args[2:]
try:
val = val(site1, site2, *[params[key] for key in param_keys])
except KeyError as key:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment