Skip to content

correct isort for test numeric #51

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

Merged
merged 5 commits into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 8 additions & 44 deletions arrayfire_wrapper/_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
from pathlib import Path
from typing import Iterator

from arrayfire_wrapper.defines import AFArray

from .version import ARRAYFIRE_VER_MAJOR

VERBOSE_LOADS = os.environ.get("AF_VERBOSE_LOADS", "") == "1"
Expand All @@ -37,7 +35,7 @@ def is_cygwin(cls, name: str) -> bool:
class _BackendPathConfig:
lib_prefix: str
lib_postfix: str
af_path: Path
af_path: Path | None
af_is_user_path: bool
cuda_found: bool

Expand Down Expand Up @@ -175,7 +173,7 @@ def __iter__(self) -> Iterator:


class Backend:
_backend_type: BackendType
_backend_type: BackendType | None
_clibs: dict[BackendType, ctypes.CDLL]

def __init__(self) -> None:
Expand Down Expand Up @@ -297,51 +295,17 @@ def _find_nvrtc_builtins_lib_name(self, search_path: Path) -> str | None:
return f.name
return None

# unified backend functions
def get_active_backend(self) -> str:
if self._backend_type == BackendType.unified:
from arrayfire_wrapper.lib.unified_api_functions import get_active_backend as unified_get_active_backend

return unified_get_active_backend()
raise RuntimeError("Using unified function on non-unified backend")

def get_available_backends(self) -> list[int]:
if self._backend_type == BackendType.unified:
from arrayfire_wrapper.lib.unified_api_functions import (
get_available_backends as unified_get_available_backends,
)

return unified_get_available_backends()
raise RuntimeError("Using unified function on non-unified backend")

def get_backend_count(self) -> int:
if self._backend_type == BackendType.unified:
from arrayfire_wrapper.lib.unified_api_functions import get_backend_count as unified_get_backend_count

return unified_get_backend_count()
raise RuntimeError("Using unified function on non-unified backend")

def get_backend_id(self, arr: AFArray, /) -> int:
if self._backend_type == BackendType.unified:
from arrayfire_wrapper.lib.unified_api_functions import get_backend_id as unified_get_backend_id

return unified_get_backend_id(arr)
raise RuntimeError("Using unified function on non-unified backend")

def get_device_id(self, arr: AFArray, /) -> int:
if self._backend_type == BackendType.unified:
from arrayfire_wrapper.lib.unified_api_functions import get_device_id as unified_get_device_id

return unified_get_device_id(arr)
raise RuntimeError("Using unified function on non-unified backend")

@property
def backend_type(self) -> BackendType:
return self._backend_type
if self._backend_type:
return self._backend_type
raise RuntimeError("No valid _backend_type")

@property
def clib(self) -> ctypes.CDLL:
return self._clibs[self._backend_type]
if self._backend_type:
return self._clibs[self._backend_type]
raise RuntimeError("No valid _backend_type")


# Initialize the backend
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
import ctypes

import arrayfire_wrapper.dtypes as dtype
import arrayfire_wrapper.lib as wrapper
from arrayfire_wrapper.defines import AFArray
from arrayfire_wrapper.dtypes import float32
from arrayfire_wrapper.lib._utility import binary_op, call_from_clib, unary_op
from arrayfire_wrapper.lib.create_and_modify_array.create_array import create_constant_array
from arrayfire_wrapper.lib.mathematical_functions.arithmetic_operations import sub


import arrayfire_wrapper.dtypes as dtype
import arrayfire_wrapper.lib as wrapper


def abs_(arr: AFArray, /) -> AFArray:
"""
source: https://arrayfire.org/docs/group__arith__func__abs.htm#ga7e8b3c848e6cda3d1f3b0c8b2b4c3f8f
Expand Down
14 changes: 7 additions & 7 deletions scripts/build_package_without_binaries.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#!/bin/bash

# Run the Python script and capture the output and error
# Run the Python script and capture the output or error
output=$(python -m build 2>&1)

# Define the expected error message
expected_error="Could not load any ArrayFire libraries."
# Define the expected output message
expected_output="Successfully built"

# Check if the output contains the expected error message
if echo "$output" | grep -q "$expected_error"; then
echo "Expected error received."
exit 0 # Exit with success as the error is expected
# Check if the output contains the expected output message
if echo "$output" | grep -q "$expected_output"; then
echo "Expected output received."
exit 0 # Exit with success as the output is expected
else
echo "Unexpected output: $output"
exit 1 # Exit with failure as the output was not expected
Expand Down
2 changes: 1 addition & 1 deletion tests/test_numeric.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import arrayfire_wrapper.dtypes as dtype
import arrayfire_wrapper.lib as wrapper
from tests.utility_functions import check_type_supported, get_all_types, get_real_types, get_complex_types
from tests.utility_functions import check_type_supported, get_all_types, get_complex_types, get_real_types


@pytest.mark.parametrize(
Expand Down
Loading