pymetrix-eviews 0.1.0a1__py3-none-any.whl

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,395 @@
1
+ """The translation's intermediate representation: what each EViews statement becomes, from which both the script
2
+ (``script.py``) and the steps (``steps.py``) are made, so the two cannot drift apart.
3
+
4
+ - ``Text``: a pymetrix expression or condition as text, with the program's scalars in it by name. The script writes
5
+ it as an f-string (``f"x*({s})"``); the steps put in the value the scalar has when the step runs.
6
+ - ``Code``: Python that is not a step: a scalar, a string, a matrix. The script has it as it is; steps mode runs the
7
+ same text.
8
+ - ``Step``: a recorded call of pymetrix's API (``make_call``), with the variable it is made on and the one it makes.
9
+ - ``Cmd``: a recorded command that is not a call (``AddToDataset``: a fit's residuals or a forecast added to a page).
10
+
11
+ A step's values may also be ``New`` (a pymetrix object made from its arguments: ``Equation("y ~ x")``, ``OLS(cov="white")``),
12
+ ``Attr`` (an attribute of a variable's value: ``m.model``), ``RefTo`` (an object of the session by its name, kept by
13
+ reference in the record: ``Scenario(adjust=af)``), ``Py`` (a Python expression worked out when the step runs:
14
+ ``main.sample``) and ``Spread`` (a string variable's words, spread over a list: ``*names.split()``).
15
+
16
+ Phase 3's control flow (``For``, ``While``, ``If``, ``Def``, ``Invoke``, ``Jump``) holds bodies of the same ops: the
17
+ script writes them as Python blocks, and steps mode runs them in Python, each statement inside a step. A name made
18
+ from the program's variables (``y_{%s}``) is a ``Text`` wherever a name goes: an f-string in the script, the name
19
+ made when the step runs. An object so named is ``globals()[f"eq_{c}"]`` in the script.
20
+ """
21
+
22
+ from __future__ import annotations
23
+
24
+ from collections.abc import Mapping
25
+ from dataclasses import dataclass
26
+ from typing import Any
27
+
28
+ __all__ = ["Arg", "Attr", "Cmd", "Code", "Def", "For", "If", "Invoke", "Jump", "New", "Op", "Py", "RefTo", "SampleSpec", "Spread",
29
+ "Step", "Text", "Var", "While", "literal", "name_code", "quote", "resolved", "step_code"]
30
+
31
+
32
+ @dataclass(frozen=True)
33
+ class Text:
34
+ """Text with scalars in it: ``parts`` are pieces of text and ``Var(name)`` for a Python variable's value."""
35
+
36
+ parts: tuple[Any, ...]
37
+
38
+ @classmethod
39
+ def plain(cls, text: str) -> Text:
40
+ return cls((text,))
41
+
42
+ @property
43
+ def names(self) -> tuple[str, ...]:
44
+ return tuple(p.name for p in self.parts if isinstance(p, Var))
45
+
46
+ def code(self) -> str:
47
+ """The text as Python: a string literal, or an f-string where it holds variables."""
48
+ if not self.names:
49
+ return quote("".join(self.parts))
50
+ body = "".join(p.replace("{", "{{").replace("}", "}}") if isinstance(p, str) else "{" + p.name + "}" for p in self.parts)
51
+ return "f" + quote(body)
52
+
53
+ def value(self, env: Mapping[str, Any]) -> str:
54
+ """The text with each variable's value, as the f-string gives it."""
55
+ return "".join(p if isinstance(p, str) else format(env[p.name]) for p in self.parts)
56
+
57
+ def __str__(self) -> str:
58
+ return "".join(p if isinstance(p, str) else "{" + p.name + "}" for p in self.parts)
59
+
60
+
61
+ @dataclass(frozen=True)
62
+ class Var:
63
+ """A Python variable's value inside a ``Text``."""
64
+
65
+ name: str
66
+
67
+
68
+ def quote(text: str) -> str:
69
+ """Text as a Python string literal, in double quotes."""
70
+ return '"' + text.replace("\\", "\\\\").replace('"', '\\"') + '"' if "\n" not in text else repr(text)
71
+
72
+
73
+ @dataclass(frozen=True)
74
+ class SampleSpec:
75
+ """A ``Sample`` to make: its ends (pymetrix periods, None for an open end) and its condition."""
76
+
77
+ start: str | None = None
78
+ end: str | None = None
79
+ where: Text | None = None
80
+
81
+ def code(self) -> str:
82
+ args = []
83
+ if self.start is not None and self.end is not None:
84
+ args.append(f"({literal(self.start)}, {literal(self.end)})")
85
+ elif self.start is not None:
86
+ args.append(f"start={literal(self.start)}")
87
+ elif self.end is not None:
88
+ args.append(f"end={literal(self.end)}")
89
+ if self.where is not None:
90
+ args.append(f"where={self.where.code()}")
91
+ return f"Sample({', '.join(args)})"
92
+
93
+ def value(self, env: Mapping[str, Any]) -> Any:
94
+ from pymetrix import Sample
95
+
96
+ start, end = (x.value(env) if isinstance(x, Text) else x for x in (self.start, self.end))
97
+ return Sample(start=start, end=end, where=self.where.value(env) if self.where is not None else None)
98
+
99
+ @property
100
+ def names(self) -> tuple[str, ...]:
101
+ return tuple(n for x in (self.start, self.end, self.where) if isinstance(x, Text) for n in x.names)
102
+
103
+
104
+ class Op:
105
+ """What a statement becomes."""
106
+
107
+
108
+ @dataclass(frozen=True)
109
+ class New:
110
+ """A pymetrix object made from its arguments: ``callee`` is its class or function as the script names it
111
+ (``Equation``, ``OLS``, ``Scenario``), found in ``pymetrix``; ``args`` as a ``Step``'s."""
112
+
113
+ callee: str
114
+ args: tuple[Any, ...] = ()
115
+
116
+ def code(self) -> str:
117
+ return f"{self.callee}({_arguments(self.args)})"
118
+
119
+ def value(self, env: Mapping[str, Any]) -> Any:
120
+ import pymetrix
121
+
122
+ positional, named = [], {}
123
+ for a in self.args:
124
+ v = resolved(a.value, env)
125
+ if a.how == "pos":
126
+ positional.append(v)
127
+ elif a.how == "star":
128
+ positional.extend(v)
129
+ elif a.how == "varkw":
130
+ named.update(v)
131
+ else:
132
+ named[a.name] = v
133
+ return getattr(pymetrix, self.callee)(*positional, **named)
134
+
135
+
136
+ @dataclass(frozen=True)
137
+ class Attr:
138
+ """An attribute of a variable's value: ``m.model``."""
139
+
140
+ base: str
141
+ attr: str
142
+
143
+ def code(self) -> str:
144
+ return f"{self.base}.{self.attr}"
145
+
146
+
147
+ @dataclass(frozen=True)
148
+ class RefTo:
149
+ """An object of the session by its name, recorded by reference (``Ref``), as the script names it (a ``Text`` for a
150
+ name made when the program runs)."""
151
+
152
+ name: Any
153
+
154
+
155
+ @dataclass(frozen=True)
156
+ class Py:
157
+ """A Python expression worked out when the step runs (``main.sample``), with the program's variables and the
158
+ session's objects; the script has it as it is."""
159
+
160
+ code: str
161
+
162
+
163
+ @dataclass(frozen=True)
164
+ class Spread:
165
+ """The words of a string variable, spread over a list (``*names.split()``): EViews's ``group g {%names}``."""
166
+
167
+ name: str
168
+
169
+
170
+ @dataclass(frozen=True)
171
+ class Code(Op):
172
+ """Python that is not a step (a scalar, a string, a matrix): ``code`` sets ``names`` (a ``Text`` for a name made
173
+ when the program runs)."""
174
+
175
+ code: str
176
+ names: tuple[Any, ...] = ()
177
+
178
+
179
+ @dataclass(frozen=True)
180
+ class Arg:
181
+ """One argument of a ``Step``: the parameter's ``name``, its ``value``, and ``how`` it is given: ``"pos"`` by
182
+ position in the script (by name to ``make_call``), ``"star"`` a tuple spread over ``*name``, ``"kw"`` by name,
183
+ ``"varkw"`` a mapping spread over ``**name``."""
184
+
185
+ name: str
186
+ value: Any
187
+ how: str = "kw"
188
+
189
+
190
+ @dataclass(frozen=True)
191
+ class Cmd(Op):
192
+ """A recorded command that is not a call: ``command`` (an ``AddToDataset``, say), whose ``to_code()`` is its line
193
+ of the script, and the variables it ``uses``."""
194
+
195
+ command: Any
196
+ uses: tuple[str, ...] = ()
197
+ fields: Any = None # {field: Text}: the command's names made when the program runs
198
+ script: str = "" # its line of the script, when it is not command.to_code()
199
+
200
+
201
+ @dataclass(frozen=True)
202
+ class Step(Op):
203
+ """A call of pymetrix's API, recorded in steps mode: ``function`` (its stable ID, ``pymetrix:dataset.with_series``)
204
+ on the variable ``receiver`` (None for a class method), making ``output``; ``callee`` is how the script calls it
205
+ (``data.with_series``, ``Dataset.read``). A value is plain (text, a number, a tuple), a ``Text``, a ``SampleSpec``
206
+ or a ``Var`` (a Python variable's value: a named sample)."""
207
+
208
+ function: str
209
+ receiver: Any # a variable's name (str or Text), None, or a value: New, Attr, Var
210
+ output: Any # a variable's name (str, or Text when it is made as the program runs)
211
+ callee: str
212
+ args: tuple[Arg, ...] = ()
213
+
214
+ @property
215
+ def names(self) -> tuple[str, ...]:
216
+ """The Python variables the step's values use."""
217
+ out: list[str] = []
218
+
219
+ def walk(v: Any) -> None:
220
+ if isinstance(v, Var):
221
+ out.append(v.name)
222
+ elif isinstance(v, RefTo):
223
+ out.extend(v.name.names if isinstance(v.name, Text) else (v.name,))
224
+ elif isinstance(v, Attr):
225
+ out.append(v.base)
226
+ elif isinstance(v, New):
227
+ for a in v.args:
228
+ walk(a.value)
229
+ elif isinstance(v, (Text, SampleSpec)):
230
+ out.extend(v.names)
231
+ elif isinstance(v, (list, tuple)):
232
+ for x in v:
233
+ walk(x)
234
+ elif isinstance(v, Mapping):
235
+ for x in v.values():
236
+ walk(x)
237
+ if isinstance(self.receiver, str):
238
+ out.append(self.receiver)
239
+ elif isinstance(self.receiver, Text):
240
+ out.extend(self.receiver.names)
241
+ elif self.receiver is not None:
242
+ walk(self.receiver)
243
+ for a in self.args:
244
+ walk(a.value)
245
+ return tuple(out)
246
+
247
+
248
+ def literal(value: Any) -> str:
249
+ """A value as Python, in the script."""
250
+ if isinstance(value, (Text, SampleSpec, New, Attr)):
251
+ return value.code()
252
+ if isinstance(value, Var):
253
+ return value.name
254
+ if isinstance(value, RefTo):
255
+ return name_code(value.name)
256
+ if isinstance(value, Py):
257
+ return value.code
258
+ if isinstance(value, Spread):
259
+ return f"*{value.name}.split()"
260
+ if isinstance(value, str):
261
+ return quote(value)
262
+ if value is None or isinstance(value, (bool, int, float)):
263
+ return repr(value)
264
+ if isinstance(value, Mapping):
265
+ return "{" + ", ".join(f"{literal(k)}: {literal(v)}" for k, v in value.items()) + "}"
266
+ if isinstance(value, (list, tuple)):
267
+ inner = ", ".join(literal(v) for v in value)
268
+ return f"[{inner}]" if isinstance(value, list) else f"({inner}{',' if len(value) == 1 else ''})"
269
+ raise TypeError(f"no Python for {type(value).__name__}")
270
+
271
+
272
+ def resolved(value: Any, env: Mapping[str, Any]) -> Any:
273
+ """A value with its variables' values put in: what steps mode passes to ``make_call``."""
274
+ if isinstance(value, (Text, SampleSpec)):
275
+ return value.value(env)
276
+ if isinstance(value, Var):
277
+ return env[value.name]
278
+ if isinstance(value, New):
279
+ return value.value(env)
280
+ if isinstance(value, Attr):
281
+ return getattr(env[value.base], value.attr)
282
+ if isinstance(value, RefTo):
283
+ from pymetrix.extension import Ref
284
+
285
+ return Ref(value.name.value(env) if isinstance(value.name, Text) else value.name)
286
+ if isinstance(value, Py):
287
+ import pymetrix
288
+
289
+ return eval(value.code, {n: getattr(pymetrix, n) for n in pymetrix.__all__ if hasattr(pymetrix, n)}, dict(env)) # noqa: S307
290
+ if isinstance(value, Mapping):
291
+ return {resolved(k, env): resolved(v, env) for k, v in value.items()}
292
+ if isinstance(value, list):
293
+ return [resolved(v, env) for v in value]
294
+ if isinstance(value, tuple):
295
+ out: list[Any] = []
296
+ for v in value:
297
+ if isinstance(v, Spread):
298
+ out.extend(str(env[v.name]).split())
299
+ else:
300
+ out.append(resolved(v, env))
301
+ return tuple(out)
302
+ return value
303
+
304
+
305
+ def name_code(name: Any) -> str:
306
+ """A variable's name in the script: as it is, or ``globals()[f"eq_{c}"]`` for a name made as the program runs."""
307
+ return f"globals()[{name.code()}]" if isinstance(name, Text) else name
308
+
309
+
310
+ def step_code(step: Step) -> str:
311
+ """A step as one line of the script: ``output = callee(arguments)``."""
312
+ return f"{name_code(step.output)} = {step.callee}({_arguments(step.args)})"
313
+
314
+
315
+ def _arguments(args: tuple[Any, ...]) -> str:
316
+ import keyword
317
+
318
+ parts: list[str] = []
319
+ for a in args:
320
+ if a.how == "pos":
321
+ parts.append(literal(a.value))
322
+ elif a.how == "star":
323
+ if isinstance(a.value, (Attr, Py)):
324
+ parts.append(f"*{literal(a.value)}")
325
+ else:
326
+ parts.extend(literal(v) for v in a.value)
327
+ elif a.how == "varkw":
328
+ for k, v in a.value.items():
329
+ if isinstance(k, str) and k.isidentifier() and not keyword.iskeyword(k):
330
+ parts.append(f"{k}={literal(v)}")
331
+ else:
332
+ parts.append(f"**{{{literal(k)}: {literal(v)}}}")
333
+ else:
334
+ parts.append(f"{a.name}={literal(a.value)}")
335
+ return ", ".join(parts)
336
+
337
+
338
+ # -- phase 3: control flow ---------------------------------------------------------------------------------------------
339
+ # A body is a tuple of (line, op, file) entries, as ProgramTranslation.ops is.
340
+
341
+
342
+ @dataclass(frozen=True)
343
+ class For(Op):
344
+ """``for var in iterable:`` (``range(1, n + 1)``, ``["a", "b"]``, ``names.split()``)."""
345
+
346
+ var: str
347
+ iterable: str
348
+ body: tuple[Any, ...] = ()
349
+
350
+
351
+ @dataclass(frozen=True)
352
+ class While(Op):
353
+ """``while cond:``; steps mode stops after a number of passes the user can change."""
354
+
355
+ cond: str
356
+ body: tuple[Any, ...] = ()
357
+
358
+
359
+ @dataclass(frozen=True)
360
+ class If(Op):
361
+ """``if cond: ... else: ...``, decided when it runs."""
362
+
363
+ cond: str
364
+ body: tuple[Any, ...] = ()
365
+ orelse: tuple[Any, ...] = ()
366
+
367
+
368
+ @dataclass(frozen=True)
369
+ class Def(Op):
370
+ """A subroutine as a function: its parameters, those it assigns (returned, as EViews passes arguments by
371
+ reference), the names it assigns at the program's level (``global``; none for a local subroutine)."""
372
+
373
+ name: str
374
+ params: tuple[str, ...]
375
+ returns: tuple[str, ...] = ()
376
+ shared: tuple[str, ...] = ()
377
+ local: bool = False
378
+ body: tuple[Any, ...] = ()
379
+
380
+
381
+ @dataclass(frozen=True)
382
+ class Invoke(Op):
383
+ """``call f(...)``: the arguments as Python, and for each parameter the subroutine assigns, the caller's variable
384
+ that takes its value back (None where the argument is not a variable)."""
385
+
386
+ name: str
387
+ args: tuple[str, ...] = ()
388
+ targets: tuple[Any, ...] = ()
389
+
390
+
391
+ @dataclass(frozen=True)
392
+ class Jump(Op):
393
+ """``exitloop`` (break), ``return`` and ``stop`` (the program ends)."""
394
+
395
+ kind: str
@@ -0,0 +1,89 @@
1
+ """What the translation leaves out, and why: the report's reasons for what stays in the report (design note, section
2
+ 2, phase 4), and the expression functions pymetrix has no equivalent of (the audit, docs/known-gaps.md); the words
3
+ of control flow (phase 3, ``control.py``), named in the report when one is out of place. Phase 2's own refusals (an estimator's option not mapped, testadd, the
4
+ extreme-value link) are given where they are met, in ``estimation.py`` and ``models.py``.
5
+
6
+ Every statement is either translated or left out with one of these reasons: nothing is dropped silently.
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ __all__ = ["GAP_FUNCTIONS", "PROGRAM_FUNCTIONS", "PHASE2_COMMANDS", "PHASE3_WORDS", "PHASE4_COMMANDS", "PHASE4_METHODS",
12
+ "STATISTICS", "left_reason"]
13
+
14
+ # state-space objects: read whole by the core reader, not line by line
15
+ PHASE2_COMMANDS = {"sspace": "read_eviews_sspace(text)"}
16
+
17
+ # phase 3: control flow, subroutines and included files (control.py translates them)
18
+ PHASE3_WORDS = {
19
+ "for": "a for loop", "next": "the end of a for loop", "while": "a while loop", "wend": "the end of a while loop",
20
+ "if": "an if block", "else": "an else branch", "endif": "the end of an if block", "subroutine": "a subroutine",
21
+ "endsub": "the end of a subroutine", "call": "a subroutine call", "include": "an included program",
22
+ "exitloop": "leaving a loop", "return": "leaving a subroutine", "stop": "stopping the program",
23
+ }
24
+
25
+ # phase 4: what stays in the report, with the reason and the pymetrix equivalent
26
+ _GRAPHS = ("graphs are not translated: their formatting has no one-to-one mapping", "data.plot(...), Figure, Data → Plot series")
27
+ _TABLES = ("tables are made by results, not cell by cell", "Table, a result's summary()")
28
+ _DISPLAY = ("display only", "the Results area; print(...) in a script")
29
+ _SETTINGS = ("a program setting or display", "none needed")
30
+ _EXTERNAL = ("runs an external program", "none")
31
+ PHASE4_COMMANDS = {
32
+ "graph": _GRAPHS, "table": _TABLES, "spool": ("output collections", "Report, File → Export report"),
33
+ "freeze": ("a view becomes an object in EViews; in pymetrix, results already are objects", "the result itself, by name"),
34
+ "show": _DISPLAY, "print": _DISPLAY, "output": _DISPLAY, "close": _DISPLAY, "logmode": _SETTINGS, "tic": _SETTINGS,
35
+ "toc": _SETTINGS, "statusline": _SETTINGS, "setmaxerrs": _SETTINGS, "pon": _SETTINGS, "poff": _SETTINGS, "cd": _SETTINGS,
36
+ "mode": _SETTINGS, "logmsg": _SETTINGS, "logclear": _SETTINGS, "logsave": _SETTINGS, "seterr": _SETTINGS, "wfstats": _DISPLAY,
37
+ "shell": _EXTERNAL, "spawn": _EXTERNAL, "xopen": _EXTERNAL, "xrun": _EXTERNAL, "xget": _EXTERNAL, "xput": _EXTERNAL,
38
+ "xclose": _EXTERNAL, "exec": ("runs another program", "translate that program too, then run its script first"),
39
+ "run": ("runs another program", "translate that program too, then run its script first"),
40
+ "text": ("text objects are notes", "a note in the project"),
41
+ }
42
+ PHASE4_METHODS = {
43
+ **dict.fromkeys(("line", "bar", "scat", "scatpair", "xyline", "area", "spike", "pie", "boxplot", "dot", "errbar", "hilo",
44
+ "distplot", "qqplot", "cdfplot", "kdensity", "addtext", "setelem", "axis", "legend", "align", "options",
45
+ "draw", "name", "datelabel", "scale", "addarrow", "setfont", "setobslabel", "template", "displayname_graph"),
46
+ _GRAPHS),
47
+ **dict.fromkeys(("setformat", "setwidth", "setjust", "setlines", "setfillcolor", "settextcolor", "setmerge", "setindent",
48
+ "title", "save", "comment"), _TABLES),
49
+ "sheet": _DISPLAY, "stats": _DISPLAY, "statby": _DISPLAY, "freq": _DISPLAY, "correl": _DISPLAY, "cor": _DISPLAY,
50
+ "cov": _DISPLAY, "show": _DISPLAY, "print": _DISPLAY, "display": _DISPLAY,
51
+ }
52
+
53
+ # EViews functions that phase 1 translates only as a scalar's whole right-hand side: the sample's statistics, and
54
+ # pandas' method that gives each (over the sample's rows, missing values skipped)
55
+ STATISTICS = {"@mean": "mean", "@sum": "sum", "@min": "min", "@max": "max", "@stdev": "std", "@median": "median",
56
+ "@obs": "count"}
57
+
58
+ # the audit (design note, phase 1): EViews expression functions found in the validation programs or named in the
59
+ # design that pymetrix's expressions have no equivalent of. Each is a gap in docs/known-gaps.md.
60
+ # The rest of the audit now translates (the core reader's render_eviews_expression with data=True): @year, @quarter,
61
+ # @month, @day, @obsnum, @obsid, @round, @floor, @ceiling, @log10, @nan, @isna, @iif, na, nrnd, rnd, @rnorm, @runif,
62
+ # @cumsum and @sumsby, @meansby, @minsby, @maxsby (by a series' name).
63
+ GAP_FUNCTIONS = {
64
+ "@date": "the period's date number: use @year, @quarter, @month and @day",
65
+ "@obssmpl": "the sample's number of observations, a number: give a scalar its value first (!n = @obssmpl)",
66
+ "@trend": "a trend from the data's dates (eviews_series makes it for a model; not for data work yet)",
67
+ "@seas": "a seasonal dummy from the data's dates (eviews_series makes it for a model; not for data work yet)",
68
+ "@elem": "a value at a date (eviews_series makes it for a model; not for data work yet)",
69
+ }
70
+
71
+
72
+ # EViews's programming-language functions (strings, dates as numbers, objects, matrices): program values, not series;
73
+ # control.py translates the string and word functions and a group's members, the rest are gaps
74
+ PROGRAM_FUNCTIONS = frozenset({
75
+ "@val", "@str", "@word", "@wcount", "@replace", "@isobject", "@wfind", "@wfindnc", "@right", "@left", "@mid", "@lower",
76
+ "@upper", "@len", "@length", "@instr", "@trim", "@ltrim", "@rtrim", "@dateval", "@datestr", "@dateadd", "@datediff",
77
+ "@dtoo", "@otod", "@strdate", "@seriesname", "@count", "@endog", "@exog", "@rows", "@columns", "@rowextract",
78
+ "@columnextract", "@sort", "@resample", "@wlookup", "@wsplit", "@wjoin", "@wkeep", "@wdrop", "@wintersect",
79
+ "@wunion", "@wnotin", "@wsort", "@winterleave", "@wcross", "@pagelist", "@pagefreq", "@pagesmpl", "@pagename",
80
+ "@wfname", "@getnextname", "@env", "@fileexist", "@folderexist", "@linepath", "@evpath", "@tablenames", "@vernum",
81
+ "@ver", "@errorcount", "@lasterrstr", "@isvalidname", "@makevalidname", "@chr", "@hasoption", "@equaloption",
82
+ "@option", "@inner", "@transpose", "@inverse", "@identity", "@vec", "@unvec", "@filledmatrix", "@filledvector",
83
+ "@convert", "@zeros", "@ones", "@getmaindiagonal", "@makediagonal", "@rank", "@det", "@trace", "@cholesky",
84
+ })
85
+
86
+
87
+ def left_reason(why: str, equivalent: str = "") -> str:
88
+ """A reason as the report gives it: why, then pymetrix's equivalent where there is one."""
89
+ return f"{why}; in pymetrix: {equivalent}" if equivalent and equivalent != "none" else why