|
@@ -300,7 +300,7 @@ export function getTensor(category: CifCategory, field: string, space: Tensor.Sp
|
|
|
}
|
|
|
|
|
|
export function getCifFieldType(field: CifField): Column.Schema.Int | Column.Schema.Float | Column.Schema.Str {
|
|
|
- let floatCount = 0, scientificCount = 0, hasString = false, undefinedCount = 0;
|
|
|
+ let floatCount = 0, hasStringOrScientific = false, undefinedCount = 0;
|
|
|
for (let i = 0, _i = field.rowCount; i < _i; i++) {
|
|
|
const k = field.valueKind(i);
|
|
|
if (k !== Column.ValueKind.Present) {
|
|
@@ -310,14 +310,11 @@ export function getCifFieldType(field: CifField): Column.Schema.Int | Column.Sch
|
|
|
const type = getNumberType(field.str(i));
|
|
|
if (type === NumberType.Int) continue;
|
|
|
else if (type === NumberType.Float) floatCount++;
|
|
|
- else if (type === NumberType.Scientific) scientificCount++;
|
|
|
- else { hasString = true; break; }
|
|
|
+ else { hasStringOrScientific = true; break; }
|
|
|
}
|
|
|
|
|
|
- if (hasString || undefinedCount === field.rowCount) return Column.Schema.str;
|
|
|
// numbers in scientific notation and plain text are not distinguishable
|
|
|
- // keep as text if there is no other number type
|
|
|
- if (scientificCount === field.rowCount) return Column.Schema.str;
|
|
|
- if (floatCount > 0 || scientificCount > 0) return Column.Schema.float;
|
|
|
+ if (hasStringOrScientific || undefinedCount === field.rowCount) return Column.Schema.str;
|
|
|
+ if (floatCount > 0) return Column.Schema.float;
|
|
|
return Column.Schema.int;
|
|
|
}
|