From c815e83c5650c02a92b083269691d054b4037775 Mon Sep 17 00:00:00 2001 From: Jayaram Kancherla Date: Tue, 31 Oct 2023 11:26:22 -0700 Subject: [PATCH] include warning messages --- src/iranges/IRanges.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/iranges/IRanges.py b/src/iranges/IRanges.py index b3631a1..a9fbfac 100644 --- a/src/iranges/IRanges.py +++ b/src/iranges/IRanges.py @@ -1,5 +1,6 @@ from copy import deepcopy from typing import List, Optional, Sequence, Union +from warnings import warn import biocutils as ut from biocframe import BiocFrame @@ -188,6 +189,10 @@ def start(self, start: Sequence[int]): start: Sequence of start positions, see the constructor for details. """ + warn( + "Setting property 'start'is an in-place operation, use 'set_start' instead", + UserWarning, + ) self.set_start(start, in_place=True) @@ -237,6 +242,10 @@ def width(self, width: Sequence[int]): width: Sequence of widths, see the constructor for details. """ + warn( + "Setting property 'width'is an in-place operation, use 'set_width' instead", + UserWarning, + ) return self.set_width(width, in_place=True) def get_end(self) -> ndarray: @@ -311,6 +320,10 @@ def names(self, names: Optional[Sequence[str]]): modified names. Otherwise, the current object is directly modified and a reference to it is returned. """ + warn( + "Setting property 'names'is an in-place operation, use 'set_names' instead", + UserWarning, + ) self.set_names(names, in_place=True) def get_mcols(self) -> BiocFrame: @@ -362,6 +375,10 @@ def mcols(self, mcols: Optional[BiocFrame]): Data frame of additional columns, see the constructor for details. """ + warn( + "Setting property 'mcols'is an in-place operation, use 'set_mcols' instead", + UserWarning, + ) self.set_mcols(mcols, in_place=True) def get_metadata(self) -> dict: @@ -411,6 +428,10 @@ def metadata(self, metadata: Optional[dict]): metadata: Additional metadata. """ + warn( + "Setting property 'metadata'is an in-place operation, use 'set_metadata' instead", + UserWarning, + ) self.set_metadata(metadata, in_place=True) def _define_output(self, in_place):