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

Preprocessor not parsing values correctly #2

Open
JCoetzee123 opened this issue Jul 24, 2019 · 0 comments
Open

Preprocessor not parsing values correctly #2

JCoetzee123 opened this issue Jul 24, 2019 · 0 comments

Comments

@JCoetzee123
Copy link
Contributor

Title

Preprocessor not parsing values correctly

Steps to reproduce

  1. Import the SPiRA framework
import spira.all as spira
  1. Create a class accepting spira.ParameterInitializer and initialize simple integer parameter
class Layer(spira.ParameterInitializer):
    integer = spira.IntegerParameter(default="1.2", preprocess=spira.ProcessorInt())
  1. Instantiate a layer class to be called in your main script
layer =  Layer()
print(layer.integer)
  1. Execute the script in bash

Expected Behavior (correct)

Paramater should print out as a rounded integer (~1)

Current Behavior (incorrect)

Traceback (most recent call last):
File "tests/createlayer.py", line 25, in
layer.interger = "1.2"
File "/home/johannes/Documents/latestspira 17jul/spira-master/spira/core/parameters/descriptor.py", line 133, in set
v = self.preprocess(value, obj)
File "/home/johannes/Documents/latestspira 17jul/spira-master/spira/core/parameters/processors.py", line 34, in call
return self.process(value, obj)
File "/home/johannes/Documents/latestspira 17jul/spira-master/spira/core/parameters/processors.py", line 93, in process
return self.cast_type(value)
ValueError: invalid literal for int() with base 10: '1.2'

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