TypeError: 'tuple' object is not callable in FLAC3D Python Script

Hi Everyone,

I am using the following Python code snippet in FLAC3D, which is taken from the documentation. However, I am encountering the following error:

Traceback (most recent call last):
File “‘’”, line 24, in
TypeError: ‘tuple’ object is not callable

Here is the code:

import functools
import numpy as np
np.set_printoptions(threshold=20)
import itasca as it
from itasca import zonearray as za
from itasca import gridpointarray as gpa
it.command(“”"
model new
model large-strain off
zone create brick size 10 10 10
zone cmodel assign elastic
zone property density 2950 young 12e9 poisson 0.25
cycle 1
“”")
za.pos()
p = za.pos()
x,y,z = p.T
from functools import reduce
corner_mask = reduce(np.logical_and, (x<3, y<3, z<3))
za.set_group(corner_mask, “corner”, “geometry”)

I believe the error might be related to how corner_mask is being passed to za.set_group(), but I am unsure of the exact issue.

Could anyone please help me understand the cause of this error and suggest a solution?

Thank you in advance for your help! :blush:

Which version are you using?
If v9.0 or older, the command “python-reset-state false” is required:


import itasca as it
it.command(“python-reset-state false”)

Thank you for your reply.
I have used the python-reset-state false command, but I am still facing the same error.
I am using v9.00.177

Hi there,

Using Flac3D6, I could not reproduce the error.
This seems to be a pure Python one, what version of Python and numpy are you using?

Did you have any chance executing line-per-line your script in Flac3D ipython console?

By the way, just a couple of NumPy tips: boolean arrays support the & operator, your reduce(np.logical_and, ...) can be written as corner_mask = (x<3) & (y<3) & (z<3).
If you like it even shorter, you can get the same result with corner_mask = (p<3).all(axis=1):

  • (p<3) is a (Nzones,3)-array where first, second and third columns correspond to x<3, y<3 and z<3, respectively
  • (p<3).all(axis=1) is a Nzones-array and ensures that all three values in each row are True

Cheers!

Theophile