Assign the `values` to the positions stated in `coords`.
(self, coords: Sequence[int], values: Sequence)
| 699 | raise IndexError(f"Invalid index or slice: {key!r}") |
| 700 | |
| 701 | def _assign_values(self, coords: Sequence[int], values: Sequence) -> None: |
| 702 | """Assign the `values` to the positions stated in `coords`.""" |
| 703 | for nrow, value in zip(coords, values): |
| 704 | if nrow >= self.nrows: |
| 705 | raise IndexError("First index out of range") |
| 706 | if nrow < 0: |
| 707 | # To support negative values |
| 708 | nrow += self.nrows |
| 709 | object_ = value |
| 710 | # Prepare the object to convert it into a NumPy object |
| 711 | atom = self.atom |
| 712 | if not hasattr(atom, "size"): # it is a pseudo-atom |
| 713 | object_ = atom.toarray(object_) |
| 714 | statom = atom.base |
| 715 | else: |
| 716 | statom = atom |
| 717 | value = convert_to_np_atom(object_, statom) |
| 718 | nobjects = self._getnobjects(value) |
| 719 | |
| 720 | # Get the previous value |
| 721 | nrow = idx2long(nrow) # To convert any possible numpy scalar value |
| 722 | nparr = self._read_array(nrow, nrow + 1, 1)[0] |
| 723 | nobjects = len(nparr) |
| 724 | if len(value) > nobjects: |
| 725 | raise ValueError( |
| 726 | "Length of value (%s) is larger than number " |
| 727 | "of elements in row (%s)" % (len(value), nobjects) |
| 728 | ) |
| 729 | try: |
| 730 | nparr[:] = value |
| 731 | except Exception as exc: # XXX |
| 732 | raise ValueError( |
| 733 | "Value parameter:\n'%r'\n" |
| 734 | "cannot be converted into an array object " |
| 735 | "compliant vlarray[%s] row: \n'%r'\n" |
| 736 | "The error was: <%s>" % (value, nrow, nparr[:], exc) |
| 737 | ) |
| 738 | |
| 739 | if nparr.size > 0: |
| 740 | self._modify(nrow, nparr, nobjects) |
| 741 | |
| 742 | def __setitem__( |
| 743 | self, |
no test coverage detected