Skip to content

Commit 67d6a5b

Browse files
committed
Replace non-existent top level scipy functions.
1 parent 517e496 commit 67d6a5b

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

factor_analyzer/factor_analyzer.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ def _fit_uls_objective(psi, corr_mtx, n_factors): # noqa: D401
366366
# implemented here using `np.tril()` when this change is
367367
# merged into the stable version of `psych`.
368368
residual = (corr_mtx - model) ** 2
369-
error = sp.sum(residual)
369+
error = np.sum(residual)
370370
return error
371371

372372
@staticmethod
@@ -995,8 +995,8 @@ def sufficiency(self, num_observations: int) -> Tuple[float, int, float]:
995995
996996
References
997997
----------
998-
[1] Lawley, D. N. and Maxwell, A. E. (1971). Factor Analysis as a Statistical Method. Second edition.
999-
Butterworths. P. 36.
998+
[1] Lawley, D. N. and Maxwell, A. E. (1971). Factor Analysis as a
999+
Statistical Method. Second edition. Butterworths. P. 36.
10001000
10011001
Examples
10021002
--------

factor_analyzer/rotator.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,6 @@ def _varimax(self, loadings):
494494

495495
d = 0
496496
for _ in range(self.max_iter):
497-
498497
old_d = d
499498

500499
# take inner product of loading matrix
@@ -560,9 +559,9 @@ def _promax(self, loadings):
560559
# pre-normalization is done in R's
561560
# `kaiser()` function when rotate='Promax'.
562561
array = X.copy()
563-
h2 = sp.diag(np.dot(array, array.T))
562+
h2 = np.diag(np.dot(array, array.T))
564563
h2 = np.reshape(h2, (h2.shape[0], 1))
565-
weights = array / sp.sqrt(h2)
564+
weights = array / np.sqrt(h2)
566565

567566
else:
568567
weights = X.copy()
@@ -576,20 +575,20 @@ def _promax(self, loadings):
576575

577576
# calculate diagonal of inverse square
578577
try:
579-
diag_inv = sp.diag(sp.linalg.inv(sp.dot(coef.T, coef)))
578+
diag_inv = np.diag(sp.linalg.inv(np.dot(coef.T, coef)))
580579
except np.linalg.LinAlgError:
581-
diag_inv = sp.diag(sp.linalg.pinv(sp.dot(coef.T, coef)))
580+
diag_inv = np.diag(sp.linalg.pinv(np.dot(coef.T, coef)))
582581

583582
# transform and calculate inner products
584-
coef = sp.dot(coef, sp.diag(sp.sqrt(diag_inv)))
585-
z = sp.dot(X, coef)
583+
coef = np.dot(coef, np.diag(np.sqrt(diag_inv)))
584+
z = np.dot(X, coef)
586585

587586
if self.normalize:
588587
# post-normalization is done in R's
589588
# `kaiser()` function when rotate='Promax'
590-
z = z * sp.sqrt(h2)
589+
z = z * np.sqrt(h2)
591590

592-
rotation_mtx = sp.dot(rotation_mtx, coef)
591+
rotation_mtx = np.dot(rotation_mtx, coef)
593592

594593
coef_inv = np.linalg.inv(coef)
595594
phi = np.dot(coef_inv, coef_inv.T)

0 commit comments

Comments
 (0)