{"id":25431934,"url":"https://github.com/jagkagd/np-xarr","last_synced_at":"2026-04-25T21:32:47.638Z","repository":{"id":57447036,"uuid":"227372942","full_name":"jagkagd/np-xarr","owner":"jagkagd","description":"Perform a numpy array transformation intuitively by giving simple patterns.","archived":false,"fork":false,"pushed_at":"2019-12-31T12:45:59.000Z","size":49,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-28T19:06:51.294Z","etag":null,"topics":["numpy","python"],"latest_commit_sha":null,"homepage":"","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/jagkagd.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":"2019-12-11T13:31:56.000Z","updated_at":"2019-12-31T12:40:05.000Z","dependencies_parsed_at":"2022-09-05T05:00:54.098Z","dependency_job_id":null,"html_url":"https://github.com/jagkagd/np-xarr","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/jagkagd/np-xarr","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jagkagd%2Fnp-xarr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jagkagd%2Fnp-xarr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jagkagd%2Fnp-xarr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jagkagd%2Fnp-xarr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jagkagd","download_url":"https://codeload.github.com/jagkagd/np-xarr/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jagkagd%2Fnp-xarr/sbom","scorecard":{"id":502094,"data":{"date":"2025-08-11","repo":{"name":"github.com/jagkagd/np-xarr","commit":"067b3a75b303a6f58846ab2198def6c51e1ccc75"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","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":"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":"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":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"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":"Code-Review","score":0,"reason":"Found 0/29 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":-1,"reason":"No tokens found","details":null,"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":"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":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"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":"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":"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 'master'"],"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":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 2 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-19T22:11:39.984Z","repository_id":57447036,"created_at":"2025-08-19T22:11:39.984Z","updated_at":"2025-08-19T22:11:39.984Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32278249,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-25T18:29:39.964Z","status":"ssl_error","status_checked_at":"2026-04-25T18:29:32.149Z","response_time":59,"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":["numpy","python"],"created_at":"2025-02-17T04:30:30.437Z","updated_at":"2026-04-25T21:32:47.604Z","avatar_url":"https://github.com/jagkagd.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# np-xarr\n\nPerform a numpy array transformation intuitively by giving simple patterns.\n\n## Install\n\n```shell script\n$ pip install np-xarr\n```\n\n## Usage\n\n```python\n\u003e\u003e from npxarr import X\n\u003e\u003e import numpy as np\n\n\u003e\u003e a = X('[1, 2, 3, ...]', '[[1, 2], [2, 3], ...]')(np.r_[0, 1, 2, 3, 4, 5]) # sliding window\n\n[[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]]\n\n\u003e\u003e a = X('[[1, 2, ...], \n    [3, 4, ...], ...]', '[[1, 3, ...], [2, 4, ...], ...]') # transpose\n\u003e\u003e a(np.array([[0, 1], [2, 3], [4, 5]])\n\n[[0 2 4]\n [1 3 5]]\n```\nor a simpler form:\n```python\n\u003e\u003e a = X('[[a0, a1], [a1, a2], ...]')\n\u003e\u003e a = X('[[a00, a10, ...], [a01, a11, ...], ...]')\n```\nwhere `a` denotes the first input array, the number behind it denotes the index of the item.\nFor example, `a01` means the item in the first input array with index `(0, 1)`.\n\n\nMultiple inputs or outputs are supported.\n\n```python\n\u003e\u003e a = X(['[1, 2, ...]', '[a, b, ...]'],  # multiple input in a list\n         '[1, a, 2, b, ...]; [[a, 1], [b, 2], ...]') # or seperate by ;\n# or \u003e\u003e a = X('[a0, b0, a1, b1, ...]; [[b0, a0], [b1, a1], ...]')\n\u003e\u003e a([np.r_[1, 2, 3, 4, 5], np.r_[10, 20, 30]]) # for incompatible input shapes, it can figure out the maximum valid output shape\n\n(array([ 1, 10,  2, 20,  3, 30,  4], dtype=int32), \n array([[10,  1], [20,  2], [30,  3]], dtype=int32))\n\n\u003e\u003e a[1]([np.r_[1, 2], np.r_[10, 20, 30]) # or just get the transformation for second output\n\n[[10  1], [20  2]]\n```\nFunctions can be applied.\n```python\n\u003e\u003e a = X('[1, 2, 3, 4, ...]', '[times(2), neg(1), times(4), neg(3), ...]', \n         f={'neg': lambda x: -x, 'times': lambda x: 10*x})\n# a = X('[times(a1), neg(a0), times(a3), neg(a2), ...]')\n```\nnotice here the output with sequence [2, 1, 4, 3, ...]\n```python\n\u003e\u003e a(np.r_[0, 1, 2, 3, 4, 5])\n\n[10, 0, 30, -2, 50, -4]\n```\nand unpacking\n```python\n\u003e\u003e a = X('1; 2', '[*1, *2, *1]')([np.r_[1, 2],  np.r_[10, 20]])\n# a = X('[*a, *b, *a]')\n\n[ 1  2 10 20  1  2]\n```\nYou can provide output shape by hand\n```python\n\u003e\u003e a = X('[1, 2, ...]', '[[1, 1, ...], [2, 2, ...], ...]')\n# a = X('[[a0, a0, ...], [a1, a1, ...], ...]')\n\u003e\u003e a(np.arange(6), outShapes=(-1, 3)) # or outShapes=[(-1, 3)], \n\n[[0 0 0]\n [1 1 1]\n [2 2 2]\n [3 3 3]\n [4 4 4]\n [5 5 5]]\n```\nAnd by providing parameter `extraShapes`...\n```python\n\u003e\u003e a = X('[1, 2, 3, ...]', '[[1, 2], [2, 3], ...]')\n# a = X('[[a0, a1], [a1, a2], ...]')\n\u003e\u003e a(np.r_[0, 1, 2, 3], extraShapes=(1, 0)))\n\n[[0 1]\n [1 2]\n [2 3]\n [3 0]]\n```\n\n## How np-xarr does\n\nWhen the pattern is given, e.g.,\n\n```python\n\u003e\u003e a = X('[a, b, c, ...]', '[[a, b], [b, c], ...]')\n```\n`X` will deduce the transformation equation between the input and output, and can be seen by\n```python\n\u003e\u003e a\n\ny0 = |_x0_| + |_x1_|\n```\nwhere `|_x0_|` means `floor(x0)`.\nThe equation `y0 = |_x0_| + |_x1_|` build the relation between the output index `(x0, x1)` and the input index `(y0,)` as follows:\n\noutput index (x0, x1) | item | equation (x0, x1) -\u003e (y0, ) | index (y0, ) | input item |\n--------------------- | ---- | -------- | ------------------ | ---- |\n(0, 0) | a | 0 + 0 = 0 | (0, ) | a\n(0, 1) | b | 0 + 1 = 1 | (1, ) | b\n(1, 0) | b | 1 + 0 = 1 | (1, ) | b\n(1, 1) | c | 1 + 1 = 2 | (2, ) | c\n\nAnother example:\n```python\n\u003e\u003e a = X('[a, b, ...]', '[a, a, b, b, ...]')\n\u003e\u003e a\n\ny0 = |_0.50*x0_|\n```\n\noutput index (x0, ) | item | equation (x0, ) -\u003e (y0, ) | input index (y0, ) | item |\n------------------- | ---- | -------- | ------------------ | ---- |\n(0, ) | a | floor(0.5*0) = 0 | (0, ) | a\n(1, ) | a | floor(0.5*1) = 0 | (0, ) | a\n(2, ) | b | floor(0.5*2) = 1 | (1, ) | b\n(3, ) | b | floor(0.5*3) = 2 | (1, ) | b\n\n## Notes:\n\n* It is recommended to write patterns with at least two periods, e.g. [1, 2, ...] -\u003e [[1, 2], ...] will be inferred as [1, 2, 3, ...] -\u003e [[1, 2], [2, 3], ...] rather than [[1, 2], [3, 4], ...]\n\n* Inefficient for large array\n\n    The output array is built by code like `np.array([inArrays[indexConverter(index)] for index \u003c= outShape])`\n\n* Only support transformation with formula `$y_j = floor(a_ij*x_i) + b_j + floor(c_ij*mod(x_i, d_ij))$`\n\n## Todo\n\n- [ ] Improve exception system\n- [ ] Try to deduce possible transformation using native numpy function from calculated equation\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjagkagd%2Fnp-xarr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjagkagd%2Fnp-xarr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjagkagd%2Fnp-xarr/lists"}