revisit 0.0.23__tar.gz → 0.0.25__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,16 @@
1
+ node_modules
2
+ .venv
3
+ dist
4
+ .DS_Store
5
+
6
+ # Python
7
+ __pycache__
8
+ .ipynb_checkpoints
9
+
10
+ src/revisit/static
11
+
12
+ # Ignoring all scripts except for single test_script
13
+ scripts/*
14
+ !scripts/test_script.py
15
+ !scripts/test_script.ipynb
16
+ !scripts/
@@ -1,13 +1,13 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: revisit
3
- Version: 0.0.23
4
- Description-Content-Type: text/markdown
3
+ Version: 0.0.25
5
4
  Requires-Dist: anywidget
6
- Requires-Dist: pydantic>=2.10.5
7
5
  Requires-Dist: pandas
6
+ Requires-Dist: pydantic>=2.10.5
8
7
  Provides-Extra: dev
9
- Requires-Dist: watchfiles; extra == "dev"
10
- Requires-Dist: jupyterlab; extra == "dev"
8
+ Requires-Dist: jupyterlab; extra == 'dev'
9
+ Requires-Dist: watchfiles; extra == 'dev'
10
+ Description-Content-Type: text/markdown
11
11
 
12
12
  # revisit
13
13
 
@@ -236,7 +236,201 @@ print(component_two)
236
236
  '''
237
237
  ```
238
238
 
239
+ #### `clone(component_name__) -> Component`
240
+
241
+ **Description**:
242
+ Clones the component with the given new component name.
243
+
244
+ **Parameters**:
245
+ | Parameter | Type | Description | Default Value |
246
+ |-------------|----------|-------------------------------------|---------------|
247
+ | `component_name__` | `str` | New component name to assign to cloned component. | _None_ |
248
+
249
+ **Returns**:
250
+ - `self`: Returns self for method chaining.
251
+
252
+ #### **Examples**:
253
+ ```python
254
+ test_response = rvt.response(
255
+ id='test_response',
256
+ type='shortText',
257
+ prompt='Original Prompt:',
258
+ required=True
259
+ )
260
+
261
+ component_one = rvt.component(
262
+ component_name__='component_one',
263
+ type='questionnaire',
264
+ response=[test_response]
265
+ )
266
+
267
+ component_two = component_one.clone(component_name__='component_two').edit_response(id='test_response', prompt='New Prompt', required=False)
268
+
269
+ print(component_one)
270
+ '''
271
+ Expected Output:
272
+ {
273
+ "response": [
274
+ {
275
+ "id": "test_response",
276
+ "prompt": "Original Prompt:",
277
+ "required": true,
278
+ "type": "shortText"
279
+ }
280
+ ],
281
+ "type": "questionnaire"
282
+ }
283
+ '''
284
+ print(component_two)
285
+ '''
286
+ {
287
+ "response": [
288
+ {
289
+ "id": "test_response",
290
+ "prompt": "New Prompt",
291
+ "required": false,
292
+ "type": "shortText"
293
+ }
294
+ ],
295
+ "type": "questionnaire"
296
+ }
297
+ '''
298
+ ```
299
+
300
+ #### `Response`
301
+
302
+ **Description**:
303
+ A brief summary of the class's purpose and functionality.
304
+
305
+ #### **Attributes**:
306
+ | Attribute | Type | Description | Default Value |
307
+ |-------------|----------|-------------------------------------|---------------|
308
+ | `component_name__` | `type` | Description of attribute 1. | `default` |
309
+ | `base__` | `type` | Description of attribute 2. | _None_ |
310
+
311
+
312
+ #### **Methods**:
313
+
314
+ #### `set(**kwargs: dict) -> self`
315
+
316
+ **Description**:
317
+
318
+ Sets the values of the response to the input dictionary. The `type` cannot be changed and would require creating a new response
319
+
320
+ **Parameters**:
321
+ | Parameter | Type | Description | Default Value |
322
+ |-------------|----------|-------------------------------------|---------------|
323
+ | `**kwargs` | `dict` | Dictionary containing valid values for the current response type. | _None_ |
324
+
325
+ **Returns**:
326
+ - `self`: Returns self for method chaining.
327
+
328
+ #### **Raises**:
329
+ - `RevisitError`: If the user attempts to change the `type` attribute of the response, an exception will be raised. Any invalid inputs for the instantiated response type will also raise an exception.
330
+
331
+ #### **Examples**:
332
+ ```python
333
+ response_one = rvt.response(
334
+ id='r-1',
335
+ type='shortText',
336
+ required=False,
337
+ location='belowStimulus',
338
+ prompt=''
339
+ )
340
+
341
+ response_one.set(prompt='New Prompt')
342
+ print(response_one)
343
+ '''
344
+ Expected Output
345
+ {
346
+ "id": "r-1",
347
+ "location": "belowStimulus",
348
+ "prompt": "New Prompt",
349
+ "required": false,
350
+ "type": "shortText"
351
+ }
352
+ '''
353
+
354
+ response_one.set(type='longText')
355
+ # Raises Exception: 'Cannot change type from shortText to longText'
356
+
357
+ response_one.set(options=[1,2,3])
358
+
359
+ ```
360
+
361
+ #### `clone() -> Response`
362
+
363
+ **Description**:
364
+ Clones the response.
365
+
366
+ **Parameters**:
367
+ _No parameters_
368
+
369
+ **Returns**:
370
+ - `self`: Returns self for method chaining.
371
+
372
+ #### **Examples**:
373
+ ```python
374
+ import random
375
+ question_1 = rvt.response(
376
+ id='q-1',
377
+ type='shortText',
378
+ prompt='What is 4 - 2?',
379
+ required=True,
380
+ location='belowStimulus'
381
+ )
382
+
383
+ # Initialize a list with first question
384
+ final_responses = [question_1]
385
+
386
+ # Randomly generate different arithmetic questions by cloning original question.
387
+ for i in range(2, 21):
388
+ curr_response = question_1.clone().set(
389
+ id=f'q-{i}',
390
+ prompt=f'What is {random.randint(1, 10)} - {random.randint(1, 10)}'
391
+ )
392
+ final_responses.append(curr_response)
393
+
394
+ component_one = rvt.component(
395
+ component_name__='component_one',
396
+ type='questionnaire',
397
+ response=final_responses
398
+ )
399
+
400
+ print(component_one)
401
+ '''
402
+ Expected Output:
403
+ {
404
+ "response": [
405
+ {
406
+ "id": "q-1",
407
+ "location": "belowStimulus",
408
+ "prompt": "What is 4 - 2?",
409
+ "required": true,
410
+ "type": "shortText"
411
+ },
412
+ {
413
+ "id": "q-2",
414
+ "location": "belowStimulus",
415
+ "prompt": "What is 10 - 4",
416
+ "required": true,
417
+ "type": "shortText"
418
+ },
419
+
420
+ ...
239
421
 
422
+ {
423
+ "id": "q-20",
424
+ "location": "belowStimulus",
425
+ "prompt": "What is 2 - 5",
426
+ "required": true,
427
+ "type": "shortText"
428
+ }
429
+ ],
430
+ "type": "questionnaire"
431
+ }
432
+ '''
433
+ ```
240
434
 
241
435
  ## Development
242
436
 
@@ -286,4 +480,4 @@ datamodel-codegen --input src/revisit/StudyConfigSchema.json --output src/revisi
286
480
  ```bash
287
481
  cd revisit-py
288
482
  python -m unittest tests.test_module_one
289
- ```
483
+ ```
@@ -1,14 +1,3 @@
1
- Metadata-Version: 2.2
2
- Name: revisit
3
- Version: 0.0.23
4
- Description-Content-Type: text/markdown
5
- Requires-Dist: anywidget
6
- Requires-Dist: pydantic>=2.10.5
7
- Requires-Dist: pandas
8
- Provides-Extra: dev
9
- Requires-Dist: watchfiles; extra == "dev"
10
- Requires-Dist: jupyterlab; extra == "dev"
11
-
12
1
  # revisit
13
2
 
14
3
  ## Installation
@@ -236,7 +225,201 @@ print(component_two)
236
225
  '''
237
226
  ```
238
227
 
228
+ #### `clone(component_name__) -> Component`
229
+
230
+ **Description**:
231
+ Clones the component with the given new component name.
232
+
233
+ **Parameters**:
234
+ | Parameter | Type | Description | Default Value |
235
+ |-------------|----------|-------------------------------------|---------------|
236
+ | `component_name__` | `str` | New component name to assign to cloned component. | _None_ |
237
+
238
+ **Returns**:
239
+ - `self`: Returns self for method chaining.
240
+
241
+ #### **Examples**:
242
+ ```python
243
+ test_response = rvt.response(
244
+ id='test_response',
245
+ type='shortText',
246
+ prompt='Original Prompt:',
247
+ required=True
248
+ )
249
+
250
+ component_one = rvt.component(
251
+ component_name__='component_one',
252
+ type='questionnaire',
253
+ response=[test_response]
254
+ )
239
255
 
256
+ component_two = component_one.clone(component_name__='component_two').edit_response(id='test_response', prompt='New Prompt', required=False)
257
+
258
+ print(component_one)
259
+ '''
260
+ Expected Output:
261
+ {
262
+ "response": [
263
+ {
264
+ "id": "test_response",
265
+ "prompt": "Original Prompt:",
266
+ "required": true,
267
+ "type": "shortText"
268
+ }
269
+ ],
270
+ "type": "questionnaire"
271
+ }
272
+ '''
273
+ print(component_two)
274
+ '''
275
+ {
276
+ "response": [
277
+ {
278
+ "id": "test_response",
279
+ "prompt": "New Prompt",
280
+ "required": false,
281
+ "type": "shortText"
282
+ }
283
+ ],
284
+ "type": "questionnaire"
285
+ }
286
+ '''
287
+ ```
288
+
289
+ #### `Response`
290
+
291
+ **Description**:
292
+ A brief summary of the class's purpose and functionality.
293
+
294
+ #### **Attributes**:
295
+ | Attribute | Type | Description | Default Value |
296
+ |-------------|----------|-------------------------------------|---------------|
297
+ | `component_name__` | `type` | Description of attribute 1. | `default` |
298
+ | `base__` | `type` | Description of attribute 2. | _None_ |
299
+
300
+
301
+ #### **Methods**:
302
+
303
+ #### `set(**kwargs: dict) -> self`
304
+
305
+ **Description**:
306
+
307
+ Sets the values of the response to the input dictionary. The `type` cannot be changed and would require creating a new response
308
+
309
+ **Parameters**:
310
+ | Parameter | Type | Description | Default Value |
311
+ |-------------|----------|-------------------------------------|---------------|
312
+ | `**kwargs` | `dict` | Dictionary containing valid values for the current response type. | _None_ |
313
+
314
+ **Returns**:
315
+ - `self`: Returns self for method chaining.
316
+
317
+ #### **Raises**:
318
+ - `RevisitError`: If the user attempts to change the `type` attribute of the response, an exception will be raised. Any invalid inputs for the instantiated response type will also raise an exception.
319
+
320
+ #### **Examples**:
321
+ ```python
322
+ response_one = rvt.response(
323
+ id='r-1',
324
+ type='shortText',
325
+ required=False,
326
+ location='belowStimulus',
327
+ prompt=''
328
+ )
329
+
330
+ response_one.set(prompt='New Prompt')
331
+ print(response_one)
332
+ '''
333
+ Expected Output
334
+ {
335
+ "id": "r-1",
336
+ "location": "belowStimulus",
337
+ "prompt": "New Prompt",
338
+ "required": false,
339
+ "type": "shortText"
340
+ }
341
+ '''
342
+
343
+ response_one.set(type='longText')
344
+ # Raises Exception: 'Cannot change type from shortText to longText'
345
+
346
+ response_one.set(options=[1,2,3])
347
+
348
+ ```
349
+
350
+ #### `clone() -> Response`
351
+
352
+ **Description**:
353
+ Clones the response.
354
+
355
+ **Parameters**:
356
+ _No parameters_
357
+
358
+ **Returns**:
359
+ - `self`: Returns self for method chaining.
360
+
361
+ #### **Examples**:
362
+ ```python
363
+ import random
364
+ question_1 = rvt.response(
365
+ id='q-1',
366
+ type='shortText',
367
+ prompt='What is 4 - 2?',
368
+ required=True,
369
+ location='belowStimulus'
370
+ )
371
+
372
+ # Initialize a list with first question
373
+ final_responses = [question_1]
374
+
375
+ # Randomly generate different arithmetic questions by cloning original question.
376
+ for i in range(2, 21):
377
+ curr_response = question_1.clone().set(
378
+ id=f'q-{i}',
379
+ prompt=f'What is {random.randint(1, 10)} - {random.randint(1, 10)}'
380
+ )
381
+ final_responses.append(curr_response)
382
+
383
+ component_one = rvt.component(
384
+ component_name__='component_one',
385
+ type='questionnaire',
386
+ response=final_responses
387
+ )
388
+
389
+ print(component_one)
390
+ '''
391
+ Expected Output:
392
+ {
393
+ "response": [
394
+ {
395
+ "id": "q-1",
396
+ "location": "belowStimulus",
397
+ "prompt": "What is 4 - 2?",
398
+ "required": true,
399
+ "type": "shortText"
400
+ },
401
+ {
402
+ "id": "q-2",
403
+ "location": "belowStimulus",
404
+ "prompt": "What is 10 - 4",
405
+ "required": true,
406
+ "type": "shortText"
407
+ },
408
+
409
+ ...
410
+
411
+ {
412
+ "id": "q-20",
413
+ "location": "belowStimulus",
414
+ "prompt": "What is 2 - 5",
415
+ "required": true,
416
+ "type": "shortText"
417
+ }
418
+ ],
419
+ "type": "questionnaire"
420
+ }
421
+ '''
422
+ ```
240
423
 
241
424
  ## Development
242
425
 
@@ -286,4 +469,4 @@ datamodel-codegen --input src/revisit/StudyConfigSchema.json --output src/revisi
286
469
  ```bash
287
470
  cd revisit-py
288
471
  python -m unittest tests.test_module_one
289
- ```
472
+ ```
@@ -1,10 +1,10 @@
1
1
  [build-system]
2
- requires = ["setuptools", "wheel"] # Use setuptools for builds
3
- build-backend = "setuptools.build_meta"
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "revisit"
7
- version = "0.0.23"
7
+ version = "0.0.25"
8
8
  dependencies = [
9
9
  "anywidget",
10
10
  "pydantic>=2.10.5",