Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python3 support #3

Closed
telegraphic opened this issue Jul 14, 2016 · 2 comments
Closed

Python3 support #3

telegraphic opened this issue Jul 14, 2016 · 2 comments

Comments

@telegraphic
Copy link
Contributor

J. Wright got filterbank.py working in Python 3, but it required some changes due to how Py3 handles strings. Here's the diff:

151c151
<     f = open(filename, 'r')

---
>     f = open(filename, 'rb')
154c154
<     header_str = ''

---
>     header_str = b""
159,160c159,160
<         if 'HEADER_START' in header_sub:
<             idx_start = header_sub.index('HEADER_START') + len('HEADER_START')

---
>         if b"HEADER_START" in header_sub:
>             idx_start = header_sub.index(b"HEADER_START") + len(b"HEADER_START")
163c163
<         if 'HEADER_END' in header_sub:

---
>         if b"HEADER_END" in header_sub:
165c165
<             idx_end = header_sub.index('HEADER_END')

---
>             idx_end = header_sub.index(b"HEADER_END")
181c181
<     f = open(filename, 'r')

---
>     f = open(filename, 'rb')
188,189c188,189
<         if 'HEADER_END' in header_sub:
<             idx_end = header_sub.index('HEADER_END') + len('HEADER_END')

---
>         if b"HEADER_END" in header_sub:
>             idx_end = header_sub.index(b"HEADER_END") + len(b"HEADER_END")
212c212,213
<     for keyword in header_keyword_types.keys():

---
>     for keyword_str in list(header_keyword_types.keys()):
>         keyword = keyword_str.encode("utf-8")
214c215
<             dtype = header_keyword_types.get(keyword, 'str')

---
>             dtype = header_keyword_types.get(keyword_str, 'str')
216c217
<             dtype = header_keyword_types[keyword]

---
>             dtype = header_keyword_types[keyword_str]
219c220
<                 header_dict[keyword] = val

---
>                 header_dict[keyword_str] = val
222c223
<                 header_dict[keyword] = val

---
>                 header_dict[keyword_str] = val
226c227
<                 header_dict[keyword] = str_val

---
>                 header_dict[keyword_str] = str_val.decode("utf-8")
230,231c231
<                 
<                 if keyword == 'src_raj':

---
>                 if keyword_str == 'src_raj':
235c235
<                 header_dict[keyword] = val                

---
>                 header_dict[keyword_str] = val                
312,313c312,313
<             print dd.shape
<             print n_ints, n_ifs, n_chans

---
>             print(dd.shape)
>             print(n_ints, n_ifs, n_chans)
334c334
<         for key, val in self.header.items():

---
>         for key, val in list(self.header.items()):
339c339
<             print "%16s : %32s" % (key, val)

---
>             print("%16s : %32s" % (key, val))
431c431
<         print plot_data.shape, plot_f.shape

---
>         print(plot_data.shape, plot_f.shape)
487c487
<             print "Start freq: %2.2f" % args.f_start

---
>             print("Start freq: %2.2f" % args.f_start)
491c491
<             print "Stop freq: %2.2f" % args.f_stop

---
>             print("Stop freq: %2.2f" % args.f_stop)
494,495c494,495
<         print "Error: Start and stop frequencies must lie inside file's frequency range."
<         print "i.e. between %2.2f-%2.2f MHz." % (fil.freqs[0], fil.freqs[-1])

---
>         print("Error: Start and stop frequencies must lie inside file's frequency range.")
>         print("i.e. between %2.2f-%2.2f MHz." % (fil.freqs[0], fil.freqs[-1]))

Probably requires some Py2/Py3 conditionals in the code

@telegraphic
Copy link
Contributor Author

Note to self: We have almost certainly broken py3 support.

@telegraphic
Copy link
Contributor Author

I think we fixed Py3 support so closing issue. Can open again if we break it again.

texadactyl pushed a commit that referenced this issue Dec 18, 2020
Replace Travis CI with Github Actions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant