Blob Blame History Raw
From 9fbe55494c62727006f143dc66cf6423c0884a56 Mon Sep 17 00:00:00 2001
From: Chris Markiewicz <effigies@gmail.com>
Date: Wed, 5 Apr 2023 13:46:10 -0400
Subject: [PATCH] FIX: Rename setattr_on_read to auto_attr

---
 nipy/algorithms/statistics/models/model.py    |  8 ++---
 .../statistics/models/regression.py           | 30 +++++++++----------
 nipy/core/image/image.py                      | 12 ++++----
 3 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/nipy/algorithms/statistics/models/model.py b/nipy/algorithms/statistics/models/model.py
index 88a46e3d77..b3535bc626 100644
--- a/nipy/algorithms/statistics/models/model.py
+++ b/nipy/algorithms/statistics/models/model.py
@@ -6,7 +6,7 @@
 
 from scipy.stats import t as t_distribution
 
-from nibabel.onetime import setattr_on_read
+from nibabel.onetime import auto_attr
 
 from ...utils.matrices import pos_recipr
 
@@ -121,14 +121,14 @@ def __init__(self, theta, Y, model, cov=None, dispersion=1., nuisance=None,
         # put this as a parameter of LikelihoodModel
         self.df_resid = self.df_total - self.df_model
 
-    @setattr_on_read
+    @auto_attr
     def logL(self):
         """
         The maximized log-likelihood
         """
         return self.model.logL(self.theta, self.Y, nuisance=self.nuisance)
 
-    @setattr_on_read
+    @auto_attr
     def AIC(self):
         """
         Akaike Information Criterion
@@ -136,7 +136,7 @@ def AIC(self):
         p = self.theta.shape[0]
         return -2 * self.logL + 2 * p
 
-    @setattr_on_read
+    @auto_attr
     def BIC(self):
         """
         Schwarz's Bayesian Information Criterion
diff --git a/nipy/algorithms/statistics/models/regression.py b/nipy/algorithms/statistics/models/regression.py
index 947950d1ee..e665936c09 100644
--- a/nipy/algorithms/statistics/models/regression.py
+++ b/nipy/algorithms/statistics/models/regression.py
@@ -30,7 +30,7 @@
 from scipy import stats
 import scipy.linalg as spl
 
-from nibabel.onetime import setattr_on_read
+from nibabel.onetime import auto_attr
 
 from nipy.algorithms.utils.matrices import matrix_rank, pos_recipr
 
@@ -262,7 +262,7 @@ def whiten(self, X):
         """
         return X
 
-    @setattr_on_read
+    @auto_attr
     def has_intercept(self):
         """
         Check if column of 1s is in column space of design
@@ -274,7 +274,7 @@ def has_intercept(self):
             return True
         return False
 
-    @setattr_on_read
+    @auto_attr
     def rank(self):
         """ Compute rank of design matrix
         """
@@ -715,14 +715,14 @@ def __init__(self, theta, Y, model, wY, wresid, cov=None, dispersion=1.,
         self.wY = wY
         self.wresid = wresid
 
-    @setattr_on_read
+    @auto_attr
     def resid(self):
         """
         Residuals from the fit.
         """
         return self.Y - self.predicted
 
-    @setattr_on_read
+    @auto_attr
     def norm_resid(self):
         """
         Residuals, normalized to have unit length.
@@ -742,7 +742,7 @@ def norm_resid(self):
         """
         return self.resid * pos_recipr(np.sqrt(self.dispersion))
 
-    @setattr_on_read
+    @auto_attr
     def predicted(self):
         """ Return linear predictor values from a design matrix.
         """
@@ -751,7 +751,7 @@ def predicted(self):
         X = self.model.design
         return np.dot(X, beta)
 
-    @setattr_on_read
+    @auto_attr
     def R2_adj(self):
         """Return the R^2 value for each row of the response Y.
 
@@ -768,7 +768,7 @@ def R2_adj(self):
         d *= ((self.df_total - 1.) / self.df_resid)
         return 1 - d
 
-    @setattr_on_read
+    @auto_attr
     def R2(self):
         """
         Return the adjusted R^2 value for each row of the response Y.
@@ -782,7 +782,7 @@ def R2(self):
         d = self.SSE / self.SST
         return 1 - d
 
-    @setattr_on_read
+    @auto_attr
     def SST(self):
         """Total sum of squares. If not from an OLS model this is "pseudo"-SST.
         """
@@ -791,34 +791,34 @@ def SST(self):
                           "SST inappropriate")
         return ((self.wY - self.wY.mean(0)) ** 2).sum(0)
 
-    @setattr_on_read
+    @auto_attr
     def SSE(self):
         """Error sum of squares. If not from an OLS model this is "pseudo"-SSE.
         """
         return (self.wresid ** 2).sum(0)
 
-    @setattr_on_read
+    @auto_attr
     def SSR(self):
         """ Regression sum of squares """
         return self.SST - self.SSE
 
-    @setattr_on_read
+    @auto_attr
     def MSR(self):
         """ Mean square (regression)"""
         return self.SSR / (self.df_model - 1)
 
-    @setattr_on_read
+    @auto_attr
     def MSE(self):
         """ Mean square (error) """
         return self.SSE / self.df_resid
 
-    @setattr_on_read
+    @auto_attr
     def MST(self):
         """ Mean square (total)
         """
         return self.SST / (self.df_total - 1)
 
-    @setattr_on_read
+    @auto_attr
     def F_overall(self):
         """ Overall goodness of fit F test,
         comparing model to a model with just an intercept.
diff --git a/nipy/core/image/image.py b/nipy/core/image/image.py
index 96c4859674..1b2e7ba0ee 100644
--- a/nipy/core/image/image.py
+++ b/nipy/core/image/image.py
@@ -19,7 +19,7 @@
 
 import numpy as np
 
-from nibabel.onetime import setattr_on_read
+from nibabel.onetime import auto_attr
 
 # These imports are used in the fromarray and subsample functions only, not in
 # Image
@@ -80,27 +80,27 @@ class Image(object):
                                np.diag([3,5,7,1]))
     _doc['coordmap'] = "Affine transform mapping from axes coordinates to reference coordinates."
 
-    @setattr_on_read
+    @auto_attr
     def shape(self):
         return self._data.shape
     _doc['shape'] = "Shape of data array."
 
-    @setattr_on_read
+    @auto_attr
     def ndim(self):
         return len(self._data.shape)
     _doc['ndim'] = "Number of data dimensions."
 
-    @setattr_on_read
+    @auto_attr
     def reference(self):
         return self.coordmap.function_range
     _doc['reference'] = "Reference coordinate system."
 
-    @setattr_on_read
+    @auto_attr
     def axes(self):
         return self.coordmap.function_domain
     _doc['axes'] = "Axes of image."
 
-    @setattr_on_read
+    @auto_attr
     def affine(self):
         if hasattr(self.coordmap, "affine"):
             return self.coordmap.affine