FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
pgvector-python/pgvector/sqlalchemy/bit.py at master · pgvector/pgvector-python · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
pgvector
/
pgvector-python
Public
Notifications
You must be signed in to change notification settings
Fork
93
Star
1.5k
Code
Issues
0
Pull requests
4
Actions
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Security and quality
Insights
Expand file tree
Breadcrumbs
pgvector-python
/
pgvector
/
sqlalchemy
/
bit.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
24 lines (18 loc) · 857 Bytes
Breadcrumbs
pgvector-python
/
pgvector
/
sqlalchemy
/
bit.py
Copy path
File metadata and controls
24 lines (18 loc) · 857 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from
sqlalchemy
.
dialects
.
postgresql
.
base
import
PGBit
from
sqlalchemy
.
types
import
TypeDecorator
,
Float
from
sqlalchemy
import
Operators
from
typing
import
Any
class
BIT
(
TypeDecorator
[
Any
]):
impl
=
PGBit
cache_ok
=
True
def
process_bind_param
(
self
,
value
:
Any
,
dialect
:
Any
)
->
Any
:
if
dialect
.
__class__
.
__name__
==
'PGDialect_asyncpg'
and
isinstance
(
value
,
str
):
import
asyncpg
return
asyncpg
.
BitString
(
value
)
# type: ignore
return
value
class
Comparator
(
TypeDecorator
.
Comparator
[
Any
]):
def
hamming_distance
(
self
,
other
:
object
,
/
)
->
Operators
:
return
self
.
op
(
'<~>'
,
return_type
=
Float
)(
other
)
def
jaccard_distance
(
self
,
other
:
object
,
/
)
->
Operators
:
return
self
.
op
(
'<%>'
,
return_type
=
Float
)(
other
)
comparator_factory
=
Comparator
# type: ignore
Back
|
FazBrowse Home
|
New Git URL