Skip to content

Commit

Permalink
add model_mat_kwarg_name
Browse files Browse the repository at this point in the history
  • Loading branch information
jwdink committed Dec 12, 2024
1 parent 8f1001b commit 62ae734
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions torchcast/process/regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ def __init__(self,
predictors: Sequence[str],
measure: Optional[str] = None,
fixed: bool = True,
decay: Optional[Tuple[float, float]] = None):
decay: Optional[Tuple[float, float]] = None,
model_mat_kwarg_name: str = 'X'):

super().__init__(
id=id,
Expand All @@ -50,7 +51,7 @@ def __init__(self,
if isinstance(decay, tuple):
decay = SingleOutput(numel=len(predictors), transform=Bounded(*decay))
self.f_modules['all_self'] = decay
self.expected_kwargs = ['X']
self.expected_kwargs = [model_mat_kwarg_name]

def _build_h_mat(self, inputs: Dict[str, torch.Tensor], num_groups: int, num_times: int) -> torch.Tensor:
# if not torch.jit.is_scripting():
Expand All @@ -59,7 +60,7 @@ def _build_h_mat(self, inputs: Dict[str, torch.Tensor], num_groups: int, num_tim
# except KeyError as e:
# raise TypeError(f"Missing required keyword-arg `X` (or `{self.id}__X`).") from e
# else:
X = inputs['X']
X = inputs[self.expected_kwargs[0]]
assert not torch.isnan(X).any()
assert not torch.isinf(X).any()

Expand Down

0 comments on commit 62ae734

Please sign in to comment.