Skip to content

Commit

Permalink
Go over datetime summaries and...
Browse files Browse the repository at this point in the history
remove Builtin object field "abstract" which is not used.
  • Loading branch information
rocky committed Jul 11, 2023
1 parent aa9e1fc commit c0e5b11
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 29 deletions.
1 change: 0 additions & 1 deletion mathics/builtin/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,6 @@ def eval_with_options(x, evaluation: Evaluation, options: dict):

name: Optional[str] = None
context: str = ""
abstract: bool = False
attributes: int = A_PROTECTED
is_numeric: bool = False
rules: Dict[str, Any] = {}
Expand Down
60 changes: 32 additions & 28 deletions mathics/builtin/datentime.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
Dates and times are represented symbolically; computations can be performed on them.
Date object can also input and output dates and times in a wide range of formats, as well as handle calendars.
Date object can also input and output dates and times in a wide range of formats, as \
well as handle calendars.
"""

import re
Expand Down Expand Up @@ -259,7 +260,6 @@ def to_datelist(self, epochtime, evaluation):
(isinstance(val, float) and i > 1) or isinstance(val, int)
for i, val in enumerate(etime)
):

default_date = [1900, 1, 1, 0, 0, 0.0]
datelist = etime + default_date[len(etime) :]
prec_part, imprec_part = datelist[:2], datelist[2:]
Expand Down Expand Up @@ -348,7 +348,8 @@ class AbsoluteTime(_DateFormat):
<dl>
<dt>'AbsoluteTime[]'
<dd>gives the local time in seconds since epoch January 1, 1900, in your time zone.
<dd>gives the local time in seconds since epoch January 1, 1900, in your \
time zone.
<dt>'AbsoluteTime[{$y$, $m$, $d$, $h$, $m$, $s$}]'
<dd>gives the absolute time specification corresponding to a date list.
Expand Down Expand Up @@ -380,9 +381,7 @@ class AbsoluteTime(_DateFormat):
= 1000
"""

abstract = "absolute time in seconds"

summary_text = "absolute time in seconds"
summary_text = "get absolute time in seconds"

def eval_now(self, evaluation):
"AbsoluteTime[]"
Expand Down Expand Up @@ -410,7 +409,8 @@ class AbsoluteTiming(Builtin):
<dl>
<dt>'AbsoluteTiming[$expr$]'
<dd>evaluates $expr$, returning a list of the absolute number of seconds in real time that have elapsed, together with the result obtained.
<dd>evaluates $expr$, returning a list of the absolute number of seconds in \
real time that have elapsed, together with the result obtained.
</dl>
>> AbsoluteTiming[50!]
Expand All @@ -421,7 +421,7 @@ class AbsoluteTiming(Builtin):

attributes = A_HOLD_ALL | A_PROTECTED

summary_text = "total wall-clock time to run a Mathics command"
summary_text = "get total wall-clock time to run a Mathics command"

def eval(self, expr, evaluation):
"AbsoluteTiming[expr_]"
Expand Down Expand Up @@ -612,7 +612,9 @@ class DateObject(_DateFormat, ImmutableValueMixin):
]

messages = {
"notz": "Argument `1` in DateObject is not a recognized TimeZone specification.",
"notz": (
"Argument `1` in DateObject is not a recognized " "TimeZone specification."
),
}

options = {
Expand All @@ -625,9 +627,7 @@ class DateObject(_DateFormat, ImmutableValueMixin):
"DateObject[]": "DateObject[AbsoluteTime[]]",
}

summary_text = (
" an object representing a date of any granularity (year, hour, instant, ...)"
)
summary_text = "get an object representing a date (year, hour, instant, ...)"

def eval_any(self, args, evaluation: Evaluation, options: dict):
"DateObject[args_, OptionsPattern[]]"
Expand Down Expand Up @@ -779,7 +779,6 @@ def eval(self, date, off, evaluation):
and isinstance(o[0], (float, int))
for o in pyoff
):

for o in pyoff:
idate.addself([o[0] * TIME_INCREMENTS[o[1]][i] for i in range(6)])
else:
Expand Down Expand Up @@ -987,7 +986,7 @@ class DateStringFormat(Predefined):
<dl>
<dt>'$DateStringFormat'
<dd>gives the format used for dates generated by 'DateString'.
<dd>get the format used for dates generated by 'DateString'.
</dl>
>> $DateStringFormat
Expand All @@ -998,7 +997,7 @@ class DateStringFormat(Predefined):

value = "DateTimeShort"

summary_text = "default date string format"
summary_text = "get default date string format as a list"

# TODO: Methods to change this

Expand Down Expand Up @@ -1091,7 +1090,8 @@ class SystemTimeZone(Predefined):
<dl>
<dt>'$SystemTimeZone'
<dd> gives the current time zone for the computer system on which Mathics is being run.
<dd> gives the current time zone for the computer system on which Mathics is \
being run.
</dl>
>> $SystemTimeZone
Expand All @@ -1101,7 +1101,7 @@ class SystemTimeZone(Predefined):
name = "$SystemTimeZone"
value = Real(-time.timezone / 3600.0)

summary_text = "time zone used by your system"
summary_text = "get the time zone used by your system"

def evaluate(self, evaluation):
return self.value
Expand All @@ -1120,7 +1120,7 @@ class Now(Predefined):
= ...
"""

summary_text = "current date and time"
summary_text = "get current date and time"

def evaluate(self, evaluation):
return Expression(SymbolDateObject.evaluate(evaluation))
Expand All @@ -1142,9 +1142,9 @@ class TimeConstrained(Builtin):
Possible issues: for certain time-consuming functions (like simplify)
which are based on sympy or other libraries, it is possible that
the evaluation continues after the timeout. However, at the end of the evaluation, the function will return '$Aborted' and the results will not affect
the state of the \\Mathics kernel.
the evaluation continues after the timeout. However, at the end of the \
evaluation, the function will return '$Aborted' and the results will not affect
the state of the Mathics3 kernel.
"""

# FIXME: these tests sometimes cause SEGVs which probably means
Expand All @@ -1166,7 +1166,10 @@ class TimeConstrained(Builtin):

attributes = A_HOLD_ALL | A_PROTECTED
messages = {
"timc": "Number of seconds `1` is not a positive machine-sized number or Infinity.",
"timc": (
"Number of seconds `1` is not a positive machine-sized number "
"or Infinity."
),
}

summary_text = "run a command for at most a specified time"
Expand Down Expand Up @@ -1219,7 +1222,7 @@ class TimeZone(Predefined):
"$TimeZone": str(value),
}

summary_text = "resettable default time zone"
summary_text = "gets the default time zone"

def eval(self, lhs, rhs, evaluation):
"lhs_ = rhs_"
Expand All @@ -1245,7 +1248,7 @@ class TimeUsed(Builtin):
"""

summary_text = (
"the total number of seconds of CPU time in the current Mathics session"
"get the total number of seconds of CPU time in the current Mathics3 session"
)

def eval(self, evaluation):
Expand Down Expand Up @@ -1274,7 +1277,7 @@ class Timing(Builtin):

attributes = A_HOLD_ALL | A_PROTECTED

summary_text = "CPU time to run a Mathics command"
summary_text = "get CPU time to run a Mathics3 command"

def eval(self, expr, evaluation):
"Timing[expr_]"
Expand All @@ -1301,7 +1304,7 @@ class SessionTime(Builtin):
"""

summary_text = (
"total elapsed time in seconds since the beginning of your Mathics session"
"get total elapsed time in seconds since the beginning of Mathics3 session"
)

def eval(self, evaluation):
Expand All @@ -1317,7 +1320,8 @@ class TimeRemaining(Builtin):
<dl>
<dt>'TimeRemaining[]'
<dd>Gives the number of seconds remaining until the earliest enclosing 'TimeConstrained' will request the current computation to stop.
<dd>Gives the number of seconds remaining until the earliest enclosing \
'TimeConstrained' will request the current computation to stop.
<dt>'TimeConstrained[$expr$, $t$, $failexpr$]'
<dd>returns $failexpr$ if the time constraint is not met.
Expand All @@ -1332,7 +1336,7 @@ class TimeRemaining(Builtin):
"""

summary_text = "time before a time constraint in a running program"
summary_text = "get remaining time in allowed to run an expression"

def eval(self, evaluation):
"TimeRemaining[]"
Expand Down

0 comments on commit c0e5b11

Please sign in to comment.