PageSourceSearch

https://revisit.dev/assets/js/d1524737.25070411.js

js revisit.dev collected 2026-10-03 23:01:44 UTC 41,858 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunkdocs_website=self.webpackChunkdocs_website||[]).push([["15611"],{62787(e,n,t){t.r(n),t.d(n,{metadata:()=>s,default:()=>a,frontMatter:()=>i,contentTitle:()=>c,toc:()=>l,assets:()=>d});var s=JSON.parse('{"id":"revisitpy-reference/classes","title":"Classes","description":"Component","source":"@site/versioned_docs/version-v2.4.3/revisitpy-reference/classes.md","sourceDirName":"revisitpy-reference","slug":"/revisitpy-reference/classes","permalink":"/docs/v2.4.3/revisitpy-reference/classes","draft":false,"unlisted":false,"editUrl":"https://github.com/revisit-studies/reVISit-studies.github.io/edit/main/versioned_docs/version-v2.4.3/revisitpy-reference/classes.md","tags":[],"version":"v2.4.3","lastUpdatedAt":1790372643000,"frontMatter":{},"sidebar":"reference","previous":{"title":"ReVISitPY Reference","permalink":"/docs/v2.4.3/category/revisitpy-reference"},"next":{"title":"Functions","permalink":"/docs/v2.4.3/revisitpy-reference/functions"}}'),o=t(74848),r=t(28453);let i={},c="Classes",d={},l=[{value:"<code>Component</code>",id:"component",level:2},{value:"<strong>Attributes</strong>:",id:"attributes",level:3},{value:"<strong>Methods</strong>:",id:"methods",level:3},{value:"<code>responses(responses: List[Response]) -&gt; self</code>",id:"responsesresponses-listresponse---self",level:4},{value:"<code>get_response(id: str) -&gt; Response | None</code>
1",id:"get_responseid-str---response--none",level:4},{value:"<code>edit_response(id: str, **kwargs: dict) -&gt; self</code>",id:"edit_responseid-str-kwargs-dict---self",level:4},{value:"<code>get(param) -&gt; Any</code>",id:"getparam---any",level:4},{value:"<code>clone(component_name__) -&gt; Component</code>",id:"clonecomponent_name__---component",level:4},{value:"<code>Response</code>",id:"response",level:2},{value:"<strong>Attributes</strong>:",id:"attributes-1",level:3},{value:"<strong>Methods</strong>:",id:"methods-1",level:3},{value:"<code>get(param) -&gt; Any</code>",id:"getparam---any-1",level:4},{value:"<code>set(**kwargs: dict) -&gt; self</code>",id:"setkwargs-dict---self",level:4},{value:"<code>clone() -&gt; Response</code>",id:"clone---response",level:4},{value:"<code>ComponentBlock</code>",id:"componentblock",level:2},{value:"<strong>Attributes</strong>:",id:"attributes-2",level:3},{value:"<strong>Methods</strong>:",id:"methods-2",level:3},{value:"<code>__add__(other: Union[ComponentBlock, Component]) -&gt; self:</code>",id:"__add__other-unioncomponentblock-component---self",level:4},{value:"<code>get_component(name: str) -&gt; Component:</code>",id:"get_componentname-str---component",level:4},{value:"<code>get_components() -&gt; List[Component]</code>",id:"get_components---listcomponent",level:4},{value:"<code>component(component_function: Optional[Callable]) -&gt; self</code>",id:"componentcomponent_function-optionalcallable---self",level:4},{value:"<strong>Examples</strong>:",id:"examples",level:4},{value:"<code>permute(factors: List[dict], order: &#39;fixed&#39; | &#39;latinSquare&#39; | &#39;random&#39;, numSamples: Optional[int]) -&gt; self</code>",id:"permutefactors-listdict-order-fixed--latinsquare--random-numsamples-optionalint---self",level:4},{value:"<strong>Examples</strong>:",id:"examples-1",level:4},{value:"<code>from_data(data_list) -&gt; self</code>",id:"from_datadata_list---self",level:4},{value:"<strong>Example</strong>:",id:"example",level:3}];function h(e){let n={a:"a",admonition:"admonition",br:"br",code:"code",em:"em",h1:"h1",h2:"h2",h3:"h3",h4:"h4",header:"header",li:"li",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,r.R)(),...e.components};return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(n.header,{children:(0,o.jsx)(n.h1,{id:"classes",children:"Classes"})}),"\n",(0,o.jsx)(n.h2,{id:"component",children:(0,o.jsx)(n.code,{children:"Component"})}),"\n",(0,o.jsxs)(n.p,{children:["The class that is instantiated when calling the ",(0,o.jsx)(n.code,{children:"component"})," factory function. Used to define the components in the study configuration file."]}),"\n",(0,o.jsxs)(n.h3,{id:"attributes",children:[(0,o.jsx)(n.strong,{children:"Attributes"}),":"]}),"\n",(0,o.jsxs)(n.table,{children:[(0,o.jsx)(n.thead,{children:(0,o.jsxs)(n.tr,{children:[(0,o.jsx)(n.th,{children:"Attribute"}),(0,o.jsx)(n.th,{children:"Type"}),(0,o.jsx)(n.th,{children:"Description"}),(0,o.jsx)(n.th,{children:"Default Value"})]})}),(0,o.jsxs)(n.tbody,{children:[(0,o.jsxs)(n.tr,{children:[(0,o.jsx)(n.td,{children:(0,o.jsx)(n.code,{children:"component_name__"})}),(0,o.jsx)(n.td,{children:(0,o.jsx)(n.code,{children:"str"})}),(0,o.jsx)(n.td,{children:"Name of the component to be used as the key in the study config."}),(0,o.jsx)(n.td,{children:(0,o.jsx)(n.em,{children:"None"})})]}),(0,o.jsxs)(n.tr,{children:[(0,o.jsx)(n.td,{children:(0,o.jsx)(n.code,{children:"base__"})}),(0,o.jsx)(n.td,{children:(0,o.jsx)(n.code,{children:"Optional[Component]"})}),(0,o.jsx)(n.td,{children:"The base component which is inherited by this component."}),(0,o.jsx)(n.td,{children:(0,o.jsx)(n.em,{children:"None"})})]}),(0,o.jsxs)(n.tr,{children:[(0,o.jsx)(n.td,{children:(0,o.jsx)(n.code,{children:"meta"})}),(0,o.jsx)(n.td,{children:(0,o.jsx)(n.code,{children:"Optional[dict]"})}),(0,o.jsxs)(n.td,{children:["A dictionary specifying metadata of the object. These attributes ",(0,o.jsx)(n.em,{children:"are"})," a part of the underlying component and will be shown when printing the components or the final configuration. These are used to attach arbitrary attributes to the component as well as for use with the ",(0,o.jsx)(n.code,{children:"Sequence"})," class's ",(0,o.jsx)(n.code,{children:"component"})," function. This attribute can also be set through the ",(0,o.jsx)(n.code,{children:"Sequence"})," class's ",(0,o.jsx)(n.code,{children:"permute"})," and ",(0,o.jsx)(n.code,{children:"from_data"})," methods."]}),(0,o.jsx)(n.td,{children:(0,o.jsx)(n.em,{children:"None"})})]})]})]}),"\n",(0,o.jsxs)(n.h3,{id:"methods",children:[(0,o.jsx)(n.strong,{children:"Methods"}),":"]}),"\n",(0,o.jsx)(n.h4,{id:"responsesresponses-listresponse---self",children:(0,o.jsx)(n.code,{children:"responses(responses: List[Response]) -> self"})}),"\n",(0,o.jsx)(n.p,{children:"Sets responses for the component"}),"\n",(0,o.jsxs)(n.p,{children:[(0,o.jsx)(n.strong,{children:"Parameters"}),":"]}),"\n",(0,o.jsxs)(n.table,{children:[(0,o.jsx)(n.thead,{children:(0,o.jsxs)(n.tr,{children:[(0,o.jsx)(n.th,{children:"Parameter"}),(0,o.jsx)(n.th,{children:"Type"}),(0,o.jsx)(n.th,{children:"Description"}),(0,o.jsx)(n.th,{children:"Default Value"})]})}),(0,o.jsx)(n.tbody,{children:(0,o.jsxs)(n.tr,{children:[(0,o.jsx)(n.td,{children:(0,o.jsx)(n.code,{children:"responses"})}),(0,o.jsx)(n.td,{children:(0,o.jsx)(n.code,{children:"List[Response]"})}),(0,o.jsx)(n.td,{children:"Valid list of responses."}),(0,o.jsx)(n.td,{children:(0,o.jsx)(n.em,{children:"None"})})]})})]}),"\n",(0,o.jsxs)(n.p,{children:[(0,o.jsx)(n.strong,{children:"Returns"}),":"]}),"\n",(0,o.jsxs)(n.ul,{children:["\n",(0,o.jsxs)(n.li,{children:[(0,o.jsx)(n.code,{children:"self"}),": Returns self for method chaining."]}),"\n"]}),"\n",(0,o.jsxs)(n.p,{children:[(0,o.jsx)(n.strong,{children:"Raises"}),":"]}),"\n",(0,o.jsxs)(n.ul,{children:["\n",(0,o.jsxs)(n.li,{children:[(0,o.jsx)(n.code,{children:"RevisitError"}),": If the list is not a valid list of responses, raises an exception."]}),"\n"]}),"\n",(0,o.jsxs)(n.p,{children:[(0,o.jsx)(n.strong,{children:"Example"}),":"]}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-python",children:"my_response=rvt.response(\n    id='my_response',\n    type='dropdown',\n    options=['Option 1', 'Option 2']\n)\n\nmy_component = rvt.component(\n    component_name__='my_component',\n    type='markdown',\n    path='assets/my-markdown-file.md'\n).responses([\n    my_response\n])\n"})}),"\n",(0,o.jsx)(n.h4,{id:"get_responseid-str---response--none",children:(0,o.jsx)(n.code,{children:"get_response(id: str) -> Response | None"})}),"\n",(0,o.jsxs)(n.p,{children:["Returns the response of the component with the given ID. If the Response does not exist, returns ",(0,o.jsx)(n.code,{children:"None"}),"."]}),"\n",(0,o.jsxs)(n.p,{children:[(0,o.jsx)(n.strong,{children:"Parameters"}),":"]}),"\n",(0,o.jsxs)(n.table,{children:[(0,o.jsx)(n.thead,{children:(0,o.jsxs)(n.tr,{children:[(0,o.jsx)(n.th,{children:"Parameter"}),(0,o.jsx)(n.th,{children:"Type"}),(0,o.jsx)(n.th,{children:"Description"}),(0,o.jsx)(n.th,{children:"Default Value"})]})}),(0,o.jsx)(n.tbody,{children:(0,o.jsxs)(n.tr,{children:[(0,o.jsx)(n.td,{children:(0,o.jsx)(n.code,{children:"id"})}),(0,o.jsx)(n.td,{children:(0,o.jsx)(n.code,{children:"str"})}),(0,o.jsx)(n.td,{children:"ID of Response"}),(0,o.jsx)(n.td,{children:(0,o.jsx)(n.em,{children:"None"})})]})})]}),"\n",(0,o.jsxs)(n.p,{children:[(0,o.jsx)(n.strong,{children:"Returns"}),":"]}),"\n",(0,o.jsxs)(n.ul,{children:["\n",(0,o.jsxs)(n.li,{children:[(0,o.jsx)(n.code,{children:"Response"}),": The response with the given ID."]}),"\n"]}),"\n",(0,o.jsxs)(n.p,{children:[(0,o.jsx)(n.strong,{children:"Example"}),":"]}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-python",children:"the_response = my_component.get_response(id='the_response')\n\nif the_response is not None:\n    print(the_response)\n"})}),"\n",(0,o.jsx)(n.h4,{id:"edit_responseid-str-kwargs-dict---self",children:(0,o.jsx)(n.code,{children:"edit_response(id: str, **kwargs: dict) -> self"})}),"\n",(0,o.jsx)(n.p,{children:"Edits the Response in the Component with the given ID. This is done by creating a new copy of the existing Response."}),"\n",(0,o.jsxs)(n.p,{children:[(0,o.jsx)(n.strong,{children:"Parameters"}),":"]}),"\n",(0,o.jsxs)(n.table,{children:[(0,o.jsx)(n.thead,{children:(0,o.jsxs)(n.tr,{children:[(0,o.jsx)(n.th,{children:"Parameter"}),(0,o.jsx)(n.th,{children:"Type"}),(0,o.jsx)(n.th,{children:"Description"}),(0,o.jsx)(n.th,{children:"Default Value"})]})}),(0,o.jsx)(n.tbody,{children:(0,o.jsxs)(n.tr,{children:[(0,o.jsx)(n.td,{children:(0,o.jsx)(n.code,{children:"id"})}),(0,o.jsx)(n.td,{children:(0,o.jsx)(n.code,{children:"str"})}),(0,o.jsx)(n.td,{children:"ID of Response"}),(0,o.jsx)(n.td,{children:(0,o.jsx)(n.em,{children:"None"})})]})})]}),"\n",(0,o.jsxs)(n.p,{children:[(0,o.jsx)(n.strong,{children:"Returns"}),":"]}),"\n",(0,o.jsxs)(n.ul,{children:["\n",(0,o.jsxs)(n.li,{children:[(0,o.jsx)(n.code,{children:"self"}),": Returns self for method chaining."]}),"\n"]}),"\n",(0,o.jsxs)(n.p,{children:[(0,o.jsx)(n.strong,{children:"Example"}),":"]}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-python",children:'test_response = rvt.response(\n    id=\'test_response\',\n    type=\'shortText\',\n    prompt=\'Original Prompt:\',\n    required=True\n)\n\ncomponent_one = rvt.component(\n    component_name__=\'component_one\',\n    type=\'questionnaire\',\n    response=[test_response]\n)\n\ncomponent_two = rvt.component(\n    component_name__=\'component_two\',\n    type=\'questionnaire\',\n    response=[test_response]\n).edit_response(id=\'test_response\', prompt=\'New Prompt\', required=False)\n\nprint(component_one)\n\'\'\'\nExpected Output:\n{\n    "response": [\n        {\n            "id": "test_response",\n            "prompt": "Original Prompt:",\n            "required": true,\n            "type": "shortText"\n        }\n    ],\n    "type": "questionnaire"\n}\n\'\'\'\nprint(component_two)\n\'\'\'\n{\n    "response": [\n        {\n            "id": "test_response",\n            "prompt": "New Prompt",\n            "required": false,\n            "type": "shortText"\n        }\n    ],\n    "type": "questionnaire"\n}\n\'\'\'\n'})}),"\n",(0,o.jsx)(n.h4,{id:"getparam---any",children:(0,o.jsx)(n.code,{children:"get(param) -> Any"})}),"\n",(0,o.jsxs)(n.p,{children:["Retrieves the given parameter from the component. The param ",(0,o.jsx)(n.code,{children:"'name'"})," can be used as shorthand for ",(0,o.jsx)(n.code,{children:"'component_name__'"}),"."]}),"\n",(0,o.jsxs)(n.p,{children:[(0,o.jsx)(n.strong,{children:"Parameters"}),":"]}),"\n",(0,o.jsxs)(n.table,{children:[(0,o.jsx)(n.thead,{children:(0,o.jsxs)(n.tr,{children:[(0,o.jsx)(n.th,{children:"Parameter"}),(0,o.jsx)(n.th,{children:"Type"}),(0,o.jsx)(n.th,{children:"Description"}),(0,o.jsx)(n.th,{children:"Default Value"})]})}),(0,o.jsx)(n.tbody,{children:(0,o.jsxs)(n.tr,{children:[(0,o.jsx)(n.td,{children:(0,o.jsx)(n.code,{children:"param"})}),(0,o.jsx)(n.td,{children:(0,o.jsx)(n.code,{children:"str"})}),(0,o.jsx)(n.td,{children:"Parameter name to be retrieved"}),(0,o.jsx)(n.td,{children:(0,o.jsx)(n.em,{children:"None"})})]})})]}),"\n",(0,o.jsx)(n.h4,{id:"clonecomponent_name__---component",children:(0,o.jsx)(n.code,{children:"clone(component_name__) -> Component"})}),"\n",(0,o.jsx)(n.p,{children:"Clones the component with the given new component name."}),"\n",(0,o.jsxs)(n.p,{children:[(0,o.jsx)(n.strong,{children:"Parameters"}),":"]}),"\n",(0,o.jsxs)(n.table,{children:[(0,o.jsx)(n.thead,{children:(0,o.jsxs)(n.tr,{children:[(0,o.jsx)(n.th,{children:"Parameter"}),(0,o.jsx)(n.th,{children:"Type"}),(0,o.jsx)(n.th,{children:"Description"}),(0,o.jsx)(n.th,{children:"Default Value"})]})}),(0,o.jsx)(n.tbody,{children:(0,o.jsxs)(n.tr,{children:[(0,o.jsx)(n.td,{children:(0,o.jsx)(n.code,{children:"component_name__"})}),(0,o.jsx)(n.td,{children:(0,o.jsx)(n.code,{children:"str"})}),(0,o.jsx)(n.td,{children:"New component name to assign to cloned component."}),(0,o.jsx)(n.td,{children:(0,o.jsx)(n.em,{children:"None"})})]})})]}),"\n",(0,o.jsxs)(n.p,{children:[(0,o.jsx)(n.strong,{children:"Returns"}),":"]}),"\n",(0,o.jsxs)(n.ul,{children:["\n",(0,o.jsxs)(n.li,{children:[(0,o.jsx)(n.code,{children:"self"}),": Returns self for method chaining."]}),"\n"]}),"\n",(0,o.jsxs)(n.p,{children:[(0,o.jsx)(n.strong,{children:"Example"}),":"]}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-python",children:'test_response = rvt.response(\n    id=\'test_response\',\n    type=\'shortText\',\n    prompt=\'Original Prompt:\',\n    required=True\n)\n\ncomponent_one = rvt.component(\n    component_name__=\'component_one\',\n    type=\'questionnaire\',\n    response=[test_response]\n)\n\ncomponent_two = component_one.clone(component_name__=\'component_two\').edit_response(id=\'test_response\', prompt=\'New Prompt\', required=False)\n\nprint(component_one)\n\'\'\'\nExpected Output:\n{\n    "response": [\n        {\n            "id": "test_response",\n            "prompt": "Original Prompt:",\n            "required": true,\n            "type": "shortText"\n        }\n    ],\n    "type": "questionnaire"\n}\n\'\'\'\nprint(component_two)\n\'\'\'\n{\n    "response": [\n        {\n            "id": "test_response",\n            "prompt": "New Prompt",\n            "required": false,\n            "type": "shortText"\n        }\n    ],\n    "type": "questionnaire"\n}\n\'\'\'\n'})}),"\n",(0,o.jsx)(n.h2,{id:"response",children:(0,o.jsx)(n.code,{children:"Response"})}),"\n",(0,o.jsxs)(n.p,{children:["This is the ",(0,o.jsx)(n.code,{children:"Response"})," class. When calling the ",(0,o.jsx)(n.code,{children:"response"})," factory function, an instantiation of this class is returned."]}),"\n",(0,o.jsxs)(n.h3,{id:"attributes-1",children:[(0,o.jsx)(n.strong,{children:"Attributes"}),":"]}),"\n",(0,o.jsx)(n.p,{children:(0,o.jsx)(n.em,{children:"No attributes"})}),"\n",(0,o.jsxs)(n.h3,{id:"methods-1",children:[(0,o.jsx)(n.strong,{children:"Methods"}),":"]}),"\n",(0,o.jsx)(n.h4,{id:"getparam---any-1",children:(0,o.jsx)(n.code,{children:"get(param) -> Any"})}),"\n",(0,o.jsxs)(n.p,{children:["Retrieves the given parameter from the response. The param ",(0,o.jsx)(n.code,{children:"'name'"})," can be used as an alternative for ",(0,o.jsx)(n.code,{children:"'id'"}),"."]}),"\n",(0,o.jsxs)(n.p,{children:[(0,o.jsx)(n.strong,{children:"Parameters"}),":"]}),"\n",(0,o.jsxs)(n.table,{children:[(0,o.jsx)(n.thead,{children:(0,o.jsxs)(n.tr,{children:[(0,o.jsx)(n.th,{children:"Parameter"}),(0,o.jsx)(n.th,{children:"Type"}),(0,o.jsx)(n.th,{children:"Description"}),(0,o.jsx)(n.th,{children:"Default Value"})]})}),(0,o.jsx)(n.tbody,{children:(0,o.jsxs)(n.tr,{children:[(0,o.jsx)(n.td,{children:(0,o.jsx)(n.code,{children:"param"})}),(0,o.jsx)(n.td,{children:(0,o.jsx)(n.code,{children:"str"})}),(0,o.jsx)(n.td,{children:"Parameter name to be retrieved"}),(0,o.jsx)(n.td,{children:(0,o.jsx)(n.em,{children:"None"})})]})})]}),"\n",(0,o.jsx)(n.h4,{id:"setkwargs-dict---self",children:(0,o.jsx)(n.code,{children:"set(**kwargs: dict) -> self"})}),"\n",(0,o.jsxs)(n.p,{children:["Sets the values of the response to the input dictionary. The ",(0,o.jsx)(n.code,{children:"type"})," cannot be changed and would require creating a new response"]}),"\n",(0,o.jsxs)(n.p,{children:[(0,o.jsx)(n.strong,{children:"Parameters"}),":"]}),"\n",(0,o.jsxs)(n.table,{children:[(0,o.jsx)(n.thead,{children:(0,o.jsxs)(n.tr,{children:[(0,o.jsx)(n.th,{children:"Parameter"}),(0,o.jsx)(n.th,{children:"Type"}),(0,o.jsx)(n.th,{children:"Description"}),(0,o.jsx)(n.th,{children:"Default Value"})]})}),(0,o.jsx)(n.tbody,{children:(0,o.jsxs)(n.tr,{children:[(0,o.jsx)(n.td,{children:(0,o.jsx)(n.code,{children:"**kwargs"})}),(0,o.jsx)(n.td,{children:(0,o.jsx)(n.code,{children:"dict"})}),(0,o.jsx)(n.td,{children:"Dictionary containing valid values for the current response type."}),(0,o.jsx)(n.td,{children:(0,o.jsx)(n.em,{children:"None"})})]})})]}),"\n",(0,o.jsxs)(n.p,{children:[(0,o.jsx)(n.strong,{children:"Returns"}),":"]}),"\n",(0,o.jsxs)(n.ul,{children:["\n",(0,o.jsxs)(n.li,{children:[(0,o.jsx)(n.code,{children:"self"}),": Returns self for method chaining."]}),"\n"]}),"\n",(0,o.jsxs)(n.p,{children:[(0,o.jsx)(n.strong,
1{children:"Raises"}),":"]}),"\n",(0,o.jsxs)(n.ul,{children:["\n",(0,o.jsxs)(n.li,{children:[(0,o.jsx)(n.code,{children:"RevisitError"}),": If the user attempts to change the ",(0,o.jsx)(n.code,{children:"type"})," attribute of the response, an exception will be raised. Any invalid inputs for the instantiated response type will also raise an exception."]}),"\n"]}),"\n",(0,o.jsxs)(n.p,{children:[(0,o.jsx)(n.strong,{children:"Examples"}),":"]}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-python",children:"response_one = rvt.response(\n    id='r-1',\n    type='shortText',\n    required=False,\n    location='belowStimulus',\n    prompt=''\n)\n\nresponse_one.set(prompt='New Prompt')\nprint(response_one)\n'''\nExpected Output\n{\n    \"id\": \"r-1\",\n    \"location\": \"belowStimulus\",\n    \"prompt\": \"New Prompt\",\n    \"required\": false,\n    \"type\": \"shortText\"\n}\n'''\n\nresponse_one.set(type='longText')\n# Raises Exception: 'Cannot change type from shortText to longText'\n\nresponse_one.set(options=[1,2,3])\n\n"})}),"\n",(0,o.jsx)(n.h4,{id:"clone---response",children:(0,o.jsx)(n.code,{children:"clone() -> Response"})}),"\n",(0,o.jsx)(n.p,{children:"Clones the response."}),"\n",(0,o.jsxs)(n.p,{children:[(0,o.jsx)(n.strong,{children:"Parameters"}),":",(0,o.jsx)(n.br,{}),"\n",(0,o.jsx)(n.em,{children:"No parameters"})]}),"\n",(0,o.jsxs)(n.p,{children:[(0,o.jsx)(n.strong,{children:"Returns"}),":"]}),"\n",(0,o.jsxs)(n.ul,{children:["\n",(0,o.jsxs)(n.li,{children:[(0,o.jsx)(n.code,{children:"self"}),": Returns self for method chaining."]}),"\n"]}),"\n",(0,o.jsxs)(n.p,{children:[(0,o.jsx)(n.strong,{children:"Examples"}),":"]}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-python",children:'import random\nquestion_1 = rvt.response(\n    id=\'q-1\',\n    type=\'shortText\',\n    prompt=\'What is 4 - 2?\',\n    required=True,\n    location=\'belowStimulus\'\n)\n\n# Initialize a list with first question\nfinal_responses = [question_1]\n\n# Randomly generate different arithmetic questions by cloning original question.\nfor i in range(2, 21):\n    curr_response = question_1.clone().set(\n        id=f\'q-{i}\',\n        prompt=f\'What is {random.randint(1, 10)} - {random.randint(1, 10)}\'\n    )\n    final_responses.append(curr_response)\n\ncomponent_one = rvt.component(\n    component_name__=\'component_one\',\n    type=\'questionnaire\',\n    response=final_responses\n)\n\nprint(component_one)\n\'\'\'\nExpected Output:\n{\n    "response": [\n        {\n            "id": "q-1",\n            "location": "belowStimulus",\n            "prompt": "What is 4 - 2?",\n            "required": true,\n            "type": "shortText"\n        },\n        {\n            "id": "q-2",\n            "location": "belowStimulus",\n            "prompt": "What is 10 - 4",\n            "required": true,\n            "type": "shortText"\n        },\n\n        ...\n\n        {\n            "id": "q-20",\n            "location": "belowStimulus",\n            "prompt": "What is 2 - 5",\n            "required": true,\n            "type": "shortText"\n        }\n    ],\n    "type": "questionnaire"\n}\n\'\'\'\n'})}),"\n",(0,o.jsx)(n.h2,{id:"componentblock",children:(0,o.jsx)(n.code,{children:"ComponentBlock"})}),"\n",(0,o.jsxs)(n.p,{children:["The ",(0,o.jsx)(n.code,{children:"ComponentBlock"}),' class (also referred to as a "Sequence"). A well-defined sequence simply contains an order and a set of components, with other optional properties. Just as in the nested structure of component blocks in the reVISit study configuration, ',(0,o.jsx)(n.code,{children:"ComponentBlock"})," classes can be added together."]}),"\n",(0,o.jsxs)(n.p,{children:["A ",(0,o.jsx)(n.code,{children:"ComponentBlock"})," automatically tracks all of its existing ",(0,o.jsx)(n.code,{children:"Component"})," classes. When the ",(0,o.jsx)(n.code,{children:"ComponentBlock"})," is added to the study configuration, all components will automatically be added to the high-level components element of the study config."]}),"\n",(0,o.jsxs)(n.h3,{id:"attributes-2",children:[(0,o.jsx)(n.strong,{children:"Attributes"}),":"]}),"\n",(0,o.jsx)(n.p,{children:(0,o.jsx)(n.em,{children:"No attributes"})}),"\n",(0,o.jsxs)(n.h3,{id:"methods-2",children:[(0,o.jsx)(n.strong,{children:"Methods"}),":"]}),"\n",(0,o.jsx)(n.h4,{id:"__add__other-unioncomponentblock-component---self",children:(0,o.jsx)(n.code,{children:"__add__(other: Union[ComponentBlock, Component]) -> self:"})}),"\n",(0,o.jsxs)(n.p,{children:["Adds two ",(0,o.jsx)(n.code,{children:"ComponentBlock"})," or ",(0,o.jsx)(n.code,{children:"Component"})," to the input sequence. When adding two sequences together, the right sequence gets added as a ",(0,o.jsx)(n.code,{children:"ComponentBlock"})," to the list of components of the left sequence. When the right object is an instance of the ",(0,o.jsx)(n.code,{children:"Component"})," class, the component is added to the ",(0,o.jsx)(n.code,{children:"ComponentBlock"}),"'s list of components."]}),"\n",(0,o.jsxs)(n.p,{children:[(0,o.jsx)(n.strong,{children:"Parameters"}),":"]}),"\n",(0,o.jsxs)(n.table,{children:[(0,o.jsx)(n.thead,{children:(0,o.jsxs)(n.tr,{children:[(0,o.jsx)(n.th,{children:"Parameter"}),(0,o.jsx)(n.th,{children:"Type"}),(0,o.jsx)(n.th,{children:"Description"}),(0,o.jsx)(n.th,{children:"Default Value"})]})}),(0,o.jsx)(n.tbody,{children:(0,o.jsxs)(n.tr,{children:[(0,o.jsx)(n.td,{children:(0,o.jsx)(n.code,{children:"other"})}),(0,o.jsx)(n.td,{children:(0,o.jsx)(n.code,{children:"Union[ComponentBlock, Component]"})}),(0,o.jsx)(n.td,{children:"Other item adding to left sequence."}),(0,o.jsx)(n.td,{children:(0,o.jsx)(n.em,{children:"None"})})]})})]}),"\n",(0,o.jsxs)(n.p,{children:[(0,o.jsx)(n.strong,{children:"Returns"}),":"]}),"\n",(0,o.jsxs)(n.ul,{children:["\n",(0,o.jsxs)(n.li,{children:[(0,o.jsx)(n.code,{children:"self"}),": Returns self for method chaining."]}),"\n"]}),"\n",(0,o.jsxs)(n.p,{children:[(0,o.jsx)(n.strong,{children:"Raises"}),":"]}),"\n",(0,o.jsxs)(n.ul,{children:["\n",(0,o.jsxs)(n.li,{children:[(0,o.jsx)(n.code,{children:"NotImplemented"}),": If the right item is not a ",(0,o.jsx)(n.code,{children:"Component"})," or ",(0,o.jsx)(n.code,{children:"ComponentBlock"}),", raises a ",(0,o.jsx)(n.code,{children:"NotImplemented"})," exception."]}),"\n"]}),"\n",(0,o.jsxs)(n.p,{children:[(0,o.jsx)(n.strong,{children:"Examples"}),":"]}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-python",children:'first_sequence = rvt.sequence(\n    order=\'fixed\',\n    components=[introduction]\n)\nsecond_sequence = rvt.sequence(\n    order=\'random\',\n    components=[comp_one, comp_two]\n)\n\nfirst_sequence = first_sequence + second_sequence\n\nprint(first_sequence)\n\'\'\'\nExpected Output:\n{\n    "order": "fixed",\n    "components" : [\n        "introduction",\n        {\n            "order": "random"\n            "components" : [\n                "comp_one",\n                "comp_two"\n            ]\n        }\n    ]\n}\n\'\'\'\npost_study = rvt.component(\n    component_name__=\'post-study\',\n    type=\'markdown\',\n    path=\'./post-study.md\'\n)\n\nfirst_sequence = first_sequence + post_study\nprint(first_sequence)\n\'\'\'\nExpected Output:\n{\n    "order": "fixed",\n    "components" : [\n        "introduction",\n        {\n            "order": "random"\n            "components" : [\n                "comp_one",\n                "comp_two"\n            ]\n        },\n        "post-study"\n    ]\n}\n\'\'\'\n'})}),"\n",(0,o.jsx)(n.h4,{id:"get_componentname-str---component",children:(0,o.jsx)(n.code,{children:"get_component(name: str) -> Component:"})}),"\n",(0,o.jsxs)(n.p,{children:["Fetches the ",(0,o.jsx)(n.code,{children:"Component"})," with the given component name from the sequence."]}),"\n",(0,o.jsxs)(n.p,{children:[(0,o.jsx)(n.strong,{children:"Parameters"}),":"]}),"\n",(0,o.jsxs)(n.table,{children:[(0,o.jsx)(n.thead,{children:(0,o.jsxs)(n.tr,{children:[(0,o.jsx)(n.th,{children:"Parameter"}),(0,o.jsx)(n.th,{children:"Type"}),(0,o.jsx)(n.th,{children:"Description"}),(0,o.jsx)(n.th,{children:"Default Value"})]})}),(0,o.jsx)(n.tbody,{children:(0,o.jsxs)(n.tr,{children:[(0,o.jsx)(n.td,{children:(0,o.jsx)(n.code,{children:"name"})}),(0,o.jsx)(n.td,{children:(0,o.jsx)(n.code,{children:"str"})}),(0,o.jsxs)(n.td,{children:["string matching the ",(0,o.jsx)(n.code,{children:"component_name__"})," attribute of the desired ",(0,o.jsx)(n.code,{children:"Component"}),"."]}),(0,o.jsx)(n.td,{children:(0,o.jsx)(n.em,{children:"None"})})]})})]}),"\n",(0,o.jsxs)(n.p,{children:[(0,o.jsx)(n.strong,{children:"Returns"}),":"]}),"\n",(0,o.jsxs)(n.ul,{children:["\n",(0,o.jsxs)(n.li,{children:[(0,o.jsx)(n.code,{children:"Component"}),": Returns desired ",(0,o.jsx)(n.code,{children:"Component"}),". If no component with specified name is found, returns ",(0,o.jsx)(n.code,{children:"None"}),"."]}),"\n"]}),"\n",(0,o.jsxs)(n.p,{children:[(0,o.jsx)(n.strong,{children:"Examples"}),":"]}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-python",children:"\nsequence = rvt.sequence(\n    order='random',\n    components=[comp_one, comp_two]\n)\n\nprint(sequence.get_component(name='comp_two'))\n'''\n{\n    \"type\": \"markdown\",\n    \"path\": \"my_markdown_file.md\",\n    \"response\": []\n}\n'''\n"})}),"\n",(0,o.jsx)(n.h4,{id:"get_components---listcomponent",children:(0,o.jsx)(n.code,{children:"get_components() -> List[Component]"})}),"\n",(0,o.jsx)(n.p,{children:"Fetches the list of all components in the sequence."}),"\n",(0,o.jsxs)(n.p,{children:[(0,o.jsx)(n.strong,{children:"Parameters"}),":",(0,o.jsx)(n.br,{}),"\n",(0,o.jsx)(n.em,{children:"None"})]}),"\n",(0,o.jsxs)(n.p,{children:[(0,o.jsx)(n.strong,{children:"Returns"}),":"]}),"\n",(0,o.jsxs)(n.ul,{children:["\n",(0,o.jsxs)(n.li,{children:[(0,o.jsx)(n.code,{children:"List[Component]"}),": Returns list of all components in the sequence."]}),"\n"]}),"\n",(0,o.jsxs)(n.p,{children:[(0,o.jsx)(n.strong,{children:"Examples"}),":"]}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-python",children:'\nsequence = rvt.sequence(\n    order=\'random\',\n    components=[comp_one, comp_two]\n)\n\n# Fetches first component in component list.\nprint(sequence.get_components()[0])\n\'\'\'\n{\n    "type": "markdown",\n    "path": "my_markdown_file.md",\n    "response": []\n}\n\'\'\'\n'})}),"\n",(0,o.jsx)(n.h4,{id:"componentcomponent_function-optionalcallable---self",children:(0,o.jsx)(n.code,{children:"component(component_function: Optional[Callable]) -> self"})}),"\n",(0,o.jsxs)(n.p,{children:["Maps each component in the current sequence to the result of the inputted ",(0,o.jsx)(n.code,{children:"component_function"}),". This will maintain the entire structure of the sequence and will recursively call this function to replace every component."]}),"\n",(0,o.jsxs)(n.p,{children:["The ",(0,o.jsx)(n.code,{children:"meta"})," attributes of components are passed in as arguments to the ",(0,o.jsx)(n.code,{children:"component_function"}),". This makes it especially useful after using the ",(0,o.jsx)(n.code,{children:"permute"})," or ",(0,o.jsx)(n.code,{children:"from_data"})," methods since both add ",(0,o.jsx)(n.code,{children:"meta"})," attributes to the components. If an exception is raised when calling the ",(0,o.jsx)(n.code,{children:"component_function"}),", the original input component will be used in its stead. Additionally, the ",(0,o.jsx)(n.code,{children:"component_function"})," can also take in the ",(0,o.jsx)(n.code,{children:"component__"})," parameter which is the original component that is being transformed."]}),"\n",(0,o.jsxs)(n.h4,{id:"examples",children:[(0,o.jsx)(n.strong,{children:"Examples"}),":"]}),"\n",(0,o.jsx)(n.p,{children:(0,o.jsx)(n.strong,{children:"Simple c
1omponent function to change the name"})}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-python",children:"\n# Basic component function\ndef my_component_function(id, value):\n    return rvt.component(\n        component_name__=f\"{id}_{value}\"\n        type='website',\n        path='path/to/html',\n    )\n\n\nfirst_boring_component = rvt.component(type='questionnaire',meta={'id': 1, 'value': 2}, component_name__='bor-comp-1')\nsecond_boring_component = rvt.component(type='questionnaire',meta={'id': 2, 'value': 7}, component_name__='bor-comp-2')\n\nsequence = rvt.sequence(order='fixed', components=[first_boring_component, second_boring_component])\n\nprint(sequence)\n'''\n{\n    'order':'fixed',\n    'components':[\n        'bor-comp-1',\n        'bor-comp-2'\n    ]\n}\n'''\n\nsequence.component(my_component_function)\n\nprint(sequence)\n'''\n{\n    'order':'fixed',\n    'components':[\n        '1_2',\n        '2_7'\n    ]\n}\n'''\n"})}),"\n",(0,o.jsx)(n.p,{children:(0,o.jsx)(n.strong,{children:"Passing in Original Components"})}),"\n",(0,o.jsxs)(n.p,{children:["In the example below, we'll use the original component to determine if we want to append the ",(0,o.jsx)(n.code,{children:"meta"})," as parameters."]}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-python",children:"def my_component_function(id, value, component__):\n    if component__.get('type') === 'website':\n        return rvt.component(\n            component_name__=f\"website_{id}_{value}\"\n            type='website',\n            path='path/to/html',\n            parameters={\n                'id':id,\n                'value':value\n            }\n        )\n    \n    return rvt.component(\n        component_name__=f'questionnaire_{id}_{value}'\n        type='questionnaire',\n    )\n\nfirst_boring_component = rvt.component(type='questionnaire',meta={'id': 1, 'value': 2}, component_name__='bor-comp-1')\nsecond_boring_component = rvt.component(type='website',meta={'id': 2, 'value': 7}, component_name__='bor-comp-2')\n\nsequence = rvt.sequence(\n    order='fixed',\n    components=[first_boring_component, second_boring_component]\n).component(my_component_function)\n\nprint(sequence)\n\n'''\n{\n    'order':'fixed',\n    'components':[\n        'questionnaire_1_2',\n        'website_2_7'\n    ]\n}\n'''\n"})}),"\n",(0,o.jsx)(n.admonition,{type:"info",children:(0,o.jsxs)(n.p,{children:["If you'd like to have your ",(0,o.jsx)(n.code,{children:"component_function"})," always take in all ",(0,o.jsx)(n.code,{children:"meta"})," entries and the original component, you can define your component function using the ",(0,o.jsx)(n.code,{children:"kwargs"})," keyword like ",(0,o.jsx)(n.code,{children:"def my_component_function(**kwargs)"}),". Then, to access each entry, you can use ",(0,o.jsx)(n.code,{children:"kwargs.get('my_metadata_key')"})," and ",(0,o.jsx)(n.code,{children:"kwargs.get('component__')"}),"."]})}),"\n",(0,o.jsxs)(n.p,{children:["You can find more examples of using the ",(0,o.jsx)(n.code,{children:"component"})," method in the ",(0,o.jsx)(n.a,{href:"../../revisitpy/examples/example_jnd_study",children:"Scatter JND Example"})," where we first construct a sequence by permuting over multiple factors, then using the ",(0,o.jsx)(n.code,{children:"component"})," method to alter the components based on the ",(0,o.jsx)(n.code,{children:"meta"})," that is applied during th permutation method."]}),"\n",(0,o.jsx)(n.h4,{id:"permutefactors-listdict-order-fixed--latinsquare--random-numsamples-optionalint---self",children:(0,o.jsx)(n.code,{children:"permute(factors: List[dict], order: 'fixed' | 'latinSquare' | 'random', numSamples: Optional[int]) -> self"})}),"\n",(0,o.jsxs)(n.p,{children:["Permutes the existing components of the sequence over the given ",(0,o.jsx)(n.code,{children:"factors"}),". The permute method can be chained to complex study sequences. By default, the factors are attached as ",(0,o.jsx)(n.code,{children:"meta"})," attributes to each component created."]}),"\n",(0,o.jsxs)(n.p,{children:[(0,o.jsx)(n.strong,{children:"Parameters"}),":"]}),"\n",(0,o.jsxs)(n.table,{children:[(0,o.jsx)(n.thead,{children:(0,o.jsxs)(n.tr,{children:[(0,o.jsx)(n.th,{children:"Parameter"}),(0,o.jsx)(n.th,{children:"Type"}),(0,o.jsx)(n.th,{children:"Description"}),(0,o.jsx)(n.th,{children:"Default Value"})]})}),(0,o.jsxs)(n.tbody,{children:[(0,o.jsxs)(n.tr,{children:[(0,o.jsx)(n.td,{children:(0,o.jsx)(n.code,{children:"factors"})}),(0,o.jsx)(n.td,{children:(0,o.jsx)(n.code,{children:"List[dict]"})}),(0,o.jsx)(n.td,{children:"A list of single-key dictionaries to permute over."}),(0,o.jsx)(n.td,{children:(0,o.jsx)(n.em,{children:"None"})})]}),(0,o.jsxs)(n.tr,{children:[(0,o.jsx)(n.td,{children:(0,o.jsx)(n.code,{children:"order"})}),(0,o.jsx)(n.td,{children:(0,o.jsx)(n.code,{children:"'fixed' | 'latinSquare' | 'random' "})}),(0,o.jsx)(n.td,{children:"The order to assign to the current permuted component block."}),(0,o.jsx)(n.td,{children:(0,o.jsx)(n.em,{children:"None"})})]}),(0,o.jsxs)(n.tr,{children:[(0,o.jsx)(n.td,{children:(0,o.jsx)(n.code,{children:"numSamples"})}),(0,o.jsx)(n.td,{children:(0,o.jsx)(n.code,{children:"Optional[int]"})}),(0,o.jsxs)(n.td,{children:["The ",(0,o.jsx)(n.code,{children:"numSamples"})," value to assign to the current permuted block."]}),(0,o.jsx)(n.td,{children:(0,o.jsx)(n.em,{children:"None"})})]})]})]}),"\n",(0,o.jsxs)(n.p,{children:[(0,o.jsx)(n.strong,{children:"Returns"}),":"]}),"\n",(0,o.jsxs)(n.ul,{children:["\n",(0,o.jsxs)(n.li,{children:[(0,o.jsx)(n.code,{children:"self"}),": Returns self for method chaining."]}),"\n"]}),"\n",(0,o.jsxs)(n.h4,{id:"examples-1",children:[(0,o.jsx)(n.strong,{children:"Examples"}),":"]}),"\n",(0,o.jsx)(n.p,{children:(0,o.jsx)(n.strong,{children:"Simple Permutation"})}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-python",children:"\ncomp_one = rvt.component(component_name__='my-base', type='markdown', path='./my-markdown.md')\n\nsequence = rvt.component(order='fixed',components=[comp_one])\n\nsequence.permute(\n    factors=[{'condition':'A'}, {'condition':'B'}],\n    order='random'\n)\n\nprint(sequence)\n'''\nExpected Output:\n{\n    \"order\": \"random\", <--- Since there was only one component in the original sequence, order gets overwritten.\n    \"components\": [\n        \"my-base_condition:A\",\n        \"my-base_condition:B\" <--- Note that the default behavior appends the factors to the name\n    ]\n}\n\nThe two components generated are inherently identical, except with different meta attributes.\nThese meta attributes are not outputed into the final JSON study config or seen when printing out\nthe individual components.\n'''\n\nsequence.permute(\n    factors=[{'type':'1'}, {'type': '2'}]\n    order='fixed',\n    numSamples=1\n)\n\nprint(sequence)\n'''\nExpected Output:\n{\n    \"order\": \"random\",\n    \"components\": [\n        {\n            \"order\": \"fixed\", <--- New order gets added to inner most component blocks.\n            \"components\": [\n                \"my-base_condition:A_type:1\",\n                \"my-base_condition:A_type:2\",\n            ],\n            \"numSamples\": 1\n        },\n        {\n            \"order\": \"fixed\",\n            \"components\": [\n                \"my-base_condition:B_type:1\",\n                \"my-base_condition:B_type:2\",\n            ],\n            \"numSamples\": 1\n        },\n    ]\n\n}\n'''\n"})}),"\n",(0,o.jsx)(n.p,{children:(0,o.jsxs)(n.strong,{children:["Using the ",(0,o.jsx)(n.code,{children:"component_function"})," in the ",(0,o.jsx)(n.code,{children:"component"})," method"]})}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-python",children:'# Defining component function.\n# Takes in kwargs to prevent conflicts with any existing metadata.\ndef my_comp_function(**kwargs):\n    condition = kwargs.get(\'condition\')\n    type_ = kwargs.get(\'type\')\n    # If condition and type_ are both defined, return new component.\n    if condition is not None and type_ is not None:\n        rvt.component(\n            type=\'website\'\n            component_name__=f"{condition}__{type_}"\n            parameters={\n                \'condition\': condition,\n                \'type\': type_\n            },\n            response=[\n                rvt.response(\n                    id=f"response_{condition}_{type_}",\n                    type="longText",\n                    prompt=f"How do you feel about condition {condition} and type {type_}?",\n                    required=True\n                )\n            ]\n        )\n\n    # If not both defined, return a blank component with "BAD-COMPONENT" name.\n    # Useful for debugging\n    return rvt.component(type=\'questionnaire\',component_name__="BAD-COMPONENT")\n\nsequence = rvt.sequence(order=\'fixed\').permute(\n    factors=[{\'condition\':\'A\'}, {\'condition\':\'B\'}
1],\n    order=\'random\'\n).permute(\n    factors=[{\'type\':\'1\'}, {\'type\': \'2\'}]\n    order=\'fixed\',\n    numSamples=1,\n).component(component_function) # <-- Uses component method to map each component to the result of the component_function\n\nprint(sequence)\n\'\'\'\nExpected Output:\n{\n    "order": "random",\n    "components": [\n        {\n            "order": "fixed", <--- New order gets added to inner most component blocks.\n            "components": [\n                "A__1",\n                "A__2",\n            ],\n            "numSamples": 1\n        },\n        {\n            "order": "fixed",\n            "components": [\n                "B__1",\n                "B__2"\n            ],\n            "numSamples": 1\n        },\n    ]\n\n}\n\'\'\'\n'})}),"\n",(0,o.jsx)(n.h4,{id:"from_datadata_list---self",children:(0,o.jsx)(n.code,{children:"from_data(data_list) -> self"})}),"\n",(0,o.jsxs)(n.p,{children:["The ",(0,o.jsx)(n.code,{children:"from_data"})," method iterates over a list of ",(0,o.jsx)(n.code,{children:"DataRows"})," and appends the data to the ",(0,o.jsx)(n.code,{children:"meta"})," attribute of the components in the sequence. You can generate a list of ",(0,o.jsx)(n.code,{children:"DataRows"})," by using the ",(0,o.jsx)(n.a,{href:"/docs/v2.4.3/revisitpy-reference/functions#datafile_path",children:"data function"})," to parse a CSV file."]}),"\n",(0,o.jsxs)(n.h3,{id:"example",children:[(0,o.jsx)(n.strong,{children:"Example"}),":"]}),"\n",(0,o.jsxs)(n.p,{children:["In the below example, we create the study data using the ",(0,o.jsx)(n.code,{children:"data"})," method, then create a sequence from this data using the ",(0,o.jsx)(n.code,{children:"from_data"})," method. Each component shown in the new sequence will have the respective data added to their ",(0,o.jsx)(n.code,{children:"meta"})," attribute. From here, you can use the ",(0,o.jsx)(n.code,{children:"component"})," method of the ",(0,o.jsx)(n.code,{children:"Sequence"})," class to transform each component based on their respective ",(0,o.jsx)(n.code,{children:"meta"})," attributes that you applied with the ",(0,o.jsx)(n.code,{children:"from_data"})," method."]}),"\n",(0,o.jsx)(n.pre,{children:(0,o.jsx)(n.code,{className:"language-python",children:"\n'''\n'my_csv_file.csv' contents\n\nid | value_1 | value_2\n---|---------|--------\n 1 | 0.3     | 3\n 2 | 0.1     | 4\n 3 | 1.2     | 1\n'''\n\nstudy_data = rvt.data('path/to/my_csv_file.csv')\n\nsequence = rvt.sequence(order='fixed').from_data(study_data)\n\nprint(sequence)\n'''\n{\n    \"order\": \"fixed\",\n    \"components\": [\n        'id:1__value_1:0.3__value_2:3',\n        'id:2__value_1:0.1__value_2:4',\n        'id:3__value_1:1.2__value_2:1',\n    ]\n}\n'''\n"})})]})}function a(e={}){let{wrapper:n}={...(0,r.R)(),...e.components};return n?(0,o.jsx)(n,{...e,children:(0,o.jsx)(h,{...e})}):h(e)}},28453(e,n,t){t.d(n,{R:()=>i,x:()=>c});var s=t(96540);let o={},r=s.createContext(o);function i(e){let n=s.useContext(r);return s.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function c(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(o):e.components||o:i(e.components),s.createElement(r.Provider,{value:n},e.children)}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.