Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exclude code from coverage #2272

Merged
merged 6 commits into from
Jan 22, 2025
Merged

Exclude code from coverage #2272

merged 6 commits into from
Jan 22, 2025

Conversation

vlad-perevezentsev
Copy link
Collaborator

This PR continues #2268 and suggests excluding some lines of code from coverage using pragma:: no cover to increase the coverage statistic

  • Have you provided a meaningful PR description?
  • Have you added a test, reproducer or referred to issue with a reproducer?
  • Have you tested your changes locally for CPU and GPU devices?
  • Have you made sure that new changes do not introduce compiler warnings?
  • Have you checked performance impact of proposed changes?
  • If this PR is a work in progress, are you filing the PR as a draft?

@coveralls
Copy link
Collaborator

Coverage Status

coverage: 71.181% (+0.2%) from 70.965%
when pulling f52bbbe on exclude_coverage_code
into 5649b06 on master.

Copy link
Contributor

Array API standard conformance tests for dpnp=0.17.0dev4=py312he4f9c94_19 ran successfully.
Passed: 954
Failed: 0
Skipped: 46

Copy link
Contributor

@antonwolfy antonwolfy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thank you @vlad-perevezentsev

@vlad-perevezentsev
Copy link
Collaborator Author

Regarding the rest of the uncovered lines

dpnp/dpnp_array.py

	def __rmatmul__(self, other): unsupported 

dpnp/dpnp_iface.py

	def get_dpnp_descriptor # partially covered, to be removed in the future -> 466, 495, 511->514, 530
	def is_supported_array_or_scalar(a):  # not used in code
	def synchronize_array_data(a):  # not used in code

dpnp/dpnp_iface_indexing.py

	def choose(x1, choices, out=None, mode="raise"):  #Not covered conditions for fallback numpy. Will be updated soon 
         # -> 142, 147, 149, 153, 155, 165,

	def putmask(x1, mask, values):
	return call_origin(numpy.putmask, x1, mask, values, dpnp_inplace=True)  # not used in tests

dpnp/dpnp_iface_libmath.py

	def erf(in_array1):
		result = create_output_descriptor_py(
		        in_array1.shape, in_array1.dtype, None
		    ).get_pyobj()
		    for i in range(result.size):
		        result[i] = math.erf(in_array1[i])
		    return result # not used in tests

dpnp/dpnp_iface_mathematical.py

	def modf(x1, **kwargs):
	if kwargs:  # not used in tests
	return call_origin(numpy.modf, x1, **kwargs) # not used in tests

dpnp/dpnp_iface_sorting.py

	def partition(x1, kth, axis=-1, kind="introselect", order=None): # Not covered conditions for fallback numpy. Will be updated soon
        # -> 232, 234

dpnp/dpnp_iface_statistics.py

	def cov(  # Not covered conditions for fallback numpy
         # ->  664, 672, 674

dpnp/dpnp_iface_types.py

     def is_type_supported(obj_type):  # deprecated function used only `def shuffle(x1)`, partially covered

@antonwolfy
Copy link
Contributor

antonwolfy commented Jan 22, 2025

def __rmatmul__(self, other): unsupported

It is not actually true. It might be covered, like:

a = dpnp.ones(10)
b = numpy.ones(10)

b @ a
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[4], line 1
----> 1 b @ a

File ~/code/dpnp/dpnp/dpnp_array.py:547, in dpnp_array.__rmatmul__(self, other)
    545 def __rmatmul__(self, other):
    546     """Return ``value@self``."""
--> 547     return dpnp.matmul(other, self)

File ~/code/dpnp/dpnp/dpnp_iface_linearalgebra.py:857, in matmul(x1, x2, out, casting, order, dtype, subok, signature, axes, axis)
    852 if axis is not None:
    853     raise NotImplementedError(
    854         "axis keyword argument is only supported by its default value."
    855     )
--> 857 return dpnp_matmul(
    858     x1,
    859     x2,
    860     out=out,
    861     casting=casting,
    862     order=order,
    863     dtype=dtype,
    864     axes=axes,
    865 )

File ~/code/dpnp/dpnp/dpnp_utils/dpnp_utils_linearalgebra.py:765, in dpnp_matmul(x1, x2, out, casting, order, dtype, axes)
    746 def dpnp_matmul(
    747     x1,
    748     x2,
   (...)
    755     axes=None,
    756 ):
    757     """
    758     Return the matrix product of two arrays.
    759
   (...)
    762
    763     """
--> 765     dpnp.check_supported_arrays_type(x1, x2)
    766     res_usm_type, exec_q = get_usm_allocations([x1, x2])
    767     _validate_out_array(out, exec_q)

File ~/code/dpnp/dpnp/dpnp_iface.py:400, in check_supported_arrays_type(scalar_type, all_scalars, *arrays)
    397     if scalar_type and dpnp.isscalar(a):
    398         continue
--> 400     raise TypeError(
    401         f"An array must be any of supported type, but got {type(a)}"
    402     )
    404 if len(arrays) > 0 and not (all_scalars or any_is_array):
    405     raise TypeError(
    406         "At least one input must be of supported array type, "
    407         "but got all scalars."
    408     )

TypeError: An array must be any of supported type, but got <class 'numpy.ndarray'>

As you can see from the call stack there is __rmatmul__ called.

For testing of positive use case you need something like:

a = dpnp.ones(10)
b = dpnp.ones(10)

class A(dpnp.ndarray):
     def __init__(self, x):
         self._array_obj = x.get_array()

     def __matmul__(self, other):
         return NotImplemented

a1 = A(a)

a1 @ b
# Out: array(10.)

@antonwolfy
Copy link
Contributor

antonwolfy commented Jan 22, 2025

def is_supported_array_or_scalar(a): # not used in code
def synchronize_array_data(a): # not used in code

We need to add tests for them. It is an interface functions.

@antonwolfy
Copy link
Contributor

The rest uncovered functions can be left unchanged, because we will rework them when remove the backend.

@vlad-perevezentsev vlad-perevezentsev merged commit 094ab7c into master Jan 22, 2025
42 of 56 checks passed
@vlad-perevezentsev vlad-perevezentsev deleted the exclude_coverage_code branch January 22, 2025 15:47
github-actions bot added a commit that referenced this pull request Jan 22, 2025
This PR continues #2268 and suggests excluding some lines of code from
coverage using `pragma:: no cover` to increase the coverage statistic 094ab7c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants