Skip to content

Commit cb67366

Browse files
committed
Administrivia - lingering distribution stuff
Go over Makefile to create docker image
1 parent edbf880 commit cb67366

File tree

9 files changed

+75
-23
lines changed

9 files changed

+75
-23
lines changed

Makefile

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,19 @@
44
# These comments before the targets start with #:
55
# remake --tasks to shows the targets and the comments
66

7+
DOCKER_COMPOSE ?= docker-compose
8+
DOCKER_COMPOSE_FILE =
79
GIT2CL ?= admin-tools/git2cl
810
PYTHON ?= python3
911
PIP ?= pip3
1012
RM ?= rm
1113

12-
.PHONY: all build check clean develop dist doc doc-data gstest pytest test djangotest rmChangeLog
14+
.PHONY: all build \
15+
check clean \
16+
develop dist doc doc-data djangotest docker \
17+
gstest pytest \
18+
rmChangeLog \
19+
test
1320

1421
#: Default target - same as "develop"
1522
all: develop
@@ -22,6 +29,10 @@ build:
2229
develop:
2330
$(PIP) install -e .
2431

32+
#: Build docker image
33+
docker-image:
34+
$(DOCKER_COMPOSE) $(DOCKER_COMPOSE_FILE) build
35+
2536
#: Install mathics
2637
install:
2738
$(PYTHON) setup.py install

admin-tools/make-dist.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
2-
PACKAGE=mathics
2+
PACKAGE=mathicsscript
33

44
# FIXME put some of the below in a common routine
55
function finish {

app/requirements-mathicsscript.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
mathics
22
colorama
33
pygments
4-
git+https://github.com/Mathics3/mathicsscript
4+
mathicsscript

mathics/builtin/assignment.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -845,7 +845,7 @@ class Information(PrefixOperator):
845845
= f[x] returns the square of x
846846
847847
>> ? Table
848-
=
848+
=
849849
. 'Table[expr, {i, n}]'
850850
. evaluates expr with i ranging from 1 to n, returning
851851
. a list of the results.
@@ -858,7 +858,7 @@ class Information(PrefixOperator):
858858
.
859859
860860
>> Information[Table]
861-
=
861+
=
862862
. 'Table[expr, {i, n}]'
863863
. evaluates expr with i ranging from 1 to n, returning
864864
. a list of the results.

mathics/builtin/files.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2186,7 +2186,7 @@ class Put(BinaryOperator):
21862186
## = Put[815915283247897734345611269596115894272000000000, fortyfactorial]
21872187
21882188
S> filename = $TemporaryDirectory <> "/fortyfactorial";
2189-
S> Put[40!, filename]
2189+
S> Put[40!, filename]
21902190
S> FilePrint[filename]
21912191
| 815915283247897734345611269596115894272000000000
21922192
S> Get[filename]
@@ -4298,13 +4298,16 @@ def apply(self, path, evaluation):
42984298
return
42994299

43004300
py_path = path.__str__()[1:-1]
4301-
py_path = path_search(py_path)
43024301

4303-
if py_path is None:
4302+
if py_path is None or not os.path.isdir(py_path):
43044303
evaluation.message('SetDirectory', 'cdir', path)
43054304
return Symbol('$Failed')
43064305

4307-
os.chdir(py_path)
4306+
try:
4307+
os.chdir(py_path)
4308+
except:
4309+
return Symbol('$Failed')
4310+
43084311
DIRECTORY_STACK.append(os.getcwd())
43094312
return String(os.getcwd())
43104313

mathics/builtin/patterns.py

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737

3838
from mathics.builtin.base import Builtin, BinaryOperator, PostfixOperator
39-
from mathics.builtin.base import PatternObject
39+
from mathics.builtin.base import PatternObject, PatternError
4040
from mathics.builtin.lists import python_levelspec, InvalidLevelspecError
4141

4242
from mathics.core.expression import (
@@ -206,6 +206,8 @@ def apply_levelspec(self, expr, rules, ls, evaluation, options):
206206
return result
207207
except InvalidLevelspecError:
208208
evaluation.message('General', 'level', ls)
209+
except PatternError as e:
210+
evaluation.message('Replace','reps', rules)
209211

210212

211213
class ReplaceAll(BinaryOperator):
@@ -267,13 +269,16 @@ class ReplaceAll(BinaryOperator):
267269

268270
def apply(self, expr, rules, evaluation):
269271
'ReplaceAll[expr_, rules_]'
272+
try:
273+
rules, ret = create_rules(rules, expr, 'ReplaceAll', evaluation)
270274

271-
rules, ret = create_rules(rules, expr, 'ReplaceAll', evaluation)
272-
if ret:
273-
return rules
275+
if ret:
276+
return rules
274277

275-
result, applied = expr.apply_rules(rules, evaluation)
276-
return result
278+
result, applied = expr.apply_rules(rules, evaluation)
279+
return result
280+
except PatternError as e:
281+
evaluation.message('Replace','reps', rules)
277282

278283

279284
class ReplaceRepeated(BinaryOperator):
@@ -309,8 +314,12 @@ class ReplaceRepeated(BinaryOperator):
309314

310315
def apply_list(self, expr, rules, evaluation):
311316
'ReplaceRepeated[expr_, rules_]'
317+
try:
318+
rules, ret = create_rules(rules, expr, 'ReplaceRepeated', evaluation)
319+
except PatternError as e:
320+
evaluation.message('Replace','reps', rules)
321+
return None
312322

313-
rules, ret = create_rules(rules, expr, 'ReplaceRepeated', evaluation)
314323
if ret:
315324
return rules
316325

@@ -374,9 +383,13 @@ def apply(self, expr, rules, max, evaluation):
374383
if max_count is None or max_count < 0:
375384
evaluation.message('ReplaceList', 'innf', 3)
376385
return
386+
try:
387+
rules, ret = create_rules(
388+
rules, expr, 'ReplaceList', evaluation, extra_args=[max])
389+
except PatternError as e:
390+
evaluation.message('Replace','reps', rules)
391+
return None
377392

378-
rules, ret = create_rules(
379-
rules, expr, 'ReplaceList', evaluation, extra_args=[max])
380393
if ret:
381394
return rules
382395

@@ -1114,7 +1127,8 @@ def init(self, expr, min=1):
11141127
self.min = min
11151128
if len(expr.leaves) == 2:
11161129
leaf_1 = expr.leaves[1]
1117-
if (leaf_1.has_form('List', 1, 2) and all(leaf.get_int_value() for leaf in leaf_1.leaves)):
1130+
allnumbers = all(not (leaf.get_int_value() is None) for leaf in leaf_1.get_leaves())
1131+
if (leaf_1.has_form('List', 1, 2) and allnumbers ):
11181132
self.max = leaf_1.leaves[-1].get_int_value()
11191133
self.min = leaf_1.leaves[0].get_int_value()
11201134
elif leaf_1.get_int_value():

mathics/builtin/system.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ class UserName(Predefined):
355355
<dl>
356356
<dt>$UserName
357357
<dd>returns a string describing the type of computer system on which
358-
\Mathics is being run.
358+
Mathics is being run.
359359
</dl>
360360
361361
X> $UserName

mathics/core/expression.py

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,9 +345,10 @@ def do_format(self, evaluation, form):
345345
try:
346346
expr = self
347347
head = self.get_head_name()
348+
leaves = self.get_leaves()
348349
include_form = False
349-
if head in formats and len(self.get_leaves()) == 1:
350-
expr = self.leaves[0]
350+
if head in formats and len(leaves) == 1:
351+
expr = leaves[0]
351352
if not (form == 'System`OutputForm' and head == 'System`StandardForm'):
352353
form = head
353354

@@ -367,6 +368,29 @@ def format_expr(expr):
367368
return None
368369

369370
if form != 'System`FullForm':
371+
# Repeated and RepeatedNull confuse the formatter,
372+
# so we need to hardlink their format rules:
373+
if head == "System`Repeated":
374+
if len(leaves)==1:
375+
return Expression("System`HoldForm",
376+
Expression("System`Postfix",
377+
Expression(
378+
"System`List",
379+
leaves[0]
380+
),"..",170))
381+
else:
382+
return Expression("System`HoldForm",expr)
383+
elif head == "System`RepeatedNull":
384+
if len(leaves)==1:
385+
return Expression("System`HoldForm",
386+
Expression("System`Postfix",
387+
Expression(
388+
"System`List",
389+
leaves[0]
390+
),"...",170))
391+
else:
392+
return Expression("System`HoldForm",expr)
393+
370394
formatted = format_expr(expr)
371395
if formatted is not None:
372396
result = formatted.do_format(evaluation, form)

mathics/core/parser/tokeniser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@
122122
('RuleDelayed', r' (\:\>)|\uF51F '),
123123
('UndirectedEdge', r' (\<\-\>)|\u29DF '),
124124
('ReplaceRepeated', r' \/\/\. '),
125-
('ReplaceAll', r' (\/\.)(?=[^0-9]) '),
125+
('ReplaceAll', r' \/\. '),
126126

127127
('Postfix', r' \/\/ '),
128128

0 commit comments

Comments
 (0)