Skip to content

Error in executing tutorials due to "TypeError: cannot use a string pattern on a bytes-like object" #136

@bobleesj

Description

@bobleesj

Problem

First error:
https://www.diffpy.org/diffpy.srmise/tutorial/extract_single_peak.html

imac@imacs-iMac examples % srmise data/Ag_nyquist_qmax30.gr --no-extract --plot

returns:

can only concatenate str (not "NoneType") to str

Second error:
https://www.diffpy.org/diffpy.srmise/tutorial/parameter_summary.html

python parameter_summary.py

returns:

imac@imacs-iMac examples % python parameter_summary.py
Traceback (most recent call last):
  File "/Users/imac/Downloads/dev/bg/diffpy.srmise/doc/examples/parameter_summary.py", line 236, in <module>
    run()
  File "/Users/imac/Downloads/dev/bg/diffpy.srmise/doc/examples/parameter_summary.py", line 45, in run
    ppe.loadpdf("data/TiO2_fine_qmax26.gr")
  File "/Users/imac/Downloads/dev/bg/diffpy.srmise/src/diffpy/srmise/pdfpeakextraction.py", line 87, in loadpdf
    d.read(pdf)
  File "/Users/imac/Downloads/dev/bg/diffpy.srmise/src/diffpy/srmise/pdfdataset.py", line 205, in read
    self.readStr(open(filename, "rb").read())
  File "/Users/imac/Downloads/dev/bg/diffpy.srmise/src/diffpy/srmise/pdfdataset.py", line 231, in readStr
    res = re.search(r"^#+ start data\s*(?:#.*\s+)*", datastring, re.M)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/imac/miniconda3/envs/srmise/lib/python3.12/re/__init__.py", line 177, in search
    return _compile(pattern, flags).search(string)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: cannot use a string pattern on a bytes-like object

Proposed solution

Reporting the bug first for now.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions