Skip to content

Commit

Permalink
Merge pull request #106 from iraf-community/rc-fixes
Browse files Browse the repository at this point in the history
2.2.0 rc fixes
  • Loading branch information
olebole authored Dec 3, 2021
2 parents fe5b103 + 560869f commit 32455a4
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 89 deletions.
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ include setup.cfg
include MANIFEST.in
recursive-include pyraf *
recursive-include tools *.py
global-exclude *.pyc *.o
global-exclude *.pyc *.o *.so *.sqlite3
recursive-inclulde docs *
9 changes: 5 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ The minimal Python required for PyRAF is 3.6, but it is recommended to
use the latest available version. An installation in an virtual
environment like venv_ or conda_ is possible.

The package can be installed from the Git repository with the command
``pip3 install .``. Note that the package requires a compilation, so
aside from pip3, the C compiler and development libraries
(on Linux ``libx11-dev``) should be installed.
The package can be installed from PyPI_ with the command ``pip3
install pyraf``. Note that if no binary installation is available on
PyPI, the package requires a compilation, so aside from pip3, the C
compiler and development libraries (on Linux ``libx11-dev``) should be
installed.

Contributing Code, Documentation, or Feedback
---------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion pyraf/GkiMpl.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ def gki_text(self, arg):
# add the text
x = gki.ndc(arg[0])
y = gki.ndc(arg[1])
text = arg[3:].astype(numpy.int8).tobytes().encode('ascii')
text = arg[3:].astype(numpy.int8).tobytes().decode('ascii')
ta = self.textAttributes

# For now, force this to be non-bold for decent looking plots. It
Expand Down
8 changes: 4 additions & 4 deletions pyraf/MplCanvasAdapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import matplotlib.backends.backend_tkagg as tkagg
from .Ptkplot import hideTkCursor
from .Ptkplot import FullWindowCursor
import tk
import tkinter
from .wutil import moveCursorTo, WUTIL_USING_X


Expand Down Expand Up @@ -84,9 +84,9 @@ def resize_widget(self, event):
self.figure.set_size_inches(winch, hinch, forward=False)

self._tkcanvas.delete(self._tkphoto)
self._tkphoto = tk.PhotoImage(master=self._tkcanvas,
width=int(width),
height=int(height))
self._tkphoto = tkinter.PhotoImage(master=self._tkcanvas,
width=int(width),
height=int(height))
self._tkcanvas.create_image(int(width / 2),
int(height / 2),
image=self._tkphoto)
Expand Down
4 changes: 2 additions & 2 deletions pyraf/tests/test_core_nongraphics.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def test_subproc_write_readline(_proc):
"""
_proc.write(b'test string one\n')
_proc.write(b'test string two\n')
time.sleep(0.01)
time.sleep(0.1)

assert _proc.readline() == b'test string one\n'
assert _proc.readline() == b'test string two\n'
Expand All @@ -44,7 +44,7 @@ def test_subproc_write_readPendingChars(_proc):
test_inputs = (b'one', b'two', b'three')
for test_input in test_inputs:
_proc.write(test_input + b'\n')
time.sleep(0.01)
time.sleep(0.1)

expected = tuple(_proc.readPendingChars().splitlines())
assert test_inputs == expected
Expand Down
11 changes: 11 additions & 0 deletions pyraf/tests/test_graphics.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@

import pytest

try:
host_arch = sys.implementation._multiarch.split("-")[0]
except AttributeError:
import platform
host_arch = platform.machine()
is_i386 = host_arch in ('i386', 'i486', 'i586', 'i686')

from stsci.tools import capable

from .utils import HAS_IRAF, DATA_DIR
Expand Down Expand Up @@ -206,6 +213,7 @@ def test_gki_control_codes():
assert gki.control2name[ctl] == 'control_unknown'


@pytest.mark.skipif(is_i386, reason='diff is not identical on i386')
def test_gki_single_prow():
""" Test a prow-plot of a single row from dev$pix to .ps """
iraf.plot(_doprint=0) # load plot for prow
Expand All @@ -220,6 +228,7 @@ def test_gki_single_prow():
diffit(EXP2IGNORE, psOut, os.path.join(DATA_DIR, PSDEV + "_prow_256.ps"))


@pytest.mark.skipif(is_i386, reason='diff is not identical on i386')
def test_gki_prow_1_append():
""" Test a prow-plot with 1 append (2 rows total, dev$pix) to .ps """
iraf.plot(_doprint=0) # load plot for prow
Expand All @@ -236,6 +245,7 @@ def test_gki_prow_1_append():
PSDEV + "_prow_256_250.ps"))


@pytest.mark.skipif(is_i386, reason='diff is not identical on i386')
def test_gki_prow_2_appends():
""" Test a prow-plot with 2 appends (3 rows total, dev$pix) to .ps """
iraf.plot(_doprint=0) # load plot for prow
Expand All @@ -253,6 +263,7 @@ def test_gki_prow_2_appends():
os.path.join(DATA_DIR, PSDEV + "_prow_256_250_200.ps"))


@pytest.mark.skipif(is_i386, reason='diff is not identical on i386')
def test_gki_2_prows_no_append():
""" Test 2 prow calls with no append (2 dev$pix rows) to 2 .ps's """
iraf.plot(_doprint=0) # load plot for prow
Expand Down
85 changes: 9 additions & 76 deletions pyraf/tpar.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,30 +21,20 @@
# Fake out import of urwid if it fails, to keep tpar from bringing down
# all of PyRAF.
class FakeModule:

def __init__(*args, **keys):
pass

pass

class FakeClass:

def __init__(*args, **keys):
pass
pass


URWID_PRE_9P9 = False

try:
import urwid.curses_display
import urwid.raw_display
import urwid
from . import urwutil
from . import urwfiledlg
urwid.set_encoding("ascii") # gives better performance than 'utf8'
if 0 == urwid.__version__.find('0.9.8') or 0 == urwid.__version__.find(
'0.9.7'):
URWID_PRE_9P9 = True
except Exception as e:
except ImportException as e:
urwid = FakeModule()
urwid.Edit = FakeClass()
urwid.Columns = FakeClass()
Expand Down Expand Up @@ -715,10 +705,7 @@ def __init__(self, taskName):

self.escape = False

if URWID_PRE_9P9:
self._createButtonsOld()
else:
self._createButtons()
self._createButtons()

self.colon_edit = PyrafEdit("",
"",
Expand Down Expand Up @@ -749,58 +736,6 @@ def __init__(self, taskName):
MODE_KEYS = MODE_KEYS_EMACS
Binder.__init__(self, BINDINGS, self.inform, MODE_KEYS)

def _createButtonsOld(self):
""" Set up all the bottom row buttons and their spacings """

isPset = isinstance(self.taskObject, iraftask.IrafPset)

self.help_button = urwid.Padding(urwid.Button("Help", self.HELP),
align="center",
width=('fixed', 8))
self.cancel_button = urwid.Padding(urwid.Button("Cancel", self.QUIT),
align="center",
width=('fixed', 10))
if not isPset:
self.save_as_button = urwid.Padding(urwid.Button(
"Save As", self.SAVEAS),
align="center",
width=('fixed', 11))
self.save_button = urwid.Padding(urwid.Button("Save", self.EXIT),
align="center",
width=('fixed', 8))
self.exec_button = urwid.Padding(urwid.Button("Exec", self.go),
align="center",
width=('fixed', 8))
if self.__areAnyToLoad:
self.open_button = urwid.Padding(urwid.Button("Open", self.PFOPEN),
align="center",
width=('fixed', 8))

# GUI button layout - weightings
if isPset: # show no Open nor Save As buttons
self.buttons = urwid.Columns([('weight', 0.2, self.exec_button),
('weight', 0.2, self.save_button),
('weight', 0.2, self.cancel_button),
('weight', 0.4, self.help_button)])
else:
if not self.__areAnyToLoad: # show Save As but not Open
self.buttons = urwid.Columns([
('weight', 0.175, self.exec_button),
('weight', 0.175, self.save_button),
('weight', 0.175, self.save_as_button),
('weight', 0.175, self.cancel_button),
('weight', 0.3, self.help_button)
])
else: # show all possible buttons (iterated on this spacing)
self.buttons = urwid.Columns([
('weight', 0.20, self.open_button),
('weight', 0.15, self.exec_button),
('weight', 0.15, self.save_button),
('weight', 0.15, self.save_as_button),
('weight', 0.18, self.cancel_button),
('weight', 0.20, self.help_button)
])

def _createButtons(self):
""" Set up all the bottom row buttons and their spacings """

Expand Down Expand Up @@ -1397,12 +1332,10 @@ def tpar_option_factory(self, param, defaultParam):

def tpar(taskName):
if isinstance(urwid, FakeModule):
print(
"The urwid package isn't found on your Python system so tpar can't be used.",
file=sys.stderr)
print(' (the error given: "' + urwid.the_error + '")',
file=sys.stderr)
print("Please install urwid version >= 0.9.7 or use epar instead.",
file=sys.stderr)
print(f'''
The urwid package isn't found on your Python system so tpar can't be used.'
(the error given: "{urwid.the_error}")'
Please install urwid or use epar instead.
''', file=sys.stderr)
return
TparDisplay(taskName).main()
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = pyraf
author = Rick White, Perry Greenfield, Chris Sontag
author = Rick White, Perry Greenfield, Chris Sontag, Ole Streicher
url = https://iraf-community.github.io/pyraf.html
description = Pythonic interface to IRAF that can be used in place of the existing IRAF CL
long_description = file:README.rst
Expand Down

0 comments on commit 32455a4

Please sign in to comment.