replace NaNs with None - correctly goes to null
@@ -730,7 +730,7 @@ class LASFile(object):
mnemonic = list(mnemonic)
if (not mnemonic) or (not all([i for i in mnemonic])):
- raise ValueError('`mnemonic` must not contain empty element')
+ raise ValueError("`mnemonic` must not contain empty element")
keys = self.curves.keys()
if isinstance(mnemonic, str):
@@ -738,16 +738,17 @@ class LASFile(object):
elif isinstance(mnemonic, Sequence):
channels = list(mnemonic)
else:
- raise TypeError('`mnemonic` argument must be string or sequence')
+ raise TypeError("`mnemonic` argument must be string or sequence")
print(channels)
if not set(keys).issuperset(set(channels)):
- missing = ', '.join(set(channels).difference(set(keys)))
- raise KeyError('{} not found in LAS curves.'.format(missing))
+ missing = ", ".join(set(channels).difference(set(keys)))
+ raise KeyError("{} not found in LAS curves.".format(missing))
if sort_curves:
- nat_sort = lambda x: \
- [int(i) if i.isdigit() else i for i in re.split(r'(\d+)', x)]
+ nat_sort = lambda x: [
+ int(i) if i.isdigit() else i for i in re.split(r"(\d+)", x)
+ ]
channels.sort(key=nat_sort)
indices = [keys.index(i) for i in channels]
@@ -903,5 +904,7 @@ class JSONEncoder(json.JSONEncoder):
for item in section:
d["metadata"][name].append(dict(item))
for curve in obj.curves:
- d["data"][curve.mnemonic] = list(curve.data)
+ d["data"][curve.mnemonic] = [
+ None if np.isnan(x) else x for x in curve.data
+ ]
return d
