Add LooseVersion compatibility
The distutils LooseVersion class is replaced by the looseversion package
This commit is contained in:
parent
c2e1384a5c
commit
fff3a01648
|
@ -17,7 +17,7 @@
|
||||||
# along with this msspec. If not, see <http://www.gnu.org/licenses/>.
|
# along with this msspec. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
# Source file : src/msspec/iodata.py
|
# Source file : src/msspec/iodata.py
|
||||||
# Last modified: Wed, 18 Jun 2025 11:46:41 +0200
|
# Last modified: Wed, 18 Jun 2025 13:30:09 +0200
|
||||||
# Committed by : Sylvain Tricot <sylvain.tricot@univ-rennes.fr>
|
# Committed by : Sylvain Tricot <sylvain.tricot@univ-rennes.fr>
|
||||||
|
|
||||||
|
|
||||||
|
@ -70,8 +70,7 @@ Here is an example of how to store values in a Data object:
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
from distutils.version import LooseVersion
|
from looseversion import LooseVersion
|
||||||
from distutils.version import StrictVersion
|
|
||||||
from io import StringIO
|
from io import StringIO
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
|
@ -80,9 +79,7 @@ from ase.io.extxyz import read_xyz, write_xyz
|
||||||
import h5py
|
import h5py
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from lxml import etree
|
from lxml import etree
|
||||||
#from matplotlib.backends.backend_wxagg import FigureCanvasWx as FigureCanvas
|
|
||||||
from matplotlib.backends.backend_agg import FigureCanvasAgg
|
from matplotlib.backends.backend_agg import FigureCanvasAgg
|
||||||
#from matplotlib.backends.backend_cairo import FigureCanvasCairo as FigureCanvasAgg
|
|
||||||
from matplotlib.figure import Figure
|
from matplotlib.figure import Figure
|
||||||
from matplotlib import pyplot as plt
|
from matplotlib import pyplot as plt
|
||||||
from terminaltables import AsciiTable
|
from terminaltables import AsciiTable
|
||||||
|
@ -513,9 +510,7 @@ class DataSet(object):
|
||||||
if isinstance(value, t):
|
if isinstance(value, t):
|
||||||
fmt = f
|
fmt = f
|
||||||
break
|
break
|
||||||
#fd.write(' ')
|
|
||||||
fd.write(fmt.format(value))
|
fd.write(fmt.format(value))
|
||||||
#fd.write(str(value) + ', ')
|
|
||||||
fd.write('\n')
|
fd.write('\n')
|
||||||
|
|
||||||
def __getitem__(self, itemspec):
|
def __getitem__(self, itemspec):
|
||||||
|
@ -560,7 +555,6 @@ class DataSet(object):
|
||||||
|
|
||||||
def __len__(self):
|
def __len__(self):
|
||||||
try:
|
try:
|
||||||
#length = len(self._col_arrays[0])
|
|
||||||
length = 0
|
length = 0
|
||||||
for array in self._col_arrays:
|
for array in self._col_arrays:
|
||||||
length = max(length, len(array))
|
length = max(length, len(array))
|
||||||
|
@ -953,7 +947,6 @@ class _DataSetView(object):
|
||||||
axes.set_yticklabels(theta_ticks)
|
axes.set_yticklabels(theta_ticks)
|
||||||
|
|
||||||
cbar = figure.colorbar(im)
|
cbar = figure.colorbar(im)
|
||||||
#im.set_clim(0, 0.0275)
|
|
||||||
|
|
||||||
elif proj == 'polar':
|
elif proj == 'polar':
|
||||||
values[0] = np.radians(values[0])
|
values[0] = np.radians(values[0])
|
||||||
|
@ -1003,7 +996,6 @@ class _DataSetView(object):
|
||||||
root = etree.Element('view', name=self.title)
|
root = etree.Element('view', name=self.title)
|
||||||
for key, value in list(plotopts.items()):
|
for key, value in list(plotopts.items()):
|
||||||
root.attrib[key] = str(value)
|
root.attrib[key] = str(value)
|
||||||
#root.attrib['dataset_name'] = self.dataset.title
|
|
||||||
|
|
||||||
for tags, cond, legend in zip(self._selection_tags,
|
for tags, cond, legend in zip(self._selection_tags,
|
||||||
self._selection_conditions,
|
self._selection_conditions,
|
||||||
|
@ -1021,21 +1013,12 @@ class _DataSetView(object):
|
||||||
def from_xml(self, xmlstr):
|
def from_xml(self, xmlstr):
|
||||||
root = etree.fromstring(xmlstr)
|
root = etree.fromstring(xmlstr)
|
||||||
self.title = root.attrib['name']
|
self.title = root.attrib['name']
|
||||||
#self._plotopts['title'] = root.attrib['title']
|
|
||||||
#self._plotopts['xlabel'] = root.attrib['xlabel']
|
|
||||||
# self._plotopts['ylabel'] = root.attrib['ylabel']
|
|
||||||
# self._plotopts['grid'] = bool(root.attrib['grid'])
|
|
||||||
# self._plotopts['colorbar'] = bool(root.attrib['colorbar'])
|
|
||||||
# self._plotopts['projection'] = root.attrib['projection']
|
|
||||||
# self._plotopts['marker'] = root.attrib['marker']
|
|
||||||
for key in list(self._plotopts.keys()):
|
for key in list(self._plotopts.keys()):
|
||||||
try:
|
try:
|
||||||
self._plotopts[key] = eval(root.attrib.get(key))
|
self._plotopts[key] = eval(root.attrib.get(key))
|
||||||
except:
|
except:
|
||||||
self._plotopts[key] = root.attrib.get(key)
|
self._plotopts[key] = root.attrib.get(key)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
legends = []
|
legends = []
|
||||||
conditions = []
|
conditions = []
|
||||||
tags = []
|
tags = []
|
||||||
|
@ -1095,8 +1078,6 @@ if has_gui:
|
||||||
if is_hidden == "True":
|
if is_hidden == "True":
|
||||||
continue
|
continue
|
||||||
group = datatree.get(p['group'], [])
|
group = datatree.get(p['group'], [])
|
||||||
#strval = str(p['value'] * p['unit'] if p['unit'] else p['value'])
|
|
||||||
#group.append("{:s} = {:s}".format(p['name'], strval))
|
|
||||||
group.append("{} = {} {}".format(p['name'], p['value'], p['unit']))
|
group.append("{} = {} {}".format(p['name'], p['value'], p['unit']))
|
||||||
datatree[p['group']] = group
|
datatree[p['group']] = group
|
||||||
|
|
||||||
|
@ -1138,7 +1119,6 @@ if has_gui:
|
||||||
# Add the notebook to hold all graphs
|
# Add the notebook to hold all graphs
|
||||||
self.notebooks = {}
|
self.notebooks = {}
|
||||||
sizer = wx.BoxSizer(wx.VERTICAL)
|
sizer = wx.BoxSizer(wx.VERTICAL)
|
||||||
#sizer.Add(self.notebook)
|
|
||||||
self.SetSizer(sizer)
|
self.SetSizer(sizer)
|
||||||
|
|
||||||
self.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, self.on_page_changed)
|
self.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, self.on_page_changed)
|
||||||
|
@ -1155,7 +1135,6 @@ if has_gui:
|
||||||
for dset in self.data:
|
for dset in self.data:
|
||||||
nb = wx.Notebook(self, -1)
|
nb = wx.Notebook(self, -1)
|
||||||
self.notebooks[dset.title] = nb
|
self.notebooks[dset.title] = nb
|
||||||
#self.GetSizer().Add(nb, 1, wx.ALL|wx.EXPAND)
|
|
||||||
self.GetSizer().Add(nb, proportion=1, flag=wx.ALL|wx.EXPAND)
|
self.GetSizer().Add(nb, proportion=1, flag=wx.ALL|wx.EXPAND)
|
||||||
for view in dset.get_views():
|
for view in dset.get_views():
|
||||||
self.create_page(nb, view)
|
self.create_page(nb, view)
|
||||||
|
@ -1291,13 +1270,6 @@ if has_gui:
|
||||||
cluster_viewer = ClusterViewer(win, size=wx.Size(480, 340))
|
cluster_viewer = ClusterViewer(win, size=wx.Size(480, 340))
|
||||||
|
|
||||||
dset = self.data[self._current_dset]
|
dset = self.data[self._current_dset]
|
||||||
#s = StringIO()
|
|
||||||
#s.write(dset.get_parameter(group='Cluster', name='cluster')['value'])
|
|
||||||
#_s = dset.get_parameter(group='Cluster', name='cluster')['value']
|
|
||||||
#print(_s)
|
|
||||||
# rewind to the begining of the string
|
|
||||||
#s.seek(0)
|
|
||||||
#atoms = ase.io.read(s, format='xyz')
|
|
||||||
atoms = dset.get_cluster()
|
atoms = dset.get_cluster()
|
||||||
cluster_viewer.set_atoms(atoms, rescale=True, center=True)
|
cluster_viewer.set_atoms(atoms, rescale=True, center=True)
|
||||||
cluster_viewer.rotate_atoms(0., 180.)
|
cluster_viewer.rotate_atoms(0., 180.)
|
||||||
|
@ -1405,41 +1377,7 @@ if has_gui:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
if False:
|
|
||||||
data = Data('all my data')
|
|
||||||
dset = data.add_dset('Dataset 0')
|
|
||||||
X = np.arange(0, 20)
|
|
||||||
Y = X**2
|
|
||||||
|
|
||||||
dset.add_columns(x=X, y=Y, z=X+2, w=Y**3)
|
|
||||||
dset.add_parameter(name='truc', group='main', value='3.14', unit='eV')
|
|
||||||
dset.add_parameter(name='machin', group='main', value='abc', unit='')
|
|
||||||
|
|
||||||
# Z = [0,1]
|
|
||||||
#
|
|
||||||
# for z in Z:
|
|
||||||
# for x, y in zip(X, Y):
|
|
||||||
# dset.add_row(x=x, y=y, z=z, random=np.random.rand())
|
|
||||||
#
|
|
||||||
#
|
|
||||||
view = dset.add_view('my view', autoscale=True)
|
|
||||||
view.select('x', 'y', where="z<10", legend=r"z = 0")
|
|
||||||
view.select('x', 'y', where="z>10", legend=r"z = 1")
|
|
||||||
print(dset.get_parameter(group='main'))
|
|
||||||
constraint = lambda a, b: (a > 10 and a < 15) and b > 0
|
|
||||||
indices = list(map(constraint, dset.x, dset.w))
|
|
||||||
print(dset.y[indices])
|
|
||||||
|
|
||||||
#data.view()
|
|
||||||
import sys
|
import sys
|
||||||
data = Data.load(sys.argv[1])
|
data = Data.load(sys.argv[1])
|
||||||
data.view()
|
data.view()
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
ase
|
ase
|
||||||
h5py
|
h5py
|
||||||
ipython
|
ipython
|
||||||
|
looseversion
|
||||||
lxml
|
lxml
|
||||||
matplotlib
|
matplotlib
|
||||||
numpy
|
numpy
|
||||||
|
|
Loading…
Reference in New Issue