MRC-CSO-SPHSU / LoneParentsModel.jl

An initial implementation of an ABM for social and child care
0 stars 5 forks source link

setAsParentChild! is wrong #40

Closed AtiyahElsheikh closed 2 years ago

AtiyahElsheikh commented 2 years ago

It includes the following statement

setParent!(child, father) # father is not defined

RunTests.jl needs to be modified to detect such bugs.

AtiyahElsheikh commented 2 years ago

When I start to conduct unit testing, I get the following:

Type Person: Error During Test at /home/atiyah/work/julia/LoneParentsModel.jl/tests/RunTests.jl:67
  Got exception outside of a @test
  MethodError: no method matching setParent!(::KinshipM.Kinship{Person}, ::typeof(KinshipM.father))
  Closest candidates are:
    setParent!(::KinshipM.Kinship{P}, ::Union{Nothing, P}) where P at ~/work/julia/LoneParentsModel.jl/src/agents/KinshipM.jl:30
    setParent!(::Person, ::Any...) at ~/.julia/packages/TypedDelegation/nCjkv/src/TypedDelegation.jl:207
  Stacktrace:
    [1] setParent!(a::Person, args::Function)
      @ XAgents ~/.julia/packages/TypedDelegation/nCjkv/src/TypedDelegation.jl:207
    [2] setAsParentChild!(child::Person, parent::Person)
      @ XAgents ~/work/julia/LoneParentsModel.jl/src/agents/Person.jl:115

Strangely, the help functions father, partner, motheretc. are conflicting with field names of structs.

I would try to change the help functions to fatherOf, motherOf, etc.

mhinsch commented 2 years ago

father etc. should not conflict with struct members. Can you maybe send me your unit test?

AtiyahElsheikh commented 2 years ago

Ok, I see the problem now:

Person.jl Line 114

mhinsch commented 2 years ago

Yep, forgot to change the variable name, should be parent.