{"id":15158073,"url":"https://github.com/rafsaf/tw-complex","last_synced_at":"2026-02-22T20:04:54.696Z","repository":{"id":62585640,"uuid":"366194584","full_name":"rafsaf/tw-complex","owner":"rafsaf","description":"Algorithms for TW","archived":false,"fork":false,"pushed_at":"2022-10-26T18:50:34.000Z","size":3568,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-11-04T15:06:19.087Z","etag":null,"topics":["mit","numpy","poetry","pypi-package","python","scipy","sklearn"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/tw-complex/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rafsaf.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-05-10T22:48:51.000Z","updated_at":"2022-02-07T02:16:12.000Z","dependencies_parsed_at":"2022-11-03T20:20:10.275Z","dependency_job_id":null,"html_url":"https://github.com/rafsaf/tw-complex","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/rafsaf/tw-complex","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rafsaf%2Ftw-complex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rafsaf%2Ftw-complex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rafsaf%2Ftw-complex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rafsaf%2Ftw-complex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rafsaf","download_url":"https://codeload.github.com/rafsaf/tw-complex/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rafsaf%2Ftw-complex/sbom","scorecard":{"id":758668,"data":{"date":"2025-08-11","repo":{"name":"github.com/rafsaf/tw-complex","commit":"cf99f313f93f48ec08f0a708b68ee691ba779d69"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.5,"checks":[{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Code-Review","score":0,"reason":"Found 0/20 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/pypi.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/pypi.yml:10: update your workflow using https://app.stepsecurity.io/secureworkflow/rafsaf/tw-complex/pypi.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/pypi.yml:11: update your workflow using https://app.stepsecurity.io/secureworkflow/rafsaf/tw-complex/pypi.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/pypi.yml:15: update your workflow using https://app.stepsecurity.io/secureworkflow/rafsaf/tw-complex/pypi.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/pypi.yml:23: update your workflow using https://app.stepsecurity.io/secureworkflow/rafsaf/tw-complex/pypi.yml/main?enable=pin","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   2 third-party GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'main'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":0,"reason":"12 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: PYSEC-2024-48 / GHSA-fj7x-q9j7-g6q6","Warn: Project is vulnerable to: GHSA-6673-4983-2vx5","Warn: Project is vulnerable to: GHSA-3f63-hfp8-52jq","Warn: Project is vulnerable to: GHSA-44wm-f244-xhp3","Warn: Project is vulnerable to: PYSEC-2023-227 / GHSA-8ghj-p4vj-mr35","Warn: Project is vulnerable to: GHSA-j7hp-h8jx-5ppr","Warn: Project is vulnerable to: PYSEC-2022-42980 / GHSA-q4mp-jvh2-76fj","Warn: Project is vulnerable to: OSV-2022-1074","Warn: Project is vulnerable to: OSV-2022-715","Warn: Project is vulnerable to: PYSEC-2023-175","Warn: Project is vulnerable to: PYSEC-2024-110 / GHSA-jw8x-6495-233v","Warn: Project is vulnerable to: PYSEC-2023-102"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-22T22:34:59.667Z","repository_id":62585640,"created_at":"2025-08-22T22:34:59.667Z","updated_at":"2025-08-22T22:34:59.667Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29725299,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-22T19:57:12.410Z","status":"ssl_error","status_checked_at":"2026-02-22T19:54:50.710Z","response_time":110,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["mit","numpy","poetry","pypi-package","python","scipy","sklearn"],"created_at":"2024-09-26T20:22:53.410Z","updated_at":"2026-02-22T20:04:54.662Z","avatar_url":"https://github.com/rafsaf.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"![GitHub](https://img.shields.io/github/license/rafsaf/tw-complex)\n![PyPI](https://img.shields.io/pypi/v/tw-complex)\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/tw-complex)\n\n# TW Complex\n\nRepo with algorithms to divide ally villages into front and back in TW.\n\nUnderneath it is a problem of dividing a set of 2D points **A** according to the `min_radius` and `max_radius` distances from a set of other 2D points **B**, which can be solved most simply by counting the distances from each point in the first set **A** to all points in the second set **B** one by one.\n\n- [Instalation](#instalation)\n- [Basic usage](#basic-usage)\n- [Examples](#examples-before---after)\n- [Running locally](#running-locally)\n\n# Instalation\n\n```bash\npip install tw_complex\n```\n\n# Basic usage\n\n```python\nfrom tw_complex import CDistBrute\nimport numpy as np\n\n# The code for Example 1 below\n\npoints1 = np.random.rand(10000, 2) + [2, 0]\npoints2 = np.random.rand(15000, 2)\nmin_radius = 1.4\nmax_radius = 2\n\nprecise_front, precise_back = CDistBrute(\n    ally_villages=points1,\n    enemy_villages=points2,\n    min_radius=min_radius,\n    max_radius=max_radius,\n).result()\n\n```\n\n# Examples (before -\u003e after)\n\n### Example 1\n\n```bash\nAlly: 10000 points\nEnemy: 15000 points\nmin_radius: 1.4\nmax_radius: 2\n```\n\n![example1](https://raw.githubusercontent.com/rafsaf/tw-complex/main/images/Figure_1.png)\n\n### Example 2\n\n```bash\nAlly: 2500 points\nEnemy: 6000 points\nmin_radius: 4\nmax_radius: 10\n```\n\n![example2](https://raw.githubusercontent.com/rafsaf/tw-complex/main/images/Figure_2.png)\n\n### Example 3\n\n```bash\nAlly: 20000 points\nEnemy: 20000 points\nmin_radius: 20\nmax_radius: 60\n```\n\n![example3](https://raw.githubusercontent.com/rafsaf/tw-complex/main/images/Figure_3.png)\n\n### Example 4\n\n```bash\nAlly: 20000 points\nEnemy: 20000 points\nmin_radius: 10\nmax_radius: 120\n```\n\n![example4](https://raw.githubusercontent.com/rafsaf/tw-complex/main/images/Figure_4.png)\n\n# Running locally\n\nYou will need to have [poetry](https://python-poetry.org/) installed.\n\n```\ngit clone https://github.com/rafsaf/tw-complex.git\ncd tw-complex\npoetry install\n\n```\n\nCode lives in `tw-complex` folder, and you may also test algorithms running in main folder\n\n```\n# In main folder\n# eg. ~/Desktop/tw-complex\n\npytest\n```\n\nFor CDistAndKNN it looks like\n\n```python\n# tests/test_cdist.py\n\nfrom tw_complex import CDistAndKNN\nimport tests.utils as utils\n\n\ndef test_CDistAndKNN():\n    utils.run_all_tests(CDistAndKNN, \"CDistAndKNN\", _precision=0.8, draw=True)\n\n# Go with `draw=False` if you do not want to use pyplot to show diagrams\n```\n\nSome hardcoded tests are located in `tests/utils.py`, it uses brute force for calculating exact result, then compare it to given algorithm using basic maths. You can even compare it to brute force itself (eg. using diffrent `_precision`). For new test there should be another file in `tests/test_name_of_file_in_tw_complex_folder.py` with pretty much the same content as above.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frafsaf%2Ftw-complex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frafsaf%2Ftw-complex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frafsaf%2Ftw-complex/lists"}