API Reference
DerivedParameter
A read-only parameter computed from other parameters.
A DerivedParameter wraps a function that maps a ParameterSet to a
scalar value. It is not sampled directly and is recomputed whenever an
instance is formed or updated.
Source code in jscip/main.py
411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 | |
compute(parameters: ParameterSet) -> float
Compute the derived value for a given parameter set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parameters
|
ParameterSet
|
The |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The computed scalar value. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in jscip/main.py
433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 | |
copy() -> DerivedParameter
Return a shallow copy preserving the underlying function.
Returns:
| Name | Type | Description |
|---|---|---|
DerivedParameter |
DerivedParameter
|
A new wrapper around the same function. |
Source code in jscip/main.py
454 455 456 457 458 459 460 461 462 | |
IndependentParameter
A real-valued parameter with optional uniform sampling over a range.
This class represents a scalar numeric parameter. When is_sampled=True, a
uniform distribution over range=(low, high) is constructed to draw
samples; otherwise the parameter is treated as fixed at value.
Attributes:
| Name | Type | Description |
|---|---|---|
value |
float
|
Current scalar value of the parameter. |
is_sampled |
float
|
Whether this parameter will be sampled from a distribution. |
range |
tuple[float, float] | None
|
Optional inclusive bounds |
Raises:
| Type | Description |
|---|---|
ValueError
|
If types are invalid, if the range is malformed, or if the value falls outside the provided range. |
Source code in jscip/main.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 | |
value: float
property
writable
Get the value of the parameter.
range: tuple[float, float] | None
property
writable
Get the range of the parameter.
sample(size: int | None = None, return_unit: bool = False) -> float | np.ndarray | object
Sample from the parameter's distribution.
If is_sampled is True, draws from a uniform distribution over
range. Otherwise, returns the fixed value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
size
|
int | None
|
Optional number of samples. If omitted, returns a scalar. |
None
|
Returns:
| Type | Description |
|---|---|
float | ndarray | object
|
float | numpy.ndarray: A single float if |
float | ndarray | object
|
a NumPy array of samples. |
Source code in jscip/main.py
297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 | |
copy() -> IndependentParameter
Return a shallow copy preserving configuration.
Returns:
| Name | Type | Description |
|---|---|---|
IndependentParameter |
IndependentParameter
|
A new parameter with the same value, range, |
IndependentParameter
|
and sampling flag. |
Source code in jscip/main.py
327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 | |
ParameterBank
A collection of parameters with sampling, constraints, and conversions.
The bank stores independent and derived parameters, optional constraint
functions, and a canonical parameter order. It can sample full parameter
instances, validate them against constraints, and convert between rich
ParameterSet and array/dataframe representations.
Source code in jscip/main.py
465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 | |
names: list[str]
property
Get the names of all parameters in the bank. This also defines the canonical order of the parameters.
sampled: list[str]
property
Get a list of all parameters that are set to be sampled.
lower_bounds: np.ndarray
property
Get the lower bounds of all sampled parameters.
upper_bounds: np.ndarray
property
Get the upper bounds of all sampled parameters.
sampled_texnames: list[str]
property
Get the TeX names of all sampled parameters.
__contains__(key: str) -> bool
Check if a parameter exists in the bank.
Source code in jscip/main.py
558 559 560 | |
__len__() -> int
Get the number of parameters in the bank.
Source code in jscip/main.py
562 563 564 | |
__iter__() -> Iterator[str]
Iterate over the parameter names in the bank.
Source code in jscip/main.py
566 567 568 | |
__getitem__(key: str) -> IndependentParameter | DerivedParameter
Get a parameter by its name.
Source code in jscip/main.py
570 571 572 573 574 575 | |
copy() -> ParameterBank
Create a copy of the ParameterBank.
Source code in jscip/main.py
577 578 579 580 581 582 583 584 585 586 | |
merge(other: 'ParameterBank') -> None
Merge another ParameterBank into this one. If a parameter with the same name exists, it will be overwritten.
Source code in jscip/main.py
594 595 596 597 598 599 600 601 602 603 604 | |
add_parameter(key: str, parameter: IndependentParameter | DerivedParameter) -> None
Add a new parameter to the bank.
Source code in jscip/main.py
606 607 608 609 610 611 612 613 614 615 616 617 | |
add_constraint(constraint: Callable[[ParameterSet], bool]) -> None
Add a new constraint to the bank.
Source code in jscip/main.py
619 620 621 622 623 624 | |
get_constraints() -> list[Callable[[ParameterSet], bool]]
Get all constraints in the bank.
Source code in jscip/main.py
626 627 628 | |
get_default_values(return_vector: bool | None = None, with_units: bool = False) -> ParameterSet | np.ndarray
Return default values for all parameters.
Computes a ParameterSet by taking the current value for all
independent parameters and computing all derived parameters from those
values. Optionally, returns the sampled subset as a NumPy array (a
parameter vector) when return_vector=True.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
return_vector
|
bool | None
|
If True, return a 1D NumPy array of sampled
parameter values in canonical sampled order. If False, return
a full |
None
|
Returns:
| Type | Description |
|---|---|
ParameterSet | ndarray
|
ParameterSet | numpy.ndarray: The default instance or the sampled |
ParameterSet | ndarray
|
values array. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in jscip/main.py
630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 | |
instance_to_vector(input: ParameterSet | list[ParameterSet]) -> np.ndarray
Convert a parameter instance (or list) to a sampled parameter vector.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input
|
ParameterSet | list[ParameterSet]
|
A single |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
numpy.ndarray: 1D array for a single instance or 2D array for a |
ndarray
|
list of instances, containing values for sampled parameters only, |
ndarray
|
in canonical sampled order. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in jscip/main.py
700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 | |
dataframe_to_vector(df: pd.DataFrame) -> np.ndarray
Extract sampled parameter columns from a DataFrame as a NumPy array.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
DataFrame containing sampled parameter columns. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
numpy.ndarray: 2D array of sampled values in canonical sampled |
ndarray
|
order. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in jscip/main.py
739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 | |
vector_to_instance(vector: np.ndarray) -> ParameterSet
Convert a parameter vector to a parameter instance.
When vector_mode is True, vector must contain only sampled
independent parameters in canonical sampled order. Otherwise, it must
contain values for all independent parameters in canonical order.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vector
|
ndarray
|
1D NumPy array. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
ParameterSet |
ParameterSet
|
A full instance with derived parameters recomputed. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If shapes are inconsistent with |
Source code in jscip/main.py
757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 | |
sample(size: int | tuple | None = None, with_units: bool = False) -> ParameterSet | pd.DataFrame | np.ndarray
Sample parameter sets or parameter vectors.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
size
|
int | tuple | None
|
If |
None
|
Returns:
| Type | Description |
|---|---|
ParameterSet | DataFrame | ndarray
|
ParameterSet | pandas.DataFrame | numpy.ndarray: Depending on |
ParameterSet | DataFrame | ndarray
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in jscip/main.py
868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 | |
instances_to_dataframe(instances: list[ParameterSet]) -> pd.DataFrame
Convert a list of parameter instances to a pandas DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
instances
|
list[ParameterSet]
|
A non-empty list of |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
pandas.DataFrame: Rows correspond to instances; columns to |
DataFrame
|
parameters in canonical order. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the input is not a non-empty list of |
Source code in jscip/main.py
961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 | |
log_prob(input: ParameterSet | pd.DataFrame | np.ndarray) -> float | np.ndarray
Compute a simple log prior for samples under uniform bounds.
Anything outside the bounds of sampled independent parameters, or
violating constraints, receives -inf; otherwise 0.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input
|
ParameterSet | DataFrame | ndarray
|
A |
required |
Returns:
| Type | Description |
|---|---|
float | ndarray
|
float | numpy.ndarray: A scalar for a single |
float | ndarray
|
NumPy array of log-probabilities for batches. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the type/shape of |
Source code in jscip/main.py
989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 | |
order(instance: ParameterSet) -> ParameterSet
Reindex an instance to the bank's canonical parameter order.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
instance
|
ParameterSet
|
The |
required |
Returns:
| Name | Type | Description |
|---|---|---|
ParameterSet |
ParameterSet
|
A new instance with parameters ordered canonically. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If reindexing fails (e.g., missing keys). |
Source code in jscip/main.py
1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 | |
summary() -> str
Return a human-readable summary of the bank configuration.
Source code in jscip/main.py
1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 | |
ParameterSet
A single parameter configuration with scalar values.
This is a thin wrapper around pandas.Series used to represent a single
instance of parameters, typically produced by sampling a ParameterBank.
It preserves the canonical parameter ordering maintained by the bank when
reindexed via ParameterBank.order.
Source code in jscip/main.py
346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 | |
satisfies(constraint: Callable[[ParameterSet], bool]) -> bool
Evaluate a boolean constraint on this instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
constraint
|
Callable[[ParameterSet], bool]
|
A callable |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the constraint is satisfied, otherwise False. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in jscip/main.py
361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 | |
copy() -> ParameterSet
Return a copy of this parameter set.
Returns:
| Name | Type | Description |
|---|---|---|
ParameterSet |
ParameterSet
|
A new instance with the same values. |
Source code in jscip/main.py
381 382 383 384 385 386 387 388 389 | |
reindex(new_index: Sequence[str]) -> ParameterSet
Reindex this instance to a new sequence of parameter names.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
new_index
|
Sequence[str]
|
Iterable of parameter names specifying the new order. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
ParameterSet |
ParameterSet
|
A new instance with the requested index. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in jscip/main.py
391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 | |