Skip to content

Commit

Permalink
fix: Fixed raising TypeError exception instead or ValueError exce…
Browse files Browse the repository at this point in the history
…ption for invalid type (#27439)
  • Loading branch information
Sai-Suraj-27 committed Dec 4, 2023
1 parent d7aedb5 commit 08bd6dc
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion ivy/compiler/replace_with.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def replace_with(new_func):

def decorator(original_func):
if not callable(original_func) or not callable(new_func):
raise ValueError(
raise TypeError(
f"Both '{original_func.__name__}' and '{new_func.__name__}' should be"
" callable."
)
Expand Down
2 changes: 1 addition & 1 deletion ivy/functional/frontends/jax/numpy/fft.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def fftfreq(n, d=1.0, *, dtype=None):
if not isinstance(
n, (int, type(ivy.int8), type(ivy.int16), type(ivy.int32), type(ivy.int64))
):
raise ValueError("n should be an integer")
raise TypeError("n should be an integer")

dtype = ivy.float64 if dtype is None else ivy.as_ivy_dtype(dtype)

Expand Down
2 changes: 1 addition & 1 deletion ivy/functional/frontends/jax/numpy/indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def __getitem__(self, key):
newobj = _make_1d_grid_from_slice(item)
item_ndim = 0
elif isinstance(item, str):
raise ValueError("string directive must be placed at the beginning")
raise TypeError("string directive must be placed at the beginning")
else:
newobj = array(item, copy=False)
item_ndim = newobj.ndim
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def fftfreq(n, d=1.0):
if not isinstance(
n, (int, type(ivy.int8), type(ivy.int16), type(ivy.int32), type(ivy.int64))
):
raise ValueError("n should be an integer")
raise TypeError("n should be an integer")

N = (n - 1) // 2 + 1
val = 1.0 / (n * d)
Expand Down Expand Up @@ -135,7 +135,7 @@ def rfftfreq(n, d=1.0):
if not isinstance(
n, (int, type(ivy.int8), type(ivy.int16), type(ivy.int32), type(ivy.int64))
):
raise ValueError("n should be an integer")
raise TypeError("n should be an integer")

val = 1.0 / (n * d)
N = n // 2 + 1
Expand Down
4 changes: 2 additions & 2 deletions ivy/functional/frontends/paddle/nn/functional/vision.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def pixel_shuffle(x, upscale_factor, data_format="NCHW"):
)

if not isinstance(upscale_factor, int):
raise ValueError("upscale factor must be int type")
raise TypeError("upscale factor must be int type")

if data_format not in ["NCHW", "NHWC"]:
raise ValueError(
Expand Down Expand Up @@ -172,7 +172,7 @@ def pixel_unshuffle(x, downscale_factor, data_format="NCHW"):
)

if not isinstance(downscale_factor, int):
raise ValueError("Downscale factor must be int type")
raise TypeError("Downscale factor must be int type")

if downscale_factor <= 0:
raise ValueError("Downscale factor must be positive")
Expand Down
2 changes: 1 addition & 1 deletion ivy/functional/frontends/torch/nn/modules/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def get_submodule(self, target: str) -> "Module":
mod = getattr(mod, item)

if not isinstance(mod, Module):
raise AttributeError("`" + item + "` is not an nn.Module")
raise TypeError("`" + item + "` is not an nn.Module")

return mod

Expand Down
2 changes: 1 addition & 1 deletion ivy/utils/assertions.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def check_same_dtype(x1, x2, message=""):

def check_unsorted_segment_valid_params(data, segment_ids, num_segments):
if not isinstance(num_segments, int):
raise ValueError("num_segments must be of integer type")
raise TypeError("num_segments must be of integer type")

valid_dtypes = [
ivy.int32,
Expand Down

0 comments on commit 08bd6dc

Please sign in to comment.