Skip to content

Commit

Permalink
unpin numpy again and set printing behaviour to np-1.25
Browse files Browse the repository at this point in the history
  • Loading branch information
marscher committed Oct 28, 2024
1 parent e2ad8c8 commit 8a30082
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ dependencies = [
"ipywidgets",
"k3d>=2.12",
"matplotlib<3.9",
"numpy<2",
"tqdm",
"weldx>=0.6",
]
Expand Down
16 changes: 10 additions & 6 deletions weldx_widgets/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@

import numpy as np
import pandas as pd
from ipyfilechooser import FileChooser
import weldx
from IPython import get_ipython
from ipyfilechooser import FileChooser
from ipywidgets import HTML, Button, HBox, Label

import weldx
from weldx_widgets.widget_base import WeldxImportExport, WidgetMyHBox, WidgetMyVBox
from weldx_widgets.widget_factory import (
WidgetLabeledTextInput,
Expand Down Expand Up @@ -147,17 +147,21 @@ def from_tree(self, tree: dict):
self.time_data.text_value = f"[{foo}]"
else:
self.time_data.text_value = ""

self.base_data.text_value = repr(list(ts.data.magnitude))
if np.__version__ > "2":
with np.printoptions(legacy='1.25'):
self.base_data.text_value = repr(list(ts.data.magnitude))
else:
self.base_data.text_value = repr(list(ts.data.magnitude))
self.base_unit.text_value = format(ts.data.units, "~")


def is_safe_nd_array(input_str: str):
"""Check if input_string is a numerical array (allowing floats [with scientific notation), and ints."""
# Regex pattern to match 1-D and N-D arrays with numbers
pattern = (
r"^\s*(\[\s*(?:(-?\d+(\.\d+)?([eE][+-]?\d+)?|\[\s*.*?\s*\])\s*(,\s*)?)*\]\s*|\s*(-?\d+(\.\d+)?"
r"([eE][+-]?\d+)?)(\s*,\s*(-?\d+(\.\d+)?([eE][+-]?\d+)?))*\s*)?\s*$"
r"^\s*(\[\s*(?:(-?\d+(\.\d+)?([eE][+-]?\d+)"
r"?|\[\s*.*?\s*\])\s*(,\s*)?)*\]\s*|\s*(-?\d+(\.\d+)"
r"?([eE][+-]?\d+)?)(\s*,\s*(-?\d+(\.\d+)?([eE][+-]?\d+)?))*\s*)?\s*$"
)

return bool(re.match(pattern, input_str))
Expand Down

0 comments on commit 8a30082

Please sign in to comment.