variable
descriptor_any_type
DescriptorAnyType
Bases: DescriptorBase
A Descriptor for any type that does not fit the other
Descriptors.
Should be avoided when possible. It was created to hold the symmetry operations used in the SpaceGroup class of EasyCrystallography.
Source code in src/easyscience/variable/descriptor_any_type.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 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 | |
__init__(name, value, unique_name=None, description=None, url=None, display_name=None, parent=None)
Constructor for the DescriptorAnyType class.
param name: Name of the descriptor
param value: Value of the descriptor
param description: Description of the descriptor
param url: URL of the descriptor
param display_name: Display name of the descriptor
param parent: Parent of the descriptor
.. note:: Undo/Redo functionality is implemented for the attributes variance, error, unit and value.
Source code in src/easyscience/variable/descriptor_any_type.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | |
__repr__()
Return a string representation of the DescriptorAnyType, showing its name and value.
Source code in src/easyscience/variable/descriptor_any_type.py
80 81 82 83 84 85 86 87 88 89 90 | |
value
property
writable
Get the value.
:return: Value of self.
descriptor_array
DescriptorArray
Bases: DescriptorBase
A Descriptor for Array values with units.
The internal representation is a scipp array.
Source code in src/easyscience/variable/descriptor_array.py
28 29 30 31 32 33 34 35 36 37 38 39 40 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 344 345 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 409 410 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 463 464 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 | |
__abs__()
Replace all elements in the DescriptorArray with their absolute values.
Note that this is different from the norm of the DescriptorArray.
Source code in src/easyscience/variable/descriptor_array.py
715 716 717 718 719 720 721 722 723 724 725 | |
__add__(other)
Perform element-wise addition with another DescriptorNumber, DescriptorArray, list, or number.
:param other: The object to add. Must be a DescriptorArray or DescriptorNumber with compatible units, or a list with the same shape if the DescriptorArray is dimensionless, or a number. :return: A new DescriptorArray representing the result of the addition.
Source code in src/easyscience/variable/descriptor_array.py
530 531 532 533 534 535 536 537 538 539 540 541 542 543 | |
__array_function__(func, types, args, kwargs)
DescriptorArray does not generally support Numpy array functions.
For example, np.argwhere(descriptorArray: DescriptorArray)
should fail. Modify this function if you want to add such
functionality.
Source code in src/easyscience/variable/descriptor_array.py
520 521 522 523 524 525 526 527 528 | |
__array_ufunc__(ufunc, method, *inputs, **kwargs)
DescriptorArray does not generally support Numpy array functions.
For example, np.argwhere(descriptorArray: DescriptorArray)
should fail. Modify this function if you want to add such
functionality.
Source code in src/easyscience/variable/descriptor_array.py
510 511 512 513 514 515 516 517 518 | |
__copy__()
Return a copy of the current DescriptorArray.
Source code in src/easyscience/variable/descriptor_array.py
327 328 329 | |
__delitem__(a)
Defer slicing to scipp.
This should fail, since scipp does not support delitem.
Source code in src/easyscience/variable/descriptor_array.py
738 739 740 741 742 743 | |
__getitem__(a)
Slice using scipp syntax.
Defer slicing to scipp.
Source code in src/easyscience/variable/descriptor_array.py
727 728 729 730 731 732 733 734 735 736 | |
__init__(name, value, unit='', variance=None, unique_name=None, description=None, url=None, display_name=None, parent=None, dimensions=None)
Constructor for the DescriptorArray class.
param name: Name of the descriptor
param value: List containing the values of the descriptor
param unit: Unit of the descriptor
param variance: Variances of the descriptor
param description: Description of the descriptor
param url: URL of the descriptor
param display_name: Display name of the descriptor
param parent: Parent of the descriptor
param dimensions: List of dimensions to pass to scipp. Will be autogenerated if not supplied.
.. note:: Undo/Redo functionality is implemented for the attributes variance, error, unit and value.
Source code in src/easyscience/variable/descriptor_array.py
34 35 36 37 38 39 40 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 | |
__mul__(other)
Perform element-wise multiplication with another DescriptorNumber, DescriptorArray, list, or number.
:param other: The object to multiply. Must be a DescriptorArray or DescriptorNumber with compatible units, or a list with the same shape if the DescriptorArray is dimensionless. :return: A new DescriptorArray representing the result of the addition.
Source code in src/easyscience/variable/descriptor_array.py
596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 | |
__neg__()
Negate all values in the DescriptorArray.
Source code in src/easyscience/variable/descriptor_array.py
708 709 710 711 712 713 | |
__pow__(other)
Perform element-wise exponentiation with another DescriptorNumber or number.
:param other: The object to use as a denominator. Must be a number or DescriptorNumber with no unit or variance. :return: A new DescriptorArray representing the result of the addition.
Source code in src/easyscience/variable/descriptor_array.py
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 | |
__radd__(other)
Handle reverse addition for DescriptorArrays, DescriptorNumbers, lists, and scalars.
Ensures unit compatibility when other is a DescriptorNumber.
Source code in src/easyscience/variable/descriptor_array.py
545 546 547 548 549 550 551 | |
__repr__()
Return a string representation of the DescriptorArray, showing its name, value, variance, and unit.
Large arrays are summarized for brevity.
Source code in src/easyscience/variable/descriptor_array.py
331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 | |
__rmul__(other)
Handle reverse multiplication for DescriptorNumbers, lists, and scalars.
Ensures unit compatibility when other is a DescriptorNumber.
Source code in src/easyscience/variable/descriptor_array.py
612 613 614 615 616 617 618 619 620 | |
__rpow__(other)
Defers reverse pow with a descriptor array, a ** array.
Exponentiation with regards to an array does not make sense, and is not implemented.
Source code in src/easyscience/variable/descriptor_array.py
700 701 702 703 704 705 706 | |
__rsub__(other)
Perform element-wise subtraction with another DescriptorNumber, list, or number.
:param other: The object to subtract. Must be a DescriptorArray with compatible units, or a list with the same shape if the DescriptorArray is dimensionless. :return: A new DescriptorArray representing the result of the subtraction.
Source code in src/easyscience/variable/descriptor_array.py
576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 | |
__rtruediv__(other)
Handle reverse division for DescriptorNumbers, lists, and scalars.
Ensures unit compatibility when other is a DescriptorNumber.
Source code in src/easyscience/variable/descriptor_array.py
649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 | |
__setitem__(a, b)
setitem via slice is not allowed, since we currently do not give back a view to the DescriptorArray upon calling __getitem.
Source code in src/easyscience/variable/descriptor_array.py
745 746 747 748 749 750 751 752 753 754 | |
__sub__(other)
Perform element-wise subtraction with another DescriptorArray, list, or number.
:param other: The object to subtract. Must be a DescriptorArray with compatible units, or a list with the same shape if the DescriptorArray is dimensionless. :return: A new DescriptorArray representing the result of the subtraction.
Source code in src/easyscience/variable/descriptor_array.py
553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 | |
__truediv__(other)
Perform element-wise division with another DescriptorNumber, DescriptorArray, list, or number.
:param other: The object to use as a denominator. Must be a DescriptorArray or DescriptorNumber with compatible units, or a list with the same shape if the DescriptorArray is dimensionless. :return: A new DescriptorArray representing the result of the addition.
Source code in src/easyscience/variable/descriptor_array.py
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 | |
as_dict(skip=None)
Dict representation of the current DescriptorArray.
The dict contains the value, unit and variances, in addition to the properties of DescriptorBase.
Source code in src/easyscience/variable/descriptor_array.py
368 369 370 371 372 373 374 375 376 377 378 379 | |
convert_unit(unit_str)
Convert the value from one unit system to another.
:param unit_str: New unit in string form
Source code in src/easyscience/variable/descriptor_array.py
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 | |
dimensions
property
writable
Get the dimensions used for the underlying scipp array.
:return: dimensions of self.
error
property
writable
The standard deviations, calculated as the square root of variances.
:return: A numpy array of standard deviations, or None if variances are not set.
from_scipp(name, full_value, **kwargs)
classmethod
Create a DescriptorArray from a scipp array.
:param name: Name of the descriptor :param full_value: Value of the descriptor as a scipp variable :param kwargs: Additional parameters for the descriptor :return: DescriptorArray
Source code in src/easyscience/variable/descriptor_array.py
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | |
full_value
property
writable
Get the value of self as a scipp array. This should be usable for most cases.
:return: Value of self with unit.
sum(dim=None)
Uses scipp to sum over the requested dims.
:param dim: The dim(s) in the scipp array to sum over. If None, will sum over all dims.
Source code in src/easyscience/variable/descriptor_array.py
816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 | |
trace(dimension1=None, dimension2=None)
Computes the trace over the descriptor array. The submatrix
defined dimension1 and dimension2 must be square. For a rank
k tensor, the trace will run over the firs two dimensions,
resulting in a rank k-2 tensor.
:param dimension1, dimension2: First and second dimension to perform trace over. Must be in self.dimensions.
If not defined, the trace will be taken over the first two dimensions.
Source code in src/easyscience/variable/descriptor_array.py
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 | |
unit
property
writable
Get the unit.
:return: Unit as a string.
value
property
writable
Get the value without units. The Scipp array can be obtained
from obj.full_value.
:return: Value of self without unit.
variance
property
writable
Get the variance as a Numpy ndarray.
:return: variance.
descriptor_base
DescriptorBase
Bases: SerializerComponent
This is the base of all variable descriptions for models. It contains all information to describe a single unique property of an object. This description includes a name and value as well as optionally a unit, description and url (for reference material). Also implemented is a callback so that the value can be read/set from a linked library object.
A Descriptor is typically something which describes part of a model and is non-fittable and generally changes the
state of an object.
Source code in src/easyscience/variable/descriptor_base.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 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 | |
__copy__()
Return a copy of the object.
Source code in src/easyscience/variable/descriptor_base.py
199 200 201 202 203 | |
__init__(name, unique_name=None, description=None, url=None, display_name=None, parent=None)
This is the base of variables for models. It contains all information to describe a single unique property of an object. This description includes a name, description and url (for reference material).
A Descriptor is typically something which describes part of a model and is non-fittable and generally changes
the state of an object.
:param name: Name of this object :param description: A brief summary of what this object is :param url: Lookup url for documentation/information :param display_name: A pretty name for the object :param parent: The object which this descriptor is attached to
.. note:: Undo/Redo functionality is implemented for the attributes name and display name.
Source code in src/easyscience/variable/descriptor_base.py
31 32 33 34 35 36 37 38 39 40 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 | |
__repr__()
abstractmethod
Return printable representation of the object.
Source code in src/easyscience/variable/descriptor_base.py
195 196 197 | |
description
property
writable
Get the description of the object.
:return: description of the object.
display_name
property
writable
Get a pretty display name.
:return: The pretty display name.
name
property
writable
Get the name of the object.
:return: name of the object.
unique_name
property
writable
Get the unique name of this object.
:return: Unique name of this object
url
property
writable
Get the url of the object.
:return: url of the object.
value
abstractmethod
property
writable
Get the value of the object.
descriptor_bool
DescriptorBool
Bases: DescriptorBase
A Descriptor for boolean values.
Source code in src/easyscience/variable/descriptor_bool.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 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 | |
__repr__()
Return printable representation.
Source code in src/easyscience/variable/descriptor_bool.py
61 62 63 64 65 66 | |
value
property
writable
Get the value of self.
:return: Value of self
descriptor_number
DescriptorNumber
Bases: DescriptorBase
A Descriptor for Number values with units.
The internal representation is a scipp scalar.
Source code in src/easyscience/variable/descriptor_number.py
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 344 345 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 409 410 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 463 464 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 | |
__init__(name, value, unit='', variance=None, unique_name=None, description=None, url=None, display_name=None, parent=None, **kwargs)
Constructor for the DescriptorNumber class.
param name: Name of the descriptor
param value: Value of the descriptor
param unit: Unit of the descriptor
param variance: Variance of the descriptor
param description: Description of the descriptor
param url: URL of the descriptor
param display_name: Display name of the descriptor
param parent: Parent of the descriptor
.. note:: Undo/Redo functionality is implemented for the attributes variance, error, unit and value.
Source code in src/easyscience/variable/descriptor_number.py
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 | |
__repr__()
Return printable representation.
Source code in src/easyscience/variable/descriptor_number.py
317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 | |
convert_unit(unit_str)
Convert the value from one unit system to another.
:param unit_str: New unit in string form
Source code in src/easyscience/variable/descriptor_number.py
305 306 307 308 309 310 311 | |
error
property
writable
The standard deviation for the parameter.
:return: Error associated with parameter
from_scipp(name, full_value, **kwargs)
classmethod
Create a DescriptorNumber from a scipp constant.
:param name: Name of the descriptor :param value: Value of the descriptor as a scipp scalar :param kwargs: Additional parameters for the descriptor :return: DescriptorNumber
Source code in src/easyscience/variable/descriptor_number.py
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | |
full_value
property
writable
Get the value of self as a scipp scalar. This is should be usable for most cases.
:return: Value of self with unit.
unit
property
writable
Get the unit.
:return: Unit as a string.
value
property
writable
Get the value. This should be usable for most cases. The full
value can be obtained from obj.full_value.
:return: Value of self with unit.
variance
property
writable
Get the variance.
:return: variance.
notify_observers(func)
Decorator to notify observers of a change in the descriptor.
:param func: Function to be decorated :return: Decorated function
Source code in src/easyscience/variable/descriptor_number.py
27 28 29 30 31 32 33 34 35 36 37 38 39 | |
descriptor_str
DescriptorStr
Bases: DescriptorBase
A Descriptor for string values.
Source code in src/easyscience/variable/descriptor_str.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 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 | |
__repr__()
Return printable representation.
Source code in src/easyscience/variable/descriptor_str.py
59 60 61 62 63 64 | |
value
property
writable
Get the value of self.
:return: Value of self with unit.
parameter
Parameter
Bases: DescriptorNumber
A Parameter is a DescriptorNumber which can be used in fitting.
It has additional fields to facilitate this.
Source code in src/easyscience/variable/parameter.py
30 31 32 33 34 35 36 37 38 39 40 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 344 345 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 409 410 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 463 464 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 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 | |
__init__(name, value, unit='', variance=0.0, min=-np.inf, max=np.inf, fixed=False, unique_name=None, description=None, url=None, display_name=None, callback=property(), parent=None, **kwargs)
This class is an extension of a DescriptorNumber. Where the
descriptor was for static objects, a Parameter is for dynamic
objects. A parameter has the ability to be used in fitting and
has additional fields to facilitate this.
:param name: Name of this object :param value: Value of this object :param unit: This object can have a physical unit associated with it :param variance: The variance of the value :param min: The minimum value for fitting :param max: The maximum value for fitting :param fixed: If the parameter is free to vary during fitting :param description: A brief summary of what this object is :param url: Lookup url for documentation/information :param display_name: The name of the object as it should be displayed :param parent: The object which is the parent to this one
Note
Undo/Redo functionality is implemented for the attributes value, variance, error, min, max, bounds, fixed, unit
Source code in src/easyscience/variable/parameter.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 | |
__repr__()
Return printable representation of a Parameter object.
Source code in src/easyscience/variable/parameter.py
779 780 781 782 783 784 785 786 787 788 | |
as_dict(skip=None)
Overwrite the as_dict method to handle dependency information.
Source code in src/easyscience/variable/parameter.py
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 | |
convert_unit(unit_str)
Perform unit conversion. The value, max and min can change on unit change.
:param new_unit: new unit :return: None
Source code in src/easyscience/variable/parameter.py
521 522 523 524 525 526 527 528 529 | |
dependency_expression
property
writable
Get the dependency expression of this parameter.
:return: The dependency expression of this parameter.
dependency_map
property
writable
Get the dependency map of this parameter.
:return: The dependency map of this parameter.
error(value)
Set the standard deviation for the parameter.
:param value: New error value
Source code in src/easyscience/variable/parameter.py
496 497 498 499 500 501 502 503 504 505 506 507 | |
fixed
property
writable
Can the parameter vary while fitting?
:return: True = fixed, False = can vary
from_dependency(name, dependency_expression, dependency_map=None, desired_unit=None, **kwargs)
classmethod
Create a dependent Parameter directly from a dependency expression.
:param name: The name of the parameter :param dependency_expression: The dependency expression to evaluate. This should be a string which can be evaluated by the ASTEval interpreter. :param dependency_map: A dictionary of dependency expression symbol name and dependency object pairs. This is inserted into the asteval interpreter to resolve dependencies. :param desired_unit: The desired unit of the dependent parameter. :param kwargs: Additional keyword arguments to pass to the Parameter constructor. :return: A new dependent Parameter object.
Source code in src/easyscience/variable/parameter.py
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 | |
from_dict(obj_dict)
classmethod
Custom deserialization to handle parameter dependencies.
Override the parent method to handle dependency information.
Source code in src/easyscience/variable/parameter.py
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 | |
full_value
property
writable
Get the value of self as a scipp scalar. This is should be
usable for most cases. If a scipp scalar is not acceptable then
the raw value can be obtained through obj.value.
:return: Value of self with unit and variance.
independent
property
writable
Is the parameter independent?
:return: True = independent, False = dependent
make_dependent_on(dependency_expression, dependency_map=None, desired_unit=None)
Make this parameter dependent on another parameter. This will overwrite the current value, unit, variance, min and max.
How to use the dependency map: If a parameter c has a dependency expression of 'a + b', where a and b are parameters belonging to the model class, then the dependency map needs to have the form {'a': model.a, 'b': model.b}, where model is the model class. I.e. the values are the actual objects, whereas the keys are how they are represented in the dependency expression.
The dependency map is not needed if the dependency expression uses the unique names of the parameters. Unique names in dependency expressions are defined by quotes, e.g. 'Parameter_0' or "Parameter_0" depending on the quotes used for the expression.
:param dependency_expression: The dependency expression to evaluate. This should be a string which can be evaluated by a python interpreter.
:param dependency_map: A dictionary of dependency expression symbol name and dependency object pairs. This is inserted into the asteval interpreter to resolve dependencies.
:param desired_unit: The desired unit of the dependent parameter. If None, the default unit of the dependency expression result is used.
Source code in src/easyscience/variable/parameter.py
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 344 345 346 347 348 | |
make_independent()
Make this parameter independent. This will remove the dependency expression, the dependency map and the dependency interpreter.
:return: None
Source code in src/easyscience/variable/parameter.py
350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 | |
max
property
writable
Get the maximum value for fitting.
:return: maximum value
min
property
writable
Get the minimum value for fitting.
:return: minimum value
resolve_pending_dependencies()
Resolve pending dependencies after deserialization.
This method should be called after all parameters have been deserialized to establish dependency relationships using serializer_ids.
Source code in src/easyscience/variable/parameter.py
1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 | |
set_desired_unit(unit_str)
Set the desired unit for a dependent Parameter. This will convert the parameter to the desired unit.
:param unit_str: The desired unit as a string.
Source code in src/easyscience/variable/parameter.py
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 | |
value
property
writable
Get the value of self as a Number.
:return: Value of self without unit.
value_no_call_back
property
Get the currently hold value of self suppressing call back.
:return: Value of self without unit.
variance(variance_float)
Set the variance.
:param variance_float: Variance as a float
Source code in src/easyscience/variable/parameter.py
483 484 485 486 487 488 489 490 491 492 493 494 | |
parameter_dependency_resolver
deserialize_and_resolve_parameters(params_data)
Deserialize parameters from a dictionary and resolve their dependencies.
This is a convenience function that combines Parameter.from_dict() deserialization with dependency resolution in a single call.
:param params_data: Dictionary mapping parameter names to their serialized data :return: Dictionary mapping parameter names to deserialized Parameters with resolved dependencies
Source code in src/easyscience/variable/parameter_dependency_resolver.py
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | |
get_parameters_with_pending_dependencies(obj)
Find all Parameter objects in an object hierarchy that have pending dependencies.
:param obj: The object to search for Parameters :return: List of Parameters with pending dependencies
Source code in src/easyscience/variable/parameter_dependency_resolver.py
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 | |
resolve_all_parameter_dependencies(obj)
Recursively find all Parameter objects in an object hierarchy and resolve their pending dependencies.
This function should be called after deserializing a complex object that contains Parameters with dependencies to ensure all dependency relationships are properly established.
:param obj: The object to search for Parameters (can be a single Parameter, list, dict, or complex object)
Source code in src/easyscience/variable/parameter_dependency_resolver.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 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 | |