Skip to content

Commit 073ea22

Browse files
committed
cleanup towards SLiM 4.1
1 parent 3b10fe7 commit 073ea22

File tree

9 files changed

+75
-52
lines changed

9 files changed

+75
-52
lines changed

EidosScribe/EidosHelpClasses.rtf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -955,7 +955,7 @@ The default
955955
\f3\fs18 '"string1"=\{int1=value1;int2=value2;\};'
956956
\f4\fs20 . Keys that are of type
957957
\f3\fs18 string
958-
\f4\fs20 will be quoted (always; note that this is a change in behavior starting in SLiM 5.0) and backslash-escaped (as needed, as for
958+
\f4\fs20 will be quoted (always; note that this is a change in behavior starting in SLiM 4.1) and backslash-escaped (as needed, as for
959959
\f3\fs18 string
960960
\f4\fs20 values); keys that are of type
961961
\f3\fs18 integer

QtSLiM/help/EidosHelpClasses.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
<p class="p4">Note that if <span class="s1">Dictionary</span> objects are contained, as values, by the dictionaries being tested for equality, they will be compared according to the standards of <span class="s1">identical()</span>, and must therefore actually be the <i>same</i> <span class="s1">Dictionary</span> object, shared by both dictionaries, for <span class="s1">isEqual()</span> to return <span class="s1">T</span>.</p>
100100
<p class="p3">– (string)serialize([string$ format = "slim"])</p>
101101
<p class="p4">Returns a serialized form of the dictionary’s contents as a <span class="s1">string</span> singleton or vector.<span class="Apple-converted-space">  </span>Four formats are supported at present, as chosen with the <span class="s1">format</span> parameter: <span class="s1">"slim"</span> and <span class="s1">“json"</span> produce a singleton string, whereas <span class="s1">"csv"</span> and <span class="s1">"tsv"</span> produce a <span class="s1">string</span> vector.<span class="Apple-converted-space">  </span>These serializations can be written to disk with <span class="s1">writeFile()</span> or <span class="s1">writeTempFile()</span>, written to the output stream with <span class="s1">cat()</span>, or used in any other way.</p>
102-
<p class="p4">The default <span class="s1">"slim"</span> format is intended for simple, informal use where a very easily parseable string is desired.<span class="Apple-converted-space">  </span>For a simple dictionary containing only keys with singleton non-object values, this will be a semicolon-delimited string like <span class="s1">'"string1"=value1;"string2"=value2;'</span> or <span class="s1">'int1=value1;int2=value2;'</span>.<span class="Apple-converted-space">  </span>Values of type <span class="s1">string</span> will be quoted, and will be escaped with backslash escape sequences, including <span class="s1">\\</span>, <span class="s1">\"</span>, <span class="s1">\'</span>, <span class="s1">\t</span>, <span class="s1">\r</span>, and <span class="s1">\n</span>.<span class="Apple-converted-space">  </span>Values that are not singleton will be separated by spaces, such as <span class="s1">'"string1"=1 2 3;'</span>, while values that are themselves dictionaries will be delimited by braces, such as <span class="s1">'"string1"={int1=value1;int2=value2;};'</span>.<span class="Apple-converted-space">  </span>Keys that are of type <span class="s1">string</span> will be quoted (always; note that this is a change in behavior starting in SLiM 5.0) and backslash-escaped (as needed, as for <span class="s1">string</span> values); keys that are of type <span class="s1">integer</span> are not quoted.<span class="Apple-converted-space">  </span>No facility for parsing <span class="s1">"slim"</span> serializations back into Eidos is presently provided.</p>
102+
<p class="p4">The default <span class="s1">"slim"</span> format is intended for simple, informal use where a very easily parseable string is desired.<span class="Apple-converted-space">  </span>For a simple dictionary containing only keys with singleton non-object values, this will be a semicolon-delimited string like <span class="s1">'"string1"=value1;"string2"=value2;'</span> or <span class="s1">'int1=value1;int2=value2;'</span>.<span class="Apple-converted-space">  </span>Values of type <span class="s1">string</span> will be quoted, and will be escaped with backslash escape sequences, including <span class="s1">\\</span>, <span class="s1">\"</span>, <span class="s1">\'</span>, <span class="s1">\t</span>, <span class="s1">\r</span>, and <span class="s1">\n</span>.<span class="Apple-converted-space">  </span>Values that are not singleton will be separated by spaces, such as <span class="s1">'"string1"=1 2 3;'</span>, while values that are themselves dictionaries will be delimited by braces, such as <span class="s1">'"string1"={int1=value1;int2=value2;};'</span>.<span class="Apple-converted-space">  </span>Keys that are of type <span class="s1">string</span> will be quoted (always; note that this is a change in behavior starting in SLiM 4.1) and backslash-escaped (as needed, as for <span class="s1">string</span> values); keys that are of type <span class="s1">integer</span> are not quoted.<span class="Apple-converted-space">  </span>No facility for parsing <span class="s1">"slim"</span> serializations back into Eidos is presently provided.</p>
103103
<p class="p4">The <span class="s1">"json"</span> format, introduced in Eidos 2.7 (SLiM 3.7), provides serialization of the <span class="s1">Dictionary</span> into the standard JSON format, which may not be quite as brief or human-readable, but which can be used as a standard interchange format and read by the <span class="s1">Dictionary()</span> constructor in Eidos as well as by many other programs.<span class="Apple-converted-space">  </span>For example, a <span class="s1">Dictionary</span> with a key <span class="s1">"key1"</span> with <span class="s1">integer</span> value <span class="s1">1:3</span> and key <span class="s1">"key2"</span> with <span class="s1">string</span> value <span class="s1">"value2"</span> would produce the JSON serialization <span class="s1">'{"key1":[1,2,3],"key2":["value2"]}'</span>, where the outer single quotes are not part of the serialization itself, but are indicating that the serialization is a <span class="s1">string</span> value.<span class="Apple-converted-space">  </span>Note that since all Eidos values are vectors, even singleton values are serialized into JSON as arrays by Eidos; the hope is that this will make automated parsing of these JSON strings easier, since the singleton case will not have to be special-cased.<span class="Apple-converted-space">  </span>For example, <span class="s1">Dictionary("a", 1, "b", Dictionary("x", 2))</span> would be serialized into JSON as <span class="s1">'{"a":[1],"b":[{"x":[2]}]}'</span>.<span class="Apple-converted-space">  </span>Note that dictionaries that use <span class="s1">integer</span> keys cannot be serialized into JSON, because JSON does not support <span class="s1">integer</span> keys.<span class="Apple-converted-space">  </span>Documentation on the JSON format can be found online.</p>
104104
<p class="p4">The <span class="s1">"csv"</span> and <span class="s1">"tsv"</span> formats produce standard comma-separated value (CSV) or tab-separated value (TSV) data.<span class="Apple-converted-space">  </span>These formats are primarily intended for output from <span class="s1">DataFrame</span>, since that class is used to represent the sort of data tables that CSV/TSV are typically used for; but it may be used with <span class="s1">Dictionary</span> too, particularly if it is being used to represent a data table with ragged columns (missing values will just be skipped over, producing two commas or two tabs in sequence).<span class="Apple-converted-space">  </span>Values of type <span class="s1">string</span> will always be quoted, with double quotes (with a repeated double quote used to indicate the presence of a double quote inside a <span class="s1">string</span> value, as usual in CSV); values of other types never will.<span class="Apple-converted-space">  </span>Decimal points (not decimal commas, regardless of system localization) will always be used for <span class="s1">float</span> values, and will never be used for <span class="s1">integer</span> values.<span class="Apple-converted-space">  </span>Values of logical type will be serialized as <span class="s1">TRUE</span> or <span class="s1">FALSE</span>, without quotes.<span class="Apple-converted-space">  </span>A header line providing the names of the columns (i.e., the keys of the target <span class="s1">Dictionary</span>) will always be generated; those column names will also be quoted (if the keys of the dictionary are type <span class="s1">string</span>; <span class="s1">integer</span> keys are not quoted).<span class="Apple-converted-space">  </span>One <span class="s1">string</span> element will be generated for each row of the target, plus one <span class="s1">string</span> element for the header line; newlines will not be present in the resulting <span class="s1">string</span> vector unless newlines were present within the <span class="s1">string</span> values in the <span class="s1">Dictionary</span>.<span class="Apple-converted-space">  </span>The resulting data, if written to a file, should be readable in Eidos using <span class="s1">readCSV()</span> (as long as there are no ragged columns or missing values), as well as in other software such as R and Excel.</p>
105105
<p class="p3">– (void)setValue(is$ key, * value)</p>

0 commit comments

Comments
 (0)