Skip to content

Update LocalScoreFunctionClass to fix issue calling local_score_BIC_from_cov #216

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

Merged
merged 2 commits into from
Jan 11, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions causallearn/score/LocalScoreFunctionClass.py
Original file line number Diff line number Diff line change
@@ -29,7 +29,7 @@ def __init__(
self.parameters = parameters
self.score_cache = {}

if self.local_score_fun == local_score_BIC_from_cov:
if self.local_score_fun.__name__ == 'local_score_BIC_from_cov':
self.cov = np.cov(self.data.T)
self.n = self.data.shape[0]

@@ -40,15 +40,15 @@ def score(self, i: int, PAi: List[int]) -> float:
hash_key = tuple(sorted(PAi))

if not self.score_cache[i].__contains__(hash_key):
if self.local_score_fun == local_score_BIC_from_cov:
if self.local_score_fun.__name__ == 'local_score_BIC_from_cov':
self.score_cache[i][hash_key] = self.local_score_fun((self.cov, self.n), i, PAi, self.parameters)
else:
self.score_cache[i][hash_key] = self.local_score_fun(self.data, i, PAi, self.parameters)

return self.score_cache[i][hash_key]

def score_nocache(self, i: int, PAi: List[int]) -> float:
if self.local_score_fun == local_score_BIC_from_cov:
if self.local_score_fun.__name__ == 'local_score_BIC_from_cov':
return self.local_score_fun((self.cov, self.n), i, PAi, self.parameters)
else:
return self.local_score_fun(self.data, i, PAi, self.parameters)
return self.local_score_fun(self.data, i, PAi, self.parameters)
2 changes: 1 addition & 1 deletion causallearn/search/PermutationBased/BOSS.py
Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@

def boss(
X: np.ndarray,
score_func: str = "local_score_BIC",
score_func: str = "local_score_BIC_from_cov",
parameters: Optional[Dict[str, Any]] = None,
verbose: Optional[bool] = True,
node_names: Optional[List[str]] = None,