Set a row, or set of rows, in the array. It takes different actions depending on the type of the *key* parameter: if it is an integer, the corresponding table row is set to *value* (a record or sequence capable of being converted to the table structure). If *key* is
(
self,
key: int | slice | Sequence[int] | np.ndarray,
value: Any,
)
| 740 | self._modify(nrow, nparr, nobjects) |
| 741 | |
| 742 | def __setitem__( |
| 743 | self, |
| 744 | key: int | slice | Sequence[int] | np.ndarray, |
| 745 | value: Any, |
| 746 | ) -> None: |
| 747 | """Set a row, or set of rows, in the array. |
| 748 | |
| 749 | It takes different actions depending on the type of the *key* |
| 750 | parameter: if it is an integer, the corresponding table row is |
| 751 | set to *value* (a record or sequence capable of being converted |
| 752 | to the table structure). If *key* is a slice, the row slice |
| 753 | determined by it is set to *value* (a record array or sequence |
| 754 | of rows capable of being converted to the table structure). |
| 755 | |
| 756 | In addition, NumPy-style point selections are supported. In |
| 757 | particular, if key is a list of row coordinates, the set of rows |
| 758 | determined by it is set to value. Furthermore, if key is an array of |
| 759 | boolean values, only the coordinates where key is True are set to |
| 760 | values from value. Note that for the latter to work it is necessary |
| 761 | that key list would contain exactly as many rows as the table has. |
| 762 | |
| 763 | .. note:: |
| 764 | |
| 765 | When updating the rows of a VLArray object which uses a |
| 766 | pseudo-atom, there is a problem: you can only update values |
| 767 | with *exactly* the same size in bytes than the original row. |
| 768 | This is very difficult to meet with object pseudo-atoms, |
| 769 | because :mod:`pickle` applied on a Python object does not |
| 770 | guarantee to return the same number of bytes than over another |
| 771 | object, even if they are of the same class. |
| 772 | This effectively limits the kinds of objects than can be |
| 773 | updated in variable-length arrays. |
| 774 | |
| 775 | Examples |
| 776 | -------- |
| 777 | :: |
| 778 | |
| 779 | vlarray[0] = vlarray[0] * 2 + 3 |
| 780 | vlarray[99] = arange(96) * 2 + 3 |
| 781 | |
| 782 | # Negative values for the index are supported. |
| 783 | vlarray[-99] = vlarray[5] * 2 + 3 |
| 784 | vlarray[1:30:2] = list_of_rows |
| 785 | vlarray[[1,3]] = new_1_and_3_rows |
| 786 | |
| 787 | """ |
| 788 | self._g_check_open() |
| 789 | self._v_file._check_writable() |
| 790 | |
| 791 | if is_idx(key): |
| 792 | # If key is not a sequence, convert to it |
| 793 | coords = [key] |
| 794 | value = [value] |
| 795 | elif isinstance(key, slice): |
| 796 | start, stop, step = self._process_range( |
| 797 | key.start, key.stop, key.step |
| 798 | ) |
| 799 | coords = range(start, stop, step) |
nothing calls this directly
no test coverage detected