浏览代码

evaluate datatype without pandas for strings (#601) (#602)

Co-authored-by: Fred Lefévère-Laoide <Fred.Lefevere-Laoide@Taipy.io>
Fred Lefévère-Laoide 1 年之前
父节点
当前提交
83b68990a8
共有 2 个文件被更改,包括 8 次插入9 次删除
  1. 1 3
      frontend/taipy-gui/src/components/Taipy/Field.tsx
  2. 7 6
      taipy/gui/utils/datatype.py

+ 1 - 3
frontend/taipy-gui/src/components/Taipy/Field.tsx

@@ -53,9 +53,7 @@ const Field = (props: TaipyFieldProps) => {
     return (
     return (
         <Tooltip title={hover || ""}>
         <Tooltip title={hover || ""}>
             {mode == "pre" ? (
             {mode == "pre" ? (
-                <pre className={className} id={id}>
-                    {value}
-                </pre>
+                <pre className={className} id={id}>{value}</pre>
             ) : mode == "markdown" || mode == "md" ? (
             ) : mode == "markdown" || mode == "md" ? (
                 <Markdown className={className}>{value}</Markdown>
                 <Markdown className={className}>{value}</Markdown>
             ) : raw || mode == "raw" ? (
             ) : raw || mode == "raw" ? (

+ 7 - 6
taipy/gui/utils/datatype.py

@@ -15,10 +15,11 @@ import pandas as pd
 
 
 
 
 def _get_data_type(value):
 def _get_data_type(value):
-    if pd.api.types.is_bool_dtype(value):
-        return "bool"
-    elif pd.api.types.is_integer_dtype(value):
-        return "int"
-    elif pd.api.types.is_float_dtype(value):
-        return "float"
+    if not isinstance(value, str):
+        if pd.api.types.is_bool_dtype(value):
+            return "bool"
+        elif pd.api.types.is_integer_dtype(value):
+            return "int"
+        elif pd.api.types.is_float_dtype(value):
+            return "float"
     return re.match(r"^<class '(.*\.)?(.*?)(\d\d)?'>", str(type(value))).group(2)
     return re.match(r"^<class '(.*\.)?(.*?)(\d\d)?'>", str(type(value))).group(2)