Skip to content

Commit

Permalink
include warning messages
Browse files Browse the repository at this point in the history
  • Loading branch information
jkanche committed Oct 31, 2023
1 parent aac383a commit c815e83
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/iranges/IRanges.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit c815e83

Please sign in to comment.