Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
1. [#733](https://github.com/influxdata/influxdb-client-python/pull/733): Write the last batch when the batching `WriteApi` is closed in an `atexit` handler instead of dropping it with "cannot schedule new futures after interpreter shutdown".
1. [#734](https://github.com/influxdata/influxdb-client-python/pull/734): Match `data_frame_timestamp_column` by exact column name, so a field whose name is part of the timestamp column name (e.g. `Open` with `OpenTime`) is no longer dropped.
1. [#739](https://github.com/influxdata/influxdb-client-python/pull/739): Async CSV query cancellation no longer raises `AttributeError` with pre 3.11 release Python platforms.
1. [#740](https://github.com/influxdata/influxdb-client-python/pull/740): Avoid loading NumPy when importing the client.

## 1.50.0 [2026-01-23]

Expand Down
14 changes: 6 additions & 8 deletions influxdb_client/client/write/point.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,6 @@
'\\': r'\\',
})

try:
import numpy as np

_HAS_NUMPY = True
except ModuleNotFoundError:
_HAS_NUMPY = False


class Point(object):
"""
Expand Down Expand Up @@ -361,7 +354,12 @@ def _convert_timestamp(timestamp, precision=DEFAULT_WRITE_PRECISION):


def _np_is_subtype(value, np_type):
if not _HAS_NUMPY or not hasattr(value, 'dtype'):
if not hasattr(value, 'dtype'):
return False

try:
import numpy as np
except ModuleNotFoundError:
return False

if np_type == 'float':
Expand Down
14 changes: 14 additions & 0 deletions tests/test_point.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# -*- coding: utf-8 -*-

import subprocess
import sys
import unittest
from datetime import datetime, timezone, timedelta
from decimal import Decimal
Expand Down Expand Up @@ -394,6 +396,18 @@ def test_backslash(self):
"test,tag1=value1,tag2=value\2,tag3=value\\3,tag4=value\\4,tag5=value\\\\5 value=10i 1624989000000000000",
point.to_line_protocol())

def test_import_does_not_load_numpy(self):
pytest.importorskip("numpy")

script = (
"import sys\n"
"from influxdb_client import Point\n"
"assert 'numpy' not in sys.modules, 'Importing influxdb_client loaded NumPy'\n"
"assert Point('sample').field('value', 1).to_line_protocol() == 'sample value=1i'\n"
"assert 'numpy' not in sys.modules, 'Serializing a built-in integer loaded NumPy'\n"
)
subprocess.run([sys.executable, "-c", script], check=True)

def test_numpy_types(self):
from influxdb_client.extras import np

Expand Down