Skip to content

Commit 294708f

Browse files
committed
[#devel] Some cleanup, almost there: twine for checking README.md
1 parent 64b0c5d commit 294708f

File tree

3 files changed

+34
-36
lines changed

3 files changed

+34
-36
lines changed

CLASSIFIERS.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,3 @@ Programming Language :: Python :: 3.9
88
Programming Language :: Python :: 3.10
99
Programming Language :: Python :: 3.11
1010
Natural Language :: English
11-
License :: OSI Approved :: MIT License

README.md

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@ Examples:
4141
Straightforward array visualization:
4242
------------------------------------
4343

44-
```
44+
``
4545
import datastock as ds
4646

4747
# any 1d, 2d or 3d array
48-
aa = np.np.random.random((100, 100, 100))
48+
aa = np.random((100, 100, 100))
4949

5050
# plot interactive figure using shortcut to method
5151
dax = ds.plot_as_array(aa)
52-
```
52+
``
5353

5454
Now do **shift + left clic** on any axes, the rest of the interactive commands are automatically printed in your python console
5555

@@ -75,7 +75,7 @@ Thanks to dref, the class knows the relationaships between all numpy arrays.
7575
In particular it knows which arrays share the same references / dimensions
7676

7777

78-
```
78+
```python
7979
import numpy as np
8080
import datastock as ds
8181

@@ -96,24 +96,24 @@ lprof = [(1 + np.cos(t)[:, None]) * x[None, :] for t in lt]
9696
# Populate DataStock
9797

9898
# instanciate
99-
st = ds.DataStock()
99+
coll = ds.DataStock()
100100

101101
# add references (i.e.: store size of each dimension under a unique key)
102-
st.add_ref(key='nc', size=nc)
103-
st.add_ref(key='nx', size=nx)
102+
coll.add_ref(key='nc', size=nc)
103+
coll.add_ref(key='nx', size=nx)
104104
for ii, nt in enumerate(lnt):
105-
st.add_ref(key=f'nt{ii}', size=nt)
105+
coll.add_ref(key=f'nt{ii}', size=nt)
106106

107107
# add data dependening on these references
108108
# you can, optionally, specify units, physical dimensionality (ex: distance, time...), quantity (ex: radius, height, ...) and name (to your liking)
109109

110-
st.add_data(key='x', data=x, dimension='distance', quant='radius', units='m', ref='nx')
110+
coll.add_data(key='x', data=x, dimension='distance', quant='radius', units='m', ref='nx')
111111
for ii, nt in enumerate(lnt):
112-
st.add_data(key=f't{ii}', data=lt[ii], dimension='time', units='s', ref=f'nt{ii}')
113-
st.add_data(key=f'prof{ii}', data=lprof[ii], dimension='velocity', units='m/s', ref=(f'nt{ii}', 'x'))
112+
coll.add_data(key=f't{ii}', data=lt[ii], dimension='time', units='s', ref=f'nt{ii}')
113+
coll.add_data(key=f'prof{ii}', data=lprof[ii], dimension='velocity', units='m/s', ref=(f'nt{ii}', 'x'))
114114

115115
# print in the console the content of st
116-
st
116+
coll
117117
```
118118

119119
<p align="center">
@@ -124,22 +124,22 @@ You can see that DataStock stores the relationships between each array and each
124124
Specifying explicitly the references is only necessary if there is an ambiguity (i.e.: several references have the same size, like nx and nt2 in our case)
125125

126126

127-
```
127+
``
128128
# plot any array interactively
129-
dax = st.plot_as_array('x')
130-
dax = st.plot_as_array('t0')
131-
dax = st.plot_as_array('prof0')
132-
dax = st.plot_as_array('prof0', keyX='t0', keyY='x', aspect='auto')
133-
```
129+
dax = coll.plot_as_array('x')
130+
dax = coll.plot_as_array('t0')
131+
dax = coll.plot_as_array('prof0')
132+
dax = coll.plot_as_array('prof0', keyX='t0', keyY='x', aspect='auto')
133+
``
134134

135135
You can then decide to store any object category
136136
Let's create a 'campaign' category to store the characteristics of each measurements campaign
137137
and let's add a 'campaign' parameter to each profile data
138138

139-
```
139+
``
140140
# add arbitrary object category as sub-dict of self.dobj
141141
for ii in range(nc):
142-
st.add_obj(
142+
coll.add_obj(
143143
which='campaign',
144144
key=f'c{ii}',
145145
start_date=f'{ii}.04.2022',
@@ -150,16 +150,16 @@ for ii in range(nc):
150150
)
151151

152152
# create new 'campaign' parameter for data arrays
153-
st.add_param('campaign', which='data')
153+
coll.add_param('campaign', which='data')
154154

155155
# tag each data with its campaign
156156
for ii in range(nc):
157-
st.set_param(which='data', key=f't{ii}', param='campaign', value=f'c{ii}')
158-
st.set_param(which='data', key=f'prof{ii}', param='campaign', value=f'c{ii}')
157+
coll.set_param(which='data', key=f't{ii}', param='campaign', value=f'c{ii}')
158+
coll.set_param(which='data', key=f'prof{ii}', param='campaign', value=f'c{ii}')
159159

160160
# print in the console the content of st
161-
st
162-
```
161+
coll
162+
``
163163

164164
<p align="center">
165165
<img align="middle" src="https://github.com/ToFuProject/datastock/blob/devel/README_figures/DataStock_Obj.png" width="600" alt="Direct 3d array visualization"/>
@@ -168,31 +168,31 @@ st
168168
DataStock also provides built-in object selection method to allow return all
169169
objects matching a criterion, as lits of int indices, bool indices or keys.
170170

171-
```
172-
In [9]: st.select(which='campaign', index=2, returnas=int)
171+
``
172+
In [9]: coll.select(which='campaign', index=2, returnas=int)
173173
Out[9]: array([2])
174174

175175
# list of 2 => return all matches inside the interval
176-
In [10]: st.select(which='campaign', index=[2, 4], returnas=int)
176+
In [10]: coll.select(which='campaign', index=[2, 4], returnas=int)
177177
Out[10]: array([2, 3, 4])
178178

179179
# tuple of 2 => return all matches outside the interval
180-
In [11]: st.select(which='campaign', index=(2, 4), returnas=int)
180+
In [11]: coll.select(which='campaign', index=(2, 4), returnas=int)
181181
Out[11]: array([0, 1])
182182

183183
# return as keys
184-
In [12]: st.select(which='campaign', index=(2, 4), returnas=str)
184+
In [12]: coll.select(which='campaign', index=(2, 4), returnas=str)
185185
Out[12]: array(['c0', 'c1'], dtype='<U2')
186186

187187
# return as bool indices
188-
In [13]: st.select(which='campaign', index=(2, 4), returnas=bool)
188+
In [13]: coll.select(which='campaign', index=(2, 4), returnas=bool)
189189
Out[13]: array([ True, True, False, False, False])
190190

191191
# You can combine as many constraints as needed
192-
In [17]: st.select(which='campaign', index=[2, 4], operator='Barnaby', returnas=str)
192+
In [17]: coll.select(which='campaign', index=[2, 4], operator='Barnaby', returnas=str)
193193
Out[17]: array(['c3', 'c4'], dtype='<U2')
194194

195-
```
195+
``
196196

197197
You can also decide to sub-class DataStock to implement methods and visualizations specific to your needs
198198

@@ -205,6 +205,6 @@ DataStock provides built-in methods like:
205205
- size is the total size of all data stored in the instance in bytes
206206
- dsize is a dict with the detail (size for each item in each sub-dict of the instance)
207207
* `save()`: will save the instance
208-
* `ds.load()`: will load a saved instance
208+
* `coll.load()`: will load a saved instance
209209

210210

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ dependencies = [
4141
"scipy",
4242
"matplotlib",
4343
"PyQt5 ; platform_system != 'Windows'",
44-
# "PySide2; platform_system == 'Windows'",
4544
"astropy",
4645
]
4746

0 commit comments

Comments
 (0)