# Contributor: Iztok Fister, Jr. <iztok@iztok-jr-fister.eu>
# Maintainer: Will Sinatra <wpsinatra@gmail.com>
pkgname=py3-imbalanced-learn
_pkgorig=imbalanced-learn
pkgver=0.12.4
pkgrel=0
pkgdesc="Toolbox for imbalanced dataset in machine learning"
url="https://imbalanced-learn.org"
arch="noarch"
license="MIT"
depends="
	py3-numpy
	py3-pandas
	py3-scikit-learn
	py3-scipy
	"
makedepends="
	py3-gpep517
	py3-setuptools
	py3-wheel
	"
checkdepends="
	py3-pytest-xdist
	"
subpackages="$pkgname-pyc"
source="$pkgname-$pkgver.tar.gz::https://files.pythonhosted.org/packages/source/i/imbalanced-learn/imbalanced-learn-$pkgver.tar.gz
	exclude-tests.patch"
builddir="$srcdir/$_pkgorig-$pkgver"

build() {
	gpep517 build-wheel \
		--wheel-dir .dist \
		--output-fd 3 3>&1 >&2
}

check() {
	python3 -m venv --clear --without-pip --system-site-packages .testenv
	.testenv/bin/python3 -m installer .dist/*.whl

	local skipped_tests="
		test_all_estimators
		and not test_classification_report_imbalanced_multiclass_with_unicode_label
		and not test_rusboost
		and not test_cluster_centroids_n_jobs
		and not test_fit_docstring
		and not keras
		and not test_function_sampler_validate
		and not test_fetch
		and not check_samplers_preserve_dtype
		and not test_pipeline_fit_then_sample_with_sampler_last_estimator
		and not test_pipeline_fit_then_sample_3_samplers_with_sampler_last_estimator"

	# shellcheck disable=SC2116
	.testenv/bin/python3 -m pytest -k "not $(echo $skipped_tests)" -n auto
}

package() {
	python3 -m installer -d "$pkgdir" \
		.dist/*.whl
}

sha512sums="
3461c9b21bd276e832f7211ffed1d510ef0da0d7ec2941feb91f8ffc830de33af0e48d8b94bb1905132306f88f464587e190b7f41d2b5e76ec80fc06a2ba31b3  py3-imbalanced-learn-0.12.4.tar.gz
57a181476c728451b4c54ae535d0f236ac7228b525c8dcbe118bfc8837f1f270fd8185beef59dcbf8fe9c12a67af9c4064339de5df1caf18743c1a4c475db9b0  exclude-tests.patch
"
