On 06/10/2010 12:33 PM, Az wrote:
> The pprintout was:
>
> {: 156,
> : 2,
> : 1,
> : 538,
> : 1130,
> : 867,
> : 1,
> : 932,
> : 577,
> : 1717,
> : 5,
> : 1,
> : 236,
> : 156,
> : 39,
> : 197}
>
> I think the InstanceStates come from the Supervisor and Project
> classes (197+39 = 236
On 06/10/2010 04:32 PM, Az wrote:
> Let me take a guess:
>
> class Supervisor(object):
> def __init__(self, ee_id, name, original_quota, loading_limit):
> self.ee_id = ee_id
> self.name = name
> self.original_quota = original_quota
> sel
Hi Conor,
Many apologies for being pushy but since I'm pretty much in the
processing of finishing up my code (due in two days), I wonder if you
could just take a look at the last three posts of mine---these
constitute the final hurdle and I'll be done :)
Cheers,
Az
On Jun 9, 9:46 pm, Conor wro
Let me take a guess:
class Supervisor(object):
def __init__(self, ee_id, name, original_quota, loading_limit):
self.ee_id = ee_id
self.name = name
self.original_quota = original_quota
self.loading_limit = loading_limit
So I laid them out like this:
class Run(Base):
# For autoincrementing run IDs
# Allows addition of more information to a run
__tablename__ = 'run'
id = Column(Integer, primary_key=True)
timestamp = Column(DateTime, nullable=False)
# comment = Column(UnicodeText(100), nu
The pprintout was:
{: 156,
: 2,
: 1,
: 538,
: 1130,
: 867,
: 1,
: 932,
: 577,
: 1717,
: 5,
: 1,
: 236,
: 156,
: 39,
: 197}
I think the InstanceStates come from the Supervisor and Project
classes (197+39 = 236)
> Sounds pretty ugly. What if you add extra tables to represent runs
>
On 06/09/2010 02:45 PM, Az wrote:
>> Expected: students, supervisors, projects, dictionaries of said objects,
>> and other attribute values (strings, ints, lists, etc.). Unexpected:
>> anything else, especially sessions, InstanceState objects, or other ORM
>> support objects.
>>
> Actually go
> Expected: students, supervisors, projects, dictionaries of said objects,
> and other attribute values (strings, ints, lists, etc.). Unexpected:
> anything else, especially sessions, InstanceState objects, or other ORM
> support objects.
Actually got some stuff like the following (copy-pasting bi
On 06/09/2010 12:44 AM, Az wrote:
> Traceback (most recent call last):
> File "Main.py", line 39, in
> MCS.monteCarloBasic(trials)
> File "//MonteCarloSimulation.py", line 163, in monteCarloBasic
> session.merge(temp_alloc)
> File "/opt/local/Library/Frameworks/Python.framework/V
On 06/08/2010 10:54 PM, Az wrote:
>> memo = {}
>> copied_students = copy.deepcopy(students, memo)
>> copied_supervisors = copy.deepcopy(supervisors, memo)
>> copied_projects = copy.deepcopy(projects, memo)
>>
>> After you do this, memo will contain a record of all copied objects. You
>> should exam
Traceback (most recent call last):
File "Main.py", line 39, in
MCS.monteCarloBasic(trials)
File "//MonteCarloSimulation.py", line 163, in monteCarloBasic
session.merge(temp_alloc)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/
lib/python2.6/site-packages/SQLAl
Also:
Traceback (most recent call last):
File "Main.py", line 39, in
MCS.monteCarloBasic(trials)
File "/Users/Azfar/Dropbox/Final Year Project/SPAllocation/
MonteCarloSimulation.py", line 163, in monteCarloBasic
session.merge(temp_alloc)
File "/opt/local/Library/Frameworks/Python.fr
> memo = {}
> copied_students = copy.deepcopy(students, memo)
> copied_supervisors = copy.deepcopy(supervisors, memo)
> copied_projects = copy.deepcopy(projects, memo)
>
> After you do this, memo will contain a record of all copied objects. You
> should examine memo.values() to see if it is copying
On 06/07/2010 07:27 PM, Az wrote:
>> By default, deepcopy will make one copy of everything in the object
>> graph reachable by the object you feed it. The scary part is that,
>> unless you also pass in a /memo/ argument to each call to deepcopy, it
>> will copy the entire graph /every single call/.
Additionally, before I tried out the create_db_record...
However whenever I try to commit:
#[§§0§]
student_records = best_node
for rec in student_records.itervalues():
MCS.session.add(rec)
MCS.session.commit()
I get:
sqlalchemy.orm.exc.UnmappedInstanceEr
> By default, deepcopy will make one copy of everything in the object
> graph reachable by the object you feed it. The scary part is that,
> unless you also pass in a /memo/ argument to each call to deepcopy, it
> will copy the entire graph /every single call/. So if you deepcopy the
> students dic
On 06/07/2010 02:56 PM, Az wrote:
>> Sounds good. Just beware that deepcopy will try to make copies of all
>> the objects referenced by your StudentUnmapped objects (assuming you
>> didn't define __deepcopy__), so you may end up copying projects,
>> supervisors, etc.
>>
> Good point. I'm deepc
> Sounds good. Just beware that deepcopy will try to make copies of all
> the objects referenced by your StudentUnmapped objects (assuming you
> didn't define __deepcopy__), so you may end up copying projects,
> supervisors, etc.
Good point. I'm deepcopying my students, projects and supervisors
di
On 06/06/2010 02:58 PM, Az wrote:
> Hi Conor,
>
> Basically I sat down and made some decisions and changes.
>
> I've created an actual copy of the Student class as in I've now got
> two classes, Student and StudentUnmapped. The Unmapped one has the
> same attributes as the mapped one, except for be
Hi Conor,
Basically I sat down and made some decisions and changes.
I've created an actual copy of the Student class as in I've now got
two classes, Student and StudentUnmapped. The Unmapped one has the
same attributes as the mapped one, except for being... well, unmapped.
Now I can a) use deepco
Also adding a bit here:
My Student (this one is mapped) class looks like this:
class Student(object):
def __init__(self, ee_id, name, stream_id, overall_proby):
self.ee_id = ee_id
self.name = name
self.stream_id = stream_id
s
This will probably help:
def addToTable():
"""Very simple SQLAlchemy function that populates the Student,
Project
and Supervisor tables."""
for student in students.itervalues():
session.add(student)
session.flush()
for project in pro
On 06/05/2010 08:06 PM, Az wrote:
> Cheers!
>
> Creating a new instance of my mapped class and settings, manually.
> Gotcha. I think this will be an easier solution for me.
>
> Nah, I'm not in a web framework.
>
> Additional Q:
>
> +++
>
> Currently, my database is being stored in memory and it's f
Cheers!
Creating a new instance of my mapped class and settings, manually.
Gotcha. I think this will be an easier solution for me.
Nah, I'm not in a web framework.
Additional Q:
+++
Currently, my database is being stored in memory and it's fine like
that since a) my data isn't very expansive a
On 06/03/2010 02:33 PM, Az wrote:
> Firstly, apologies if I'm demanding too much but basically I'm quite a
> beginner at Python programming and this is for a University project,
> which is why I'm keen to get this done (due in a few days!). So I hope
> you won't mind me asking some questions that m
Sorry, meant to reply to you Michael... ended up replying to myself!
---
Firstly, apologies if I'm demanding too much but basically I'm quite a
beginner at Python programming and this is for a University project,
which is why I'm keen to get this done (due in a few days!). So I hope
you won't mind
Firstly, apologies if I'm demanding too much but basically I'm quite a
beginner at Python programming and this is for a University project,
which is why I'm keen to get this done (due in a few days!). So I hope
you won't mind me asking some questions that may seem really basic.
> deepcopy has issu
I think I get what you mean. In the mean time, another error popped
up:
Traceback (most recent call last):
File "Main.py", line 32, in
MCS.addToTable()
File "XXX/MonteCarloSimulation.py", line 138, in addToTable
### <--- This function is described in the first post
session
On Jun 3, 2010, at 1:58 PM, Az wrote:
> "Owning session has been closed"? Can I still use deepcopy if the
> session has not been closed?
deepcopy has issues because SQLAlchemy places extra information on your
objects, i.e. an _sa_instance_state attribute, that you dont want in your copy.
You
"Owning session has been closed"? Can I still use deepcopy if the
session has not been closed? How can I stop it from closing the
sessions? The problem is that if I change my shallow copied
dictionary, the objects are changed.
Basically, I'm trying to do this state change thing where I'll take a
d
Also:
I'm using [Python 2.6.5] and [SQLAlchemy 0.5.8]
Previously I was just shallow copying my dictionaries, and there were
no issues then with my simulations.
My dictionaries contain objects such that my students dictionary is
basically:
students[stud_id] = Student(stud_id, name, preferences,..
31 matches
Mail list logo