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

context_clean.py exception #11

Closed
slawkory opened this issue Jan 6, 2018 · 3 comments
Closed

context_clean.py exception #11

slawkory opened this issue Jan 6, 2018 · 3 comments

Comments

@slawkory
Copy link

slawkory commented Jan 6, 2018

As I understand after compilation of PyNEC, component is added only for python2.7 so I used 2.7.
There was exception in my environment for
python2.7 dipole.py
Wavelength is 0.1224m, initial length is 0.0612m

Traceback (most recent call last):
  File "dipole.py", line 96, in <module>
    z = impedance(design_freq_mhz, initial_length, nr_segments)
  File "dipole.py", line 40, in impedance
    nec = geometry(freq_mhz, length, nr_segments)
  File "dipole.py", line 17, in geometry
    nec.set_extended_thin_wire_kernel(False)
  File "/home/(..)/python-necpp/PyNEC/example/context_clean.py", line 107, in set_extended_thin_wire_kernel
    self.context.set_extended_thin_wire_kernel(0)
  File "/usr/lib64/python2.7/site-packages/PyNEC.py", line 181, in set_extended_thin_wire_kernel
    return _PyNEC.nec_context_set_extended_thin_wire_kernel(self, ekflag)
TypeError: in method 'nec_context_set_extended_thin_wire_kernel', argument 2 of type 'bool'

To see example result I have added locally that change which works:

+++ b/PyNEC/example/context_clean.py
@@ -101,10 +101,10 @@ class context_clean(object):
     def set_extended_thin_wire_kernel(self, enable):
         if enable:
             debug ("EK", 0)
-            self.context.set_extended_thin_wire_kernel(1)
+            self.context.set_extended_thin_wire_kernel(True)
         else:
             debug ("EK", -1)
-            self.context.set_extended_thin_wire_kernel(0)
+            self.context.set_extended_thin_wire_kernel(False)

BTW: Is there any reconfiguration trick to install PyNec for Python3?

@slawkory slawkory changed the title slawkory context_clean.py exception Jan 6, 2018
@tmolteno
Copy link
Owner

I believe this is now working. There have been quite a few changes, but installing via pip should also work now.

@glenndk
Copy link

glenndk commented Jan 4, 2020

Hi tmolteno - thank for sharing your necpp/PyNEC package. I am starting to learn using them.

Unfortunately I encountered the same exception:

$ python /Volumes/Data13/python/logperiodic_opt.py
Wavelength is 0.1224m, initial length is 0.0612m
Unoptimized antenna...
Traceback (most recent call last):
File "/Volumes/Data13/python/logperiodic_opt.py", line 225, in
show_report(initial_l1, initial_x1, initial_tau)
File "/Volumes/Data13/python/logperiodic_opt.py", line 168, in show_report
nec = geometry_logperiodic(l1, x1, tau)
File "/Volumes/Data13/python/logperiodic_opt.py", line 30, in geometry_logperiodic
nec.set_extended_thin_wire_kernel(True)
File "/Volumes/Data13/python/context_clean.py", line 104, in set_extended_thin_wire_kernel
self.context.set_extended_thin_wire_kernel(1)
File "/opt/local/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/PyNEC.py", line 181, in set_extended_thin_wire_kernel
return _PyNEC.nec_context_set_extended_thin_wire_kernel(self, ekflag)
TypeError: in method 'nec_context_set_extended_thin_wire_kernel', argument 2 of type 'bool'
$

My installation:

$ pip freeze
cycler==0.10.0
kiwisolver==1.1.0
matplotlib==3.0.3
necpp==1.7.3.5
numpy==1.18.0
PyNEC==1.7.3.4
pyparsing==2.4.6
python-dateutil==2.8.1
scipy==1.4.1
six==1.13.0
$

tmolteno added a commit that referenced this issue May 13, 2020
…sion bug introduced with the shift to python3. Closes #11, #14
@tmolteno
Copy link
Owner

Finally fixed. Thanks for reporting.

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

3 participants