You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
See the [Axis](../api.rst#axis) section of the API Reference to explore all methods of Axis objects.
56
+
57
57
58
58
- markdown: |
59
59
## Groups
@@ -75,7 +75,6 @@ cells:
75
75
76
76
teens
77
77
78
-
id: 4
79
78
80
79
- markdown: |
81
80
It is possible to set a name or to rename a group after its declaration:
@@ -90,12 +89,19 @@ cells:
90
89
91
90
teens
92
91
93
-
id: 5
92
+
93
+
- markdown: |
94
+
See the [Group](../api.rst#group) section of the API Reference to explore all methods of Group objects.
95
+
94
96
95
97
- markdown: |
96
98
## LArray
97
99
98
-
A ``LArray`` object represents a multidimensional array with labeled axes (#ref needed).
100
+
A ``LArray`` object represents a multidimensional array with labeled axes.
101
+
102
+
See the [LArray](../api.rst#larray) section of the API Reference to explore all methods of LArray objects.
103
+
104
+
To know how to save and load arrays in CSV, Excel or HDF format, please refer to the [Loading and Dumping Arrays](tutorial_IO.ipynb#Loading-and-Dumping-Arrays) section of the tutorial.
99
105
100
106
### Create an array from scratch
101
107
@@ -116,7 +122,6 @@ cells:
116
122
arr = LArray(data, axes, meta=meta)
117
123
arr
118
124
119
-
id: 6
120
125
121
126
- markdown: |
122
127
Metadata can be added to an array at any time using:
All the above functions exist in *(func)_like* variants which take axes from another array
@@ -216,7 +214,6 @@ cells:
216
214
- code: |
217
215
ones_like(arr)
218
216
219
-
id: 14
220
217
221
218
- markdown: |
222
219
Create an array using the special ``sequence`` function (see link to documention of ``sequence`` in API reference for more examples):
@@ -226,7 +223,6 @@ cells:
226
223
# With initial=1.0 and inc=0.5, we generate the sequence 1.0, 1.5, 2.0, 2.5, 3.0, ...
227
224
sequence('sex=M,F', initial=1.0, inc=0.5)
228
225
229
-
id: 15
230
226
231
227
- markdown: |
232
228
### Inspecting LArray objects
@@ -236,7 +232,6 @@ cells:
236
232
# create a test array
237
233
arr = ndtest([age, sex, time, other])
238
234
239
-
id: 16
240
235
241
236
- markdown: |
242
237
Get array summary : dimensions + description of axes
@@ -245,7 +240,6 @@ cells:
245
240
- code: |
246
241
arr.info
247
242
248
-
id: 17
249
243
250
244
- markdown: |
251
245
Get axes
@@ -254,7 +248,6 @@ cells:
254
248
- code: |
255
249
arr.axes
256
250
257
-
id: 18
258
251
259
252
- markdown: |
260
253
Get array dimensions
@@ -263,7 +256,6 @@ cells:
263
256
- code: |
264
257
arr.shape
265
258
266
-
id: 19
267
259
268
260
- markdown: |
269
261
Get number of elements
@@ -272,7 +264,6 @@ cells:
272
264
- code: |
273
265
arr.size
274
266
275
-
id: 20
276
267
277
268
- markdown: |
278
269
Get size in memory
@@ -281,7 +272,6 @@ cells:
281
272
- code: |
282
273
arr.memory_used
283
274
284
-
id: 21
285
275
286
276
- markdown: |
287
277
Display the array in the viewer (graphical user interface) in read-only mode.
@@ -306,39 +296,63 @@ cells:
306
296
A ``Session`` object is a dictionary-like object used to gather several arrays, axes and groups.
307
297
A session is particularly adapted to gather all input objects of a model or to gather the output arrays from different scenarios. Like with arrays, it is possible to associate metadata to sessions.
308
298
309
-
In addition to act like dictionaries, sessions offer several specific methods, like:
310
-
- ``save`` and ``load`` to save and load all arrays of a session at once in/from CSV or Excel or HDF5 file(s),
311
-
- ``equals`` and ``array_equals`` to compare arrays between two sessions (scenarios) one by one,
312
-
- ``apply`` to apply a function to all arrays of a session.
299
+
See the [Session](../api.rst#session) section of the API Reference to explore all methods of Session objects.
300
+
301
+
To know how to save and load sessions in CSV, Excel or HDF format, please refer to the [Loading and Dumping Sessions](tutorial_IO.ipynb#Loading-and-Dumping-Sessions) section of the tutorial.
313
302
314
-
See the API Reference section to explore all methods of Session objects.
303
+
To see how to work with sessions, please read the [Working With Sessions](tutorial_sessions.ipynb#Working-With-Sessions) section of the tutorial.
315
304
316
305
317
306
- markdown: |
318
-
### Create a Session
307
+
### Creating Sessions
319
308
320
-
Create an empty session and populate it:
309
+
To create a session, you can first create an empty session and then populate it with arrays, axes and groups:
321
310
322
311
323
312
- code: |
324
313
# create an empty session
325
-
s = Session()
314
+
s_pop = Session()
326
315
327
-
# populate the session (with arrays, axes or groups) using 2 ways:
328
-
# 1) with syntax: session.object_name = object
329
-
s.axisa = Axis('a=a0..a2')
330
-
s.arr1 = ndtest(s.axisa)
331
-
# 2) like a dictionary: session['object_name'] = object
332
-
s['axisb'] = Axis('b=b0..b3')
333
-
s['arr2'] = ndtest((s['axisa'], s['axisb']))
316
+
# add axes to the session
317
+
gender = Axis("gender=Male,Female")
318
+
s_pop.gender = gender
319
+
time = Axis("time=2013,2014,2015")
320
+
s_pop.time = time
321
+
322
+
# add arrays to the session
323
+
s_pop.pop = zeros((gender, time))
324
+
s_pop.births = zeros((gender, time))
325
+
s_pop.deaths = zeros((gender, time))
334
326
335
327
# add metadata after creation
336
-
s.meta.title = 'Input objects'
337
-
s.meta.description = 'Input axes and arrays for the model X'
328
+
s_pop.meta.title = 'Demographic Model of Belgium'
329
+
s_pop.meta.description = 'Modelize the demography of Belgium'
330
+
331
+
# print content of the session
332
+
print(s_pop.summary())
333
+
334
+
335
+
- markdown: |
336
+
or you can create and populate a session in one step:
0 commit comments