i am a beginner and i trying to model system dynamic model using python programming.the problem is when i trying to print the components of the sd model, the error message comes out like this:
"AttributeError: 'module' object has no attribute 'doc'"
my code:
import pysd
educationmodel = pysd.read_vensim('Education.mdl')
print educationmodel.components.doc()
As far as understand from the git repo, the doc() method is inside Class PySD. Also, read_vensim returns an instance of this class.
So your problem should get solved if you directly use educationmodel.doc().
That may be my fault - I had to move the .doc() function to the model object instead of the components object as a way to work towards including Vensim macros properly. If it's still an issue, may want to update to the latest release (0.7.4). If that doesn't help either, then we may have to fix something. =)
Related
I used PyCaret 3.0-rc. I developed model and saved them. after almost 3 weeks, now I loaded model. But when I want to use them :
train_predictions = predict_model(model, data=train)
I got the following error:
AttributeError: 'TransformerWrapper' object has no attribute '_memory_transform'
Can any one help me solve it?
I'm trying to instantiate the following PubsubMessage:
timestamp = Timestamp()
timestamp.GetCurrentTime()
message = pubsub_v1.types.PubsubMessage(
data=b'{"id": 123}',
attributes={"some_attribute": "abcd"},
message_id="1",
publish_time=timestamp,
)
When I inspect the timestamp variable, it is of type Timestamp with seconds and nanos attributes, just as expected. However when I inspect message.publish_time I get a DatetimeWithNanoseconds object instead which does not have the aforementioned attributes so I get an error later in my code (because of this line in google-pubsub)
I've checked google's docs but I can't seem to find anything like this. Any help is appreciated.
Ok, so it seems that when passing a PubsubMessage instance to the constructor of the Message class, you can actually do the following:
message=message._pb
I noticed this in this line of the google-pubsub repo
By passing the message as its ._pb attribute you don't get an exception when trying to access message.publish_time.seconds or message.publish_time.seconds. I'm not sure why this is the case but it solved my problem. I'll add an update if I find more info on this.
I am trying to perform a Firebase Query, am using python and firebase-admin, using only startAt brings no results, adding end at throws the error shown below. Thanks for any guidance.
Query
self.users = self.ref.child("products").order_by_child(chosenCriteria).start_at(searchWord).endAt(searchWord+"\uf8ff").get()
Error
self.users = self.ref.child("products").order_by_child(chosenCriteria).start_at(searchWord).endAt(searchWord+"\uf8ff").get()
AttributeError: 'Query' object has no attribute 'endAt'
This reference has helped me, I have had to restructure my queries, though am still not certain why it didn't work the above way
https://morioh.com/p/a593f973aff0
I am new on chemical network model. Currently I am converting a previous student python code to adapt the new version in the lab as titled.
firstly, a gas mixture from mechanism (pre defined) is defined
gas_mix = ct.import_phases(mech,['gas'])
then, I want to get the number of the species and use cantera nSpecies
nsp = gas_mix.nSpecies()
and I got the error message as
AttributeError: 'list' object has no attribute 'nSpecies'
Also I tried:
nsp = gas_mix.n_species
and it also shows
AttributeError: 'list' object has no attribute
Would you please kindly help me on this ?
Thank you and best regards,
YouBe
It looks like import_phases returns a list of objects--either a list of "gas mix" or just "gas" objects. I'm not really sure because this is very specific to the program you're working with.
Anyway, try looping over the values in the gas_mix and see if you can call the nSpecies() method or access the n_species attribute:
gas_mix = ct.import_phases(mech,['gas'])
for gm in gas_mix:
print(gm.nSpecies())
# or you can try this:
print(gm.n_species)
Maybe that will get you closer to what you want.
The function import_phases returns a list, which is useful for the case where you want to import multiple phase definitions from the same file, e.g.
mixtures = ct.import_phases(mech, ['gas1', 'gas2'])
where both mixtures[0] and mixtures[2] will then be a single phase definition. If you only want to define a single phase, it is easier to write:
gas_mix = ct.Solution(mech,'gas')
Or, if the mechanism file only contains one phase definition, just
gas_mix = ct.Solution(mech)
From here, you should be able to access the number of species as
gas_mix.n_species
Many of the details of migrating from the old to new Cantera interfaces are described in the documentation page "Migrating from the Old Python Module".
I can't say I fully understand the script, because classes go beyond me as yet. Anyway, I've downloaded the py-omegle module from here . And I don't seem to be able to get it to run.
Hoping that I don't need to post the whole class including functions, the part in particular that I'm having trouble with pertains to urllib2 - so I guess It's not too specific an issue - the line that causes all of the issues is:
self.connector = urllib2.build_opener(processor),urllib2.HTTPHandler(debuglevel=1)
and it's not letting me:
#omegle.py
[ln33] self.connector.addheaders = [
[ln34] ('User-agent',user_agent)
[ln35] ]
# or
[ln98] self.id = self.connector.open(self.url+'start',data={}).read().strip('"')
Both return AttributeError:
AttributeError: 'tuple' object has no attribute 'addheaders'
# and further down
AttributeError: 'tuple' object has no attribute 'open'
Could someone please explain how to fix this? I'm sure it has something to do with the first line I posted. The entire source of the ONLY file in this module can be accessed here.
I think it's a case of misplaced parentheses.
The first line:
self.connector = urllib2.build_opener(processor),urllib2.HTTPHandler(debuglevel=1)
creates a tuple consisting of
urllib2.build_opener(processor)
and
urllib2.HTTPHandler(debuglevel=1)
And then assigns this tuple to self.connector.