GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

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 #119

Copy link
Copy link
Closed
#129
Closed
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#119
#129
Copy link

Description

@tae898
tae898
opened on Oct 3, 2026
Issue body actions

Level: bindings. numpy.bool_ is not a subclass of bool, so convert_python_to_java and Database._convert_args hand it to JPype unchanged, and JPype converts it as a number: the property is stored as a Java Double 1.0 or 0.0. It reads back as a Python float, WHERE ok = true no longer matches it, and no error is raised. A declared BOOLEAN property converts the value to a boolean, so the same program stores a bool or a float depending on the schema. The value is easy to produce by accident: df.iloc[0]["ok"] on a pandas DataFrame with a bool column is a numpy.bool, as are the results of numpy comparisons.

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 arcadedb_embedded-26.10.1.dev0-cp312-cp312-manylinux_2_34_x86_64.whl with its bundled JRE (OpenJDK 25.0.4.1), JPype 1.7.1, and Python 3.12.13. The engine build the wheel reports through com.arcadedb.Constants is 26.10.1-SNAPSHOT (build 04bb03ebec07fce19101595d65ca1e3bdf516755), an ancestor of upstream cecb369df9. The repository is at f92ac1381c8335249a6fde644cbf04594f6d6391, and the installed Python sources are identical to bindings/python/src/arcadedb_embedded/ at that commit.

df.iloc[0]['ok'] is <class 'numpy.bool'> ; isinstance(..., bool): False
  Document.set     reads back 1.0 (float)
  SQL positional   reads back 1.0 (float)
  SQL named        reads back 1.0 (float)
  python bool      reads back True (bool)
  declared BOOLEAN reads back True
  WHERE ok = true matches: 1 of 4 rows

A probe that wrote the other numpy scalars through the same four paths found only this one wrong: np.int64 and np.int32 come back as int, np.float64, np.float32, and np.float16 as float, np.str_ as str, and np.uint64(2**63) raises OverflowError.

Cause

convert_python_to_java converts Decimal, set, dict, list, tuple, datetime, date, bytes, and bytearray, and returns every other value as is (type_conversion.py L539). Database._convert_args does the same for a positional parameter (core.py L104), and for a named parameter the dict goes through convert_python_to_java. The numpy.bool_ therefore reaches JPype, which maps it to a number.

Expected

A numpy.bool_ is stored as a boolean, like a Python bool.

Proposed fix

Convert numpy.bool_ to bool in convert_python_to_java and in the final branch of _convert_args. The check is narrow on purpose: numpy.generic.item() would also change datetime64 and float32 values, which are better left as they are. I checked this with a run-time monkeypatch that leaves the repository untouched: with it all four paths read back True and WHERE ok = true matches 4 of 4 rows.

--- 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 Decimal, date, and datetime parameters and did not cover numpy scalars.

In this repository's tracker no issue is about this. The searches for numpy and numpy bool found nothing.

Related reports from the same review: #120 (to_java_int_array wraps).

Activity

  1. tae898
    added a commit that references this issue on Oct 3, 2026

    bindings: numpy bool, int32 arrays, lookup_by_key, append_samples, ge…

    663a57e
  2. tae898
    closed this as completedin #129on Oct 3, 2026
  3. tae898
    added a commit that references this issue on Oct 6, 2026

    benchmarks: the instrument changes for the 26.10.1 re-pin campaign, w…

    11cdf96
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue 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.