René's URL Explorer Experiment


Title: Fix SparseVector error for non-1D NumPy arrays by Aftabbs · Pull Request #175 · pgvector/pgvector-python · GitHub

Open Graph Title: Fix SparseVector error for non-1D NumPy arrays by Aftabbs · Pull Request #175 · pgvector/pgvector-python

X Title: Fix SparseVector error for non-1D NumPy arrays by Aftabbs · Pull Request #175 · pgvector/pgvector-python

Description: Summary SparseVector accepted any NumPy array and only failed (or silently misbehaved) deep inside _from_dense. Vector, HalfVector, Bit and the scipy path of SparseVector all raise ValueError('expected ndim to be 1') for non-1D input; this makes the dense NumPy path consistent. Root Cause / Motivation _from_dense does len(value) and float(v) per element: SparseVector(np.zeros((2, 2))) raised TypeError: only length-1 arrays can be converted to Python scalars SparseVector(np.array(5.0)) raised TypeError: len() of unsized object SparseVector(np.array([[1], [0], [2]])) was silently accepted as a 3-dimensional vector (each size-1 row coerced by float()), while Vector rejects the same input Callers that catch ValueError for bad input (e.g. the SQLAlchemy test_bad_ndim pattern) never see these cases. Changes File What changed pgvector/sparsevec.py Raise ValueError('expected ndim to be 1') in _from_dense for non-1D ndarrays tests/test_sparse_vector.py test_init_ndarray_ndim covers 2D, column, and 0-d arrays (fails before the fix) CHANGELOG.md Entry under 0.5.2 Testing Existing tests pass (123 across sparse/vector/halfvec/bit) New test fails without the change, passes with it Impact Consistent, catchable error for bad NumPy input across all vector types; no behavior change for valid 1D input. 🤖 Generated with Claude Code

Open Graph Description: Summary SparseVector accepted any NumPy array and only failed (or silently misbehaved) deep inside _from_dense. Vector, HalfVector, Bit and the scipy path of SparseVector all raise ValueError('...

X Description: Summary SparseVector accepted any NumPy array and only failed (or silently misbehaved) deep inside _from_dense. Vector, HalfVector, Bit and the scipy path of SparseVector all raise ValueError(&...

Opengraph URL: https://github.com/pgvector/pgvector-python/pull/175

X: @github

direct link

Domain: github.com

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:d4d49365-2acc-7862-e3c2-606b60f77f69
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-id9A56:A7C31:B6054A:EE8EF8:6AFE8858
html-safe-nonceb00bd4bdf5373165afb1acadadfb2370fdd8cf259d3d8e72c4da804160d638dc
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QTU2OkE3QzMxOkI2MDU0QTpFRThFRjg6NkFGRTg4NTgiLCJ2aXNpdG9yX2lkIjoiMTM0MDkwMTE2MTExMjA3ODQyNCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac35ec9d3f7bdcc14e721dbd1d509ce354e2c1a20392739a8b7af0005765e935cf
hovercard-subject-tagpull_request:5288425077
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/pgvector/pgvector-python/pull/175/files
twitter:imagehttps://avatars.githubusercontent.com/u/112916888?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/112916888?s=400&v=4
og:image:altSummary SparseVector accepted any NumPy array and only failed (or silently misbehaved) deep inside _from_dense. Vector, HalfVector, Bit and the scipy path of SparseVector all raise ValueError('...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
Noneb3c0f155eafc27e60db6e254d1ffff0e072e9ab3b4018a5ee518797c19d89f86
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/pgvector/pgvector-python git https://github.com/pgvector/pgvector-python.git
octolytics-dimension-user_id98363230
octolytics-dimension-user_loginpgvector
octolytics-dimension-repository_id376300726
octolytics-dimension-repository_nwopgvector/pgvector-python
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id376300726
octolytics-dimension-repository_network_root_nwopgvector/pgvector-python
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release4a10310af51a1bfffbedc4fd81cb582acf0cb0ff
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/pgvector/pgvector-python/pull/175/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpgvector%2Fpgvector-python%2Fpull%2F175%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpgvector%2Fpgvector-python%2Fpull%2F175%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=pgvector%2Fpgvector-python
Reloadhttps://github.com/pgvector/pgvector-python/pull/175/files
Reloadhttps://github.com/pgvector/pgvector-python/pull/175/files
Reloadhttps://github.com/pgvector/pgvector-python/pull/175/files
pgvectorhttps://github.com/pgvector
pgvector-pythonhttps://github.com/pgvector/pgvector-python
Codehttps://github.com/pgvector/pgvector-python
Issues2 (2)https://github.com/pgvector/pgvector-python/issues
Pull requests8 (8)https://github.com/pgvector/pgvector-python/pulls
Actionshttps://github.com/pgvector/pgvector-python/actions
Security and qualityhttps://github.com/pgvector/pgvector-python/security
Insightshttps://github.com/pgvector/pgvector-python/insights
Sign up for GitHub https://github.com/signup?return_to=%2Fpgvector%2Fpgvector-python%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fpgvector%2Fpgvector-python%2Fissues%2Fnew%2Fchoose
Aftabbshttps://github.com/Aftabbs
pgvector:masterhttps://github.com/pgvector/pgvector-python/tree/master
Aftabbs:fix/sparsevector-ndarray-ndimhttps://github.com/Aftabbs/pgvector-python/tree/fix/sparsevector-ndarray-ndim
Conversation 0 https://github.com/pgvector/pgvector-python/pull/175
Commits 1 https://github.com/pgvector/pgvector-python/pull/175/commits
Checks 0 https://github.com/pgvector/pgvector-python/pull/175/checks
Files changed 3 https://github.com/pgvector/pgvector-python/pull/175/files
Fix SparseVector error for non-1D NumPy arrays https://github.com/pgvector/pgvector-python/pull/175/files#top
Show all changes 1 commit https://github.com/pgvector/pgvector-python/pull/175/files
3112762 fix(sparsevec): reject non-1D NumPy arrays with ValueError Aftabbs Nov 13, 2026 https://github.com/pgvector/pgvector-python/pull/175/commits/311276216e7197b5307c65d4bf87db51c89c6c48
Clear filters https://github.com/pgvector/pgvector-python/pull/175/files
Please reload this pagehttps://github.com/pgvector/pgvector-python/pull/175/files
Please reload this pagehttps://github.com/pgvector/pgvector-python/pull/175/files
CHANGELOG.md https://github.com/pgvector/pgvector-python/pull/175/files#diff-06572a96a58dc510037d5efa622f9bec8519bc1beab13c9f251e97e657a9d4ed
sparsevec.py https://github.com/pgvector/pgvector-python/pull/175/files#diff-9c620d300643a28e15ec266adb7af3fe7aadd4ebd49de2577d23c934b3ce0822
test_sparse_vector.py https://github.com/pgvector/pgvector-python/pull/175/files#diff-538d462d1f06ddc91e5be9c6805907e1a1d5edbc3aab0f8007ff8ef5bed9dccb
CHANGELOG.mdhttps://github.com/pgvector/pgvector-python/pull/175/files#diff-06572a96a58dc510037d5efa622f9bec8519bc1beab13c9f251e97e657a9d4ed
View file https://github.com/pgvector/pgvector-python/blob/311276216e7197b5307c65d4bf87db51c89c6c48/CHANGELOG.md
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/pgvector/pgvector-python/pull/175/{{ revealButtonHref }}
https://github.com/pgvector/pgvector-python/pull/175/files#diff-06572a96a58dc510037d5efa622f9bec8519bc1beab13c9f251e97e657a9d4ed
https://github.com/pgvector/pgvector-python/pull/175/files#diff-06572a96a58dc510037d5efa622f9bec8519bc1beab13c9f251e97e657a9d4ed
pgvector/sparsevec.pyhttps://github.com/pgvector/pgvector-python/pull/175/files#diff-9c620d300643a28e15ec266adb7af3fe7aadd4ebd49de2577d23c934b3ce0822
View file https://github.com/pgvector/pgvector-python/blob/311276216e7197b5307c65d4bf87db51c89c6c48/pgvector/sparsevec.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/pgvector/pgvector-python/pull/175/{{ revealButtonHref }}
https://github.com/pgvector/pgvector-python/pull/175/files#diff-9c620d300643a28e15ec266adb7af3fe7aadd4ebd49de2577d23c934b3ce0822
https://github.com/pgvector/pgvector-python/pull/175/files#diff-9c620d300643a28e15ec266adb7af3fe7aadd4ebd49de2577d23c934b3ce0822
https://github.com/pgvector/pgvector-python/pull/175/files#diff-9c620d300643a28e15ec266adb7af3fe7aadd4ebd49de2577d23c934b3ce0822
tests/test_sparse_vector.pyhttps://github.com/pgvector/pgvector-python/pull/175/files#diff-538d462d1f06ddc91e5be9c6805907e1a1d5edbc3aab0f8007ff8ef5bed9dccb
View file https://github.com/pgvector/pgvector-python/blob/311276216e7197b5307c65d4bf87db51c89c6c48/tests/test_sparse_vector.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/pgvector/pgvector-python/pull/175/{{ revealButtonHref }}
https://github.com/pgvector/pgvector-python/pull/175/files#diff-538d462d1f06ddc91e5be9c6805907e1a1d5edbc3aab0f8007ff8ef5bed9dccb
https://github.com/pgvector/pgvector-python/pull/175/files#diff-538d462d1f06ddc91e5be9c6805907e1a1d5edbc3aab0f8007ff8ef5bed9dccb
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.