|
23 | 23 |
|
24 | 24 | # Gets the character at a specific index.
|
25 | 25 | get_char(str, idx) = collect(str)[idx]
|
26 |
| -get_char_end(str, offset) = collect(str)[end - offset] |
| 26 | +get_char_end(str, offset) = collect(str)[end+offset] |
27 | 27 | # Gets a substring (which is robust to unicode characters like η).
|
28 |
| -get_substring(str, idx1, idx2) = String(collect(str)[idx1, idx2]) |
29 |
| -get_substring_end(str, idx1, offset) = String(collect(str)[idx1, end - offset]) |
| 28 | +get_substring(str, idx1, idx2) = String(collect(str)[idx1:idx2]) |
| 29 | +get_substring_end(str, idx1, offset) = String(collect(str)[idx1:end+offset]) |
30 | 30 |
|
31 | 31 |
|
32 | 32 | ### Field Serialisation Support Functions ###
|
|
79 | 79 | # any calls (e.g. X(t) becomes X). E.g. a species vector [X, Y, Z] is converted to "[X, Y, Z]".
|
80 | 80 | function syms_2_strings(syms)
|
81 | 81 | strip_called_syms = [strip_call(Symbolics.unwrap(sym)) for sym in syms]
|
82 |
| - return get_substring("$(convert(Vector{Any}, strip_called_syms))", 4) |
| 82 | + return get_substring_end("$(convert(Vector{Any}, strip_called_syms))", 4, 0) |
83 | 83 | end
|
84 | 84 |
|
85 | 85 | # Converts a vector of symbolics (e.g. the species or parameter vectors) to a string corresponding to
|
@@ -127,7 +127,7 @@ function sym_2_declaration_string(sym; multiline_format = false)
|
127 | 127 | for metadata in metadata_to_declare
|
128 | 128 | @string_append! metadata_string metadata_2_string(sym, metadata) ", "
|
129 | 129 | end
|
130 |
| - @string_append! dec_string $(get_substring_end(metadata_string, 1, -2)) "]" |
| 130 | + @string_append! dec_string get_substring_end(metadata_string, 1, -2) "]" |
131 | 131 | end
|
132 | 132 |
|
133 | 133 | # Returns the declaration entry for the symbol.
|
|
0 commit comments