GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — A numpy bool (np.bool_) is stored as the float 1.0 or 0.0 by Document.set, positional and named parameters, and every other write path · Issue #119 · humemai/arcadedb-embedded-python
This repository was archived by the owner on Nov 21, 2026. It is now read-only.
This repository was archived by the owner on Nov 21, 2026. It is now read-only.
A numpy bool (np.bool_) is stored as the float 1.0 or 0.0 by Document.set, positional and named parameters, and every other write path #119Copy link Copy link Closed DescriptionLevel: bindings. Repro The script prints to stdout. The JVM's own log lines go to stderr and are discarded by the command below. uv venv .venv
uv pip install --python .venv/bin/python arcadedb_embedded-26.10.1.dev0-cp312-cp312-manylinux_2_34_x86_64.whl numpy pandas
.venv/bin/python repro-12-numpy-bool-becomes-float.py 2>/dev/null"""A numpy bool (np.bool_) is stored as the float 1.0 / 0.0, through every write path, with no error.""" import os import tempfile import numpy as np import pandas as pd import arcadedb_embedded as arcade from arcadedb_embedded.jvm import start_jvm start_jvm(heap_size="2g") db = arcade.create_database(os.path.join(tempfile.mkdtemp(prefix="hb12-"), "db")) db.command("sql", "CREATE DOCUMENT TYPE Flag") db.command("sql", "CREATE DOCUMENT TYPE FlagBool") db.command("sql", "CREATE PROPERTY FlagBool.ok BOOLEAN") df = pd.DataFrame({"n": [1, 2], "ok": [True, False]}) value = df.iloc[0]["ok"] # what row access on a DataFrame hands back print("df.iloc[0]['ok'] is", type(value), "; isinstance(..., bool):", isinstance(value, bool)) with db.transaction(): d = db.new_document("Flag") d.set("how", "Document.set") d.set("ok", value) d.save() db.command("sql", "INSERT INTO Flag SET how = 'SQL positional', ok = ?", value) db.command("sql", "INSERT INTO Flag SET how = 'SQL named', ok = :ok", {"ok": value}) d = db.new_document("FlagBool") # a declared BOOLEAN converts it d.set("ok", value) d.save() db.command("sql", "INSERT INTO Flag SET how = 'python bool', ok = ?", True) for row in db.query("sql", "SELECT how, ok FROM Flag ORDER BY @rid").to_list(): print(f" {row['how']:<16} reads back {row['ok']!r} ({type(row['ok']).__name__})") print(f" {'declared BOOLEAN':<16} reads back {db.query('sql', 'SELECT ok FROM FlagBool').first().get('ok')!r}") print(" WHERE ok = true matches:", db.query("sql", "SELECT FROM Flag WHERE ok = true").count(), "of", db.count_type("Flag"), "rows") db.close() Output Wheel A probe that wrote the other numpy scalars through the same four paths found only this one wrong: Cause
Expected A Proposed fix Convert --- a/bindings/python/src/arcadedb_embedded/type_conversion.py +++ b/bindings/python/src/arcadedb_embedded/type_conversion.py @@ def convert_python_to_java(value): + if _np is not None and isinstance(value, _np.bool_): + return bool(value) --- a/bindings/python/src/arcadedb_embedded/core.py +++ b/bindings/python/src/arcadedb_embedded/core.py @@ def _convert_args(args): - converted_args.append(arg) + converted_args.append(bool(arg) if _np is not None and isinstance(arg, _np.bool_) else arg) Related issues Nothing found upstream. Issue #58 (closed) fixed In this repository's tracker no issue is about this. The searches for Related reports from the same review: #120 (to_java_int_array wraps). Activity
MetadataMetadataAssigneesLabelsNo labels TypeProjectsMilestoneRelationshipsDevelopmentIssue actions |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |