Skip to content

Commit 440afcf

Browse files
authored
Merge pull request #1176 from mathics/windows-compatability
Improve Windows coverage and fix Windows tests
2 parents c7f18fe + 0e87781 commit 440afcf

14 files changed

Lines changed: 633 additions & 1372 deletions

File tree

.github/workflows/windows.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Mathics (Windows)
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
build:
11+
runs-on: windows-latest
12+
strategy:
13+
matrix:
14+
os: [windows]
15+
python-version: [3.7, 3.8]
16+
steps:
17+
- uses: actions/checkout@v2
18+
- name: Set up Python ${{ matrix.python-version }}
19+
uses: actions/setup-python@v2
20+
with:
21+
python-version: ${{ matrix.python-version }}
22+
- name: Install dependencies
23+
run: |
24+
python -m pip install --upgrade pip
25+
python -m pip install wheel
26+
choco install llvm
27+
set LLVM_DIR="C:\Program Files\LLVM"
28+
pip install llvmlite
29+
pip install numpy
30+
pip install sympy
31+
pip install pillow
32+
pip install scikit-image
33+
pip install requests
34+
pip install wordcloud
35+
pip install PyYAML
36+
pip install palettable
37+
pip install mpmath
38+
pip install mathics_scanner
39+
- name: Install Mathics
40+
run: |
41+
python setup.py install
42+
- name: Test Mathics
43+
run: |
44+
pip install pytest
45+
py.test test

CHANGES.rst

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,28 @@
11
CHANGES
22
=======
33

4-
New builtins
4+
2.1.0
5+
-----
6+
7+
New builtins
8+
++++++++++++++
9+
10+
* ``ByteArray``
11+
* ``FileNames``
12+
* ``CreateFile``
13+
* ``CreateTemporary``
14+
15+
16+
Enhancements
517
++++++++++++
6-
ByteArray
7-
FileNames
8-
CreateFile
9-
CreateTemporary
1018

19+
* ``FileNameJoin`` - implement ``OperatingSystem`` option
20+
21+
Miscellanea
22+
+++++++++++
1123

24+
A pass was made to improve Microsof Windows compatability and testin
25+
Windows under MSYS.
1226

1327
2.0.0
1428
-----
@@ -88,7 +102,7 @@ Numerous bugs were fixed while working on Combinatorica V0.9 and CellsToTeX.
88102
Document updates
89103
++++++++++++++++
90104

91-
- Start a readthedocs `Developer Guide <https://mathics-development-guide.readthedocs.io/en/latest/>`_
105+
- Start a readthedocs `Developer Guide <https://mathics-development-guide.reandthedocs.io/en/latest/>`_
92106

93107
Enhancements and bug fixes:
94108
+++++++++++++++++++++++++++

mathics/builtin/datentime.py

Lines changed: 58 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44
Date and Time
55
"""
66

7-
import time
87
from datetime import datetime, timedelta
98
import dateutil.parser
109
import re
10+
import sys
11+
import time
1112

1213
from mathics.version import __version__ # noqa used in loading to check consistency.
1314

@@ -126,62 +127,63 @@ def apply(self, evaluation):
126127
return SymbolInfinity
127128

128129

129-
class TimeConstrained(Builtin):
130-
"""
131-
<dl>
132-
<dt>'TimeConstrained[$expr$, $t$]'
133-
<dd>'evaluates $expr$, stopping after $t$ seconds.'
134-
<dt>'TimeConstrained[$expr$, $t$, $failexpr$]'
135-
<dd>'returns $failexpr$ if the time constraint is not met.'
136-
</dl>
137-
>> TimeConstrained[Integrate[Sin[x]^1000000,x],1]
138-
= $Aborted
139-
140-
>> TimeConstrained[Integrate[Sin[x]^1000000,x], 1, Integrate[Cos[x],x]]
141-
= Sin[x]
142-
143-
>> s=TimeConstrained[Integrate[Sin[x] ^ 3, x], a]
144-
: Number of seconds a is not a positive machine-sized number or Infinity.
145-
= TimeConstrained[Integrate[Sin[x] ^ 3, x], a]
146-
147-
>> a=1; s
148-
= -Cos[x] + Cos[x] ^ 3 / 3
149-
150-
Possible issues: for certain time-consuming functions (like simplify)
151-
which are based on sympy or other libraries, it is possible that
152-
the evaluation continues after the timeout. However, at the end of the evaluation, the function will return $\\$Aborted$ and the results will not affect
153-
the state of the mathics kernel.
154-
155-
"""
156-
157-
attributes = ('HoldAll',)
158-
messages = {
159-
'timc': 'Number of seconds `1` is not a positive machine-sized number or Infinity.',
160-
}
161-
162-
def apply_2(self, expr, t, evaluation):
163-
'TimeConstrained[expr_, t_]'
164-
return self.apply_3(expr, t, SymbolAborted, evaluation)
165-
166-
def apply_3(self, expr, t, failexpr, evaluation):
167-
'TimeConstrained[expr_, t_, failexpr_]'
168-
t = t.evaluate(evaluation)
169-
if not t.is_numeric():
170-
evaluation.message('TimeConstrained', 'timc', t)
171-
return
172-
try:
173-
t = float(t.to_python())
174-
evaluation.timeout_queue.append((t, datetime.now().timestamp()))
175-
request = lambda : expr.evaluate(evaluation)
176-
res = run_with_timeout_and_stack(request, t, evaluation)
177-
except TimeoutInterrupt:
178-
evaluation.timeout_queue.pop()
179-
return failexpr.evaluate(evaluation)
180-
except:
130+
if sys.platform != "win32":
131+
class TimeConstrained(Builtin):
132+
"""
133+
<dl>
134+
<dt>'TimeConstrained[$expr$, $t$]'
135+
<dd>'evaluates $expr$, stopping after $t$ seconds.'
136+
<dt>'TimeConstrained[$expr$, $t$, $failexpr$]'
137+
<dd>'returns $failexpr$ if the time constraint is not met.'
138+
</dl>
139+
>> TimeConstrained[Integrate[Sin[x]^1000000,x],1]
140+
= $Aborted
141+
142+
>> TimeConstrained[Integrate[Sin[x]^1000000,x], 1, Integrate[Cos[x],x]]
143+
= Sin[x]
144+
145+
>> s=TimeConstrained[Integrate[Sin[x] ^ 3, x], a]
146+
: Number of seconds a is not a positive machine-sized number or Infinity.
147+
= TimeConstrained[Integrate[Sin[x] ^ 3, x], a]
148+
149+
>> a=1; s
150+
= -Cos[x] + Cos[x] ^ 3 / 3
151+
152+
Possible issues: for certain time-consuming functions (like simplify)
153+
which are based on sympy or other libraries, it is possible that
154+
the evaluation continues after the timeout. However, at the end of the evaluation, the function will return $\\$Aborted$ and the results will not affect
155+
the state of the mathics kernel.
156+
157+
"""
158+
159+
attributes = ('HoldAll',)
160+
messages = {
161+
'timc': 'Number of seconds `1` is not a positive machine-sized number or Infinity.',
162+
}
163+
164+
def apply_2(self, expr, t, evaluation):
165+
'TimeConstrained[expr_, t_]'
166+
return self.apply_3(expr, t, SymbolAborted, evaluation)
167+
168+
def apply_3(self, expr, t, failexpr, evaluation):
169+
'TimeConstrained[expr_, t_, failexpr_]'
170+
t = t.evaluate(evaluation)
171+
if not t.is_numeric():
172+
evaluation.message('TimeConstrained', 'timc', t)
173+
return
174+
try:
175+
t = float(t.to_python())
176+
evaluation.timeout_queue.append((t, datetime.now().timestamp()))
177+
request = lambda : expr.evaluate(evaluation)
178+
res = run_with_timeout_and_stack(request, t, evaluation)
179+
except TimeoutInterrupt:
180+
evaluation.timeout_queue.pop()
181+
return failexpr.evaluate(evaluation)
182+
except:
183+
evaluation.timeout_queue.pop()
184+
raise
181185
evaluation.timeout_queue.pop()
182-
raise
183-
evaluation.timeout_queue.pop()
184-
return res
186+
return res
185187

186188

187189
class Timing(Builtin):

0 commit comments

Comments
 (0)