@@ -183,12 +183,11 @@ class TimingModel:
183
183
removed with methods on this object, and for many of them additional
184
184
parameters in families (``DMXEP_1234``) can be added.
185
185
186
- Parameters in a TimingModel object are listed in the ``model.params`` and
187
- ``model.params_ordered`` objects. Each Parameter can be set as free or
188
- frozen using its ``.frozen`` attribute, and a list of the free parameters
189
- is available through the ``model.free_params`` property; this can also
190
- be used to set which parameters are free. Several methods are available
191
- to get and set some or all parameters in the forms of dictionaries.
186
+ Parameters in a TimingModel object are listed in the ``model.params`` object.
187
+ Each Parameter can be set as free or frozen using its ``.frozen`` attribute,
188
+ and a list of the free parameters is available through the ``model.free_params``
189
+ property; this can also be used to set which parameters are free. Several methods
190
+ are available to get and set some or all parameters in the forms of dictionaries.
192
191
193
192
TimingModel objects also support a number of functions for computing
194
193
various things like orbital phase, and barycentric versions of TOAs,
@@ -500,20 +499,30 @@ def __getattr__(self, name):
500
499
)
501
500
502
501
@property_exists
503
- def params (self ):
504
- """List of all parameter names in this model and all its components (order is arbitrary)."""
505
- # FIXME: any reason not to just use params_ordered here?
506
- p = self .top_level_params
507
- for cp in self .components .values ():
508
- p = p + cp .params
509
- return p
502
+ def params_ordered (self ):
503
+ """List of all parameter names in this model and all its components.
504
+ This is the same as `params`."""
505
+
506
+ # Historically, this was different from `params` because Python
507
+ # dictionaries were unordered until Python 3.7. Now there is no reason for
508
+ # them to be different.
509
+
510
+ warn (
511
+ "`TimingModel.params_ordered` is now deprecated and may be removed in the future. "
512
+ "Use `TimingModel.params` instead. It gives the same output as `TimingModel.params_ordered`." ,
513
+ DeprecationWarning ,
514
+ )
515
+
516
+ return self .params
510
517
511
518
@property_exists
512
- def params_ordered (self ):
519
+ def params (self ):
513
520
"""List of all parameter names in this model and all its components, in a sensible order."""
521
+
514
522
# Define the order of components in the list
515
523
# Any not included will be printed between the first and last set.
516
524
# FIXME: make order completely canonical (sort components by name?)
525
+
517
526
start_order = ["astrometry" , "spindown" , "dispersion" ]
518
527
last_order = ["jump_delay" ]
519
528
compdict = self .get_components_by_category ()
@@ -551,15 +560,15 @@ def params_ordered(self):
551
560
def free_params (self ):
552
561
"""List of all the free parameters in the timing model. Can be set to change which are free.
553
562
554
- These are ordered as ``self.params_ordered `` does.
563
+ These are ordered as ``self.params `` does.
555
564
556
565
Upon setting, order does not matter, and aliases are accepted.
557
566
ValueError is raised if a parameter is not recognized.
558
567
559
568
On setting, parameter aliases are converted with
560
569
:func:`pint.models.timing_model.TimingModel.match_param_aliases`.
561
570
"""
562
- return [p for p in self .params_ordered if not getattr (self , p ).frozen ]
571
+ return [p for p in self .params if not getattr (self , p ).frozen ]
563
572
564
573
@free_params .setter
565
574
def free_params (self , params ):
@@ -620,7 +629,7 @@ def get_params_dict(self, which="free", kind="quantity"):
620
629
if which == "free" :
621
630
ps = self .free_params
622
631
elif which == "all" :
623
- ps = self .params_ordered
632
+ ps = self .params
624
633
else :
625
634
raise ValueError ("get_params_dict expects which to be 'all' or 'free'" )
626
635
c = OrderedDict ()
@@ -2014,10 +2023,7 @@ def compare(
2014
2023
log .debug ("Check verbosity - only warnings/info will be displayed" )
2015
2024
othermodel = copy .deepcopy (othermodel )
2016
2025
2017
- if (
2018
- "POSEPOCH" in self .params_ordered
2019
- and "POSEPOCH" in othermodel .params_ordered
2020
- ):
2026
+ if "POSEPOCH" in self .params and "POSEPOCH" in othermodel .params :
2021
2027
if (
2022
2028
self .POSEPOCH .value is not None
2023
2029
and othermodel .POSEPOCH .value is not None
@@ -2028,7 +2034,7 @@ def compare(
2028
2034
% (other_model_name , model_name )
2029
2035
)
2030
2036
othermodel .change_posepoch (self .POSEPOCH .value )
2031
- if "PEPOCH" in self .params_ordered and "PEPOCH" in othermodel .params_ordered :
2037
+ if "PEPOCH" in self .params and "PEPOCH" in othermodel .params :
2032
2038
if (
2033
2039
self .PEPOCH .value is not None
2034
2040
and self .PEPOCH .value != othermodel .PEPOCH .value
@@ -2037,7 +2043,7 @@ def compare(
2037
2043
"Updating PEPOCH in %s to match %s" % (other_model_name , model_name )
2038
2044
)
2039
2045
othermodel .change_pepoch (self .PEPOCH .value )
2040
- if "DMEPOCH" in self .params_ordered and "DMEPOCH" in othermodel .params_ordered :
2046
+ if "DMEPOCH" in self .params and "DMEPOCH" in othermodel .params :
2041
2047
if (
2042
2048
self .DMEPOCH .value is not None
2043
2049
and self .DMEPOCH .value != othermodel .DMEPOCH .value
@@ -2072,7 +2078,7 @@ def compare(
2072
2078
f"{ model_name } is in ECL({ self .ECL .value } ) coordinates but { other_model_name } is in ICRS coordinates and convertcoordinates=False"
2073
2079
)
2074
2080
2075
- for pn in self .params_ordered :
2081
+ for pn in self .params :
2076
2082
par = getattr (self , pn )
2077
2083
if par .value is None :
2078
2084
continue
@@ -2299,8 +2305,8 @@ def compare(
2299
2305
)
2300
2306
2301
2307
# Now print any parameters in othermodel that were missing in self.
2302
- mypn = self .params_ordered
2303
- for opn in othermodel .params_ordered :
2308
+ mypn = self .params
2309
+ for opn in othermodel .params :
2304
2310
if opn in mypn and getattr (self , opn ).value is not None :
2305
2311
continue
2306
2312
if nodmx and opn .startswith ("DMX" ):
0 commit comments