@@ -28,7 +28,7 @@ class NotLoaded:
2828
2929 # the implementation of the class below is inspired by the 'ConstrainedBytes' class
3030 # from the types.py module of the 'pydantic' library
31- class ConstrainedArrayImpl (Array ):
31+ class CheckedArrayImpl (Array ):
3232 expected_axes : AxisCollection
3333 dtype : np .dtype = np .dtype (float )
3434
@@ -73,10 +73,10 @@ def validate(cls, value, field: ModelField):
7373 # the implementation of the function below is inspired by the 'conbytes' function
7474 # from the types.py module of the 'pydantic' library
7575
76- def ConstrainedArray (axes : AxisCollection , dtype : np .dtype = float ) -> Type [Array ]:
76+ def CheckedArray (axes : AxisCollection , dtype : np .dtype = float ) -> Type [Array ]:
7777 # XXX: for a very weird reason I don't know, I have to put the fake import below
7878 # to get autocompletion from PyCharm
79- from larray .core .constrained import ConstrainedArrayImpl
79+ from larray .core .checked import CheckedArrayImpl
8080 """
8181 Represents a constrained array.
8282 Its axes are assumed to be "frozen", meaning they are constant all along the execution of the program.
@@ -98,13 +98,13 @@ def ConstrainedArray(axes: AxisCollection, dtype: np.dtype = float) -> Type[Arra
9898 axes = AxisCollection (axes )
9999 _dtype = np .dtype (dtype )
100100
101- class ConstrainedArrayValue ( ConstrainedArrayImpl ):
101+ class CheckedArrayValue ( CheckedArrayImpl ):
102102 expected_axes = axes
103103 dtype = _dtype
104104
105- return ConstrainedArrayValue
105+ return CheckedArrayValue
106106
107- class AbstractConstrainedSession :
107+ class AbstractCheckedSession :
108108 pass
109109
110110 # Simplified version of the ModelMetaclass class from pydantic:
@@ -125,7 +125,7 @@ def __new__(mcs, name, bases, namespace, **kwargs):
125125 validators : Dict [str , List [Validator ]] = {}
126126
127127 for base in reversed (bases ):
128- if issubclass (base , AbstractConstrainedSession ) and base != AbstractConstrainedSession :
128+ if issubclass (base , AbstractCheckedSession ) and base != AbstractCheckedSession :
129129 config = inherit_config (base .__config__ , config )
130130 fields .update (deepcopy (base .__fields__ ))
131131 validators = inherit_validators (base .__validators__ , validators )
@@ -147,7 +147,7 @@ def __new__(mcs, name, bases, namespace, **kwargs):
147147 # extract and build fields
148148 class_vars = set ()
149149 if (namespace .get ('__module__' ), namespace .get ('__qualname__' )) != \
150- ('larray.core.constrained ' , 'ConstrainedSession ' ):
150+ ('larray.core.checked ' , 'CheckedSession ' ):
151151 untouched_types = UNTOUCHED_TYPES + config .keep_untouched
152152
153153 # annotation only fields need to come first in fields
@@ -190,12 +190,12 @@ def __new__(mcs, name, bases, namespace, **kwargs):
190190 }
191191 return super ().__new__ (mcs , name , bases , new_namespace , ** kwargs )
192192
193- class ConstrainedSession (Session , AbstractConstrainedSession , metaclass = ModelMetaclass ):
193+ class CheckedSession (Session , AbstractCheckedSession , metaclass = ModelMetaclass ):
194194 """
195195 This class is intended to be inherited by user defined classes in which the variables of a model are declared.
196196 Each declared variable is constrained by a type defined explicitly or deduced from the given default value
197197 (see examples below).
198- All classes inheriting from `ConstrainedSession ` will have access to all methods of the
198+ All classes inheriting from `CheckedSession ` will have access to all methods of the
199199 :py:class:`Session` class.
200200
201201 The special :py:funct:`ConstantAxesArray` type represents an Array object with constant axes.
@@ -207,7 +207,7 @@ class ConstrainedSession(Session, AbstractConstrainedSession, metaclass=ModelMet
207207 to enter after only a few characters have been typed).
208208
209209 As for normal Session objects, it is still possible to add undeclared variables to instances of
210- classes inheriting from `ConstrainedSession ` but this must be done with caution.
210+ classes inheriting from `CheckedSession ` but this must be done with caution.
211211
212212 Parameters
213213 ----------
@@ -223,8 +223,8 @@ class ConstrainedSession(Session, AbstractConstrainedSession, metaclass=ModelMet
223223
224224 Warnings
225225 --------
226- The :py:method:`ConstrainedSession .filter`, :py:method:`ConstrainedSession .compact`
227- and :py:method:`ConstrainedSession .apply` methods return a simple Session object.
226+ The :py:method:`CheckedSession .filter`, :py:method:`CheckedSession .compact`
227+ and :py:method:`CheckedSession .apply` methods return a simple Session object.
228228 The type of the declared variables (and the value for the declared constants) will
229229 no longer be checked.
230230
@@ -246,7 +246,7 @@ class ConstrainedSession(Session, AbstractConstrainedSession, metaclass=ModelMet
246246
247247 Content of file 'model.py'
248248
249- >>> class ModelVariables(ConstrainedSession ):
249+ >>> class ModelVariables(CheckedSession ):
250250 ... # --- declare variables with defined types ---
251251 ... # Their values will be defined at runtime but must match the specified type.
252252 ... variant_name: str
@@ -260,10 +260,10 @@ class ConstrainedSession(Session, AbstractConstrainedSession, metaclass=ModelMet
260260 ... # --- declare constrained arrays ---
261261 ... # the constrained arrays have axes assumed to be "frozen", meaning they are
262262 ... # constant all along the execution of the program.
263- ... mortality_rate: ConstrainedArray ((AGE, GENDER))
263+ ... mortality_rate: CheckedArray ((AGE, GENDER))
264264 ... # for constrained arrays, the default value can be given as a scalar.
265265 ... # A dtype can be also optionally specified (defaults to float).
266- ... deaths: ConstrainedArray ((AGE, GENDER, TIME), dtype=int) = 0
266+ ... deaths: CheckedArray ((AGE, GENDER, TIME), dtype=int) = 0
267267
268268 >>> variant_name = 'variant_1'
269269 >>> # instantiation --> create an instance of the ModelVariables class
@@ -455,9 +455,9 @@ def dict(self, exclude: Set[str] = None):
455455 del d [name ]
456456 return d
457457
458- class Parameters (ConstrainedSession ):
458+ class Parameters (CheckedSession ):
459459 """
460- Same as py:class:`ConstrainedSession ` but declared variables cannot be modified after initialization.
460+ Same as py:class:`CheckedSession ` but declared variables cannot be modified after initialization.
461461
462462 Parameters
463463 ----------
@@ -473,7 +473,7 @@ class Parameters(ConstrainedSession):
473473
474474 See Also
475475 --------
476- ConstrainedSession
476+ CheckedSession
477477
478478 Examples
479479 --------
@@ -513,12 +513,12 @@ class Config:
513513 allow_mutation = False
514514
515515else :
516- def ConstrainedArray (axes : AxisCollection , dtype : np .dtype = float ) -> Type [Array ]:
517- raise NotImplementedError ("ConstrainedArray cannot be used because pydantic is not installed" )
516+ def CheckedArray (axes : AxisCollection , dtype : np .dtype = float ) -> Type [Array ]:
517+ raise NotImplementedError ("CheckedArray cannot be used because pydantic is not installed" )
518518
519- class ConstrainedSession (object ):
519+ class CheckedSession (object ):
520520 def __init__ (self , * args , ** kwargs ):
521- raise NotImplementedError ("ConstrainedSession class cannot be instantiated "
521+ raise NotImplementedError ("CheckedSession class cannot be instantiated "
522522 "because pydantic is not installed" )
523523
524524 class Parameters (object ):
0 commit comments