Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
mmatera committed Jan 19, 2024
2 parents 15bc589 + 8027c56 commit eac1c85
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 14 deletions.
3 changes: 2 additions & 1 deletion mathics/builtin/box/graphics.py
Original file line number Diff line number Diff line change
Expand Up @@ -1102,7 +1102,8 @@ def init(self, graphics, style, item=None):

if item is not None:
if len(item.elements) != 1:
raise BoxExpressionError(item)
print("item:", item)
raise BoxExpressionError
points = item.elements[0]
if points.has_form("List", None) and len(points.elements) != 0:
if all(
Expand Down
5 changes: 3 additions & 2 deletions mathics/builtin/box/graphics3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
"""
Boxing Symbols for 3D Graphics
"""
# Docs are not yet ready for prime time. Maybe after release 6.0.0.
no_doc = True

import json
import logging
Expand Down Expand Up @@ -33,6 +31,9 @@
from mathics.core.symbols import Symbol, SymbolTrue
from mathics.eval.nevaluator import eval_N

# Docs are not yet ready for prime time. Maybe after release 7.0.0.
no_doc = True


class Graphics3DBox(GraphicsBox):
"""
Expand Down
3 changes: 0 additions & 3 deletions mathics/builtin/colors/color_directives.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,6 @@ class _ColorObject(_GraphicsDirective, ImmutableValueMixin):
components_sizes = []
default_components = []

def __repr__(self):
return f"Color object of type {type(self)} with components:{ self.components}"

def init(self, item=None, components=None):
super(_ColorObject, self).init(None, item)
if item is not None:
Expand Down
3 changes: 1 addition & 2 deletions mathics/builtin/graphics.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,10 @@
get_class,
)
from mathics.builtin.options import options_to_rules
from mathics.core.atoms import Integer, Integer0, Integer1, Rational, Real
from mathics.core.atoms import Integer, Rational, Real
from mathics.core.attributes import A_PROTECTED, A_READ_PROTECTED
from mathics.core.builtin import Builtin
from mathics.core.convert.expression import to_expression, to_mathics_list
from mathics.core.convert.python import from_python
from mathics.core.exceptions import BoxExpressionError
from mathics.core.expression import Expression
from mathics.core.formatter import lookup_method
Expand Down
11 changes: 6 additions & 5 deletions mathics/core/evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ def message(self, symbol_name: str, tag, *msgs) -> "Message":
symbol_shortname = self.definitions.shorten_name(symbol)

if settings.DEBUG_PRINT:
print("MESSAGE: %s::%s (%s)" % (symbol_shortname, tag, msgs))
print(f"MESSAGE: {symbol_shortname}::{tag} ({msgs})")

text = self.definitions.get_value(symbol, "System`Messages", pattern, self)
if text is None:
Expand All @@ -481,7 +481,7 @@ def message(self, symbol_name: str, tag, *msgs) -> "Message":
)

if text is None:
text = String("Message %s::%s not found." % (symbol_shortname, tag))
text = String(f"Message {symbol_shortname}::{tag} not found.")

text = self.format_output(
Expression(SymbolStringForm, text, *(from_python(arg) for arg in msgs)),
Expand Down Expand Up @@ -587,8 +587,9 @@ def __init__(self, symbol: Union[Symbol, str], tag: str, text: str) -> None:
use a string.
tag: a short slug string that indicates the kind of message
In Django we need to use a string for symbol, since we need something that is JSON serializable
and a Mathics3 Symbol is not like this.
In Django we need to use a string for symbol, since we need
something that is JSON serializable and a Mathics3 Symbol is not
like this.
"""
super(Message, self).__init__()
self.is_message = True # Why do we need this?
Expand All @@ -607,7 +608,7 @@ def get_data(self):
"message": True,
"symbol": self.symbol,
"tag": self.tag,
"prefix": "%s::%s" % (self.symbol, self.tag),
"prefix": f"{self.symbol}::{self.tag}",
"text": self.text,
}

Expand Down
6 changes: 6 additions & 0 deletions mathics/core/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# -*- coding: utf-8 -*-
"""
Various Exception objects used in Mathics3.
"""


class BoxExpressionError(Exception):
Expand Down Expand Up @@ -35,4 +38,7 @@ def __init__(self, *message):
self._message = message

def message(self, evaluation):
"""
Transfer this exception to evaluation's ``message`` method.
"""
evaluation.message(*self._message)
2 changes: 1 addition & 1 deletion requirements-full.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ psutil # SystemMemory and MemoryAvailable
pyocr # Used for TextRecognize
scikit-image >= 0.17 # FindMinimum can use this; used by Image as well
unidecode # Used in Transliterate
wordcloud # Used in builtin/image.py by WordCloud()
wordcloud >= 1.9.3 # Used in builtin/image.py by WordCloud(). Previous versions assume "image.textsize" which no longer exists

0 comments on commit eac1c85

Please sign in to comment.